Environment
Describe the bug
misa initially has both User (U, bit 20) and Supervisor (S, bit 18) set. Clearing only U should also clear S because S depends on U. NutShell leaves misa unchanged (both bits still set).
Minimal trigger:
csrr s0, misa
li t0, (1 << 20) # U
csrc misa, t0 # clear U while S is still 1
csrr s1, misa # mismatch here
Observed values:
| Stage |
Value |
Meaning |
Initial misa |
0x8000000000141105 |
MXL=RV64, extensions include U|S|M|I|C|A |
After csrc (Sail) |
0x8000000000001105 |
U and S both cleared → M|I|C|A |
After csrc (NutShell) |
0x8000000000141105 |
U and S both still set (write ineffective w.r.t. dependency) |
Mismatch at pc = 0x8000000c on s1:
- riscv-Sail (right):
0x8000000000001105
- NutShell (wrong):
0x8000000000141105
Expected behavior
Per RISC-V Privileged Spec (machine.adoc — misa extension dependencies):
If an ISA feature x depends on an ISA feature y, then attempting to enable feature x but disable feature y results in both features being disabled.
For example, setting "F"=0 and "D"=1 results in both "F" and "D" being cleared.
Similarly, setting "U"=0 and "S"=1 results in both "U" and "S" being cleared.
Clearing U while S remains set is exactly that illegal combination: the write must clear both U and S.
|
After csrc misa, (1<<20) |
| Expected (Sail) |
misa = 0x8000000000001105 (U=0, S=0) |
| Actual (NutShell) |
misa = 0x8000000000141105 (U=1, S=1 unchanged) |
Environment
0b3d3a86feb1e0c7c10f446a460443ad2d696e6dDescribe the bug
misainitially has both User (U, bit 20) and Supervisor (S, bit 18) set. Clearing onlyUshould also clearSbecause S depends on U. NutShell leavesmisaunchanged (both bits still set).Minimal trigger:
Observed values:
misa0x8000000000141105csrc(Sail)0x8000000000001105M|I|C|Acsrc(NutShell)0x8000000000141105Mismatch at
pc = 0x8000000cons1:0x80000000000011050x8000000000141105Expected behavior
Per RISC-V Privileged Spec (machine.adoc — misa extension dependencies):
Clearing
UwhileSremains set is exactly that illegal combination: the write must clear bothUandS.csrc misa, (1<<20)misa = 0x8000000000001105(U=0,S=0)misa = 0x8000000000141105(U=1,S=1unchanged)