sifive/freedom-e-sdk

Handling exceptions/interrupts within the user-mode

Closed this issue · 1 comments

I am implementing the user-mode in RISCV (machine-mode ->
supervisor-mode -> user-mode). In user-mode, I make an ecall which
triggers my cpu exception handler with the ecode 8, however, my
handler calls a log_error function which basically calls fprintf to
log some context information. The fprintf is generating another cpu
exception with ecall 7 (Store/AMO Access Fault).

Why is this happening? log_error works correctly when working on
supervisor or machine mode, why is this failing in user-mode and how
can I get this resolved?

One clue you could pursue is: which address is triggering the access fault? You can get the address by reading the mtval CSR from your exception handler.