Is it a normal user-mode instruction?
No. These instructions are constrained by privilege level and extension support; user-mode legality must follow the privileged rules.
Machine trap return: pc<-mepc, privilege<-mstatus.MPP, MIE<-MPIE.
MRET uses opcode 1110011 (0x73), funct3 000, funct12 001100000010. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.
MRET returns from a machine-mode trap handler: pc is set to mepc, the current privilege mode is restored from mstatus.MPP, MIE is restored from MPIE, MPIE is set to 1, and MPP is set to the least-privileged supported mode. With the H extension, virtualization state is also restored according to MPV/MPP. MRET is legal only in M-mode; execution in a lower privilege mode raises an illegal-instruction exception.
MRET is a system-level instruction defined by the privileged architecture. This page covers architectural semantics only, not platform firmware policy.
Understand this scenario with real code like «mret # Return from M-mode trap».
Understand this scenario with real code like «mret # Return from M-mode trap».
No. These instructions are constrained by privilege level and extension support; user-mode legality must follow the privileged rules.
No. Address translation, instruction fetch, and data-memory ordering use different fence/invalidation instructions.