From: Yunhui Cui Date: Wed, 14 Aug 2024 06:26:25 +0000 (+0800) Subject: riscv: add a warning when physical memory address overflows X-Git-Tag: v6.14-rc1~15^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=101971298be2;p=thirdparty%2Flinux.git 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 Reviewed-by: Alexandre Ghiti Tested-by: Alexandre Ghiti Link: https://lore.kernel.org/r/20240814062625.19794-1-cuiyunhui@bytedance.com Signed-off-by: Palmer Dabbelt --- diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 0e8c20adcd98d..9641e4ad387f4 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -256,8 +256,12 @@ static void __init setup_bootmem(void) */ if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU)) { max_mapped_addr = __pa(PAGE_OFFSET) + KERN_VIRT_SIZE; - memblock_cap_memory_range(phys_ram_base, - max_mapped_addr - phys_ram_base); + if (memblock_end_of_DRAM() > max_mapped_addr) { + memblock_cap_memory_range(phys_ram_base, + max_mapped_addr - phys_ram_base); + pr_warn("Physical memory overflows the linear mapping size: region above %pa removed", + &max_mapped_addr); + } } /* diff --git a/scripts/selinux/genheaders/genheaders b/scripts/selinux/genheaders/genheaders new file mode 100755 index 0000000000000..3fc32a664a793 Binary files /dev/null and b/scripts/selinux/genheaders/genheaders differ