Skip to content

Fix XLEN classification of Smrnmi and odd pmpcfg CSRs - #448

Merged
Andrew Waterman (aswaterman) merged 1 commit into
riscv:masterfrom
BiNeurale:fix-csr-xlen
Nov 25, 2026
Merged

Andrew Waterman (aswaterman) merged 1 commit into
riscv:masterfrom
BiNeurale:fix-csr-xlen

Conversation

@BiNeurale

Copy link
Copy Markdown
Contributor

mnscratch, mnepc, mncause and mnstatus are in csrs32.csv, but they are MXLEN-bit registers (smrnmi.adoc) and exist on RV64. The odd pmpcfg registers have the opposite problem: they are in csrs.csv, but machine.adoc says "For RV64, the odd-numbered configuration registers, pmpcfg1, pmpcfg3, ..., pmpcfg15, are illegal."

This PR moves the 12 lines between the two files. Nothing else changes.

Where it shows: the Go generator reads only csrs.csv, so Go's riscv64 assembler (go1.27.4) accepts PMPCFG1 and rejects MNSCRATCH ("illegal or missing addressing mode for symbol MNSCRATCH"). Chisel CSRs.all / CSRs.all32 are off the same way. The C, Rust and SystemVerilog outputs merge both files, so encoding.out.h has the same set of CSR_* defines before and after (checked), only the order changes.

binutils (CSR_CLASS_I_32 for odd pmpcfg, CSR_CLASS_SMRNMI for mn*) and llvm-mc ("system register 'pmpcfg1' is RV32 only", mnscratch accepted on riscv64 with +smrnmi) already classify them this way.

Tests pass (17/17). Note that #422 moves these files into csrs/; happy to rebase onto it if that lands first.

mnscratch, mnepc, mncause and mnstatus are MXLEN-bit CSRs that exist on
RV64 too, so they belong in csrs.csv rather than csrs32.csv.

pmpcfg1, pmpcfg3, ..., pmpcfg15 are illegal on RV64, so they belong in
csrs32.csv rather than csrs.csv.

Signed-off-by: Emanuele Lovato <bineurale@gmail.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@aswaterman
Andrew Waterman (aswaterman) merged commit 5e641d2 into riscv:master Nov 25, 2026
1 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants