[patch 2/2 V2] KVM: LAPIC: cap __delay at lapic_timer_advance_ns

Marcelo Tosatti
2016-06-21T01:34:31Z

Reported-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

---

v2: s/max/min/ !

Index: kvm/arch/x86/kvm/lapic.c
===================================================================
--- kvm.orig/arch/x86/kvm/lapic.c
+++ kvm/arch/x86/kvm/lapic.c
@@ -1164,7 +1164,8 @@ void wait_lapic_expire(struct kvm_vcpu *

/* __delay is delay_tsc whenever the hardware has TSC, thus always. */
if (guest_tsc < tsc_deadline)
- __delay(tsc_deadline - guest_tsc);
+ __delay(min(tsc_deadline - guest_tsc,
+ nsec_to_cycles(vcpu, lapic_timer_advance_ns)));
}

static void start_apic_timer(struct kvm_lapic *apic)