Repository navigation
fix(csr): allow non-virtual user access and enforce counter enables - #6
Merged
RossComputerGuy merged 3 commits intoOct 6, 2026
Merged
Conversation
Delegate implemented-address, privilege and read-only checks to the CSR file in static and microcoded execution. Enforce mcounteren/scounteren and expose TM only with a live time source. Add 40 RV32/RV64 regressions. The complete CSR directory passes 73 tests versus 65 passes and eight failures on the baseline, preserving all existing passes. Checkpoint before upstream submission: hcounteren and VS/VU trap semantics still require review. Architectural FCSR support is separate and is not implemented by this change.
Limit new user CSR access and counter-enable checks to non-virtual execution. Keep the prior VU rejection until hcounteren, shared supervisor CSR handling, virtual time and cause-22 selection can be implemented together. Add eight H-enabled boundary cases, including ordinary U-mode with hcounteren clear and retained VU read/write rejection. All 81 CSR cases and 11 existing hypervisor tests pass; the same baseline has ten expected CSR failures and no hypervisor failures.
RossComputerGuy
requested changes
Oct 6, 2026
Replace helper and entrypoint wrappers with one test file and a shared teardown. Preserve all 48 cases and assertions; all cases pass after consolidation. No production-code changes.
Contributor
Author
|
Consolidated into Re-ran all 48 cases from the consolidated file; all pass, and analysis of the test file is clean. Process isolation for validation stays outside the PR. No production-code changes in this update. |
RossComputerGuy
approved these changes
Oct 6, 2026
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.
This follows up on the user-mode CSR problems encountered during River/ZedBoard bring-up. Both the static and microcoded executors rejected every U-mode CSR instruction before the CSR file could check whether the access was legal.
That prevented ordinary user code from reading an enabled
timecounter or accessing an implemented user-level CSR. Removing the blanket rejection alone wasn't enough: the CSR file also needed to enforce the counter-enable bits.This permits implemented CSR accesses from non-virtual U-mode, leaving address privilege, existence and read-only checks in the CSR file. For non-virtual execution, it also:
mcounterenbelow M-mode.scounterenwhen S-mode exists.rdtimecontinues to trap for firmware emulation.Scope
This deliberately does not enable VU CSR access. The previous VU rejection and virtual-mode counter behavior are preserved until
hcounteren, virtual-instruction exception selection, shared supervisor CSRs and virtual time can be handled together. The VU tests here check that compatibility boundary, not H-extension conformance.It also doesn't implement
fflags,frmorfcsr, which are absent from the current CSR file. This is a prerequisite for the local user FCSR fix, not the complete FP architectural port. Existing static virtual-instruction checks and SATP fence wiring are retained.Testing
Added 40 cases across RV32/RV64 and static/microcoded execution. These cover enabled user counter reads, implemented user CSR read/write forms, M/S/U counter-enable combinations, and rejection of privileged, absent and read-only CSR accesses. Denied accesses also check that the destination register is preserved.
Another eight RV64 H-enabled cases check that ordinary U-mode works with
hcounterenclear while VU read/write access remains rejected.I compared the exact upstream parent (
61acd21) and this branch with identical locked dependencies, Dart 3.13.0, and the same new tests/harness support:All 44 pre-existing cases remain passing. Ten of the new cases fail on baseline and pass with the fix; the other 38 check protection and compatibility. No tests were removed.
For the final comparison, each of the 81 CSR cases ran in a fresh process to avoid accumulating simulator overhead from repeated full-core builds:
The hypervisor directory ran on both versions with:
dart test packages/river_hdl/test/hypervisor \ --concurrency=4 --timeout=60s --reporter=jsonChanged-file analysis reports the same two warnings and one info as baseline, with no new diagnostics.
git diff --checkpasses.I haven't run the full River suite, external RTL simulation, synthesis or hardware validation for this upstream port.