From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH v5 5/6] KVM: nVMX: Fix conditions for NMI injection Date: Mon, 15 Apr 2013 18:42:37 +0300 Message-ID: <20130415154237.GB5807@redhat.com> References: <523b4691a695525a22102c496a078fda6a13d392.1365934368.git.jan.kiszka@web.de> <20130414152359.GT17919@redhat.com> <516AD0E1.5000000@web.de> <20130414161806.GA6542@redhat.com> <516ADAC2.7090306@web.de> <20130414164321.GB6542@redhat.com> <516AFDBA.9050805@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Marcelo Tosatti , kvm , Paolo Bonzini , "Nadav Har'El" To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55549 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933100Ab3DOPmp (ORCPT ); Mon, 15 Apr 2013 11:42:45 -0400 Content-Disposition: inline In-Reply-To: <516AFDBA.9050805@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Apr 14, 2013 at 09:04:26PM +0200, Jan Kiszka wrote: > From: Jan Kiszka > > The logic for checking if interrupts can be injected has to be applied > also on NMIs. The difference is that if NMI interception is on these > events are consumed and blocked by the VM exit. > > Signed-off-by: Jan Kiszka Reviewed-by: Gleb Natapov This should be applied after not yet applied 3/6. > --- > arch/x86/kvm/vmx.c | 26 ++++++++++++++++++++++++++ > 1 files changed, 26 insertions(+), 0 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 74dea94..9ad30d8 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -4190,6 +4190,12 @@ static bool nested_exit_on_intr(struct kvm_vcpu *vcpu) > PIN_BASED_EXT_INTR_MASK; > } > > +static bool nested_exit_on_nmi(struct kvm_vcpu *vcpu) > +{ > + return get_vmcs12(vcpu)->pin_based_vm_exec_control & > + PIN_BASED_NMI_EXITING; > +} > + > static void enable_irq_window(struct kvm_vcpu *vcpu) > { > u32 cpu_based_vm_exec_control; > @@ -4315,6 +4321,26 @@ static void vmx_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked) > > static int vmx_nmi_allowed(struct kvm_vcpu *vcpu) > { > + if (is_guest_mode(vcpu)) { > + struct vmcs12 *vmcs12 = get_vmcs12(vcpu); > + > + if (to_vmx(vcpu)->nested.nested_run_pending) > + return 0; > + if (nested_exit_on_nmi(vcpu)) { > + nested_vmx_vmexit(vcpu); > + vmcs12->vm_exit_reason = EXIT_REASON_EXCEPTION_NMI; > + vmcs12->vm_exit_intr_info = NMI_VECTOR | > + INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK; > + /* > + * The NMI-triggered VM exit counts as injection: > + * clear this one and block further NMIs. > + */ > + vcpu->arch.nmi_pending = 0; > + vmx_set_nmi_mask(vcpu, true); > + return 0; > + } > + } > + > if (!cpu_has_virtual_nmis() && to_vmx(vcpu)->soft_vnmi_blocked) > return 0; > > -- > 1.7.3.4 -- Gleb.