Skip to content

Commit c3bcc65

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Start of DRAM should at least be aligned on PMD size for the direct mapping
So that we do not end up mapping the whole linear mapping using 4K pages, which is slow at boot time, and also very likely at runtime. So make sure we align the start of DRAM on a PMD boundary. Signed-off-by: Alexandre Ghiti <[email protected]> Reported-by: Song Shuai <[email protected]> Fixes: 3335068 ("riscv: Use PUD/P4D/PGD pages for the linear mapping") Tested-by: Song Shuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent f806982 commit c3bcc65

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/riscv/mm/init.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,13 @@ static void __init setup_bootmem(void)
214214
memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
215215

216216
phys_ram_end = memblock_end_of_DRAM();
217+
218+
/*
219+
* Make sure we align the start of the memory on a PMD boundary so that
220+
* at worst, we map the linear mapping with PMD mappings.
221+
*/
217222
if (!IS_ENABLED(CONFIG_XIP_KERNEL))
218-
phys_ram_base = memblock_start_of_DRAM();
223+
phys_ram_base = memblock_start_of_DRAM() & PMD_MASK;
219224

220225
/*
221226
* In 64-bit, any use of __va/__pa before this point is wrong as we

0 commit comments

Comments
 (0)