From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH v2 5/8] KVM: nVMX: Fix guest CR3 read-back on VM-exit Date: Tue, 6 Aug 2013 13:12:36 +0300 Message-ID: <20130806101236.GN8218@redhat.com> References: <0816baee846f9c8f4d54c6738b2582a95f9c56a3.1375778397.git.jan.kiszka@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Paolo Bonzini , kvm , Xiao Guangrong , Jun Nakajima , Yang Zhang , Arthur Chunqi Li To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:15657 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755844Ab3HFKMl (ORCPT ); Tue, 6 Aug 2013 06:12:41 -0400 Content-Disposition: inline In-Reply-To: <0816baee846f9c8f4d54c6738b2582a95f9c56a3.1375778397.git.jan.kiszka@web.de> Sender: kvm-owner@vger.kernel.org List-ID: 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 exits. > We therefore have to read the current value from the VMCS when switching > 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. > 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 = vmcs_read64(GUEST_CR3); > + vmcs12->guest_cr3 = kvm_read_cr3(vcpu); > vmcs12->guest_pdptr0 = vmcs_read64(GUEST_PDPTR0); > vmcs12->guest_pdptr1 = vmcs_read64(GUEST_PDPTR1); > vmcs12->guest_pdptr2 = vmcs_read64(GUEST_PDPTR2); > -- > 1.7.3.4 -- Gleb.