[PATCH v2 4/6] KVM: arm64: ptdump: Factor out initialization of kvm_ptdump_guest_state

Wei-Lin Chang weilin.chang at arm.com
Tue Jun 30 05:10:03 PDT 2026


Extract the code for initializing kvm_ptdump_guest_state to allow
reusing the same instance for dumping multiple page tables.

Signed-off-by: Wei-Lin Chang <weilin.chang at arm.com>
---
 arch/arm64/kvm/ptdump.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/kvm/ptdump.c b/arch/arm64/kvm/ptdump.c
index 752d8e0cd25c..0c9647666e65 100644
--- a/arch/arm64/kvm/ptdump.c
+++ b/arch/arm64/kvm/ptdump.c
@@ -112,6 +112,23 @@ static int kvm_ptdump_build_levels(struct ptdump_pg_level *level, u32 start_lvl)
 	return 0;
 }
 
+static int kvm_ptdump_parser_init(struct kvm_ptdump_guest_state *st, struct kvm *kvm,
+				  struct kvm_pgtable *pgt)
+{
+	int ret;
+
+	ret = kvm_ptdump_build_levels(&st->level[0], pgt->start_level);
+	if (ret)
+		return ret;
+
+	st->ipa_marker[0].name          = "Guest IPA";
+	st->ipa_marker[1].start_address = BIT(pgt->ia_bits);
+
+	st->kvm                         = kvm;
+
+	return 0;
+}
+
 static struct kvm_ptdump_guest_state *kvm_ptdump_parser_create(struct kvm *kvm)
 {
 	struct kvm_ptdump_guest_state *st;
@@ -129,17 +146,13 @@ static struct kvm_ptdump_guest_state *kvm_ptdump_parser_create(struct kvm *kvm)
 	}
 
 	pgtable = kvm->arch.mmu.pgt;
+	ret = kvm_ptdump_parser_init(st, kvm, pgtable);
 
-	ret = kvm_ptdump_build_levels(&st->level[0], pgtable->start_level);
 	if (ret) {
 		kfree(st);
 		return ERR_PTR(ret);
 	}
 
-	st->ipa_marker[0].name		= "Guest IPA";
-	st->ipa_marker[1].start_address = BIT(pgtable->ia_bits);
-
-	st->kvm				= kvm;
 	return st;
 }
 
-- 
2.43.0




More information about the linux-arm-kernel mailing list