[PATCH v2 1/2] arm64: ptdump: Make note_page_flush() range aware

Will Deacon will at kernel.org
Fri Aug 7 04:46:43 PDT 2026


On Fri, Jul 24, 2026 at 07:54:30PM +0100, Wei-Lin Chang wrote:
> note_page_flush() calls note_page() with addr == 0 and level == -1 to
> dump the last row of a ptdump. addr == 0 (1 << 64 wrapped around)
> renders a huge region with enormous size for address spaces with
> IA bits < 64. For example the stage-2 page tables and the EFI runtime
> page table.
> 
> More importantly, the last region of the address space and everything
> after the address space up to 1 << 64 are merged into one row of
> output. If the last region within the address space is valid, it will
> appear to remain valid up to 1 << 64 with the same attributes.
> 
> Currently only the EFI runtime ptdump is affected by this, but KVM will
> soon fix its stage-2 ptdump by using note_page_flush(). Here is an
> example of an EFI runtime ptdump (last row):
> 
> 0x0000008000000000-0x0000000000000000   17179868672G PGD
> 
> With this patch:
> 
> 0x0000008000000000-0x0001000000000000      261632G PGD
> 
> To fix this, use ptdump_state.range[] to figure out where the address
> space ends, and call note_page() with that.
> 
> Fixes: 9d80448ac92b ("efi/arm64: Add debugfs node to dump UEFI runtime page tables")
> Signed-off-by: Wei-Lin Chang <weilin.chang at arm.com>
> ---
>  arch/arm64/mm/ptdump.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c
> index 1c20144700d7..5b34060ceb96 100644
> --- a/arch/arm64/mm/ptdump.c
> +++ b/arch/arm64/mm/ptdump.c
> @@ -278,9 +278,24 @@ void note_page_pgd(struct ptdump_state *pt_st, unsigned long addr, pgd_t pgd)
>  
>  void note_page_flush(struct ptdump_state *pt_st)
>  {
> +	const struct ptdump_range *range = pt_st->range;
> +	unsigned long end = 0;
>  	pte_t pte_zero = {0};
>  
> -	note_page(pt_st, 0, -1, pte_val(pte_zero));
> +	while (range->start != range->end) {
> +		end = range->end;
> +		range++;
> +	}

This seems to be duplicating some of what the core code does already in
ptdump_walk_pgd(). Can we retrieve the information we need from the
containing 'struct ptdump_pg_state' structure instead of recomputing
the address?

Will



More information about the linux-arm-kernel mailing list