[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 <smokewood@qq.com>

---------

Co-authored-by: Shell <smokewood@qq.com>
This commit is contained in:
zhangjing0303 2024-10-11 12:10:46 +08:00 committed by GitHub
parent 9a010bb71b
commit 523b123995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -29,9 +29,10 @@ static rt_uint64_t global_asid_generation;
void rt_hw_asid_init(void) 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); satp_reg |= (((rt_uint64_t)0xffff) << PPN_BITS);
write_csr(satp, satp_reg); write_csr(satp, satp_reg);
__asm__ volatile("sfence.vma x0, x0");
unsigned short valid_asid_bit = ((read_csr(satp) >> PPN_BITS) & 0xffff); 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 // The maximal value of ASIDLEN, is 9 for Sv32 or 16 for Sv39, Sv48, and Sv57