diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2016-06-20 21:33:48 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-27 09:30:41 -0400 |
commit | b606f189c7d5bf9b875bba168162fe05287880fe (patch) | |
tree | 20a06328aec2cbd036406e0e701cd21324a5f9fc | |
parent | 8d93c874ac899bfdf0ad3787baef684a0c878c2c (diff) |
KVM: LAPIC: cap __delay at lapic_timer_advance_ns
The host timer which emulates the guest LAPIC TSC deadline
timer has its expiration diminished by lapic_timer_advance_ns
nanoseconds. Therefore if, at wait_lapic_expire, a difference
larger than lapic_timer_advance_ns is encountered, delay at most
lapic_timer_advance_ns.
This fixes a problem where the guest can cause the host
to delay for large amounts of time.
Reported-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/lapic.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index bbb5b283ff63..a397200281c1 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -1310,7 +1310,8 @@ void wait_lapic_expire(struct kvm_vcpu *vcpu) | |||
1310 | 1310 | ||
1311 | /* __delay is delay_tsc whenever the hardware has TSC, thus always. */ | 1311 | /* __delay is delay_tsc whenever the hardware has TSC, thus always. */ |
1312 | if (guest_tsc < tsc_deadline) | 1312 | if (guest_tsc < tsc_deadline) |
1313 | __delay(tsc_deadline - guest_tsc); | 1313 | __delay(min(tsc_deadline - guest_tsc, |
1314 | nsec_to_cycles(vcpu, lapic_timer_advance_ns))); | ||
1314 | } | 1315 | } |
1315 | 1316 | ||
1316 | static void start_apic_timer(struct kvm_lapic *apic) | 1317 | static void start_apic_timer(struct kvm_lapic *apic) |