Message ID | 20190412201834.10831-6-sean.j.christopherson@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: lapic: Fix a variety of timer adv issues | expand |
> On 12 Apr 2019, at 23:18, Sean Christopherson <sean.j.christopherson@intel.com> wrote: > > ...now that VMX's preemption timer, i.e. the hv_timer, also adjusts its > programmed time based on lapic_timer_advance_ns. Without the delay, a > guest can see a timer interrupt arrive before the requested time when > KVM is using the hv_timer to emulate the guest's interrupt. > > Fixes: c5ce8235cffa0 ("KVM: VMX: Optimize tscdeadline timer latency") > Cc: <stable@vger.kernel.org> > Cc: Wanpeng Li <wanpengli@tencent.com> > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Nice catch. Reviewed-by: Liran Alon <liran.alon@oracle.com> > --- > arch/x86/kvm/lapic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > index c43cd26f040b..1d649a2af04c 100644 > --- a/arch/x86/kvm/lapic.c > +++ b/arch/x86/kvm/lapic.c > @@ -1455,7 +1455,7 @@ static void apic_timer_expired(struct kvm_lapic *apic) > if (swait_active(q)) > swake_up_one(q); > > - if (apic_lvtt_tscdeadline(apic)) > + if (apic_lvtt_tscdeadline(apic) || ktimer->hv_timer_in_use) > ktimer->expired_tscdeadline = ktimer->tscdeadline; > } > > -- > 2.21.0 >
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index c43cd26f040b..1d649a2af04c 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1455,7 +1455,7 @@ static void apic_timer_expired(struct kvm_lapic *apic) if (swait_active(q)) swake_up_one(q); - if (apic_lvtt_tscdeadline(apic)) + if (apic_lvtt_tscdeadline(apic) || ktimer->hv_timer_in_use) ktimer->expired_tscdeadline = ktimer->tscdeadline; }
...now that VMX's preemption timer, i.e. the hv_timer, also adjusts its programmed time based on lapic_timer_advance_ns. Without the delay, a guest can see a timer interrupt arrive before the requested time when KVM is using the hv_timer to emulate the guest's interrupt. Fixes: c5ce8235cffa0 ("KVM: VMX: Optimize tscdeadline timer latency") Cc: <stable@vger.kernel.org> Cc: Wanpeng Li <wanpengli@tencent.com> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> --- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)