riscv-fast-interrupt
riscv-fast-interrupt copied to clipboard
Simplify and fully specify xscratchcsw[l]
I think the specification for xscratchcsw[l] could be significantly simplified and tightened up to avoid implementation defined behaviour by changing it to be something like this:
xscratchcswandxscratchcswlhave behaviour that depends on a condition, respectively:
- the current privilege is not equal to the previous privilege
- the current interrupt level ....
If the condition is true, then
csr* rd, xscratchcsw[l], rs1/immbehaves the same ascsr* rd, xscratch, rs1/imm. Otherwise it behaves the same asmv rd, rs1/imm.
This is way simpler to understand, and avoids all of the ambiguity around csrs and csrc. It's the most obvious thing to do, and it is also what we have implemented in the Sail model (not upstreamed yet) and in our designs.
Potentially something similar could be done for xnxti but I haven't fully understood that bit of the spec yet.