Skip to content

EPC behavior #210

@pdonahue-ventana

Description

@pdonahue-ventana

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions