I am about to write my own RV32I core with a CLINT. However there is something which is not fully clear to me. At least I could not find it in the docs. Here is what the privileged isa spec says for ecall/ebreak:
ECALL and EBREAK cause the receiving privilege mode’s epc register to be set to the address of the ECALL or EBREAK instruction itself, not the address of the following instruction.
So this means, that setting the right mepc for mret is the responsibility of the SW handler. I assume that this behavior applies to all other exceptions too.
What about asynchronous interrupts? Does the HW set mepc to PC+4 automatically? From what I saw in different SW handlers it seems that it is like this, but I actually could not find it in the docs.
Hopefully someone can point me to the right documentation.