Skip to content

Commit 3922ec7

Browse files
zhangjing0303Rbb666
authored andcommitted
[libcpu][risc-v] fix:only map the 1GB space where the original code segment is located
1 parent 951bc92 commit 3922ec7

File tree

1 file changed

+4
-5
lines changed
  • libcpu/risc-v/common64

1 file changed

+4
-5
lines changed

libcpu/risc-v/common64/mmu.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,10 @@ void rt_hw_mem_setup_early(void)
691691
* identical mapping,
692692
* PC are still at lower region before relocating to high memory
693693
*/
694-
for (size_t i = 0; i < __SIZE(PPN0_BIT); i++)
695-
{
696-
early_pgtbl[i] = COMBINEPTE(ps, MMU_MAP_EARLY);
697-
ps += L1_PAGE_SIZE;
698-
}
694+
rt_ubase_t pg_idx ;
695+
ps = (rt_ubase_t)symb_pc & (~(L1_PAGE_SIZE - 1));
696+
pg_idx = GET_L1(ps);
697+
early_pgtbl[pg_idx] = COMBINEPTE(ps, MMU_MAP_EARLY);
699698

700699
/* relocate text region */
701700
__asm__ volatile("la %0, _start\n" : "=r"(ps));

0 commit comments

Comments
 (0)