Accessing non-existent CSR does not raise an illegal instruction, but instead hangs after a couple of instructions later.
The RISC-V specification says:
Attempts to access a non-existent CSR raise an illegal instruction exception.
Example snippet
Here is an example snippet, given that, as specified by the RISC-V specification:
In systems without S-mode, the medeleg and mideleg registers should not exist.
In the snippet below, the program should take the exception, store 1 into address 0x0 and then take infinite_loop1.
Instead, it hangs after fetching 4 instructions after the CSR instruction.
Remark that the nops here matter, because the CPU does not immediately hang.
Hi there!
I've detected a bug in Kronos.
Brief bug description
Accessing non-existent CSR does not raise an illegal instruction, but instead hangs after a couple of instructions later.
The RISC-V specification says:
Example snippet
Here is an example snippet, given that, as specified by the RISC-V specification:
In the snippet below, the program should take the exception, store 1 into address 0x0 and then take infinite_loop1. Instead, it hangs after fetching 4 instructions after the CSR instruction. Remark that the nops here matter, because the CPU does not immediately hang.
Thanks! Flavien
EDIT: The hang only seems to happen when we read the non-existent CSR, i.e., with a destination register that is not
zero
.