Skip to content

Commit aea702d

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Fix loading 64-bit NOMMU kernels past the start of RAM
commit 3335068 ("riscv: Use PUD/P4D/PGD pages for the linear mapping") added logic to allow using RAM below the kernel load address. However, this does not work for NOMMU, where PAGE_OFFSET is fixed to the kernel load address. Since that range of memory corresponds to PFNs below ARCH_PFN_OFFSET, mm initialization runs off the beginning of mem_map and corrupts adjacent kernel memory. Fix this by restoring the previous behavior for NOMMU kernels. Fixes: 3335068 ("riscv: Use PUD/P4D/PGD pages for the linear mapping") Signed-off-by: Samuel Holland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 6065e73 commit aea702d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arch/riscv/include/asm/page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ typedef struct page *pgtable_t;
8989
#define PTE_FMT "%08lx"
9090
#endif
9191

92-
#ifdef CONFIG_64BIT
92+
#if defined(CONFIG_64BIT) && defined(CONFIG_MMU)
9393
/*
9494
* We override this value as its generic definition uses __pa too early in
9595
* the boot process (before kernel_map.va_pa_offset is set).

arch/riscv/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void __init setup_bootmem(void)
232232
* In 64-bit, any use of __va/__pa before this point is wrong as we
233233
* did not know the start of DRAM before.
234234
*/
235-
if (IS_ENABLED(CONFIG_64BIT))
235+
if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU))
236236
kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base;
237237

238238
/*

0 commit comments

Comments
 (0)