diff --git a/lib/sbi/sbi_expected_trap.S b/lib/sbi/sbi_expected_trap.S index 99dede5f..f85a0082 100644 --- a/lib/sbi/sbi_expected_trap.S +++ b/lib/sbi/sbi_expected_trap.S @@ -23,6 +23,8 @@ .global __sbi_expected_trap __sbi_expected_trap: /* Without H-extension so, MTVAL2 and MTINST CSRs and GVA not available */ + li a4, MSTATUS_MPRV + csrc CSR_MSTATUS, a4 csrr a4, CSR_MCAUSE REG_S a4, SBI_TRAP_INFO_OFFSET(cause)(a3) csrr a4, CSR_MTVAL @@ -39,6 +41,8 @@ __sbi_expected_trap: .global __sbi_expected_trap_hext __sbi_expected_trap_hext: /* With H-extension so, MTVAL2 and MTINST CSRs and GVA available */ + li a4, MSTATUS_MPRV + csrc CSR_MSTATUS, a4 csrr a4, CSR_MCAUSE REG_S a4, SBI_TRAP_INFO_OFFSET(cause)(a3) csrr a4, CSR_MTVAL