sret

Returns from an exception. When `sret` is allowed to execute, its behavior depends on whether or not the current privilege mode is virtualized. *When the current privilege mode is (H)S-mode or M-mode* `sret` sets `hstatus.HPV` = 0, `mstatus.SPP` = 0, `mstatus.SIE` = `mstatus.SPIE`, and `mstatus.SPIE` = 1, changes the privilege mode according to the table below, and then jumps to the address in `sepc`. .Next privilege mode following an `sret` in (H)S-mode or M-mode [%autowidth] |=== | [.rotate]#`mstatus.SPP`# | [.rotate]#`hstatus.SPV`# .>| Mode after `sret` | 0 | 0 | U-mode | 0 | 1 | VU-mode | 1 | 0 | (H)S-mode | 1 | 1 | VS-mode |=== *When the current privilege mode is VS-mode* `sret` sets `vsstatus.SPP` = 0, `vsstatus.SIE` = `vstatus.SPIE`, and `vsstatus.SPIE` = 1, changes the privilege mode according to the table below, and then jumps to the address in `vsepc`. .Next privilege mode following an `sret` in (H)S-mode or M-mode [%autowidth] |=== | [.rotate]#`vsstatus.SPP`# .>| Mode after `sret` | 0 | VU-mode | 1 | VS-mode |===

Synopsis

sret

Encoding

Type:

03100010000001000000000000001110011
funct7: 0001000
funct3: 000
opcode: 1110011

RISC-V Instruction Encoder/Decoder

open sret in rvcodecjs

Availability