lkml.org 
[lkml]   [2011]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 03/11] KVM: x86: retry non-page-table writing instruction
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 = kvm_mmu_gva_to_gpa_write(vcpu, cr2, NULL);
> >
> > If mmu_is_nested() cr2 is an ngpa, we have to translate it to a gpa, no?
> >
>
> Yeah, will fix it.
>
> And this bug also exists in the current code: it always uses L2 gpa to emulate
> write operation.

Can you please send this fix separately, so it can be backported if needed?

> I guess the reason that it is not triggered is: the gpa of L2's shadow page can
> not be touched by L2, it means no page table is write-protected by L2.

Yes. All real guest hypervisors will do that. But it is technically
possible for a hypervisor to allow its guest access to the real page tables.

> > 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 = kvm_init_shadow_mmu(vcpu,&vcpu->arch.mmu);
>
> vcpu->arch.mmu.set_cr3 = nested_svm_set_tdp_cr3;
> vcpu->arch.mmu.get_cr3 = nested_svm_get_tdp_cr3;
> vcpu->arch.mmu.get_pdptr = nested_svm_get_tdp_pdptr;
> vcpu->arch.mmu.inject_page_fault = nested_svm_inject_npf_exit;
> vcpu->arch.mmu.shadow_root_level = get_npt_level();
> vcpu->arch.walk_mmu =&vcpu->arch.nested_mmu;
>
> return r;
> }
>
> It is initialized in kvm_init_shadow_mmu :-)

Yes, need new eyeglasses.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-09-14 11:55    [W:0.182 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site