Skip to content

Commit ecd7eba

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Fix ptdump when KASAN is enabled
The KASAN shadow region was moved next to the kernel mapping but the ptdump code was not updated and it appears to break the dump of the kernel page table, so fix this by moving the KASAN shadow region in ptdump. Fixes: f7ae023 ("riscv: Move KASAN mapping next to the kernel mapping") Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Tested-by: Björn Töpel <bjorn@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20230203075232.274282-6-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 617955c commit ecd7eba

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

arch/riscv/mm/ptdump.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ struct ptd_mm_info {
5959
};
6060

6161
enum address_markers_idx {
62-
#ifdef CONFIG_KASAN
63-
KASAN_SHADOW_START_NR,
64-
KASAN_SHADOW_END_NR,
65-
#endif
6662
FIXMAP_START_NR,
6763
FIXMAP_END_NR,
6864
PCI_IO_START_NR,
@@ -74,6 +70,10 @@ enum address_markers_idx {
7470
VMALLOC_START_NR,
7571
VMALLOC_END_NR,
7672
PAGE_OFFSET_NR,
73+
#ifdef CONFIG_KASAN
74+
KASAN_SHADOW_START_NR,
75+
KASAN_SHADOW_END_NR,
76+
#endif
7777
#ifdef CONFIG_64BIT
7878
MODULES_MAPPING_NR,
7979
KERNEL_MAPPING_NR,
@@ -82,10 +82,6 @@ enum address_markers_idx {
8282
};
8383

8484
static struct addr_marker address_markers[] = {
85-
#ifdef CONFIG_KASAN
86-
{0, "Kasan shadow start"},
87-
{0, "Kasan shadow end"},
88-
#endif
8985
{0, "Fixmap start"},
9086
{0, "Fixmap end"},
9187
{0, "PCI I/O start"},
@@ -97,6 +93,10 @@ static struct addr_marker address_markers[] = {
9793
{0, "vmalloc() area"},
9894
{0, "vmalloc() end"},
9995
{0, "Linear mapping"},
96+
#ifdef CONFIG_KASAN
97+
{0, "Kasan shadow start"},
98+
{0, "Kasan shadow end"},
99+
#endif
100100
#ifdef CONFIG_64BIT
101101
{0, "Modules/BPF mapping"},
102102
{0, "Kernel mapping"},
@@ -362,10 +362,6 @@ static int __init ptdump_init(void)
362362
{
363363
unsigned int i, j;
364364

365-
#ifdef CONFIG_KASAN
366-
address_markers[KASAN_SHADOW_START_NR].start_address = KASAN_SHADOW_START;
367-
address_markers[KASAN_SHADOW_END_NR].start_address = KASAN_SHADOW_END;
368-
#endif
369365
address_markers[FIXMAP_START_NR].start_address = FIXADDR_START;
370366
address_markers[FIXMAP_END_NR].start_address = FIXADDR_TOP;
371367
address_markers[PCI_IO_START_NR].start_address = PCI_IO_START;
@@ -377,6 +373,10 @@ static int __init ptdump_init(void)
377373
address_markers[VMALLOC_START_NR].start_address = VMALLOC_START;
378374
address_markers[VMALLOC_END_NR].start_address = VMALLOC_END;
379375
address_markers[PAGE_OFFSET_NR].start_address = PAGE_OFFSET;
376+
#ifdef CONFIG_KASAN
377+
address_markers[KASAN_SHADOW_START_NR].start_address = KASAN_SHADOW_START;
378+
address_markers[KASAN_SHADOW_END_NR].start_address = KASAN_SHADOW_END;
379+
#endif
380380
#ifdef CONFIG_64BIT
381381
address_markers[MODULES_MAPPING_NR].start_address = MODULES_VADDR;
382382
address_markers[KERNEL_MAPPING_NR].start_address = kernel_map.virt_addr;

0 commit comments

Comments
 (0)