From: "Dylan.Wu" <fredwudi0305@gmail.com>
To: palmer@dabbelt.com, pjw@kernel.org, aou@eecs.berkeley.edu,
anup@brainfault.org
Cc: alex@ghiti.fr, atish.patra@linux.dev, zhouquan@iscas.ac.cn,
linux-riscv@lists.infradead.org, kvm@vger.kernel.org,
kvm-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
"Dylan.Wu" <fredwudi0305@gmail.com>
Subject: [PATCH 0/2] riscv: ptdump: Refactor for KVM gstage ptdump support
Date: Wed, 1 Jul 2026 04:50:28 -0400 [thread overview]
Message-ID: <20260701085030.124579-1-fredwudi0305@gmail.com> (raw)
This series refactors the RISC-V ptdump implementation to support
dumping KVM gstage (stage-2) page tables via debugfs.
Patch 1 moves the pagetable walking state and level definitions to a
common header (arch/riscv/include/asm/ptdump.h), updates the attribute
parsing logic to use per-level bit definitions, and exports note_page()
so that it can be reused by the KVM ptdump implementation.
Patch 2 introduces KVM gstage ptdump support, registering a
'gstage_page_tables' file under the guest debugfs directory. This
allows userspace to inspect the gstage layout and permissions, which
is useful for architectural debugging and memory management audits.
Testing:
- Booted on QEMU riscv64 with CONFIG_PTDUMP_DEBUGFS=y and
CONFIG_PTDUMP_GSTAGE_DEBUGFS=y
- Verified /sys/kernel/debug/kernel_page_tables output unchanged
- Created a KVM guest and verified gstage_page_tables output:
0x0000000080200000-0x0000000080209000 0x000000010c94e000 36K PTE .. D A U X W R V
0x000000008020a000-0x0000000080223000 0x000000010c9af000 100K PTE .. D A U X W R V
0x0000000080229000-0x000000008022b000 0x000000010c978000 8K PTE .. D A U X W R V
0x000000008022d000-0x000000008022e000 0x000000010c844000 4K PTE .. D A U X W R V
0x000000008022f000-0x0000000080232000 0x000000010c846000 12K PTE .. D A U X W R V
0x0000000080234000-0x0000000080238000 0x000000010ca13000 16K PTE .. D A U X W R V
0x000000008023a000-0x000000008023f000 0x00000001083bd000 20K PTE .. D A U X W R V
0x0000000080242000-0x000000008024b000 0x0000000106975000 36K PTE .. D A U X W R V
0x000000008024d000-0x0000000080252000 0x000000010cb54000 20K PTE .. D A U X W R V
0x0000000080255000-0x0000000080258000 0x000000010c164000 12K PTE .. D A U X W R V
0x000000008025a000-0x000000008025c000 0x00000001036a9000 8K PTE .. D A U X W R V
0x0000000080260000-0x0000000080275000 0x0000000107917000 84K PTE .. D A U X W R V
0x0000000080276000-0x000000008027e000 0x00000001078ed000 32K PTE .. D A U X W R V
0x000000008027f000-0x00000000802bb000 0x0000000108986000 240K PTE .. D A U X W R V
0x00000000802bc000-0x00000000802c0000 0x000000010762b000 16K PTE .. D A U X W R V
0x00000000802c2000-0x00000000802d2000 0x00000001083fd000 64K PTE .. D A U X W R V
0x00000000802d4000-0x00000000802e0000 0x000000010790b000 48K PTE .. D A U X W R V
0x00000000802e1000-0x00000000802e4000 0x0000000102f74000 12K PTE .. D A U X W R V
0x00000000802e5000-0x00000000802ef000 0x0000000104b9c000 40K PTE .. D A U X W R V
0x00000000802f1000-0x00000000802f2000 0x0000000103778000 4K PTE .. D A U X W R V
0x00000000802f3000-0x00000000802f9000 0x000000010377a000 24K PTE .. D A U X W R V
Dylan.Wu (2):
riscv: ptdump: Move pagetable definitions to common header
KVM: riscv: Register ptdump with debugfs on guest creation
arch/riscv/include/asm/kvm_host.h | 6 +
arch/riscv/include/asm/ptdump.h | 42 +++++++
arch/riscv/kvm/Kconfig | 15 +++
arch/riscv/kvm/Makefile | 1 +
arch/riscv/kvm/ptdump.c | 178 ++++++++++++++++++++++++++++++
arch/riscv/kvm/vm.c | 5 +
arch/riscv/mm/ptdump.c | 102 ++++++-----------
7 files changed, 282 insertions(+), 67 deletions(-)
create mode 100644 arch/riscv/include/asm/ptdump.h
create mode 100644 arch/riscv/kvm/ptdump.c
--
2.34.1
next reply other threads:[~2026-07-01 8:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 8:50 Dylan.Wu [this message]
2026-07-01 8:50 ` [PATCH 1/2] riscv: ptdump: Move pagetable definitions to common header Dylan.Wu
2026-07-01 9:01 ` sashiko-bot
2026-07-01 8:50 ` [PATCH 2/2] KVM: riscv: Register ptdump with debugfs on guest creation Dylan.Wu
2026-07-01 9:06 ` sashiko-bot
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=20260701085030.124579-1-fredwudi0305@gmail.com \
--to=fredwudi0305@gmail.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atish.patra@linux.dev \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=zhouquan@iscas.ac.cn \
/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