-
Notifications
You must be signed in to change notification settings - Fork 57
Description
I don't understand this sentence in the trace spec:
(The reason for not reporting the EPC for all exceptions when thaddr is 0 is that it may be at either the address of the next instruction or current instruction depending on the exception cause, which can be inferred by the decoder without adding complexity to the encoder.)
mepc is defined as:
mepc is written with the virtual address of the instruction that was interrupted or that encountered the exception.
Thanks to the fact that ebreak and ecall are defined to never retire, EPC always points to the first instruction that did not retire. For instance, it points to the load that got a page fault (and trapped instead of retiring), the ecall/ebreak (that trapped instead of retiring), or the first unretired instruction on an interrupt. Other architectures may do EPC=PC+4 on an ecall and some other cases where the handler is expected not to re-execute the instruction but RISC-V puts the burden of incrementing EPC on the handler.
Am I misunderstanding the purpose of this sentence or does this sentence assume some variability of EPC behavior on RISC-V that doesn't exist?