From e3d7bbb47c0728f8c4b5a4837a2075513093ab51 Mon Sep 17 00:00:00 2001 From: zhangjing Date: Wed, 28 May 2025 09:38:54 +0000 Subject: [PATCH] [libcpu][risc-v]:add comment for the round down of symb_pc --- libcpu/risc-v/common64/mmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libcpu/risc-v/common64/mmu.c b/libcpu/risc-v/common64/mmu.c index a260a06e58..19c7f7c019 100644 --- a/libcpu/risc-v/common64/mmu.c +++ b/libcpu/risc-v/common64/mmu.c @@ -692,6 +692,9 @@ void rt_hw_mem_setup_early(void) * PC are still at lower region before relocating to high memory */ rt_ubase_t pg_idx ; + /* Round down symb_pc to L1_PAGE_SIZE boundary to ensure proper page alignment. + * This is necessary because MMU operations work with page-aligned addresses, and + * make sure all the text region is mapped.*/ ps = (rt_ubase_t)symb_pc & (~(L1_PAGE_SIZE - 1)); pg_idx = GET_L1(ps); early_pgtbl[pg_idx] = COMBINEPTE(ps, MMU_MAP_EARLY);