Bug Description:
MPRV is bit 17 of the mstatus CSR.
According to the RISC-V Privileged Specification:
An MRET or SRET instruction that changes the privilege mode to a mode less privileged than M also sets MPRV=0.
However, in NutShell, when using MRET or SRET to transition from M-mode to a lower-privilege mode, the MPRV bit remains set to 1, which violates the specification.
To Reproduce:
- Start in M-mode.
- Write mstatus with MPRV=1
- Execute MRET (or SRET) so that the privilege mode drops from M-mode to a lower privilege (e.g., U-mode).
- Compare mstatus between NutShell and Spike.
Test program and log information: test_MPRV.zip
Inconsistent information:
sret also observed the same inconsistency.
Environment:
NutShell: commit e315a27