All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>, Gleb Natapov <gleb@redhat.com>
Subject: [PATCH] KVM: VMX: Translate interrupt shadow when waiting on NMI window
Date: Tue, 16 Feb 2010 10:16:12 +0100	[thread overview]
Message-ID: <4B7A625C.4070803@siemens.com> (raw)

Found while browsing Xen code: While we assume that the STI interrupt
shadow also inplies virtual NMI blocking, some processors may have a
different opinion (SDM 3: 22.3). To avoid misunderstandings that would
cause endless VM entry attempts, translate STI into MOV SS blocking when
requesting the NMI window.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

 arch/x86/kvm/vmx.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 14873b9..474f720 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2614,12 +2614,27 @@ static void enable_irq_window(struct kvm_vcpu *vcpu)
 static void enable_nmi_window(struct kvm_vcpu *vcpu)
 {
 	u32 cpu_based_vm_exec_control;
+	u32 interruptibility;
 
 	if (!cpu_has_virtual_nmis()) {
 		enable_irq_window(vcpu);
 		return;
 	}
 
+	/*
+	 * SDM 3: 22.3 (June 2009)
+	 * "A logical processor may also prevent such a VM exit [NMI-window
+	 * exit] if there is blocking of events by STI."
+	 * So better convert STI blocking into MOV SS to avoid premature VM
+	 * exits that would end up in an endless loop.
+	 */
+	interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO);
+	if (interruptibility & GUEST_INTR_STATE_STI) {
+		interruptibility &= ~GUEST_INTR_STATE_STI;
+		interruptibility |= GUEST_INTR_STATE_MOV_SS;
+		vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, interruptibility);
+	}
+
 	cpu_based_vm_exec_control = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
 	cpu_based_vm_exec_control |= CPU_BASED_VIRTUAL_NMI_PENDING;
 	vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);

             reply	other threads:[~2010-02-16  9:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-16  9:16 Jan Kiszka [this message]
2010-02-16 10:00 ` [PATCH] KVM: VMX: Translate interrupt shadow when waiting on NMI window Gleb Natapov
2010-02-16 10:04   ` Jan Kiszka
2010-02-16 10:06     ` Gleb Natapov
2010-02-16 10:14       ` Jan Kiszka
2010-02-16 10:17         ` Gleb Natapov
2010-02-16 10:27           ` Jan Kiszka
2010-02-16 10:32             ` Gleb Natapov
2010-02-16 10:37               ` Jan Kiszka
2010-02-16 10:38                 ` Gleb Natapov
2010-04-21 14:17                   ` Jan Kiszka
2010-04-21 14:30                     ` Gleb Natapov
2010-04-21 14:41                       ` Jan Kiszka
2010-04-21 14:44                         ` Gleb Natapov
2010-04-21 15:14                           ` Jan Kiszka
2010-04-21 15:30                             ` Gleb Natapov
2010-05-03  7:32                             ` Gleb Natapov

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=4B7A625C.4070803@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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.