On Tue, Sep 03, 2024 at 10:58:24AM +0800, lijiang wrote:
Hi, Kuan Ying
Thank you for the patch set.
On Thu, Aug 22, 2024 at 3:50 PM <devel-request(a)lists.crash-utility.osci.io>
wrote:
> Date: Thu, 22 Aug 2024 15:43:16 +0800
> From: Kuan-Ying Lee <kuan-ying.lee(a)canonical.com>
> Subject: [Crash-utility] [PATCH 1/4] arm64: fix indent issue and
> refactor PTE_TO_PHYS
> To: kuan-ying.lee(a)canonical.com,
> devel(a)lists.crash-utility.osci.io
> Message-ID: <20240822074333.249243-2-kuan-ying.lee(a)canonical.com>
>
> 1. Fix indent issue.
> 2. Use PTE_TO_PHYS() to translate PTE to physical address instead of
> using open-coded to mask.
>
> Signed-off-by: Kuan-Ying Lee <kuan-ying.lee(a)canonical.com>
> ---
> arm64.c | 118 ++++++++++++++++++++++++++++----------------------------
> defs.h | 1 +
> 2 files changed, 61 insertions(+), 58 deletions(-)
>
> diff --git a/arm64.c b/arm64.c
> index 06e7451e0629..8812110fb950 100644
> --- a/arm64.c
> +++ b/arm64.c
> @@ -1881,8 +1881,11 @@ arm64_uvtop(struct task_context *tc, ulong uvaddr,
> physaddr_t *paddr, int verbos
>
> #define PTE_ADDR_LOW ((((1UL) << (48 - machdep->pageshift)) - 1)
<<
> machdep->pageshift)
> #define PTE_ADDR_HIGH ((0xfUL) << 12)
> +#define PTE_ADDR_MASK (machdep->max_physmem_bits == 52 ? \
> + (PTE_ADDR_LOW | PTE_ADDR_HIGH) : PTE_ADDR_LOW)
> +#define PTE_ADDR_HIGH_SHIFT 36
> #define PTE_TO_PHYS(pteval) (machdep->max_physmem_bits == 52 ? \
> - (((pteval & PTE_ADDR_LOW) | ((pteval & PTE_ADDR_HIGH) << 36)))
:
> (pteval & PTE_ADDR_LOW))
> + (((pteval & PTE_ADDR_LOW) | ((pteval & PTE_ADDR_HIGH) <<
> PTE_ADDR_HIGH_SHIFT))) : (pteval & PTE_ADDR_MASK))
>
Other changes are fine to me, only one question:
The macro PTE_ADDR_MASK looks redundant? And no need to use it in the macro
definition PTE_TO_PHYS, because only when the condition
'machdep->max_physmem_bits == 52' is false, the (pteval & PTE_ADDR_MASK)
gets executed, it is redundant to check the same condition again in the
macro PTE_ADDR_MASK.
Maybe it is good enough like this? And remove the macro definition
PTE_ADDR_MASK.
#define PTE_TO_PHYS(pteval) (machdep->max_physmem_bits == 52 ? \
- (((pteval & PTE_ADDR_LOW) | ((pteval & PTE_ADDR_HIGH) << 36))) :
(pteval & PTE_ADDR_LOW))
+ (((pteval & PTE_ADDR_LOW) | ((pteval & PTE_ADDR_HIGH) <<
PTE_ADDR_HIGH_SHIFT))) : (pteval & PTE_ADDR_LOW))
Just want to confirm with you.
Hi Lianbo,
You are right.
I will send the v2 version.
Thanks,
Kuan-Ying Lee
>
> Thanks
> Lianbo
>
>
> > #define PUD_TYPE_MASK 3
> > #define PUD_TYPE_SECT 1
> > @@ -1906,9 +1909,9 @@ arm64_vtop_2level_64k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > pgd_base = (ulong *)pgd;
> > FILL_PGD(pgd_base, KVADDR, machdep->ptrs_per_pgd * sizeof(ulong));
> > pgd_ptr = pgd_base + (((vaddr) >> PGDIR_SHIFT_L2_64K) &
> > (machdep->ptrs_per_pgd - 1));
> > - pgd_val = ULONG(machdep->pgd + PAGEOFFSET(pgd_ptr));
> > - if (verbose)
> > - fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > + pgd_val = ULONG(machdep->pgd + PAGEOFFSET(pgd_ptr));
> > + if (verbose)
> > + fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > if (!pgd_val)
> > goto no_page;
> >
> > @@ -1918,7 +1921,7 @@ arm64_vtop_2level_64k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > */
> >
> > if ((pgd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) {
> > - ulong sectionbase = (pgd_val & SECTION_PAGE_MASK_512MB)
&
> > PHYS_MASK;
> > + ulong sectionbase = PTE_TO_PHYS(pgd_val &
> > SECTION_PAGE_MASK_512MB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (512MB%s)\n\n",
> > sectionbase,
> > IS_ZEROPAGE(sectionbase) ? ", ZERO
PAGE" :
> > "");
> > @@ -1928,17 +1931,17 @@ arm64_vtop_2level_64k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > return TRUE;
> > }
> >
> > - pte_base = (ulong *)PTOV(pgd_val & PHYS_MASK &
> > (s32)machdep->pagemask);
> > + pte_base = (ulong *)PTOV(PTE_TO_PHYS(pgd_val));
> > FILL_PTBL(pte_base, KVADDR, PTRS_PER_PTE_L2_64K * sizeof(ulong));
> > pte_ptr = pte_base + (((vaddr) >> machdep->pageshift) &
> > (PTRS_PER_PTE_L2_64K - 1));
> > - pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > - if (verbose)
> > - fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > + pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > + if (verbose)
> > + fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > if (!pte_val)
> > goto no_page;
> >
> > if (pte_val & PTE_VALID) {
> > - *paddr = (PAGEBASE(pte_val) & PHYS_MASK) +
> > PAGEOFFSET(vaddr);
> > + *paddr = PTE_TO_PHYS(pte_val) + PAGEOFFSET(vaddr);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx %s\n\n",
> > PAGEBASE(*paddr),
> > IS_ZEROPAGE(PAGEBASE(*paddr)) ? "(ZERO
> > PAGE)" : "");
> > @@ -1972,9 +1975,9 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > pgd_base = (ulong *)pgd;
> > FILL_PGD(pgd_base, KVADDR, machdep->ptrs_per_pgd * sizeof(ulong));
> > pgd_ptr = pgd_base + (((vaddr) >> PGDIR_SHIFT_L3_64K) &
> > (machdep->ptrs_per_pgd - 1));
> > - pgd_val = ULONG(machdep->pgd + PGDIR_OFFSET_L3_64K(pgd_ptr));
> > - if (verbose)
> > - fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > + pgd_val = ULONG(machdep->pgd + PGDIR_OFFSET_L3_64K(pgd_ptr));
> > + if (verbose)
> > + fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > if (!pgd_val)
> > goto no_page;
> >
> > @@ -1985,14 +1988,14 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > pmd_base = (ulong *)PTOV(PTE_TO_PHYS(pgd_val));
> > FILL_PMD(pmd_base, KVADDR, PTRS_PER_PMD_L3_64K * sizeof(ulong));
> > pmd_ptr = pmd_base + (((vaddr) >> PMD_SHIFT_L3_64K) &
> > (PTRS_PER_PMD_L3_64K - 1));
> > - pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr));
> > - if (verbose)
> > - fprintf(fp, " PMD: %lx => %lx\n",
(ulong)pmd_ptr,
> > pmd_val);
> > + pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr));
> > + if (verbose)
> > + fprintf(fp, " PMD: %lx => %lx\n",
(ulong)pmd_ptr,
> > pmd_val);
> > if (!pmd_val)
> > goto no_page;
> >
> > if ((pmd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) {
> > - ulong sectionbase = PTE_TO_PHYS(pmd_val) &
> > SECTION_PAGE_MASK_512MB;
> > + ulong sectionbase = PTE_TO_PHYS(pmd_val &
> > SECTION_PAGE_MASK_512MB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (512MB%s)\n\n",
> > sectionbase,
> > IS_ZEROPAGE(sectionbase) ? ", ZERO
PAGE" :
> > "");
> > @@ -2005,9 +2008,9 @@ arm64_vtop_3level_64k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > pte_base = (ulong *)PTOV(PTE_TO_PHYS(pmd_val));
> > FILL_PTBL(pte_base, KVADDR, PTRS_PER_PTE_L3_64K * sizeof(ulong));
> > pte_ptr = pte_base + (((vaddr) >> machdep->pageshift) &
> > (PTRS_PER_PTE_L3_64K - 1));
> > - pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > - if (verbose)
> > - fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > + pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > + if (verbose)
> > + fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > if (!pte_val)
> > goto no_page;
> >
> > @@ -2045,7 +2048,7 @@ arm64_vtop_2level_16k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > pgd_base = (ulong *)pgd;
> > FILL_PGD(pgd_base, KVADDR, machdep->ptrs_per_pgd * sizeof(ulong));
> > pgd_ptr = pgd_base + (((vaddr) >> PGDIR_SHIFT_L2_16K) &
> > (machdep->ptrs_per_pgd - 1));
> > - pgd_val = ULONG(machdep->pgd + PAGEOFFSET(pgd_ptr));
> > + pgd_val = ULONG(machdep->pgd + PGDIR_OFFSET_L2_16K(pgd_ptr));
> > if (verbose)
> > fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > if (!pgd_val)
> > @@ -2057,7 +2060,7 @@ arm64_vtop_2level_16k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > */
> >
> > if ((pgd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) {
> > - ulong sectionbase = (pgd_val & SECTION_PAGE_MASK_32MB)
&
> > PHYS_MASK;
> > + ulong sectionbase = PTE_TO_PHYS(pgd_val &
> > SECTION_PAGE_MASK_32MB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (32MB%s)\n\n",
> > sectionbase,
> > IS_ZEROPAGE(sectionbase) ? ", ZERO
PAGE" :
> > "");
> > @@ -2067,7 +2070,7 @@ arm64_vtop_2level_16k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > return TRUE;
> > }
> >
> > - pte_base = (ulong *)PTOV(pgd_val & PHYS_MASK &
> > (s32)machdep->pagemask);
> > + pte_base = (ulong *)PTOV(PTE_TO_PHYS(pgd_val));
> > FILL_PTBL(pte_base, KVADDR, PTRS_PER_PTE_L2_16K * sizeof(ulong));
> > pte_ptr = pte_base + (((vaddr) >> machdep->pageshift) &
> > (PTRS_PER_PTE_L2_16K - 1));
> > pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > @@ -2077,7 +2080,7 @@ arm64_vtop_2level_16k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > goto no_page;
> >
> > if (pte_val & PTE_VALID) {
> > - *paddr = (PAGEBASE(pte_val) & PHYS_MASK) +
> > PAGEOFFSET(vaddr);
> > + *paddr = PTE_TO_PHYS(pte_val) + PAGEOFFSET(vaddr);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx %s\n\n",
> > PAGEBASE(*paddr),
> > IS_ZEROPAGE(PAGEBASE(*paddr)) ? "(ZERO
> > PAGE)" : "");
> > @@ -2130,7 +2133,7 @@ arm64_vtop_3level_16k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > goto no_page;
> >
> > if ((pmd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) {
> > - ulong sectionbase = PTE_TO_PHYS(pmd_val) &
> > SECTION_PAGE_MASK_32MB;
> > + ulong sectionbase = PTE_TO_PHYS(pmd_val &
> > SECTION_PAGE_MASK_32MB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (32MB%s)\n\n",
> > sectionbase,
> > IS_ZEROPAGE(sectionbase) ? ", ZERO
PAGE" :
> > "");
> > @@ -2184,14 +2187,14 @@ arm64_vtop_3level_4k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > pgd_base = (ulong *)pgd;
> > FILL_PGD(pgd_base, KVADDR, PTRS_PER_PGD_L3_4K * sizeof(ulong));
> > pgd_ptr = pgd_base + (((vaddr) >> PGDIR_SHIFT_L3_4K) &
> > (PTRS_PER_PGD_L3_4K - 1));
> > - pgd_val = ULONG(machdep->pgd + PAGEOFFSET(pgd_ptr));
> > - if (verbose)
> > - fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > + pgd_val = ULONG(machdep->pgd + PAGEOFFSET(pgd_ptr));
> > + if (verbose)
> > + fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > if (!pgd_val)
> > goto no_page;
> >
> > if ((pgd_val & PUD_TYPE_MASK) == PUD_TYPE_SECT) {
> > - ulong sectionbase = (pgd_val & SECTION_PAGE_MASK_1GB) &
> > PHYS_MASK;
> > + ulong sectionbase = PTE_TO_PHYS(pgd_val &
> > SECTION_PAGE_MASK_1GB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (1GB)\n\n",
sectionbase);
> > arm64_translate_pte(pgd_val, 0, 0);
> > @@ -2203,17 +2206,17 @@ arm64_vtop_3level_4k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > * #define __PAGETABLE_PUD_FOLDED
> > */
> >
> > - pmd_base = (ulong *)PTOV(pgd_val & PHYS_MASK &
> > (s32)machdep->pagemask);
> > + pmd_base = (ulong *)PTOV(PTE_TO_PHYS(pgd_val));
> > FILL_PMD(pmd_base, KVADDR, PTRS_PER_PMD_L3_4K * sizeof(ulong));
> > pmd_ptr = pmd_base + (((vaddr) >> PMD_SHIFT_L3_4K) &
> > (PTRS_PER_PMD_L3_4K - 1));
> > - pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr));
> > - if (verbose)
> > - fprintf(fp, " PMD: %lx => %lx\n",
(ulong)pmd_ptr,
> > pmd_val);
> > + pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr));
> > + if (verbose)
> > + fprintf(fp, " PMD: %lx => %lx\n",
(ulong)pmd_ptr,
> > pmd_val);
> > if (!pmd_val)
> > goto no_page;
> >
> > if ((pmd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) {
> > - ulong sectionbase = (pmd_val & SECTION_PAGE_MASK_2MB) &
> > PHYS_MASK;
> > + ulong sectionbase = PTE_TO_PHYS(pmd_val &
> > SECTION_PAGE_MASK_2MB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (2MB%s)\n\n",
> > sectionbase,
> > IS_ZEROPAGE(sectionbase) ? ", ZERO
PAGE" :
> > "");
> > @@ -2223,17 +2226,17 @@ arm64_vtop_3level_4k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > return TRUE;
> > }
> >
> > - pte_base = (ulong *)PTOV(pmd_val & PHYS_MASK &
> > (s32)machdep->pagemask);
> > + pte_base = (ulong *)PTOV(PTE_TO_PHYS(pmd_val));
> > FILL_PTBL(pte_base, KVADDR, PTRS_PER_PTE_L3_4K * sizeof(ulong));
> > pte_ptr = pte_base + (((vaddr) >> machdep->pageshift) &
> > (PTRS_PER_PTE_L3_4K - 1));
> > - pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > - if (verbose)
> > - fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > + pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > + if (verbose)
> > + fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > if (!pte_val)
> > goto no_page;
> >
> > if (pte_val & PTE_VALID) {
> > - *paddr = (PAGEBASE(pte_val) & PHYS_MASK) +
> > PAGEOFFSET(vaddr);
> > + *paddr = PTE_TO_PHYS(pte_val) + PAGEOFFSET(vaddr);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx %s\n\n",
> > PAGEBASE(*paddr),
> > IS_ZEROPAGE(PAGEBASE(*paddr)) ? "(ZERO
> > PAGE)" : "");
> > @@ -2268,24 +2271,23 @@ arm64_vtop_4level_4k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > pgd_base = (ulong *)pgd;
> > FILL_PGD(pgd_base, KVADDR, PTRS_PER_PGD_L4_4K * sizeof(ulong));
> > pgd_ptr = pgd_base + (((vaddr) >> PGDIR_SHIFT_L4_4K) &
> > (PTRS_PER_PGD_L4_4K - 1));
> > - pgd_val = ULONG(machdep->pgd + PGDIR_OFFSET_48VA(pgd_ptr));
> > - if (verbose)
> > - fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > + pgd_val = ULONG(machdep->pgd + PGDIR_OFFSET_48VA(pgd_ptr));
> > + if (verbose)
> > + fprintf(fp, " PGD: %lx => %lx\n",
(ulong)pgd_ptr,
> > pgd_val);
> > if (!pgd_val)
> > goto no_page;
> >
> > - pud_base = (ulong *)PTOV(pgd_val & PHYS_MASK &
PGDIR_MASK_48VA);
> > -
> > + pud_base = (ulong *)PTOV(PTE_TO_PHYS(pgd_val));
> > FILL_PUD(pud_base, KVADDR, PTRS_PER_PUD_L4_4K * sizeof(ulong));
> > pud_ptr = pud_base + (((vaddr) >> PUD_SHIFT_L4_4K) &
> > (PTRS_PER_PUD_L4_4K - 1));
> > - pud_val = ULONG(machdep->pud + PAGEOFFSET(pud_ptr));
> > - if (verbose)
> > - fprintf(fp, " PUD: %lx => %lx\n",
(ulong)pud_ptr,
> > pud_val);
> > + pud_val = ULONG(machdep->pud + PAGEOFFSET(pud_ptr));
> > + if (verbose)
> > + fprintf(fp, " PUD: %lx => %lx\n",
(ulong)pud_ptr,
> > pud_val);
> > 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;
> > + ulong sectionbase = PTE_TO_PHYS(pud_val &
> > SECTION_PAGE_MASK_1GB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (1GB)\n\n",
sectionbase);
> > arm64_translate_pte(pud_val, 0, 0);
> > @@ -2294,17 +2296,17 @@ arm64_vtop_4level_4k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > return TRUE;
> > }
> >
> > - pmd_base = (ulong *)PTOV(pud_val & PHYS_MASK &
> > (s32)machdep->pagemask);
> > + pmd_base = (ulong *)PTOV(PTE_TO_PHYS(pud_val));
> > 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));
> > - pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr));
> > - if (verbose)
> > - fprintf(fp, " PMD: %lx => %lx\n",
(ulong)pmd_ptr,
> > pmd_val);
> > + pmd_val = ULONG(machdep->pmd + PAGEOFFSET(pmd_ptr));
> > + if (verbose)
> > + fprintf(fp, " PMD: %lx => %lx\n",
(ulong)pmd_ptr,
> > pmd_val);
> > if (!pmd_val)
> > goto no_page;
> >
> > if ((pmd_val & PMD_TYPE_MASK) == PMD_TYPE_SECT) {
> > - ulong sectionbase = (pmd_val & SECTION_PAGE_MASK_2MB) &
> > PHYS_MASK;
> > + ulong sectionbase = PTE_TO_PHYS(pmd_val &
> > SECTION_PAGE_MASK_2MB);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx (2MB%s)\n\n",
> > sectionbase,
> > IS_ZEROPAGE(sectionbase) ? ", ZERO
PAGE" :
> > "");
> > @@ -2314,17 +2316,17 @@ arm64_vtop_4level_4k(ulong pgd, ulong vaddr,
> > physaddr_t *paddr, int verbose)
> > return TRUE;
> > }
> >
> > - pte_base = (ulong *)PTOV(pmd_val & PHYS_MASK &
> > (s32)machdep->pagemask);
> > + pte_base = (ulong *)PTOV(PTE_TO_PHYS(pmd_val));
> > FILL_PTBL(pte_base, KVADDR, PTRS_PER_PTE_L4_4K * sizeof(ulong));
> > pte_ptr = pte_base + (((vaddr) >> machdep->pageshift) &
> > (PTRS_PER_PTE_L4_4K - 1));
> > - pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > - if (verbose)
> > - fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > + pte_val = ULONG(machdep->ptbl + PAGEOFFSET(pte_ptr));
> > + if (verbose)
> > + fprintf(fp, " PTE: %lx => %lx\n",
(ulong)pte_ptr,
> > pte_val);
> > if (!pte_val)
> > goto no_page;
> >
> > if (pte_val & PTE_VALID) {
> > - *paddr = (PAGEBASE(pte_val) & PHYS_MASK) +
> > PAGEOFFSET(vaddr);
> > + *paddr = PTE_TO_PHYS(pte_val) + PAGEOFFSET(vaddr);
> > if (verbose) {
> > fprintf(fp, " PAGE: %lx %s\n\n",
> > PAGEBASE(*paddr),
> > IS_ZEROPAGE(PAGEBASE(*paddr)) ? "(ZERO
> > PAGE)" : "");
> > diff --git a/defs.h b/defs.h
> > index dfbd2419f969..92e8708367d1 100644
> > --- a/defs.h
> > +++ b/defs.h
> > @@ -3311,6 +3311,7 @@ typedef signed int s32;
> > #define PGDIR_SHIFT_L2_16K (25)
> > #define PGDIR_SIZE_L2_16K ((1UL) << PGDIR_SHIFT_L2_16K)
> > #define PGDIR_MASK_L2_16K (~(PGDIR_SIZE_L2_16K-1))
> > +#define PGDIR_OFFSET_L2_16K(X) (((ulong)(X)) & ((machdep->ptrs_per_pgd
*
> > 8) - 1))
> >
> > /*
> > * 3-levels / 16K pages
> > --
> > 2.43.0
> >