diff --git a/arch/inst/I/mret.yaml b/arch/inst/I/mret.yaml index 6792a0dd30..34d490017e 100644 --- a/arch/inst/I/mret.yaml +++ b/arch/inst/I/mret.yaml @@ -14,9 +14,16 @@ access: encoding: match: "00110000001000000000000001110011" operation(): | - if (implemented?(ExtensionName::S) && CSR[mstatus].MPP != 2'b11) { + if (CSR[mstatus].MPP != 2'b11) { CSR[mstatus].MPRV = 0; } + if (implemented?(ExtensionName::Smdbltrp)) { + if (xlen() == 64) { + CSR[mstatus].MDT = 1'b0; + } else { + CSR[mstatush].MDT = 1'b0; + } + } CSR[mstatus].MIE = CSR[mstatus].MPIE; CSR[mstatus].MPIE = 1; if (CSR[mstatus].MPP == 2'b00) { diff --git a/arch/inst/Smrnmi/mnret.yaml b/arch/inst/Smrnmi/mnret.yaml index bd314fc499..da4c94c0cc 100644 --- a/arch/inst/Smrnmi/mnret.yaml +++ b/arch/inst/Smrnmi/mnret.yaml @@ -3,9 +3,13 @@ $schema: inst_schema.json# kind: instruction name: mnret -long_name: No synopsis available. +long_name: Machine mode resume from the RNMI or Double Trap handler. description: | - No description available. + MNRET is an M-mode-only instruction that uses the values in mnepc and mnstatus to return to the + program counter, privilege mode, and virtualization mode of the interrupted context. This instruction + also sets mnstatus.NMIE. If MNRET changes the privilege mode to a mode less privileged than M, it + also sets mstatus.MPRV to 0. If the Zicfilp extension is implemented, then if the new privileged mode is + y, MNRET sets ELP to the logical AND of yLPE (see Section 22.1.1) and mnstatus.MNPELP. definedBy: Smrnmi assembly: mnret encoding: @@ -18,9 +22,17 @@ access: vu: always data_independent_timing: false operation(): | - if (implemented?(ExtensionName::S) && CSR[mstatus].MPP != 2'b11) { + if (CSR[mnstatus].MNPP != 2'b11) { CSR[mstatus].MPRV = 0; + if (implemented?(ExtensionName::Smdbltrp)) { + if (xlen() == 64) { + CSR[mstatus].MDT = 1'b0; + } else { + CSR[mstatush].MDT = 1'b0; + } + } } + CSR[mnstatus].NMIE = 1'b1; if (CSR[mnstatus].MNPP == 2'b00) { set_mode(PrivilegeMode::U); } else if (CSR[mnstatus].MNPP == 2'b01) {