From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: VMX: Fix locking order in handle_invalid_guest_state Date: Fri, 24 Jul 2009 09:00:45 +0200 Message-ID: <4A695C1D.7030807@web.de> References: <4A678A56.7050901@web.de> <20090723214553.GA10152@amt.cnet> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig05AE805BC0683734356F5574" Cc: kvm-devel To: Marcelo Tosatti Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:41994 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbZGXHAw (ORCPT ); Fri, 24 Jul 2009 03:00:52 -0400 In-Reply-To: <20090723214553.GA10152@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig05AE805BC0683734356F5574 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Marcelo Tosatti wrote: > On Wed, Jul 22, 2009 at 11:53:26PM +0200, Jan Kiszka wrote: >> Release and re-acquire preemption and IRQ lock in the same order as >> vcpu_enter_guest does. >=20 > This should happen in vcpu_enter_guest, before it decides to disable > preemption/irqs (so you consolidate the control there). Maybe, maybe not. handle_invalid_guest_state is an alternative way of "executing" guest code, and it currently shares the setup and tear-down with vmx_vcpu_run. If it has to share parts that actually require preemption and IRQ lock, then moving makes not much sense. Can anyone comment on what the requirements for handle_invalid_guest_state are? I would suggest to merge this fix first and then decide about and potentially merge a refactoring patch. Jan >=20 > Maybe add a new member to x86_ops? >=20 >> Signed-off-by: Jan Kiszka >> --- >> >> arch/x86/kvm/vmx.c | 4 ++-- >> 1 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index d75c271..4f914c3 100644 >> --- a/arch/x86/kvm/vmx.c >> +++ b/arch/x86/kvm/vmx.c >> @@ -3324,8 +3324,8 @@ static void handle_invalid_guest_state(struct kv= m_vcpu *vcpu, >> struct vcpu_vmx *vmx =3D to_vmx(vcpu); >> enum emulation_result err =3D EMULATE_DONE; >> =20 >> - preempt_enable(); >> local_irq_enable(); >> + preempt_enable(); >> =20 >> while (!guest_state_valid(vcpu)) { >> err =3D emulate_instruction(vcpu, kvm_run, 0, 0, 0); >> @@ -3344,8 +3344,8 @@ static void handle_invalid_guest_state(struct kv= m_vcpu *vcpu, >> schedule(); >> } >> =20 >> - local_irq_disable(); >> preempt_disable(); >> + local_irq_disable(); >> =20 >> vmx->invalid_state_emulation_result =3D err; >> } >> >=20 >=20 --------------enig05AE805BC0683734356F5574 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.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkppXCEACgkQniDOoMHTA+mwrACfTJQv0ZL3BgTshyy7dbqyTz+B 3BIAnRCmN43p/4or5pexbz3sV/+Sc4xM =CjFz -----END PGP SIGNATURE----- --------------enig05AE805BC0683734356F5574--