[PATCH] riscv: Skip add_resource() for memory regions without a full page
Wandun Chen
chenwandun1 at gmail.com
Mon Nov 30 04:42:21 PST 2026
From: Wandun Chen <chenwandun at lixiang.com>
If a memblock.memory region contains no full page, rounding it inward can
leave the end address below the start address. add_resource() rejects
such a range, and init_resources() discards the entries already in the
iomem resource tree.
Skip memblock.memory regions that contain no full page.
Fixes: 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree")
Reported-by: Sashiko <sashiko-bot at kernel.org>
Closes: https://lore.kernel.org/r/sashiko-outbox-181183@kernel.org
Signed-off-by: Wandun Chen <chenwandun at lixiang.com>
---
arch/riscv/kernel/setup.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 1bc57e20c0ae..5d602013079d 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -191,6 +191,10 @@ static void __init init_resources(void)
/* Add /memory regions to the resource tree */
for_each_mem_region(region) {
+ if (memblock_region_memory_base_pfn(region) >=
+ memblock_region_memory_end_pfn(region))
+ continue;
+
res = &mem_res[res_idx--];
non_resv_res++;
--
2.43.0
More information about the linux-riscv
mailing list