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

Wei-Lin Chang <[email protected]>
Newsgroups org.infradead.lists.linux-arm-kernel,dev.linux.lists.kvmarm,org.kernel.vger.linux-kernel
Message-ID <6psvlhoi727cullfgafzjjtih24setwhm3pfbyeakliytw6ft7@lfk3to4l7huv>
Hi Will,

On Fri, Aug 07, 2026 at 12:46:43PM +0100, Will Deacon wrote:
> 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 <[email protected]>
> > ---
> >  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?

I can add a member end_address in ptdump_pg_state, and initialize it
with the last range->end when users initialize ptdump_pg_state
(ptdump_walk() and ptdump_check_wx()). Is that what you had in mind?

Thanks,
Wei-Lin Chang

> 
> Will
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.