From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Radim Krcmar <rkrcmar@redhat.com>,
Alan Jenkins <alan.christopher.jenkins@gmail.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 2/2] KVM: LAPIC: cap __delay at lapic_timer_advance_ns
Date: Mon, 20 Jun 2016 22:28:03 -0300 [thread overview]
Message-ID: <20160621012829.699158610@redhat.com> (raw)
In-Reply-To: 20160621012801.145630514@redhat.com
[-- Attachment #1: lapic-cap-wait --]
[-- Type: text/plain, Size: 1009 bytes --]
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>
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(max(tsc_deadline - guest_tsc,
+ nsec_to_cycles(vcpu, lapic_timer_advance_ns)));
}
static void start_apic_timer(struct kvm_lapic *apic)
next prev parent reply other threads:[~2016-06-21 1:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-21 1:28 [patch 0/2] fix lapic_timer_advance_ns guest triggerable unlimited delays Marcelo Tosatti
2016-06-21 1:28 ` [patch 1/2] KVM: x86: move nsec_to_cycles from x86.c to x86.h Marcelo Tosatti
2016-06-21 1:28 ` Marcelo Tosatti [this message]
2016-06-21 1:33 ` [patch 2/2 V2] KVM: LAPIC: cap __delay at lapic_timer_advance_ns Marcelo Tosatti
2016-06-21 12:13 ` Alan Jenkins
2016-06-21 7:53 ` [patch 0/2] fix lapic_timer_advance_ns guest triggerable unlimited delays Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160621012829.699158610@redhat.com \
--to=mtosatti@redhat.com \
--cc=alan.christopher.jenkins@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.