1 From ee66e453db13d4837a0dcf9d43efa7a88603161b Mon Sep 17 00:00:00 2001
2 From: Sean Christopherson <sean.j.christopherson@intel.com>
3 Date: Tue, 16 Apr 2019 13:32:44 -0700
4 Subject: KVM: lapic: Busy wait for timer to expire when using hv_timer
6 From: Sean Christopherson <sean.j.christopherson@intel.com>
8 commit ee66e453db13d4837a0dcf9d43efa7a88603161b upstream.
10 ...now that VMX's preemption timer, i.e. the hv_timer, also adjusts its
11 programmed time based on lapic_timer_advance_ns. Without the delay, a
12 guest can see a timer interrupt arrive before the requested time when
13 KVM is using the hv_timer to emulate the guest's interrupt.
15 Fixes: c5ce8235cffa0 ("KVM: VMX: Optimize tscdeadline timer latency")
16 Cc: <stable@vger.kernel.org>
17 Cc: Wanpeng Li <wanpengli@tencent.com>
18 Reviewed-by: Liran Alon <liran.alon@oracle.com>
19 Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
20 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 arch/x86/kvm/lapic.c | 2 +-
25 1 file changed, 1 insertion(+), 1 deletion(-)
27 --- a/arch/x86/kvm/lapic.c
28 +++ b/arch/x86/kvm/lapic.c
29 @@ -1449,7 +1449,7 @@ static void apic_timer_expired(struct kv
33 - if (apic_lvtt_tscdeadline(apic))
34 + if (apic_lvtt_tscdeadline(apic) || ktimer->hv_timer_in_use)
35 ktimer->expired_tscdeadline = ktimer->tscdeadline;