2.2The CSR Listing

Part II Linux boot: required Vol. II (Privileged) pp. 16–23 · ~1 min read

Tables 4–7 allocate every currently-defined CSR address. Here they are as one searchable map — filter by privilege class (URW/URO, SRW/SRO, HRW/HRO, MRW/MRO, DRW) or search by name/function. Not every register exists on every implementation: unimplemented addresses simply raise illegal-instruction.

82/82
CSRPrivAddressGroupFunction
fflagsURW0x001FPAccrued exception flags (NV/DZ/OF/UF/NX)
frmURW0x002FPDynamic rounding mode
fcsrURW0x003FPfrm + fflags combined
vstartURW0x008VectorVector start position
vxsatURW0x009VectorFixed-point saturation flag
vxrmURW0x00AVectorFixed-point rounding mode
vcsrURW0x00FVectorVector control and status
vlURO0xC20VectorVector length
vtypeURO0xC21VectorVector data type
vlenbURO0xC22VectorVector register length in bytes
sspURW0x011CFIShadow stack pointer (Zicfiss)
seedURW0x015CryptoEntropy source seed
jvtURW0x017ZcmtTable jump base vector + mode
cycleURO0xC00CountersCycle counter (shadow of mcycle)
timeURO0xC01CountersWall-clock timer (platform mtime)
instretURO0xC02CountersInstructions retired (shadow of minstret)
hpmcounter3-31URO0xC03-0xC1FCountersPerformance counters (shadows)
cycleh…URO0xC80-0xC9FCountersRV32 high halves of the above
sstatusSRW0x100S trap setupSupervisor status (restricted mstatus view)
sieSRW0x104S trap setupSupervisor interrupt-enable
stvecSRW0x105S trap setupSupervisor trap vector base + mode
scounterenSRW0x106S trap setupCounter access for U-mode
senvcfgSRW0x10AS configSupervisor environment configuration
scountinhibitSRW0x120S countersSupervisor counter-inhibit (Smcdeleg)
sscratchSRW0x140S trap handlingSupervisor scratch
sepcSRW0x141S trap handlingSupervisor exception PC
scauseSRW0x142S trap handlingSupervisor trap cause
stvalSRW0x143S trap handlingSupervisor trap value (bad addr/insn)
sipSRW0x144S trap handlingSupervisor interrupt-pending
scountovfSRO0xDA0S countersCount-overflow bits (Sscofpmf)
siselect/sireg*SRW0x150-0x157S indirectIndirect CSR access window (Sscsrind)
satpSRW0x180S translationAddress translation & protection: MODE/ASID/PPN
stimecmpSRW0x14DS timerSupervisor timer compare (Sstc)
scontextSRW0x5A8DebugSupervisor context for triggers
srmcfgSRW0x181QoSResource management config (Ssqosid)
sstateen0-3SRW0x10C-0x10FS stateenState-enable gates for U-mode
sctrctl/sctrstatus/sctrdepthSRW0x14E/0x14F/0x15FCTRControl transfer records (Smctr)
hstatusHRW0x600H trap setupHypervisor status
hedeleg/hidelegHRW0x602/0x603H trap setupDelegation to VS-mode
hie/hip/hvipHRW0x604/0x644/0x645H interruptsVS-level interrupt enable/pending/inject
hcounterenHRW0x606H trap setupCounter access for VS/VU
hgeieHRW0x607H interruptsGuest external interrupt enables
hgeipHRO0xE12H interruptsGuest external interrupt pending
henvcfgHRW0x60AH configHypervisor environment configuration
htimedeltaHRW0x605H timerGuest time offset
htval/htinstHRW0x643/0x64AH trap handlingGuest trap value / transformed instruction
hgatpHRW0x680H translationGuest (G-stage) address translation
vsstatus/vsie/vstvec …HRW0x200/0x204/0x205 …VS twinsVirtual-supervisor copies of the S CSRs
vsatpHRW0x280VS twinsVS-stage address translation
vstimecmpHRW0x24DVS twinsVirtual supervisor timer compare
mvendoridMRO0xF11M infoVendor ID (JEDEC)
marchidMRO0xF12M infoMicroarchitecture ID
mimpidMRO0xF13M infoImplementation version
mhartidMRO0xF14M infoHart ID (one hart must be 0)
mconfigptrMRO0xF15M infoPointer to config structure
mstatusMRW0x300M trap setupMachine status: privilege stack, interrupt enables, FS/XS, endianness…
misaMRW0x301M trap setupISA width + extension letters (WARL)
medeleg/midelegMRW0x302/0x303M trap setupException/interrupt delegation to S-mode
mieMRW0x304M interruptsMachine interrupt-enable
mtvecMRW0x305M trap setupMachine trap vector base + mode (direct/vectored)
mcounterenMRW0x306M trap setupCounter access for S-mode
mstatushMRW0x310M trap setupRV32: upper mstatus bits
mscratchMRW0x340M trap handlingMachine scratch (trap-handler stack anchor)
mepcMRW0x341M trap handlingMachine exception PC (WARL, IALIGN-masked)
mcauseMRW0x342M trap handlingTrap cause: interrupt bit + code
mtvalMRW0x343M trap handlingFaulting address / instruction bits
mipMRW0x344M interruptsMachine interrupt-pending
mtinst/mtval2MRW0x34A/0x34BM trap handlingH-extension guest-trap details
menvcfgMRW0x30AM configEnvironment config (FIOM, CBIE, PBMTE, STCE…)
mseccfgMRW0x747M configSecurity config (PMP enhancements, Zkr)
pmpcfg0-15MRW0x3A0-0x3AFPMPPMP configuration bytes (RV64: even only)
pmpaddr0-63MRW0x3B0-0x3EFPMPPMP address registers (WARL grain)
mstateen0-3MRW0x30C-0x30FM stateenState-enable gates for S/U
mnscratch/mnepc/mncause/mnstatusMRW0x740-0x744RNMIResumable NMI state (Smrnmi)
mcycleMRW0xB00M countersCycle counter (writable master)
minstretMRW0xB02M countersInstret counter (writable master)
mhpmcounter3-31MRW0xB03-0xB1FM countersHPM counter masters
mcountinhibitMRW0x320M countersStop counters (power/measurement)
mhpmevent3-31MRW0x323-0x33FM countersEvent selectors
mcyclecfg/minstretcfgMRW0x321/0x322M countersPrivilege-mode filtering (Smcntrpmf)
tselect/tdata1-3MRW0x7A0-0x7A3DebugTrigger module (M-visible)
dcsr/dpc/dscratch…DRW0x7B0-0x7BFDebugDebug-mode-only — M access traps

Hardware Designer Notes

This table is the register-file floorplan for Part II: each following chapter specifies the fields behind one group. Budget note — the genuinely stateful CSRs for a minimal Linux hart number only about thirty; the rest of the 4096-entry space is decode-and-trap.

Minimal Linux-boot hart MUST

  • Implement the Linux-boot set: M info (mhartid may hardwire per-hart), M trap setup/handling, mcounteren, the S twins + satp + stimecmp, menvcfg, and the counter file
  • Trap accesses to everything you leave out — unimplemented CSRs are not read-as-zero
  • Alias sstatus/sie/sip as masked views of mstatus/mie/mip, not separate flops

MAY simplify / trap-and-emulate

  • Skip whole optional blocks (H, vector, indirect-access, CTR, RNMI, stateen) on a first Linux core
  • Hardwire the info registers (mvendorid=0 is legal for non-commercial)

Check yourself — the CSR map

1.Which four CSRs form the minimal machine trap-handling set every trap handler touches?

2.Why does sstatus (0x100) exist when S-mode state already lives in mstatus (0x300)?

3.For a minimal Linux-boot RV64 hart (no H, no vector, no debug), roughly which CSR groups from the listing are mandatory?

3 questions