From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v3 4/5] KVM: nVMX: Fix conditions for interrupt injection Date: Thu, 11 Apr 2013 16:27:23 +0200 Message-ID: <5166C84B.3010907@web.de> References: <8d319389dd68794c629b10ce3a071f16119d248b.1364150685.git.jan.kiszka@web.de> <20130411112018.GU17919@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="----enig2OOMNWFNQDJFNAHRCSDEG" Cc: Marcelo Tosatti , kvm , Paolo Bonzini , Nadav Har'El To: Gleb Natapov Return-path: Received: from mout.web.de ([212.227.15.4]:62714 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1765597Ab3DKO1m (ORCPT ); Thu, 11 Apr 2013 10:27:42 -0400 In-Reply-To: <20130411112018.GU17919@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2OOMNWFNQDJFNAHRCSDEG Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2013-04-11 13:20, Gleb Natapov wrote: > On Sun, Mar 24, 2013 at 07:44:47PM +0100, Jan Kiszka wrote: >> From: Jan Kiszka >> >> If we are in guest mode, L0 can only inject events into L2 if L1 has >> nothing pending. Otherwise, L0 would overwrite L1's events and they >> would get lost. But even if no injection of L1 is pending, we do not >> want L0 to interrupt unnecessarily an on going vmentry with all its si= de >> effects on the vmcs. Therefore, injection shall be disallowed during >> L1->L2 transitions. This check is conceptually independent of >> nested_exit_on_intr. >> >> If L1 traps external interrupts, then we also need to look at L1's >> idt_vectoring_info_field. If it is empty, we can kick the guest from L= 2 >> to L1, just like the previous code worked. >> >> Signed-off-by: Jan Kiszka >> --- >> arch/x86/kvm/vmx.c | 28 ++++++++++++++++++++-------- >> 1 files changed, 20 insertions(+), 8 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index d1bc834..30aa198 100644 >> --- a/arch/x86/kvm/vmx.c >> +++ b/arch/x86/kvm/vmx.c >> @@ -4325,16 +4325,28 @@ static int vmx_nmi_allowed(struct kvm_vcpu *vc= pu) >> =20 >> static int vmx_interrupt_allowed(struct kvm_vcpu *vcpu) >> { >> - if (is_guest_mode(vcpu) && nested_exit_on_intr(vcpu)) { >> + if (is_guest_mode(vcpu)) { >> struct vmcs12 *vmcs12 =3D get_vmcs12(vcpu); >> - if (to_vmx(vcpu)->nested.nested_run_pending || >> - (vmcs12->idt_vectoring_info_field & >> - VECTORING_INFO_VALID_MASK)) >> + >> + if (to_vmx(vcpu)->nested.nested_run_pending) >> return 0; >> - nested_vmx_vmexit(vcpu); >> - vmcs12->vm_exit_reason =3D EXIT_REASON_EXTERNAL_INTERRUPT; >> - vmcs12->vm_exit_intr_info =3D 0; >> - /* fall through to normal code, but now in L1, not L2 */ >> + if (nested_exit_on_intr(vcpu)) { >> + /* >> + * Check if the idt_vectoring_info_field is free. We >> + * cannot raise EXIT_REASON_EXTERNAL_INTERRUPT if it >> + * isn't. >> + */ >> + if (vmcs12->idt_vectoring_info_field & >> + VECTORING_INFO_VALID_MASK) >> + return 0; > After patch 2 I do not see how this can be true. Now this case is > handled by the common code: since event queue is not empty the code wil= l not > get here. The event queue is unconditionally cleared (after being migrated to vmcs12) in patch 2. Jan ------enig2OOMNWFNQDJFNAHRCSDEG 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/ iEYEARECAAYFAlFmyE4ACgkQitSsb3rl5xQd8QCeNzntGbgFbvUNN06dnNkFMBIa NwMAoKlGehuu14S0oQuEJm4sE9L0MBs1 =/n8z -----END PGP SIGNATURE----- ------enig2OOMNWFNQDJFNAHRCSDEG--