From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v2 5/8] KVM: nVMX: Fix guest CR3 read-back on VM-exit Date: Tue, 06 Aug 2013 12:25:55 +0200 Message-ID: <5200CF33.3000307@web.de> References: <0816baee846f9c8f4d54c6738b2582a95f9c56a3.1375778397.git.jan.kiszka@web.de> <20130806101236.GN8218@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aMVx3PcmTKVImFkxEhRkc980nVNp8HNqh" Cc: Paolo Bonzini , kvm , Xiao Guangrong , Jun Nakajima , Yang Zhang , Arthur Chunqi Li To: Gleb Natapov Return-path: Received: from mout.web.de ([212.227.15.3]:51865 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755674Ab3HFK0D (ORCPT ); Tue, 6 Aug 2013 06:26:03 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.58.223]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0MGiPJ-1VKAyc3ZJZ-00DbQ8 for ; Tue, 06 Aug 2013 12:26:00 +0200 In-Reply-To: <20130806101236.GN8218@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --aMVx3PcmTKVImFkxEhRkc980nVNp8HNqh Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2013-08-06 12:12, Gleb Natapov wrote: > On Tue, Aug 06, 2013 at 10:39:59AM +0200, Jan Kiszka wrote: >> From: Jan Kiszka >> >> If nested EPT is enabled, the L2 guest may change CR3 without any exit= s. >> We therefore have to read the current value from the VMCS when switchi= ng >> to L1. However, if paging wasn't enabled, L0 tracks L2's CR3, and >> GUEST_CR3 rather contains the real-mode identity map. So we need to >> retrieve CR3 from the architectural state after conditionally updating= >> it - and this is what kvm_read_cr3 does. >> > I have a headache from trying to think about it already, but shouldn't > L1 be the one who setups identity map for L2? I traced what > vmcs_read64(GUEST_CR3)/kvm_read_cr3(vcpu) return here and do not see > different values in real mode. Did you try with my patches applied and unrestricted guest mode in use? Jan >=20 >> Signed-off-by: Jan Kiszka >> --- >> arch/x86/kvm/vmx.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index b482d47..09666aa 100644 >> --- a/arch/x86/kvm/vmx.c >> +++ b/arch/x86/kvm/vmx.c >> @@ -8106,7 +8106,7 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu= , struct vmcs12 *vmcs12) >> * Additionally, restore L2's PDPTR to vmcs12. >> */ >> if (enable_ept) { >> - vmcs12->guest_cr3 =3D vmcs_read64(GUEST_CR3); >> + vmcs12->guest_cr3 =3D kvm_read_cr3(vcpu); >> vmcs12->guest_pdptr0 =3D vmcs_read64(GUEST_PDPTR0); >> vmcs12->guest_pdptr1 =3D vmcs_read64(GUEST_PDPTR1); >> vmcs12->guest_pdptr2 =3D vmcs_read64(GUEST_PDPTR2); >> --=20 >> 1.7.3.4 >=20 > -- > Gleb. >=20 --aMVx3PcmTKVImFkxEhRkc980nVNp8HNqh 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/ iEYEARECAAYFAlIAzzYACgkQitSsb3rl5xQG3wCgq7ERVQJ8XulQh1sgosSZxDN+ aLoAnAwMnRc+gNl4Ui6Dm2HNeHr8txD8 =ZRwH -----END PGP SIGNATURE----- --aMVx3PcmTKVImFkxEhRkc980nVNp8HNqh--