Overview
A Control and Status Register (CSR) appears in the evidence as software-visible RISC-V state involved in privileged behavior, exception handling, and implementation-capability reporting. The paper notes that, because RISC-V is modular and extensible, software can query CSRs to obtain processor capabilities; therefore, allowing unsupported or reserved CSR values can mislead software about what the implementation supports. [csr-capability-query]
CSR correctness issues observed in testing
The cited cross-level testing campaign reported several CSR-related failures in a RISC-V RTL core:
- A write access to a read-only CSR did not cause an illegal-instruction trap; conversely, for some CSRs and options, a legal write to a non-read-only CSR caused an exception. [csr-readonly-write]
MEPCwas not updated correctly in its lower two bits, allowing software to write an unaligned address that could lead to an unaligned jump. [csr-mepc-lower-bits]MISAwas not initialized correctly and could be updated by software to unsupported values. [csr-misa-values]MTVALshould be set to zero on anECALL, but the implementation set it to theECALLinstruction encoding. [csr-mtval-ecall]- Software could write a reserved value into the
MODEfield ofMTVEC, although the field should only hold supported values. The paper identifies this as a forward-compatibility problem because software can query CSRs for capabilities. [csr-mtvec-mode] EBREAKsetMCAUSEto illegal instruction instead of breakpoint. [csr-mcause-ebreak]- Writes to the
MINSTRETandMCYCLECSRs erroneously caused illegal-instruction traps, although the cited text states that these special counter CSRs are allowed to be modified by software. [csr-counter-writes] MINSTRET, which counts retired instructions, was not correctly updated on a write access; the cited text states that it should avoid incrementing for the instruction that performs the write. [csr-minstret-write]
Verification significance
The paper reports that all described bugs were found in less than five minutes each. In a one-hour run, the test process generated and co-simulated 226 million instructions: 12 million illegal instructions and 214 million legal instructions. Of the legal instructions, 156 million completed normally and 58 million caused a trap. [csr-verification-performance]
The same work describes its approach as generating an endless instruction stream and feeding it to both an RTL core and a reference instruction-set simulator in a tightly coupled co-simulation setting. The instruction stream evolves on the fly, which the authors argue avoids restrictions on generated instructions and helps expose corner cases involving irregular control flow, tight loops, and traps. [csr-cross-level-testing]