From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v4 5/6] KVM: nVMX: Fix conditions for NMI injection Date: Sun, 14 Apr 2013 17:53:05 +0200 Message-ID: <516AD0E1.5000000@web.de> References: <523b4691a695525a22102c496a078fda6a13d392.1365934368.git.jan.kiszka@web.de> <20130414152359.GT17919@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="----enig2OSXMXXVEKEJEGKQURVAK" Cc: Marcelo Tosatti , kvm , Paolo Bonzini , Nadav Har'El To: Gleb Natapov Return-path: Received: from mout.web.de ([212.227.17.11]:53444 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751877Ab3DNPxO (ORCPT ); Sun, 14 Apr 2013 11:53:14 -0400 In-Reply-To: <20130414152359.GT17919@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2OSXMXXVEKEJEGKQURVAK Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2013-04-14 17:23, Gleb Natapov wrote: > On Sun, Apr 14, 2013 at 12:12:49PM +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 >> --- >> arch/x86/kvm/vmx.c | 28 ++++++++++++++++++++++++++++ >> 1 files changed, 28 insertions(+), 0 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index 56e7519..ad9b4bc 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; >> } >> =20 >> +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,28 @@ static void vmx_set_nmi_mask(struct kvm_vcpu *v= cpu, bool masked) >> =20 >> static int vmx_nmi_allowed(struct kvm_vcpu *vcpu) >> { >> + if (is_guest_mode(vcpu)) { >> + struct vmcs12 *vmcs12 =3D get_vmcs12(vcpu); >> + >> + if (to_vmx(vcpu)->nested.nested_run_pending || >> + vmcs_read32(GUEST_ACTIVITY_STATE) =3D=3D >> + GUEST_ACTIVITY_WAIT_SIPI) > The same is true for interrupt too, Yes, but aren't we already waiting with interrupts disabled in that state= ? > but I do not think that we should allow > nested guest directly enter GUEST_ACTIVITY_WAIT_SIPI state or any other= > state except ACTIVE. They should be emulated instead. Well, they aren't emulated yet but directly applied. So I think the patch is correct in the current context at least. What negative effects do you expect from entering those states with L2? > From quick look at > the spec it looks like external interrupts do not cause VMEXIT while > vcpu is in GUEST_ACTIVITY_WAIT_SIPI. Yes, see above. Jan ------enig2OSXMXXVEKEJEGKQURVAK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlFq0OQACgkQitSsb3rl5xTzuACfZYkxq+VezBKno7R0fZwCmo7u bD4AoMo42ZdBUMU46Q4uKY5/xSh5mzZe =BQek -----END PGP SIGNATURE----- ------enig2OSXMXXVEKEJEGKQURVAK--