From: Mark Rutland <mark.rutland@arm.com>
To: Wei-Lin Chang <weilin.chang@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
Oliver Upton <oupton@kernel.org>, Fuad Tabba <tabba@google.com>,
Joey Gouly <joey.gouly@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Dev Jain <dev.jain@arm.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Sebastian Ene <sebastianene@google.com>,
Vincent Donnefort <vdonnefort@google.com>
Subject: Re: [PATCH] KVM: arm64: ptdump: Flush the last region
Date: Mon, 20 Jul 2026 13:37:51 +0100 [thread overview]
Message-ID: <al4Wn4Wb6GrOAw70@J2N7QTR9R3.cambridge.arm.com> (raw)
In-Reply-To: <n5yni7vnama2ok2uzmhahrghrioqjbpcqui44v367rqc57qzqu@wfnio5stdmp3>
On Mon, Jul 20, 2026 at 11:58:44AM +0100, Wei-Lin Chang wrote:
> On Mon, Jul 20, 2026 at 09:35:01AM +0100, Mark Rutland wrote:
> > On Sat, Jul 18, 2026 at 12:12:33AM +0100, Wei-Lin Chang wrote:
> > > @@ -155,11 +155,13 @@ static int kvm_ptdump_guest_show(struct seq_file *m, void *unused)
> > > .seq = m,
> > > };
> > >
> > > - write_lock(&kvm->mmu_lock);
> > > + guard(write_lock)(&kvm->mmu_lock);
> > > ret = kvm_pgtable_walk(mmu->pgt, 0, BIT(mmu->pgt->ia_bits), &walker);
> > > - write_unlock(&kvm->mmu_lock);
> > > + if (ret)
> > > + return ret;
> > > + note_page(&st->parser_state.ptdump, BIT(mmu->pgt->ia_bits), -1, 0);
> >
> > This can be:
> >
> > note_page_flush(&st->parser_state.ptdump);
> >
> > The level change alone should trigger the dump, so the address doesn't
> > need to be at the end of the guest IPA space.
> >
> > Importantly, note_page_flush() will pass 0 as the address, which won't
> > trigger the checks you try to suppress below.
> >
> > Please use note_page_flush() here, and drop the changes to
> > arch/arm64/mm/ptdump.c.
>
> Sorry, I shouldn't have omitted this information, but I did try
> note_page_flush(). And it gives something like this in the last row:
>
> 0x00000000ffc00000-0x0000000000000000 17592186040324M 2 R W px ux AF BLK
>
> The astronomical size is from (addr - st->start_address). As IA bits for
> stage-2 are not close to 64, we'll have large sizes for the last row.
Ok. That's a bug in the current implementation of note_page_flush(),
then. The *intent* is that note_page_flush() is used to terminate
output, and we should mak it work.
Do we need to pass additional information, or do we have the necessary
values in (or accessible from) struct ptdump_state?
> That's one of the reasons I chose to call note_page() with
> BIT(pgtable->ia_bits) as addr, to end the ptdump at the end of the guest
> IPA space.
>
> Additionally, the last row is combining two ranges:
>
> 1. 0x00000000ffc00000-0x0000000100000000 4M 2 R W px ux AF BLK
> 2. 0x0000000100000000-0x0000000000000000 BIG_SIZE - (empty prot)
>
> The attributes are wrong for the large range after
> BIT(pgtable->ia_bits). This is because before dumping the last row, the
> ptdump code is waiting to be notified of the end of the final region
> with all those {R, W, px, ux, AF, BLK} attributes. Using
> note_page_flush() essentially tells it the valid range ends at 1 << 64.
> So actually using note_page() with BIT(pgtable->ia_bits) is required for
> correctness.
>
> The kernel ptdump is not affected by this (at least from my quick test):
>
> 0xffffffffff6fe000-0xffffffffff800000 1032K PTE
> 0xffffffffff800000-0x0000000000000000 8M PMD
Yes, it's not affected because its final VA is 0xffffffffffffffff (i.e.
2^64i - 1), and so using 0 as the next address does the right thing
modulo 64 bits.
We use ptdump for non-kernel tables today (e.g. the EFI mm), so
presumably they suffer the same problem?
Mark.
next prev parent reply other threads:[~2026-07-20 12:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 23:12 Wei-Lin Chang
2026-07-20 8:35 ` Mark Rutland
2026-07-20 10:58 ` Wei-Lin Chang
2026-07-20 11:08 ` Wei-Lin Chang
2026-07-20 12:37 ` Mark Rutland [this message]
2026-07-20 21:21 ` Wei-Lin Chang
2026-07-20 8:53 ` Dev Jain
2026-07-20 9:03 ` Marc Zyngier
2026-07-20 9:10 ` Dev Jain
2026-07-20 9:30 ` Dev Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=al4Wn4Wb6GrOAw70@J2N7QTR9R3.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=catalin.marinas@arm.com \
--cc=dev.jain@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=sebastianene@google.com \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=vdonnefort@google.com \
--cc=weilin.chang@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®