From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v3 03/11] KVM: x86: retry non-page-table writing instruction Date: Wed, 14 Sep 2011 12:53:21 +0300 Message-ID: <4E707991.10705@redhat.com> References: <4E5C4C20.3000403@cn.fujitsu.com> <4E5C4C5C.8030602@cn.fujitsu.com> <4E6F34CF.1060302@redhat.com> <4E6F9FD2.4010407@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Marcelo Tosatti , LKML , KVM To: Xiao Guangrong Return-path: In-Reply-To: <4E6F9FD2.4010407@cn.fujitsu.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 09/13/2011 09:24 PM, Xiao Guangrong wrote: > >> > >> +static bool retry_instruction(struct x86_emulate_ctxt *ctxt, > >> + unsigned long cr2, int emulation_type) > >> +{ > >> + if (!vcpu->arch.mmu.direct_map&& !mmu_is_nested(vcpu)) > >> + gpa =3D kvm_mmu_gva_to_gpa_write(vcpu, cr2, NULL); > > > > If mmu_is_nested() cr2 is an ngpa, we have to translate it to a gp= a, no? > > > > Yeah, will fix it. > > And this bug also exists in the current code: it always uses L2 gpa t= o emulate > write operation. Can you please send this fix separately, so it can be backported if nee= ded? > I guess the reason that it is not triggered is: the gpa of L2's shado= w page can > not be touched by L2, it means no page table is write-protected by L2= =2E Yes. All real guest hypervisors will do that. But it is technically=20 possible for a hypervisor to allow its guest access to the real page ta= bles. > > btw, I don't see mmu.direct_map initialized for nested npt? > > > > nested_svm_vmrun() -> nested_svm_init_mmu_context(): > static int nested_svm_init_mmu_context(struct kvm_vcpu *vcpu) > { > int r; > > r =3D kvm_init_shadow_mmu(vcpu,&vcpu->arch.mmu); > > vcpu->arch.mmu.set_cr3 =3D nested_svm_set_tdp_cr3; > vcpu->arch.mmu.get_cr3 =3D nested_svm_get_tdp_cr3; > vcpu->arch.mmu.get_pdptr =3D nested_svm_get_tdp_pdptr; > vcpu->arch.mmu.inject_page_fault =3D nested_svm_inject_npf_exit; > vcpu->arch.mmu.shadow_root_level =3D get_npt_level(); > vcpu->arch.walk_mmu =3D&vcpu->arch.nested_mmu; > > return r; > } > > It is initialized in kvm_init_shadow_mmu=E3=80=80:-) Yes, need new eyeglasses. --=20 error compiling committee.c: too many arguments to function