Control and Status Register (CSR)
ConceptControl and Status Registers (CSRs) are software-visible processor registers that control and hold processor state, mediate privileged behavior, exception handling, capability reporting, and participate in the operand data path. In RISC-V designs, transitions in CSRs indicate new processor states, a property exploited by the ProcessorFuzz hardware fuzzer as a coverage signal. Cross-level and grammar-based testing campaigns have identified multiple CSR-related correctness bugs involving privileged-ISA semantics, trap-handling CSRs, counter CSRs, and dynamic-configuration effects, and CSR values are tracked alongside other architectural state (integer, floating-point, vector registers, PC, trap counter) inside a Machine State data structure used to extract, modify, compare, and re-establish RISC-V machine state.
WIKI
Overview
Control and Status Registers (CSRs) are software-visible processor registers that, in RISC-V designs, are "in charge of controlling and holding the state of the processor." They are queried by software to determine implementation capabilities, and the allowed values of CSR fields determine what software may assume about the underlying implementation. Because RISC-V is modular and extensible, allowing unsupported or reserved CSR values can mislead software about what the implementation supports. [csr-overview] [csr-capability-query]
In addition to holding processor state, CSRs participate in the operand data path. In the formal microarchitectural control-flow-integrity (μCFI) model, an in-order load-store CPU is defined to load data from memory or from a CSR into a General-Purpose Register (GPR) before an instruction operates on the GPR. [csr-as-data-source]