[Crash-utility] [PATCH][v2] x86_64: vtop supports 1G huge pages
HAGIO KAZUHITO(萩尾 一仁)
k-hagio-ab at nec.com
Thu Jun 11 14:44:33 UTC 2020
-----Original Message-----
> 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 at baidu.com>
> Signed-off-by: chukaiping <chukaiping at foxmail.com>
Looks good to me, thank you Li RongQing. Please wait for another ack.
Acked-by: Kazuhito Hagio <k-hagio-ab at nec.com>
If someone can comment or create a patch for Xen, please let us know.
I cannot test it, but I think we can integrate it with this patch if any.
Thanks,
Kazu
> ---
> 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
More information about the Crash-utility
mailing list