mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Anshuman Khandual <anshuman.khandual@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Mark Brown <broonie@kernel.org>,
	Ryan Roberts <ryan.roberts@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-kernel@vger.kernel.org
Subject: [RFC 3/3] arm64/ptdump: Add ARM64_PTDUMP_CONSOLE
Date: Mon, 18 Aug 2025 14:44:36 +0530	[thread overview]
Message-ID: <20250818091436.938517-4-anshuman.khandual@arm.com> (raw)
In-Reply-To: <20250818091436.938517-1-anshuman.khandual@arm.com>

Enable early kernel page table dump for debug purpose when required via new
config ARM64_PDUMP_CONSOLE. This calls existing ptdump_walk() early on just
after ptdump has been initialized with ptdump_init().

Suggested-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm64/Kconfig.debug        | 12 ++++++++++++
 arch/arm64/include/asm/ptdump.h |  7 +++++++
 arch/arm64/kernel/setup.c       |  1 +
 arch/arm64/mm/ptdump.c          |  7 +++++++
 4 files changed, 27 insertions(+)

diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug
index 265c4461031f..0f8af0dd0f4c 100644
--- a/arch/arm64/Kconfig.debug
+++ b/arch/arm64/Kconfig.debug
@@ -20,4 +20,16 @@ config ARM64_RELOC_TEST
 	depends on m
 	tristate "Relocation testing module"
 
+config ARM64_PTDUMP_CONSOLE
+	bool "Dump early kernel page table"
+	depends on DEBUG_KERNEL
+	depends on ARCH_HAS_PTDUMP
+	select PTDUMP
+	help
+	  Enable this option to dump early kernel page table entries during
+	  boot using the PTDUMP framework. This helps in examining kernel's
+	  page table mapping entries and their attributes etc.
+
+	  If in doubt, say N.
+
 source "drivers/hwtracing/coresight/Kconfig"
diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h
index 27e774134e7f..81dc53ca9643 100644
--- a/arch/arm64/include/asm/ptdump.h
+++ b/arch/arm64/include/asm/ptdump.h
@@ -74,8 +74,15 @@ void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name);
 static inline void ptdump_debugfs_register(struct ptdump_info *info,
 					   const char *name) { }
 #endif /* CONFIG_PTDUMP_DEBUGFS */
+
+#ifdef CONFIG_ARM64_PTDUMP_CONSOLE
+void __init arm64_kernel_pgtable_dump(void);
+#else
+static inline void __init arm64_kernel_pgtable_dump(void) { }
+#endif /* CONFIG_ARM64_PTDUMP_CONSOLE */
 #else
 static inline void __init ptdump_init(void) { }
+static inline void __init arm64_kernel_pgtable_dump(void) { }
 static inline void note_page(struct ptdump_state *pt_st, unsigned long addr,
 			     int level, pteval_t val) { }
 static inline void note_page_pte(struct ptdump_state *st, unsigned long addr, pte_t pte) { }
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 0a3812c8e177..86bf7607d304 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -361,6 +361,7 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)
 	init_bootcpu_ops();
 	smp_init_cpus();
 	smp_build_mpidr_hash();
+	arm64_kernel_pgtable_dump();
 
 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
 	/*
diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c
index c78e6b496dea..f6d22462add6 100644
--- a/arch/arm64/mm/ptdump.c
+++ b/arch/arm64/mm/ptdump.c
@@ -407,6 +407,13 @@ void __init ptdump_init(void)
 	ptdump_initialize();
 }
 
+#ifdef CONFIG_ARM64_PTDUMP_CONSOLE
+void __init arm64_kernel_pgtable_dump(void)
+{
+	ptdump_walk(CONSOLE, &kernel_ptdump_info);
+}
+#endif
+
 static int __init ptdump_debugfs_init(void)
 {
 	ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");
-- 
2.25.1


  parent reply	other threads:[~2025-08-18  9:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-18  9:14 [RFC 0/3] " Anshuman Khandual
2025-08-18  9:14 ` [RFC 1/3] arm64/ptdump: Re-organize ptdump_init() Anshuman Khandual
2025-08-18  9:14 ` [RFC 2/3] arm64/ptdump: Enable console output in pt_dump_seq_[printf|puts]() Anshuman Khandual
2025-08-18  9:14 ` Anshuman Khandual [this message]
2025-08-26 15:46   ` [RFC 3/3] arm64/ptdump: Add ARM64_PTDUMP_CONSOLE Ritesh Harjani
2025-08-28  2:22     ` Anshuman Khandual
2025-08-29  3:42       ` Ritesh Harjani
2025-08-29  6:12         ` Anshuman Khandual

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=20250818091436.938517-4-anshuman.khandual@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=will@kernel.org \
    /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®