Skip to content

Commit 1019712

Browse files
cuiyunhuipalmer-dabbelt
authored andcommitted
riscv: add a warning when physical memory address overflows
The part of physical memory that exceeds the size of the linear mapping will be discarded. When the system starts up normally, a warning message will be printed to prevent confusion caused by the mismatch between the system memory and the actual physical memory. Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/r/20240814062625.19794-1-cuiyunhui@bytedance.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent b6de116 commit 1019712

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

arch/riscv/mm/init.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,12 @@ static void __init setup_bootmem(void)
256256
*/
257257
if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU)) {
258258
max_mapped_addr = __pa(PAGE_OFFSET) + KERN_VIRT_SIZE;
259-
memblock_cap_memory_range(phys_ram_base,
260-
max_mapped_addr - phys_ram_base);
259+
if (memblock_end_of_DRAM() > max_mapped_addr) {
260+
memblock_cap_memory_range(phys_ram_base,
261+
max_mapped_addr - phys_ram_base);
262+
pr_warn("Physical memory overflows the linear mapping size: region above %pa removed",
263+
&max_mapped_addr);
264+
}
261265
}
262266

263267
/*

scripts/selinux/genheaders/genheaders

88 KB
Binary file not shown.

0 commit comments

Comments
 (0)