From patchwork Tue Feb 16 09:16:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 79563 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1G9GZ3J026842 for ; Tue, 16 Feb 2010 09:16:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756803Ab0BPJQd (ORCPT ); Tue, 16 Feb 2010 04:16:33 -0500 Received: from goliath.siemens.de ([192.35.17.28]:17842 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755620Ab0BPJQb (ORCPT ); Tue, 16 Feb 2010 04:16:31 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1G9GCdI019460; Tue, 16 Feb 2010 10:16:12 +0100 Received: from [139.25.109.167] (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail1.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1G9GCXA012846; Tue, 16 Feb 2010 10:16:12 +0100 Message-ID: <4B7A625C.4070803@siemens.com> Date: Tue, 16 Feb 2010 10:16:12 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti CC: kvm , Gleb Natapov Subject: [PATCH] KVM: VMX: Translate interrupt shadow when waiting on NMI window Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 16 Feb 2010 09:16:35 +0000 (UTC) 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 --- 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);