diff options
| author | Anup Patel <[email protected]> | 2020-11-21 11:28:39 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2020-12-04 17:56:10 +0530 |
| commit | 8d2edc4fc957588e23d09c8f567a94cd737405d3 (patch) | |
| tree | 8a3d3600d83002c98eebd8334789e88c624d29f4 | |
| parent | 2677324f906133db8596de4868df87cb1224f113 (diff) | |
lib: sbi: Fix sbi_hart_switch_mode() for u-mode
We should check and access N-extension CSRs in sbi_hart_switch_mode()
when next_mode is u-mode because N-extension is optional.
Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Atish Patra <[email protected]>
| -rw-r--r-- | lib/sbi/sbi_hart.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 30d8aefe..fc86e9f3 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -522,9 +522,11 @@ sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1, csr_write(CSR_SIE, 0); csr_write(CSR_SATP, 0); } else if (next_mode == PRV_U) { - csr_write(CSR_UTVEC, next_addr); - csr_write(CSR_USCRATCH, 0); - csr_write(CSR_UIE, 0); + if (misa_extension('N')) { + csr_write(CSR_UTVEC, next_addr); + csr_write(CSR_USCRATCH, 0); + csr_write(CSR_UIE, 0); + } } register unsigned long a0 asm("a0") = arg0; |
