MIE Field of MSTATUS CSR Is Updated Wrongly
Created by: shetalani
RISC-V Specification:
- "The MRET, SRET, or URET instructions are used to return from traps in M-mode, S-mode, or U-mode respectively. When executing an xRET instruction, supposing xPP holds the value y, xIE is set to xPIE; the privilege mode is changed to y; xPIE is set to 1; and xPP is set to U (or M if user-mode is not supported)."
- "The MRET instruction is used to return from a trap taken into M-mode. MRET sets the privilege mode according to the values of MPP and MPV in mstatus, as encoded in Table 5.6. MRET then in mstatus sets MPV=0, MPP=0, MIE=MPIE, and MPIE=1, and also sets pc=mepc."
Issue Description:
MIE field of MSTATUS CSR is not updated to take the value of MPIE when MRET instruction is executed and the MPP field has the value 0.
Example:
As shown below, the instruction 32'h30200073 (mret) is decoded at time point t##0 where the current privilege is M and MPP has the value associated with U mode. When it updates MSTATUS value at t##3 (closed), it sets all fields correctly except MIE, which stays asserted instead of taking the value of MPIE.
On the other hand, in the opposite scenario, when an exception occurring in U mode is handled, MPIE is not taking the value of MIE as the specification states.
Product: OneSpin 360 DV-Verify App: RVV Tool's version: 2019.2.2