From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v2] KVM: VMX: Do not overwrite vcpu->srcu_idx in vmx_vcpu_reset Date: Fri, 15 Mar 2013 08:09:17 +0100 Message-ID: <5142C91D.7080708@web.de> References: <5141E41B.8080804@siemens.com> <20130314150004.GX11223@redhat.com> <20130314191438.GA9009@amt.cnet> <514222FA.9060706@siemens.com> <51422773.9010901@siemens.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="----enig2SVUKENPCUICWGOJAEVTI" Cc: Marcelo Tosatti , Gleb Natapov , kvm , Paolo Bonzini To: unlisted-recipients:; (no To-header on input) Return-path: Received: from mout.web.de ([212.227.15.4]:58088 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278Ab3COHJZ (ORCPT ); Fri, 15 Mar 2013 03:09:25 -0400 In-Reply-To: <51422773.9010901@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2SVUKENPCUICWGOJAEVTI Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2013-03-14 20:39, Jan Kiszka wrote: > vmx_vcpu_reset may now be called while already holding the srcu lock, s= o > we may overwrite what was already saved there. Save and restore it. >=20 > Signed-off-by: Jan Kiszka > --- >=20 > Even if this should be unneeded, it looks more consistent. In any case,= > all versions on the table, pick what you prefer. >=20 > arch/x86/kvm/vmx.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) >=20 > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 958ac3a..7bc49ca 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -4117,6 +4117,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu)= > { > struct vcpu_vmx *vmx =3D to_vmx(vcpu); > u64 msr; > + int idx; > =20 > vmx->rmode.vm86_active =3D 0; > =20 > @@ -4190,9 +4191,11 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu= ) > vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); > =20 > vmx->vcpu.arch.cr0 =3D X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; > + idx =3D vcpu->srcu_idx; > vcpu->srcu_idx =3D srcu_read_lock(&vcpu->kvm->srcu); > vmx_set_cr0(&vmx->vcpu, kvm_read_cr0(vcpu)); /* enter rmode */ > srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); > + vcpu->srcu_idx =3D idx; > vmx_set_cr4(&vmx->vcpu, 0); > vmx_set_efer(&vmx->vcpu, 0); > vmx_fpu_activate(&vmx->vcpu); >=20 This cannot work either: I think we really need to drop the srcu lock before calling vmx_set_tss_addr. But if we nest the lock, we may only drop it once now in enter_rmode. OK, I'll propose a patch to remove that TSS bug workaround from enter_rmode. Will dig a bit in the archives as well to check which version of qemu-kvm was actually exposing this. Jan ------enig2SVUKENPCUICWGOJAEVTI 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/ iEYEARECAAYFAlFCySEACgkQitSsb3rl5xRsCACeM2G3G28Z6bTbmfgBAjxOYr5c QZcAoJSOnATMo0rcdLmsueWU3azc8Ibf =sHSy -----END PGP SIGNATURE----- ------enig2SVUKENPCUICWGOJAEVTI--