From 9fca12559e540e72b62cbbbe26fa565770f38cc4 Mon Sep 17 00:00:00 2001 From: Gokturk Yuksek Date: Tue, 24 Nov 2020 00:46:00 -0500 Subject: Replace sptbr with satp throughout The RISC-V Privileged ISA v1.10 uses satp instead of sptbr. Although GCC can cope with sptbr, clang cannot. It fails with: error: operand must be a valid system register name or an integer in the range [0, 4095] Modified the variable name in vm.c as well to ensure consistency and avoid possible confusion. --- p/riscv_test.h | 2 +- v/vm.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/p/riscv_test.h b/p/riscv_test.h index 2b6ff83..a08f49e 100644 --- a/p/riscv_test.h +++ b/p/riscv_test.h @@ -110,7 +110,7 @@ #define INIT_SATP \ la t0, 1f; \ csrw mtvec, t0; \ - csrwi sptbr, 0; \ + csrwi satp, 0; \ .align 2; \ 1: diff --git a/v/vm.c b/v/vm.c index 71700f5..d03f3b1 100644 --- a/v/vm.c +++ b/v/vm.c @@ -253,10 +253,10 @@ void vm_boot(uintptr_t test_addr) # error #endif uintptr_t vm_choice = SATP_MODE_CHOICE; - uintptr_t sptbr_value = ((uintptr_t)l1pt >> PGSHIFT) + uintptr_t satp_value = ((uintptr_t)l1pt >> PGSHIFT) | (vm_choice * (SATP_MODE & ~(SATP_MODE<<1))); - write_csr(sptbr, sptbr_value); - if (read_csr(sptbr) != sptbr_value) + write_csr(satp, satp_value); + if (read_csr(satp) != satp_value) assert(!"unsupported satp mode"); // Set up PMPs if present, ignoring illegal instruction trap if not. -- cgit v1.1 From 6f81792315c7263a3c4cd40c05cfc54aa95cbd49 Mon Sep 17 00:00:00 2001 From: Gokturk Yuksek Date: Tue, 24 Nov 2020 00:50:12 -0500 Subject: v/entry.S: replace sbadaddr with stval The RISC-V Privileged ISA v1.10 uses stval instead of sbadaddr. Although GCC can cope with sbadaddr, clang cannot. It fails with: error: operand must be a valid system register name or an integer in the range [0, 4095] --- v/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v/entry.S b/v/entry.S index fa492e6..49b2d3e 100644 --- a/v/entry.S +++ b/v/entry.S @@ -153,7 +153,7 @@ trap_entry: STORE t0,32*REGBYTES(sp) csrr t0,sepc STORE t0,33*REGBYTES(sp) - csrr t0,sbadaddr + csrr t0,stval STORE t0,34*REGBYTES(sp) csrr t0,scause STORE t0,35*REGBYTES(sp) -- cgit v1.1