[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250910094623.2356282-4-anshuman.khandual@arm.com>
Date: Wed, 10 Sep 2025 15:16:23 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: linux-arm-kernel@...ts.infradead.org
Cc: Anshuman Khandual <anshuman.khandual@....com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Mark Brown <broonie@...nel.org>,
Ryan Roberts <ryan.roberts@....com>,
Mark Rutland <mark.rutland@....com>,
Ard Biesheuvel <ardb@...nel.org>,
Ritesh Harjani <ritesh.list@...il.com>,
linux-kernel@...r.kernel.org,
linux-efi@...r.kernel.org,
Jonathan Corbet <corbet@....net>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-doc@...r.kernel.org
Subject: [PATCH 3/3] arm64/ptdump: Add 'early_ptdump' kernel command line option
Enable kernel pgtable dump during boot via a new kernel command line option
'early_ptdump'. This calls ptdump_walk() during boot right after ptdump has
been initialized with ptdump_init().
Cc: Jonathan Corbet <corbet@....net>
Cc: Catalin Marinas <catalin.marinas@....com>
Cc: Will Deacon <will@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-doc@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Cc: linux-arm-kernel@...ts.infradead.org
Suggested-by: Ryan Roberts <ryan.roberts@....com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
---
Documentation/admin-guide/kernel-parameters.txt | 4 ++++
arch/arm64/include/asm/ptdump.h | 2 ++
arch/arm64/kernel/setup.c | 1 +
arch/arm64/mm/ptdump.c | 16 ++++++++++++++++
4 files changed, 23 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 747a55abf494..f8e916750e2e 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1295,6 +1295,10 @@
Enable debug messages in early_ioremap support. This
is useful for tracking down temporary early mappings
which are not unmapped.
+ early_ptdump[=on]
+ Enable kernel page table dump during boot in current
+ ptdump format. This helps analyze early boot mapping
+ kernel regions.
earlycon= [KNL,EARLY] Output early console device and options.
diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h
index 27e774134e7f..ed30d25ca9de 100644
--- a/arch/arm64/include/asm/ptdump.h
+++ b/arch/arm64/include/asm/ptdump.h
@@ -74,8 +74,10 @@ 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 */
+void __init arm64_kernel_pgtable_dump(void);
#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..1624be5160e4 100644
--- a/arch/arm64/mm/ptdump.c
+++ b/arch/arm64/mm/ptdump.c
@@ -407,6 +407,22 @@ void __init ptdump_init(void)
ptdump_initialize();
}
+static bool early_ptdump __initdata;
+
+static int __init parse_early_ptdump(char *arg)
+{
+ if (strcmp(arg, "on") == 0)
+ early_ptdump = true;
+ return 0;
+}
+early_param("early_ptdump", parse_early_ptdump);
+
+void __init arm64_kernel_pgtable_dump(void)
+{
+ if (early_ptdump)
+ ptdump_walk(CONSOLE, &kernel_ptdump_info);
+}
+
static int __init ptdump_debugfs_init(void)
{
ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");
--
2.25.1
Powered by blists - more mailing lists