Crash utility currently does not supporting virtual to physical address translation for 1G huge pages on x86_64, This patch tries to address this issue by providing address translation support for huge pages in 'vtop' command. Without this patch: crash> vtop 7f6e40000000 VIRTUAL PHYSICAL vtop: seek error: physical address: 3f53f000f000 type: "page table" crash> With this patch: crash> vtop 7f6e40000000 VIRTUAL PHYSICAL 7f6e40000000 1d40000000 PGD: 1fdb6cc7f0 => 80000001e715f067 PUD: 1e715fdc8 => 8000001d400008e7 PAGE: 1d40000000 (1GB) PTE PHYSICAL FLAGS 8000001d400008e7 1d40000000 (PRESENT|RW|USER|ACCESSED|DIRTY|PSE|NX) VMA START END FLAGS FILE ffff99869b7791f8 7f6e40000000 7f6ec0000000 c4400fb /var/lib/libvirt/qemu/hugetlbfs/qemu_back_mem._objects_ram-node0.WjBfNa PAGE PHYSICAL MAPPING INDEX CNT FLAGS ffffd90cf5000000 1d40000000 ffff996836978650 0 7 17ffffc000801c referenced,uptodate,dirty,head crash> add the 1G huge pages translation for kvtop as HAGIO KAZUHITO suggested Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx> Signed-off-by: chukaiping <chukaiping@xxxxxxxxxxx> --- diff with v1: add the 1G huge pages translation for kvtop as HAGIO KAZUHITO suggested defs.h | 1 + x86_64.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/defs.h b/defs.h index aba58ff..e73778b 100644 --- a/defs.h +++ b/defs.h @@ -5996,6 +5996,7 @@ struct machine_specific { #define VM_FLAGS (VM_ORIG|VM_2_6_11|VM_XEN|VM_XEN_RHEL4|VM_5LEVEL) #define _2MB_PAGE_MASK (~((MEGABYTES(2))-1)) +#define _1GB_PAGE_MASK (~((GIGABYTES(1))-1)) #endif diff --git a/x86_64.c b/x86_64.c index 4f1a6d7..fc05e8a 100644 --- a/x86_64.c +++ b/x86_64.c @@ -2020,6 +2020,19 @@ x86_64_uvtop_level4(struct task_context *tc, ulong uvaddr, physaddr_t *paddr, in if (!(pud_pte & _PAGE_PRESENT)) goto no_upage; + if (pud_pte & _PAGE_PSE) { + if (verbose) { + fprintf(fp, " PAGE: %lx (1GB)\n\n", + PAGEBASE(pud_pte) & PHYSICAL_PAGE_MASK); + x86_64_translate_pte(pud_pte, 0, 0); + } + + physpage = (PAGEBASE(pud_pte) & PHYSICAL_PAGE_MASK) + + (uvaddr & ~_1GB_PAGE_MASK); + *paddr = physpage; + return TRUE; + } + /* * pmd = pmd_offset(pud, address); */ @@ -2429,6 +2442,19 @@ start_vtop_with_pagetable: if (!(pud_pte & _PAGE_PRESENT)) goto no_kpage; + if (pud_pte & _PAGE_PSE) { + if (verbose) { + fprintf(fp, " PAGE: %lx (1GB)\n\n", + PAGEBASE(pud_pte) & PHYSICAL_PAGE_MASK); + x86_64_translate_pte(pud_pte, 0, 0); + } + + physpage = (PAGEBASE(pud_pte) & PHYSICAL_PAGE_MASK) + + (kvaddr & ~_1GB_PAGE_MASK); + *paddr = physpage; + return TRUE; + } + /* * pmd = pmd_offset(pud, address); */ -- 2.16.2 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility