Skip to content

Commit

Permalink
KVM: LAPIC: cap __delay at lapic_timer_advance_ns
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marcelo Tosatti authored and Paolo Bonzini committed Jun 27, 2016
1 parent 8d93c87 commit b606f18
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/x86/kvm/lapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,8 @@ void wait_lapic_expire(struct kvm_vcpu *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)
Expand Down

0 comments on commit b606f18

Please sign in to comment.