ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 1,823 microarchs · 16,083 chips · 105 sources
Arch:
Tier:

sret

T1 riscv system insn
Supervisor Mode Return from Trap
SourceRISC-V Official Unified Database (riscv-unified-db) (riscv_unified_db)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeRV32/RV64 S
RV32 / RV64 (Ratified & Standard Extensions)
License & VersionApache-2.0 / CC-BY-4.0
main
Upstreamhttps://github.com/riscv/riscv-unified-db
Privilegesupervisor
ExtensionsS

Summary

Returns from supervisor mode after handling a trap.

Syntax / Encoding

sret | 00010000001000000000000001110011 (mask=0xffffffff match=0x10200073)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32RV000100000010000000000000011100110xffffffff / 0x10200073

Reference Notes

Returns from supervisor mode after handling a trap.

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
|===