diff options
| author | zhangjing0303 <[email protected]> | 2024-10-11 12:10:46 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-10-11 00:10:46 -0400 |
| commit | 523b123995eaa47a33d47bdb2682f7a9ab862f7f (patch) | |
| tree | 9098c41aa384815c01fb88c62271466234371fb3 /libcpu | |
| parent | 9a010bb71b278afb3fcb4b98f28668b598f01369 (diff) | |
[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]>
Diffstat (limited to 'libcpu')
| -rw-r--r-- | libcpu/risc-v/common64/asid.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libcpu/risc-v/common64/asid.c b/libcpu/risc-v/common64/asid.c index 5d7bffa3dc..c8ed61eb67 100644 --- a/libcpu/risc-v/common64/asid.c +++ b/libcpu/risc-v/common64/asid.c @@ -29,9 +29,10 @@ static rt_uint64_t global_asid_generation; void rt_hw_asid_init(void) { - unsigned int satp_reg = read_csr(satp); + rt_uint64_t satp_reg = read_csr(satp); satp_reg |= (((rt_uint64_t)0xffff) << PPN_BITS); write_csr(satp, satp_reg); + __asm__ volatile("sfence.vma x0, x0"); unsigned short valid_asid_bit = ((read_csr(satp) >> PPN_BITS) & 0xffff); // The maximal value of ASIDLEN, is 9 for Sv32 or 16 for Sv39, Sv48, and Sv57 |
