[RFC PATCH 18/34] riscv: mm: use proper set_pXd() for generic compile-time folded patable in setup_vm_final()
Yeoreum Yun
yeoreum.yun at arm.com
Mon Jul 13 06:55:57 PDT 2026
We want to rework how set_pXd() behaves for generic compile-time folded
page tables by disallowing its use and triggering a compile-time error
when it is used improperly, ensuring that the actual first-level
set_pXd() function is used instead.
Therefore, replace set_pgd() with set_pmd() to setup swapper_pg_dir
in setup_vm_final() since PGTABLE_LEVELS is always 2 in CONFIG_32BIT.
There should be no functional change.
Signed-off-by: Yeoreum Yun <yeoreum.yun at arm.com>
---
arch/riscv/mm/init.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 5b1b3c88b4d13..78017edf7c343 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1264,7 +1264,12 @@ static void __init setup_vm_final(void)
*/
unsigned long idx = pgd_index(__fix_to_virt(FIX_FDT));
- set_pgd(&swapper_pg_dir[idx], early_pg_dir[idx]);
+ BUILD_BUG_ON (CONFIG_PGTABLE_LEVELS != 2);
+
+ pmd_t *pmdp_s = (void *)&swapper_pg_dir[idx];
+ pmd_t *pmdp = (void *)&early_pg_dir[idx];
+
+ set_pmd(pmdp_s, pmdp_get(pmdp));
#endif
create_pgd_mapping(swapper_pg_dir, FIXADDR_START,
__pa_symbol(fixmap_pgd_next),
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
More information about the kvm-riscv
mailing list