From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: VMX: simplify NMI mask management Date: Wed, 23 Mar 2011 15:54:05 +0100 Message-ID: <4D8A098D.5070902@siemens.com> References: <1300885976-8755-1-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , "kvm@vger.kernel.org" To: Avi Kivity Return-path: Received: from david.siemens.de ([192.35.17.14]:15892 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932337Ab1CWOyO (ORCPT ); Wed, 23 Mar 2011 10:54:14 -0400 In-Reply-To: <1300885976-8755-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2011-03-23 14:12, Avi Kivity wrote: > Use vmx_set_nmi_mask() instead of open-coding management of > the hardware bit and the software hint (nmi_known_unmasked). > > There's a slight change of behaviour when running without > hardware virtual NMI support - we now clear the NMI mask if > NMI delivery faulted in that case as well. This improves > emulation accuracy. > > Signed-off-by: Avi Kivity > --- > arch/x86/kvm/vmx.c | 10 ++-------- > 1 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 1bdb49d..2b99ae7 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -3532,11 +3532,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu) > switch (type) { > case INTR_TYPE_NMI_INTR: > vcpu->arch.nmi_injected = false; > - if (cpu_has_virtual_nmis()) { > - vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, > - GUEST_INTR_STATE_NMI); > - vmx->nmi_known_unmasked = false; > - } > + vmx_set_nmi_mask(vcpu, true); > break; > case INTR_TYPE_EXT_INTR: > case INTR_TYPE_SOFT_INTR: > @@ -3991,9 +3987,7 @@ static void __vmx_complete_interrupts(struct vcpu_vmx *vmx, > * Clear bit "block by NMI" before VM entry if a NMI > * delivery faulted. > */ > - vmcs_clear_bits(GUEST_INTERRUPTIBILITY_INFO, > - GUEST_INTR_STATE_NMI); > - vmx->nmi_known_unmasked = true; > + vmx_set_nmi_mask(&vmx->vcpu, false); > break; > case INTR_TYPE_SOFT_EXCEPTION: > vmx->vcpu.arch.event_exit_inst_len = Looks consistent to me, but maybe you should update the comment above that's now also applied to the emulated mask. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux