summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorzhangjing <[email protected]>2025-04-03 10:30:30 +0800
committerRbb666 <[email protected]>2025-05-28 19:37:51 +0800
commit3922ec7e99c85d9258e90b1c3fccf3abdd3ae939 (patch)
tree3359544a1f73e5a29bf8607e8c7e4c1ec41a713d /libcpu
parent951bc922bc20dafaf25e456be9619c36ec157a26 (diff)
[libcpu][risc-v] fix:only map the 1GB space where the original code segment is located
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/risc-v/common64/mmu.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libcpu/risc-v/common64/mmu.c b/libcpu/risc-v/common64/mmu.c
index 6cab811eca..a260a06e58 100644
--- a/libcpu/risc-v/common64/mmu.c
+++ b/libcpu/risc-v/common64/mmu.c
@@ -691,11 +691,10 @@ void rt_hw_mem_setup_early(void)
* identical mapping,
* PC are still at lower region before relocating to high memory
*/
- for (size_t i = 0; i < __SIZE(PPN0_BIT); i++)
- {
- early_pgtbl[i] = COMBINEPTE(ps, MMU_MAP_EARLY);
- ps += L1_PAGE_SIZE;
- }
+ rt_ubase_t pg_idx ;
+ ps = (rt_ubase_t)symb_pc & (~(L1_PAGE_SIZE - 1));
+ pg_idx = GET_L1(ps);
+ early_pgtbl[pg_idx] = COMBINEPTE(ps, MMU_MAP_EARLY);
/* relocate text region */
__asm__ volatile("la %0, _start\n" : "=r"(ps));