[PATCH 1/2] riscv: mm: WARN_ON() for bad addresses in vmemmap_populate()

Vivian Wang wangruikang at iscas.ac.cn
Mon Mar 9 04:09:37 PDT 2026


Similarly to the same check in arch/arm64/mm/mmu.c, in
vmemmap_populate(), add a warning for start and end being outside of the
range of vmemmap.

Signed-off-by: Vivian Wang <wangruikang at iscas.ac.cn>
---
 arch/riscv/mm/init.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 811e03786c56..c12590ab3d0e 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1453,6 +1453,8 @@ int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
 			       struct vmem_altmap *altmap)
 {
+	WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END));
+
 	/*
 	 * Note that SPARSEMEM_VMEMMAP is only selected for rv64 and that we
 	 * can't use hugepage mappings for 2-level page table because in case of

-- 
2.53.0




More information about the linux-riscv mailing list