On Wed, Apr 6, 2022 at 11:48 PM <crash-utility-request@redhat.com> wrote:
Date: Wed,  6 Apr 2022 22:38:40 +0800
From: Rongwei Wang <rongwei.wang@linux.alibaba.com>
To: crash-utility@redhat.com, k-hagio-ab@nec.com,
        shijie@os.amperecomputing.com, piliu@redhat.com
Subject: [Crash-utility] [PATCH v2] arm64: handle 1GB block for
        VM_L4_4K
Message-ID: <20220406143840.76523-1-rongwei.wang@linux.alibaba.com>
Content-Type: text/plain; charset="US-ASCII"; x-default=true

When arm64 is configured with PAGE_SIZE=4k and 4 level
translation, the pagetable of all pages may be created with
block mapping or contiguous mapping as much as possible, likes
disable CONFIG_RODATA_FULL_DEFAULT_ENABLED. But now, vtop
command can not handle 1GB block (PUD mapping) well, and just
shows a seek error:

crash> vtop ffff00184a800000
VIRTUAL           PHYSICAL
ffff00184a800000  188a800000

PAGE DIRECTORY: ffff8000110aa000
   PGD: ffff8000110aa000 => 203fff9003
   PUD: ffff001fffff9308 => 68001880000705
   PMD: ffff0018400002a0 => ffff8000103b4fd0
vtop: seek error: kernel virtual address: ffff7fffd03b4000  type: "page table"

This patch fixes it, and shows as following:

crash> vtop ffff00184a800000
VIRTUAL           PHYSICAL
ffff00184a800000  188a800000

PAGE DIRECTORY: ffff8000110aa000
   PGD: ffff8000110aa000 => 203fff9003
   PUD: ffff001fffff9308 => 68001880000705
  PAGE: 1880000000  (1GB)

     PTE         PHYSICAL   FLAGS
68001880000705  1880000000  (VALID|SHARED|AF|PXN|UXN)

      PAGE         PHYSICAL      MAPPING       INDEX CNT FLAGS
fffffe00610a0000 188a800000                0        0  0 77fffe0000000000

Acked-by: Kazuhito Hagio <k-hagio-ab@nec.com>
Signed-off-by: Rongwei Wang <rongwei.wang@linux.alibaba.com>
---
 arm64.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arm64.c b/arm64.c
index 2177c52..65f6cdf 100644
--- a/arm64.c
+++ b/arm64.c
@@ -1999,6 +1999,16 @@ arm64_vtop_4level_4k(ulong pgd, ulong vaddr, physaddr_t *paddr, int verbose)
        if (!pud_val)
                goto no_page;

+       if ((pud_val & PUD_TYPE_MASK) == PUD_TYPE_SECT) {
+               ulong sectionbase = (pud_val & SECTION_PAGE_MASK_1GB) & PHYS_MASK;
+               if (verbose) {
+                       fprintf(fp, "  PAGE: %lx  (1GB)\n\n", sectionbase);
+                       arm64_translate_pte(pud_val, 0, 0);
+               }
+               *paddr = sectionbase + (vaddr & ~SECTION_PAGE_MASK_1GB);
+               return TRUE;
+       }
+
        pmd_base = (ulong *)PTOV(pud_val & PHYS_MASK & (s32)machdep->pagemask);
        FILL_PMD(pmd_base, KVADDR, PTRS_PER_PMD_L4_4K * sizeof(ulong));
        pmd_ptr = pmd_base + (((vaddr) >> PMD_SHIFT_L4_4K) & (PTRS_PER_PMD_L4_4K - 1));
--

Thank you for the fix.
The v2 looks good to me. Applied.

Thanks.
Lianbo


2.27.0