From: Marc Zyngier <maz@kernel.org>
To: Dev Jain <dev.jain@arm.com>
Cc: Wei-Lin Chang <weilin.chang@arm.com>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.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>,
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 10:03:57 +0100 [thread overview]
Message-ID: <868q76f2wy.wl-maz@kernel.org> (raw)
In-Reply-To: <ad52d1ee-04cb-42d7-b50c-dfb3d28db5df@arm.com>
On Mon, 20 Jul 2026 09:53:29 +0100,
Dev Jain <dev.jain@arm.com> wrote:
>
>
>
> On 18/07/26 4:42 am, Wei-Lin Chang wrote:
> > Currently the stage-2 ptdump calls note_page() at each leaf entry visit.
> > This simply misses the output of the last region, because note_page()
> > only dumps output when it detects a change in level/prot, or when the
> > walk enters a next marker section. The last region in the guest IPA
> > space with the same level/prot is not dumped since there is no change
> > after it.
> >
> > To dump the final region, manually issue a note_page() call with address
> > BIT(ia_bits) (end of guest IPA space) and level == -1 to trigger a level
> > change after the last region. Additionally treat level == -1 as a last
> > flushing note_page() call and avoid dumping the name of the next marker
> > for this case.
> >
> > Fixes: 7c4f73548ed1 ("KVM: arm64: Register ptdump with debugfs on guest creation")
> > Reported-by: Sashiko AI <sashiko-bot@kernel.org>
> > Closes: https://lore.kernel.org/kvmarm/20260630122758.891011F00A3A@smtp.kernel.org/
> > Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com>
> > ---
> > arch/arm64/kvm/ptdump.c | 8 +++++---
> > arch/arm64/mm/ptdump.c | 5 +++--
> > 2 files changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
> > index c9140e22abcf..4096e4a92fae 100644
> > --- a/arch/arm64/kvm/ptdump.c
> > +++ b/arch/arm64/kvm/ptdump.c
> > @@ -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);
>
> The guard clause change has nothing to do with the fix I think? Although the change
> is small and the fix is for a recent commit so maybe we don't care having this
> in the same patch - not sure how strict kvm reviewers are about this : )
>
Look at the quality spaghetti code this would otherwise result in:
write_lock();
ret = kvm_pgtable_walk();
if (ret) {
write_unlock();
return ret;
}
note_page_flush();
write_unlock();
return 0;
How is that better? So it has *everything* to do with the fix.
And FWIW, the policy for KVM is that we don't do lock->guard
conversions as a separate patches. Only when we need to change the
code, and as part of the patch that changes that code. Which is
exactly what is happening here.
>
> > 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);
> >
> > - return ret;
> > + return 0;
> > }
> >
> > static int kvm_ptdump_guest_open(struct inode *m, struct file *file)
> > diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c
> > index ab9899ca1e5f..fed4e4407e0e 100644
> > --- a/arch/arm64/mm/ptdump.c
> > +++ b/arch/arm64/mm/ptdump.c
> > @@ -194,6 +194,7 @@ void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
> > struct ptdump_pg_state *st = container_of(pt_st, struct ptdump_pg_state, ptdump);
> > struct ptdump_pg_level *pg_level = st->pg_level;
> > static const char units[] = "KMGTPE";
> > + bool flush = level == -1;
>
> Can we do something similar to what S1 ptdump does (note_page_flush in ptdump_walk_pgd).
See Mark's email.
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2026-07-20 9:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 23:12 [PATCH] KVM: arm64: ptdump: Flush the last region 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
2026-07-20 21:21 ` Wei-Lin Chang
2026-07-20 8:53 ` Dev Jain
2026-07-20 9:03 ` Marc Zyngier [this message]
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=868q76f2wy.wl-maz@kernel.org \
--to=maz@kernel.org \
--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=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