From: Li RongQing <lirongqing(a)baidu.com>
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>
Signed-off-by: Li RongQing <lirongqing(a)baidu.com>
Signed-off-by: Chu Kaiping <chukaiping(a)foxmail.com>
---
defs.h | 1 +
x86_64.c | 13 +++++++++++++
2 files changed, 14 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..98bb685 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);
*/
--
2.16.2
Show replies by date