← Home

scontext

Supervisor Context

Address: 0x5A8 (1448) · Privilege: S · Length: XLEN · Writable · Defined by: Sdtrig and S and SCONTEXT_IMPLEMENTED == True

This optional register is only accessible in S/HS-mode, VS-mode, M-mode and Debug Mode. Accessibility of this CSR is controlled by `mstateen0[57]` and `hstateen0[57]` in the Smstateen extension. Enabling `scontext` can be a security risk in a virtualized system with a hypervisor that does not swap `scontext`.

Fields

RV32

31:2423:1615:87:0
DATA

RV64

63:5655:4847:4039:3231:2423:1615:87:0
—DATA
BitsFieldAliasDescriptionTypeReset
[31:0]DATASupervisor mode software can write a context number to this register, which can be used to set triggers that only fire in that specific context. An implementation may tie any number of high bits in this field to 0. It’s recommended to implement 16 bits on RV32 and 32 bits on RV64.RW0

Software read

# check if mstateen0 or hstateen0 is clear
if (implemented?(ExtensionName::Smstateen) && ((CSR[mstateen0].CONTEXT != 0) || (CSR[hstateen0].CONTEXT != 0))) {
  unimplemented_csr($encoding);
}
return $bits(CSR[scontext]);

Version af3eaf9+cheriot.f635218

Data from the RISC-V Unified Database, copyright RISC-V International and contributors.

CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.

This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.