Skip to content

Commit 34f879f

Browse files
ardbiesheuvelctmarinas
authored andcommitted
arm64: ptdump: Allow all region boundaries to be defined at boot time
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 <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Acked-by: Mark Rutland <[email protected]>
1 parent b730b0f commit 34f879f

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

arch/arm64/mm/ptdump.c

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,6 @@
2626
#include <asm/ptdump.h>
2727

2828

29-
enum address_markers_idx {
30-
PAGE_OFFSET_NR = 0,
31-
PAGE_END_NR,
32-
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
33-
KASAN_START_NR,
34-
#endif
35-
};
36-
37-
static struct addr_marker address_markers[] = {
38-
{ PAGE_OFFSET, "Linear Mapping start" },
39-
{ 0 /* PAGE_END */, "Linear Mapping end" },
40-
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
41-
{ 0 /* KASAN_SHADOW_START */, "Kasan shadow start" },
42-
{ KASAN_SHADOW_END, "Kasan shadow end" },
43-
#endif
44-
{ MODULES_VADDR, "Modules start" },
45-
{ MODULES_END, "Modules end" },
46-
{ VMALLOC_START, "vmalloc() area" },
47-
{ VMALLOC_END, "vmalloc() end" },
48-
{ VMEMMAP_START, "vmemmap start" },
49-
{ VMEMMAP_END, "vmemmap end" },
50-
{ PCI_IO_START, "PCI I/O start" },
51-
{ PCI_IO_END, "PCI I/O end" },
52-
{ FIXADDR_TOT_START, "Fixmap start" },
53-
{ FIXADDR_TOP, "Fixmap end" },
54-
{ -1, NULL },
55-
};
56-
5729
#define pt_dump_seq_printf(m, fmt, args...) \
5830
({ \
5931
if (m) \
@@ -339,9 +311,8 @@ static void __init ptdump_initialize(void)
339311
pg_level[i].mask |= pg_level[i].bits[j].mask;
340312
}
341313

342-
static struct ptdump_info kernel_ptdump_info = {
314+
static struct ptdump_info kernel_ptdump_info __ro_after_init = {
343315
.mm = &init_mm,
344-
.markers = address_markers,
345316
.base_addr = PAGE_OFFSET,
346317
};
347318

@@ -375,10 +346,29 @@ void ptdump_check_wx(void)
375346

376347
static int __init ptdump_init(void)
377348
{
378-
address_markers[PAGE_END_NR].start_address = PAGE_END;
349+
struct addr_marker m[] = {
350+
{ PAGE_OFFSET, "Linear Mapping start" },
351+
{ PAGE_END, "Linear Mapping end" },
379352
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
380-
address_markers[KASAN_START_NR].start_address = KASAN_SHADOW_START;
353+
{ KASAN_SHADOW_START, "Kasan shadow start" },
354+
{ KASAN_SHADOW_END, "Kasan shadow end" },
381355
#endif
356+
{ MODULES_VADDR, "Modules start" },
357+
{ MODULES_END, "Modules end" },
358+
{ VMALLOC_START, "vmalloc() area" },
359+
{ VMALLOC_END, "vmalloc() end" },
360+
{ VMEMMAP_START, "vmemmap start" },
361+
{ VMEMMAP_END, "vmemmap end" },
362+
{ PCI_IO_START, "PCI I/O start" },
363+
{ PCI_IO_END, "PCI I/O end" },
364+
{ FIXADDR_TOT_START, "Fixmap start" },
365+
{ FIXADDR_TOP, "Fixmap end" },
366+
{ -1, NULL },
367+
};
368+
static struct addr_marker address_markers[ARRAY_SIZE(m)] __ro_after_init;
369+
370+
kernel_ptdump_info.markers = memcpy(address_markers, m, sizeof(m));
371+
382372
ptdump_initialize();
383373
ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");
384374
return 0;

0 commit comments

Comments
 (0)