Hi,
thanks for your reply.
On Thu, Jan 11, 2018 at 01:08:42PM -0800, Andrew Waterman wrote:
> > In case of a jump or branch instruction that jumps to the middle of a
> > memory region that cannot be executed, it seems like the jump itself should
> > trigger the exception:
> >
> > RISC-V Priv Spec V1.10, Section 3.1.19, Page 34:
> >
> > The mepc register can never hold a PC value that would cause an
> > instruction-address-misaligned exception.
>
> Instruction-address-misaligned exceptions are treated differently than
> access exceptions; there, the fault is considered to be on the branch or
> jump that caused the misalignment.
Ah, sorry. I misread that as instruction-access-fault. (And once the wrong
thing got stuck in my head I consistently misread it until now. Oops.)
> If the trap is resumable (e.g., a page fault that can be resolved), that
> implies the address is valid, so mtval must be able to store it.
>
> If the trap is not resumable (e.g., an access fault to an unimplemented
> part of the address space), mtval might not be able to represent it.
and the same with mpec (RISC-V Priv Spec V1.10, Section 3.1.19, page 34):
mepc is a WARL register that must be able to hold all valid
physical and virtual addresses. It need not be capable of holding
all possible invalid addresses. Implementations may convert some
invalid address patterns into other invalid addresses prior to
writing them to mepc.
So that means that if the program jumps to an unimplemented part of the
address space, neither mtval nor mepc might be able to hold the address the
program did jump to. I.e. the exception handler is called, but in the
exception handler we might have no way of figuring out what just happened.
Is this correct?
regards,
- clifford