Skip to content

Commit

Permalink
riscv: Start of DRAM should at least be aligned on PMD size for the d…
Browse files Browse the repository at this point in the history
…irect 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]>
  • Loading branch information
Alexandre Ghiti authored and pull[bot] committed Aug 12, 2023
1 parent 947073a commit 84550f1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arch/riscv/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,13 @@ static void __init setup_bootmem(void)
memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);

phys_ram_end = memblock_end_of_DRAM();

/*
* Make sure we align the start of the memory on a PMD boundary so that
* at worst, we map the linear mapping with PMD mappings.
*/
if (!IS_ENABLED(CONFIG_XIP_KERNEL))
phys_ram_base = memblock_start_of_DRAM();
phys_ram_base = memblock_start_of_DRAM() & PMD_MASK;

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

0 comments on commit 84550f1

Please sign in to comment.