mret

Machine Exception Return

Returns from an exception in M-mode.

Assembly format

`mret `

Decode Variables

Execution

  • IDL

  • Sail

if (mstatus.MPP != 2'b11) {
  mstatus.MPRV = 0;
}
if (implemented?(ExtensionName::Smdbltrp)) {
  if (xlen() == 64) {
    mstatus.MDT = 1'b0;
  } else {
    mstatush.MDT = 1'b0;
  }
}
mstatus.MIE = mstatus.MPIE;
mstatus.MPIE = 1;
if (mstatus.MPP == 2'b00) {
  set_mode(PrivilegeMode::U);
} else if (mstatus.MPP == 2'b01) {
  set_mode(PrivilegeMode::S);
} else if (mstatus.MPP == 2'b11) {
  set_mode(PrivilegeMode::M);
}
mstatus.MPP = implemented?(ExtensionName::U) ? 2'b00 : 2'b11;
$pc = $bits(mepc);
{
  if   cur_privilege != Machine
  then { handle_illegal(); RETIRE_FAIL }
  else if not(ext_check_xret_priv (Machine))
  then { ext_fail_xret_priv(); RETIRE_FAIL }
  else {
    set_next_pc(exception_handler(cur_privilege, CTL_MRET(), PC));
    RETIRE_SUCCESS
  }
}

Encoding

svg

Defining extension

  • Sm, version >= Sm@1.11.0

Access

M HS U VS VU

Always

Never

Never

Never

Never

Containing profiles

  • Mandatory: RVA23M64, RVB23M64

  • Optional: