Repository navigation
Make mstateen0 P1P13 and ENVCFG read-only zero when their CSRs don't exist - #2467
Merged
aswaterman merged 2 commits intoOct 9, 2026
Conversation
…exist P1P13 controls hedelegh, which only exists on RV32 with H, and ENVCFG controls senvcfg/henvcfg, which need S-mode. Smstateen requires stateen bits for unimplemented state to be read-only zero. Fixes #2464 Signed-off-by: Zhaoqi Xu <[email protected]>
Signed-off-by: Andrew Waterman <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2464
mstateen0bits that control state the hart doesn't implement have to be read-only zero, but two of them were writable:hedelegh, which only exists on RV32 with H. Implement hedelegh, gated by mstateen0.P1P13 #2439 made it writable whenever H is present, including RV64.senvcfg(andhenvcfg), which need S-mode, but it was writable with--priv=mu.This only adds P1P13 to the
mstateen0mask whenxlen == 32, and ENVCFG when S is supported.hstateen0shares that mask but only exists with H, so nothing changes for it.Tested: built spike from fdc1ffa with and without this change and ran the
stateen_ro0reproducer from the issue (riscv64-unknown-elf-gcc 14.2):--isa=rv64gch_smstateen--isa=rv32gch_smstateen--priv=mu --isa=rv64gc_smstateen--priv=mu --isa=rv32gc_smstateenI also wrote all ones to
mstateen0/mstateen0hand read back bits 63:56 to check nothing else moved: P1P13 still sticks onrv32gch, and ENVCFG still sticks onrv64gc/rv32gcwith S.seip-rmwandwfi-as-nopfromci-testsstill pass.