]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm64: ptdump: Allow all region boundaries to be defined at boot time
authorArd Biesheuvel <ardb@kernel.org>
Wed, 13 Dec 2023 08:40:28 +0000 (09:40 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 9 Feb 2024 10:56:11 +0000 (10:56 +0000)
Rework the way the address_markers array is populated so that we can
tolerate values that are not compile time constants generally, rather
than keeping track manually of the array indexes in question, and poking
new values into them manually. This will be needed for VMALLOC_END,
which will cease to be a compile time constant after a subsequent patch.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20231213084024.2367360-12-ardb@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
arch/arm64/mm/ptdump.c

index a929b5a321dbacb42e299a9f926b4f39ab22590a..66ccb8d6997e8b0f2aab0517f040524ac3bac3d5 100644 (file)
 #include <asm/ptdump.h>
 
 
-enum address_markers_idx {
-       PAGE_OFFSET_NR = 0,
-       PAGE_END_NR,
-#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
-       KASAN_START_NR,
-#endif
-};
-
-static struct addr_marker address_markers[] = {
-       { PAGE_OFFSET,                  "Linear Mapping start" },
-       { 0 /* PAGE_END */,             "Linear Mapping end" },
-#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
-       { 0 /* KASAN_SHADOW_START */,   "Kasan shadow start" },
-       { KASAN_SHADOW_END,             "Kasan shadow end" },
-#endif
-       { MODULES_VADDR,                "Modules start" },
-       { MODULES_END,                  "Modules end" },
-       { VMALLOC_START,                "vmalloc() area" },
-       { VMALLOC_END,                  "vmalloc() end" },
-       { VMEMMAP_START,                "vmemmap start" },
-       { VMEMMAP_END,                  "vmemmap end" },
-       { PCI_IO_START,                 "PCI I/O start" },
-       { PCI_IO_END,                   "PCI I/O end" },
-       { FIXADDR_TOT_START,            "Fixmap start" },
-       { FIXADDR_TOP,                  "Fixmap end" },
-       { -1,                           NULL },
-};
-
 #define pt_dump_seq_printf(m, fmt, args...)    \
 ({                                             \
        if (m)                                  \
@@ -339,9 +311,8 @@ static void __init ptdump_initialize(void)
                                pg_level[i].mask |= pg_level[i].bits[j].mask;
 }
 
-static struct ptdump_info kernel_ptdump_info = {
+static struct ptdump_info kernel_ptdump_info __ro_after_init = {
        .mm             = &init_mm,
-       .markers        = address_markers,
        .base_addr      = PAGE_OFFSET,
 };
 
@@ -375,10 +346,29 @@ void ptdump_check_wx(void)
 
 static int __init ptdump_init(void)
 {
-       address_markers[PAGE_END_NR].start_address = PAGE_END;
+       struct addr_marker m[] = {
+               { PAGE_OFFSET,          "Linear Mapping start" },
+               { PAGE_END,             "Linear Mapping end" },
 #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
-       address_markers[KASAN_START_NR].start_address = KASAN_SHADOW_START;
+               { KASAN_SHADOW_START,   "Kasan shadow start" },
+               { KASAN_SHADOW_END,     "Kasan shadow end" },
 #endif
+               { MODULES_VADDR,        "Modules start" },
+               { MODULES_END,          "Modules end" },
+               { VMALLOC_START,        "vmalloc() area" },
+               { VMALLOC_END,          "vmalloc() end" },
+               { VMEMMAP_START,        "vmemmap start" },
+               { VMEMMAP_END,          "vmemmap end" },
+               { PCI_IO_START,         "PCI I/O start" },
+               { PCI_IO_END,           "PCI I/O end" },
+               { FIXADDR_TOT_START,    "Fixmap start" },
+               { FIXADDR_TOP,          "Fixmap end" },
+               { -1,                   NULL },
+       };
+       static struct addr_marker address_markers[ARRAY_SIZE(m)] __ro_after_init;
+
+       kernel_ptdump_info.markers = memcpy(address_markers, m, sizeof(m));
+
        ptdump_initialize();
        ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");
        return 0;