diff options
Diffstat (limited to 'machine/mtrap.c')
-rw-r--r-- | machine/mtrap.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/machine/mtrap.c b/machine/mtrap.c index c114757..d0c1684 100644 --- a/machine/mtrap.c +++ b/machine/mtrap.c @@ -161,8 +161,9 @@ send_ipi: regs[10] = retval; } -void redirect_trap(uintptr_t epc, uintptr_t mstatus) +void redirect_trap(uintptr_t epc, uintptr_t mstatus, uintptr_t badaddr) { + write_csr(sbadaddr, badaddr); write_csr(sepc, epc); write_csr(scause, read_csr(mcause)); write_csr(mepc, read_csr(stvec)); @@ -180,7 +181,7 @@ void redirect_trap(uintptr_t epc, uintptr_t mstatus) void pmp_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc) { - redirect_trap(mepc, read_csr(mstatus)); + redirect_trap(mepc, read_csr(mstatus), read_csr(mbadaddr)); } static void machine_page_fault(uintptr_t* regs, uintptr_t dummy, uintptr_t mepc) @@ -188,8 +189,7 @@ static void machine_page_fault(uintptr_t* regs, uintptr_t dummy, uintptr_t mepc) // MPRV=1 iff this trap occurred while emulating an instruction on behalf // of a lower privilege level. In that case, a2=epc and a3=mstatus. if (read_csr(mstatus) & MSTATUS_MPRV) { - write_csr(sbadaddr, read_csr(mbadaddr)); - return redirect_trap(regs[12], regs[13]); + return redirect_trap(regs[12], regs[13], read_csr(mbadaddr)); } bad_trap(regs, dummy, mepc); } |