]> Git Repo - linux.git/commitdiff
riscv: add a warning when physical memory address overflows
authorYunhui Cui <[email protected]>
Wed, 14 Aug 2024 06:26:25 +0000 (14:26 +0800)
committerPalmer Dabbelt <[email protected]>
Thu, 30 Jan 2025 02:36:09 +0000 (18:36 -0800)
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 <[email protected]>
Reviewed-by: Alexandre Ghiti <[email protected]>
Tested-by: Alexandre Ghiti <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Palmer Dabbelt <[email protected]>
arch/riscv/mm/init.c
scripts/selinux/genheaders/genheaders [new file with mode: 0755]

index 0e8c20adcd98df5874fecb70573f9375ca333407..9641e4ad387f46cfdad7e88c4358f2f8f46a0396 100644 (file)
@@ -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 (executable)
index 0000000..3fc32a6
Binary files /dev/null and b/scripts/selinux/genheaders/genheaders differ
This page took 0.068682 seconds and 4 git commands to generate.