Skip to content

Commit 523b123

Browse files
[libcpu][risc-v] fix the bug when using ASID in the RV64 MMU
* (fix) mmu: satp value should be 64-bit Corrected the SATP register to ensure it uses the correct 64-bit format as required by the system architecture. * use __asm__ instead of asm for the GNU C compiler Co-authored-by: Shell <[email protected]> --------- Co-authored-by: Shell <[email protected]>
1 parent 9a010bb commit 523b123

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libcpu/risc-v/common64/asid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ static rt_uint64_t global_asid_generation;
2929

3030
void rt_hw_asid_init(void)
3131
{
32-
unsigned int satp_reg = read_csr(satp);
32+
rt_uint64_t satp_reg = read_csr(satp);
3333
satp_reg |= (((rt_uint64_t)0xffff) << PPN_BITS);
3434
write_csr(satp, satp_reg);
35+
__asm__ volatile("sfence.vma x0, x0");
3536
unsigned short valid_asid_bit = ((read_csr(satp) >> PPN_BITS) & 0xffff);
3637

3738
// The maximal value of ASIDLEN, is 9 for Sv32 or 16 for Sv39, Sv48, and Sv57

0 commit comments

Comments
 (0)