Marcelo Tosatti wrote: > On Thu, May 06, 2010 at 03:03:48PM +0800, Lai Jiangshan wrote: >> Marcelo Tosatti wrote: >>> On Thu, Apr 29, 2010 at 09:43:40PM +0300, Avi Kivity wrote: >>>> On 04/29/2010 09:09 PM, Marcelo Tosatti wrote: >>>>> You missed quadrant on 4mb large page emulation with shadow (see updated >>>>> patch below). >>>> Good catch. >>>> >>>>> Also for some reason i can't understand the assumption >>>>> does not hold for large sptes with TDP, so reverted for now. >>>> It's unrelated to TDP, same issue with shadow. I think the >>>> calculation is correct. For example the 4th spte for a level=2 page >>>> will yield gfn=4*512. >>> Under testing i see sp at level 2, with sp->gfn == 4096, mmu_set_spte >>> setting index 8 to gfn 4096 (whereas kvm_mmu_page_get_gfn returns 4096 + >>> 8*512). >>> >>> Lai, can you please take a look at it? You should see the >>> kvm_mmu_page_set_gfn BUG_ON by using -mem-path on hugetlbfs. >>> >> Could you tell me how you test it? It will be better if I follow >> your test steps. > > mount -t hugetlbfs none /mnt/ > echo xyz > /proc/sys/vm/nr_hugepages > qemu-kvm parameters -mem-path /mnt/ > >> I also hit the kvm_mmu_page_set_gfn BUG_ON, It is because >> FNAME(fetch)() set sp->gfn wrong. The patch: >> [PATCH] kvm: calculate correct gfn for small host pages which emulates large >> guest pages >> fix it. >> >> I can not hit kvm_mmu_page_set_gfn BUG_ON after this patch also >> applied. >> >> So could you tell me your test steps: >> The host: ept/npt enabled? 64bit? testing codes in host? > > Intel EPT enabled. > >> The guest: OS? PAE? 32bit? 64bit? testing codes in guest? > > FC12 guest. >
I forgot to check if the calculation of base gfn is correct in __direct_map(). Subject: [PATCH] kvm, tdp: calculate correct base gfn for non-DIR level the base gfn calculation is incorrect in __direct_map(), it does not calculate correctly when level=3 or 4. Signed-off-by: Lai Jiangshan <la...@cn.fujitsu.com> Reported-by: Marcelo Tosatti <mtosa...@redhat.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); -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html