]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: arm64: ptdump: Initialize parser_state before pgtable walk
authorZenghui Yu (Huawei) <zenghui.yu@linux.dev>
Sat, 28 Mar 2026 05:31:55 +0000 (13:31 +0800)
committerMarc Zyngier <maz@kernel.org>
Sat, 28 Mar 2026 10:02:55 +0000 (10:02 +0000)
commit570428601ba506e76c265a65626524ef3c5cbc04
treee94ae3bf2d4a512d96fdf2db60eb51bd9ea3a616
parent19e15dc73f0fc74eaf63ad9b3a50648450269b4d
KVM: arm64: ptdump: Initialize parser_state before pgtable walk

If we go through the "need a bigger buffer" path in seq_read_iter(), which
is likely to happen as we're dumping page tables, we will pass the
populated-by-last-run st::parser_state to
kvm_pgtable_walk()/kvm_ptdump_visitor(). As a result, the output of
stage2_page_tables on my box looks like

0x0000000240000000-0x0000000000000000   17179869175G 1
0x0000000000000000-0x0000000000200000           2M 2   R   px ux  AF BLK
0x0000000000200000-0x0000000040000000        1022M 2
0x0000000040000000-0x0000000040200000           2M 2   R W PXNUXN AF BLK
[...]

Fix it by always initializing st::parser_state before starting a new
pgtable walk.

Besides, remove st::range as it's not used by note_page(); remove the
explicit initialization of parser_state::start_address as it will be
initialized in note_page() anyway.

Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
Link: https://patch.msgid.link/20260328053155.12219-1-zenghui.yu@linux.dev
[maz: rebased on top of NV support]
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/ptdump.c