[PATCH v3 0/2] arm64: ptdump flush fixes

Wei-Lin Chang posted 2 patches 1 month, 2 weeks ago
arch/arm64/include/asm/ptdump.h |  2 ++
arch/arm64/kvm/ptdump.c         | 11 +++++++----
arch/arm64/mm/ptdump.c          | 14 +++++++++++++-
3 files changed, 22 insertions(+), 5 deletions(-)
[PATCH v3 0/2] arm64: ptdump flush fixes
Posted by Wei-Lin Chang 1 month, 2 weeks ago
Hi,

This series fixes two problems around ptdumps:

1. note_page_flush(), which flushes out the last row of ptdumps, does
   not account for address spaces that have IA < 64. Other than making
   the last region extremely huge, the attributes of the last region
   within the address spaces appear to extend all the way to 1 << 64.

2. KVM/arm64's stage-2 ptdump missed calling note_page_flush().

To address Will's comment [1], I have created an end_address field for
struct ptdump_pg_state, and initialized it with the end address of the
ptdumps. It follows the same convention as the last range->end:
exclusive end, except for the case where the address space ends at
1 << 64. In that case it is set as ULONG_MAX.

Caching the end address avoids duplicating the range iteration in
note_page_flush(), at the cost of duplicating state in ptdump_pg_state.

Series is based on v7.2-rc5.

* Changes from v2:

  - Instead of scanning ptdump_state.range[] to find the end address,
    cache the end address in a new field end_address when we initialize
    struct ptdump_pg_state.

  - Adjust KVM's struct ptdump_pg_state initialization so it uses
    end_address instead of ptdump_state.range[].

  - Collected Reviewed-by and Tested-by from Dev, thanks!

  - v2: https://lore.kernel.org/r/20260724185431.2990395-1-weilin.chang@arm.com/

* Changes from v1:

  - Instead of manually calling note_page() for flushing, fix
    note_page_flush() so that it ends the ptdump at the end of the
    address space.

  - Changed the start address of the second marker to ULONG_MAX for KVM
    ptdump, so we don't output extra marker names, and advance past the
    end of the marker array.

  - v1: https://lore.kernel.org/r/20260717231233.2299068-1-weilin.chang@arm.com/

Thanks!

[1]: https://lore.kernel.org/r/anXFo-igVdqrCogQ@willie-the-truck/

Wei-Lin Chang (2):
  arm64: ptdump: Make note_page_flush() range aware
  KVM: arm64: ptdump: Flush the last region

 arch/arm64/include/asm/ptdump.h |  2 ++
 arch/arm64/kvm/ptdump.c         | 11 +++++++----
 arch/arm64/mm/ptdump.c          | 14 +++++++++++++-
 3 files changed, 22 insertions(+), 5 deletions(-)

-- 
2.43.0
Re: [PATCH v3 0/2] arm64: ptdump flush fixes
Posted by Will Deacon 1 month ago
On Fri, 14 Aug 2026 23:24:56 +0100, Wei-Lin Chang wrote:
> This series fixes two problems around ptdumps:
> 
> 1. note_page_flush(), which flushes out the last row of ptdumps, does
>    not account for address spaces that have IA < 64. Other than making
>    the last region extremely huge, the attributes of the last region
>    within the address spaces appear to extend all the way to 1 << 64.
> 
> [...]

Applied to arm64 (for-next/core), thanks!

[1/2] arm64: ptdump: Make note_page_flush() range aware
      https://git.kernel.org/arm64/c/902caade3cfd
[2/2] KVM: arm64: ptdump: Flush the last region
      https://git.kernel.org/arm64/c/beca1b97a21d

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
Re: [PATCH v3 0/2] arm64: ptdump flush fixes
Posted by Marc Zyngier 1 month ago
On Fri, 14 Aug 2026 23:24:56 +0100,
Wei-Lin Chang <weilin.chang@arm.com> wrote:
> 
> Hi,
> 
> This series fixes two problems around ptdumps:
> 
> 1. note_page_flush(), which flushes out the last row of ptdumps, does
>    not account for address spaces that have IA < 64. Other than making
>    the last region extremely huge, the attributes of the last region
>    within the address spaces appear to extend all the way to 1 << 64.
> 
> 2. KVM/arm64's stage-2 ptdump missed calling note_page_flush().
> 
> To address Will's comment [1], I have created an end_address field for
> struct ptdump_pg_state, and initialized it with the end address of the
> ptdumps. It follows the same convention as the last range->end:
> exclusive end, except for the case where the address space ends at
> 1 << 64. In that case it is set as ULONG_MAX.
> 
> Caching the end address avoids duplicating the range iteration in
> note_page_flush(), at the cost of duplicating state in ptdump_pg_state.
> 
> Series is based on v7.2-rc5.

Reviewed-by: Marc Zyngier <maz@kernel.org>

Will, if you're OK with patch #1, do you want the whole thing to go
via the arm64 or the kvmarm tree?

Thanks,

	M.

-- 
Jazz isn't dead. It just smells funny.
Re: [PATCH v3 0/2] arm64: ptdump flush fixes
Posted by Will Deacon 1 month ago
On Sun, Aug 23, 2026 at 11:13:15AM +0100, Marc Zyngier wrote:
> On Fri, 14 Aug 2026 23:24:56 +0100,
> Wei-Lin Chang <weilin.chang@arm.com> wrote:
> > 
> > Hi,
> > 
> > This series fixes two problems around ptdumps:
> > 
> > 1. note_page_flush(), which flushes out the last row of ptdumps, does
> >    not account for address spaces that have IA < 64. Other than making
> >    the last region extremely huge, the attributes of the last region
> >    within the address spaces appear to extend all the way to 1 << 64.
> > 
> > 2. KVM/arm64's stage-2 ptdump missed calling note_page_flush().
> > 
> > To address Will's comment [1], I have created an end_address field for
> > struct ptdump_pg_state, and initialized it with the end address of the
> > ptdumps. It follows the same convention as the last range->end:
> > exclusive end, except for the case where the address space ends at
> > 1 << 64. In that case it is set as ULONG_MAX.
> > 
> > Caching the end address avoids duplicating the range iteration in
> > note_page_flush(), at the cost of duplicating state in ptdump_pg_state.
> > 
> > Series is based on v7.2-rc5.
> 
> Reviewed-by: Marc Zyngier <maz@kernel.org>
> 
> Will, if you're OK with patch #1, do you want the whole thing to go
> via the arm64 or the kvmarm tree?

I can pick 'em both up, as I already have some other fixes on my radar
for -rc1.

Cheers,

Will