forked from Mirrors/opensbi
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 <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
@@ -522,10 +522,12 @@ sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
|
|||||||
csr_write(CSR_SIE, 0);
|
csr_write(CSR_SIE, 0);
|
||||||
csr_write(CSR_SATP, 0);
|
csr_write(CSR_SATP, 0);
|
||||||
} else if (next_mode == PRV_U) {
|
} else if (next_mode == PRV_U) {
|
||||||
|
if (misa_extension('N')) {
|
||||||
csr_write(CSR_UTVEC, next_addr);
|
csr_write(CSR_UTVEC, next_addr);
|
||||||
csr_write(CSR_USCRATCH, 0);
|
csr_write(CSR_USCRATCH, 0);
|
||||||
csr_write(CSR_UIE, 0);
|
csr_write(CSR_UIE, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
register unsigned long a0 asm("a0") = arg0;
|
register unsigned long a0 asm("a0") = arg0;
|
||||||
register unsigned long a1 asm("a1") = arg1;
|
register unsigned long a1 asm("a1") = arg1;
|
||||||
|
Reference in New Issue
Block a user