Skip to content

Add mseccfg/mseccfgh CSRs, gated on the extensions that define them - #1891

Draft
davidharrishmc wants to merge 4 commits into
openhwfoundation:rva23from
davidharrishmc:dh/mseccfg
Draft

davidharrishmc wants to merge 4 commits into
openhwfoundation:rva23from
davidharrishmc:dh/mseccfg

Conversation

@davidharrishmc

@davidharrishmc davidharrishmc commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Adds the mseccfg (0x747) and mseccfgh (0x757) CSRs to csrm.sv, implemented only when an extension that defines a field in them is present.

The privileged spec defines mseccfg only for Smepmp, Zkr, Zicfilp and Smmpm. A new derived parameter MSECCFG_SUPPORTED in config-shared.vh gates the register, the CSR read decode and the tracer connections. When it is 0, both addresses raise an illegal instruction exception, as they did before this PR, and no flops are generated. Wally does not yet implement any of those extensions, so MSECCFG_SUPPORTED is presently 0, with the intended OR of the extension parameters commented beside it. When it is set, every field is read-only 0 until the extensions are added.

  • mseccfg is 64 bits wide even on RV32, where the upper half is reached through mseccfgh; the register is split into low/high flops on RV32 following the existing menvcfg/menvcfgh pattern.
  • mseccfgh reads the high half on RV32 and traps illegal on RV64.
  • Each field in the write value is a 1'b0 constant with the enabling term commented out beside it, so turning a field on later is a pure uncomment:
Bits Field Gate
33:32 PMM P.SMMPM_SUPPORTED & (P.XLEN==64)
10 MLPE P.ZICFILP_SUPPORTED
9 SSEED P.ZKR_SUPPORTED & P.S_SUPPORTED
8 USEED P.ZKR_SUPPORTED & P.U_SUPPORTED
2 RLB P.SMEPMP_SUPPORTED
1 MMWP P.SMEPMP_SUPPORTED
0 MML P.SMEPMP_SUPPORTED

None of those config parameters exist yet; they come with the extensions.

Two WARL/legalization requirements are captured in comments so they are not missed later:

  • PMM is WARL with 01 reserved, and Smmpm requires the largest supported address to fit in XLEN-PMLEN bits, so PMLEN 16 (11) is unavailable with Sv57 or PA_BITS > 48 — which includes the current rv64gc config. The commented LegalizedPMM keeps the old value on an illegal write, matching the menvcfg.CBIE convention already in this file.
  • Smepmp fields additionally need sticky/locking behavior: MML and MMWP cannot be cleared once set, and RLB cannot be set once any pmpcfg entry has its L bit set, both until a PMP reset.

wallyTracer.sv connects mseccfg/mseccfgh to the register only when MSECCFG_SUPPORTED; otherwise they are not traced.

Testing

lint-wally passes on all standard configs plus fdqh_rv64gc, both as committed (MSECCFG_SUPPORTED = 0) and with MSECCFG_SUPPORTED temporarily set to 1 so the gated register logic is also linted. With the parameter at 0, behavior is unchanged from rva23: both addresses still trap. No directed test was added; one belongs with the first extension that enables the register.

🤖 Generated with Claude Code

davidharrishmc and others added 2 commits October 10, 2026 07:36
The tracer reported both CSRs as literal 0, which is right only while
every field is read-only zero.  Connect it to MSECCFG_REGW so that
enabling a field later cannot silently leave lockstep comparing against
a stale constant.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@rosethompson

Copy link
Copy Markdown
Contributor

General question. What is Wally's default behavior for non-existing CSRs? I thought it was to raise an illegal-instruction exception and since mseccfg requires at least one of three extensions should a read of these two CSRs cause an illegal-instruction exception if non of these extensions exist?

@jordancarlin

Copy link
Copy Markdown
Contributor

Wally implements Ssstrict in its rv64/32gc configs, which requires raising an illegal instruction for any CSR that is not implemented. Agreed that we should continue to throw an illegal instruction exception for mseccfg when Zkr/Smepmp/etc. are not implemented.

@davidharrishmc

Copy link
Copy Markdown
Contributor Author

Agreed. Will fix.

mseccfg/mseccfgh exist only if Smepmp, Zkr, Zicfilp or Smmpm is
implemented; otherwise accesses are illegal.  Add a derived
MSECCFG_SUPPORTED parameter (presently 0, since Wally supports none of
those extensions) that gates the register, the CSR read decode and the
tracer connections.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@davidharrishmc davidharrishmc changed the title Add mseccfg/mseccfgh CSRs (read-only zero) Add mseccfg/mseccfgh CSRs, gated on the extensions that define them Oct 12, 2026
# Conflicts:
#	config/shared/parameter-defs.vh
#	src/cvw.sv
#	src/privileged/csrm.sv
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.

3 participants