Skip to content

fix(riscv): canonicalize reserved WARL encodings in four CSRs - #312

Open
carlosqwqqwq wants to merge 4 commits into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-warl-csr-canonicalize
Open

fix(riscv): canonicalize reserved WARL encodings in four CSRs#312
carlosqwqqwq wants to merge 4 commits into
HexRaysSA:masterfrom
carlosqwqqwq:fix-riscv-warl-csr-canonicalize

Conversation

@carlosqwqqwq

Copy link
Copy Markdown
Contributor

Summary

mstatus.MPP, mip, mideleg and medeleg are WARL CSRs: writes to reserved fields must be canonicalized to the legal value set. RAX's csr_write stored the raw value, so reserved encodings (MPP=0b10, mip[0], mideleg[0], medeleg[10]) became readable.

This change masks the WARL fields in csr_write for these four CSRs: MPP to the implemented privilege set, mip/mideleg to the writable interrupt bits, and medeleg to the delegatable exception causes.

Validation

  • New regression tests cover each reserved field: MPP=0b10 canonicalizes to U, mip[0]/mideleg[0]/medeleg[10] clear to 0, and legal values are preserved.
  • cargo test --lib targeted tests pass; full suite shows no regressions.

Closes #307

@carlosqwqqwq
carlosqwqqwq force-pushed the fix-riscv-warl-csr-canonicalize branch from 060a3c8 to 71c52eb Compare August 14, 2026 03:29
@carlosqwqqwq

Copy link
Copy Markdown
Contributor Author

The test-core (linux-x64) failure is unrelated to this patch: it fails in the x86-64 evex_fma3_* / legacy_sha_replay native-replay tests (SIGILL or SHA assertion), while this PR only touches RISC-V CSR code. The same tests pass locally (full cargo test --lib on master + this patch) and on the linux-arm64/macos lanes.

Root cause: this PR's CI merge base is master, which does not yet contain the scalar EVEX FMA3 LLIG canonicalization from #296 (src/smir/ir/x86_native_replay/classifiers/evex_scalar_fma_llig.rs). Until #296 lands, the native-replay tests are unstable on hosted linux-x64 runners. Once #296 is merged, these lanes should be stable for every PR based on master.

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.

Reserved encodings of four WARL CSRs are stored instead of canonicalized

1 participant