lkml.org 
[lkml]   [2010]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[RESEND PATCH 2/3] kvm, tdp: calculate correct base gfn for non-DIR level

    In Document/kvm/mmu.txt:
    gfn:
    Either the guest page table containing the translations shadowed by this
    page, or the base page frame for linear translations. See role.direct.

    But in __direct_map(), the base gfn calculation is incorrect,
    it does not calculate correctly when level=3 or 4.

    Reported-by: Marcelo Tosatti <mtosatti@redhat.com>
    Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
    ---
    diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
    index a5c6719..6986a6f 100644
    --- a/arch/x86/kvm/mmu.c
    +++ b/arch/x86/kvm/mmu.c
    @@ -1955,7 +1956,10 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
    }

    if (*iterator.sptep == shadow_trap_nonpresent_pte) {
    - pseudo_gfn = (iterator.addr & PT64_DIR_BASE_ADDR_MASK) >> PAGE_SHIFT;
    + u64 base_addr = iterator.addr;
    +
    + base_addr &= PT64_LVL_ADDR_MASK(iterator.level);
    + pseudo_gfn = base_addr >> PAGE_SHIFT;
    sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr,
    iterator.level - 1,
    1, ACC_ALL, iterator.sptep);





    \
     
     \ /
      Last update: 2010-05-26 10:51    [W:0.033 / U:33.068 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site