Representing invalid addresses


Josh Scheid
 

mepc, as an example, has this:

"""
mepc is a WARL register that must be able to hold all valid 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.
"""

It does not say that it need hold any invalid addresses at at (if there are any).

For implementations where a subset of XLEN values are valid, should there be an explicit requirement that such state should represent all invalid addresses as an invalid address value?

A problematic situation would be if all invalid addresses are represented as the "module" valid address value.  SW would not know the invalid address, but it also would not know that the address was invalid at all.

This issue applies generally to CSR state that represents addresses written to by HW.

-Josh


Andrew Waterman
 

In writing "Implementations may convert some invalid address patterns into other invalid addresses prior to writing them to mepc", of course we meant to imply that the new invalid address is something the CSR is capable of representing.  Then, by implication, the CSR would be capable of representing at least one invalid address (unless, of course, all 2^XLEN addresses are valid).

To clarify this point, I'll reword the sentence as: "Prior to writing {\tt mepc}, implementations may convert an invalid address into some other invalid address that {\tt mepc} is capable of holding."  Then, by necessity, if there are any invalid addresses, mepc must be capable of holding at least one of them.

Same fix applies to a few mtval/stval/sepc.

On Thu, Aug 5, 2021 at 6:23 PM Josh Scheid <jscheid@...> wrote:
mepc, as an example, has this:

"""
mepc is a WARL register that must be able to hold all valid 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.
"""

It does not say that it need hold any invalid addresses at at (if there are any).

For implementations where a subset of XLEN values are valid, should there be an explicit requirement that such state should represent all invalid addresses as an invalid address value?

A problematic situation would be if all invalid addresses are represented as the "module" valid address value.  SW would not know the invalid address, but it also would not know that the address was invalid at all.

This issue applies generally to CSR state that represents addresses written to by HW.

-Josh