← Home

mcontext

Machine Context

Address: 0x7A8 (1960) · Privilege: M · Length: MXLEN · Writable · Defined by: Sdtrig

This register must be implemented if `hcontext` is implemented, and is optional otherwise. It is only accessible in M-mode and Debug mode.

`hcontext` is primarily useful to set triggers on hypervisor systems that only fire when a given VM is executing. It is also useful in systems where M-Mode implements something like a hypervisor directly.

Fields

RV32

31:2423:1615:87:0
—HCONTEXT

RV64

63:5655:4847:4039:3231:2423:1615:87:0
—HCONTEXT
BitsFieldAliasDescriptionTypeReset
[13:0]HCONTEXTM-Mode or HS-Mode (using `hcontext`) 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 upper bits in this field to 0. If the H extension is not implemented, it’s recommended to implement 6 bits on RV32 and 13 bits on RV64 (as visible through the `mcontext` register). If the H extension is implemented, it’s recommended to implement 7 bits on RV32 and 14 bits on RV64.RW0

Software read

# check if MCONTEXT is implemented
if (!MCONTEXT_IMPLEMENTED) {
  unimplemented_csr($encoding);
}
return $bits(CSR[mcontext]);

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.