Skip to content

Commit 3c2897f

Browse files
zhangjing0303Rbb666
authored andcommitted
[libcpu][risc-v] fix:only map the 1GB space where the original code segment is located
1 parent aaae1a8 commit 3c2897f

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy