mcontext
Machine-mode context register
- Address
0x7A8- Group
- Debug CSRs (0x7A0 to 0x7BF)
- Privilege
MRW(privileged spec CSR listing, Debug/Trace Registers (shared with Debug Mode))- Access
- read/write; lowest privilege M (machine)
- Address range
- Standard read/write debug CSRs
- Name in riscv-unified-db
- Machine Context
Privileged spec: Machine-mode context register
Description
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.
From riscv-unified-db, reformatted.
Fields
| Field | Bits | Type | Description |
|---|---|---|---|
HCONTEXT | 13-0 | RW | M-Mode or HS-Mode (using 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 |
Fields from riscv-unified-db; field types computed by IDL functions there are not shown.
Specification and related pages
- The RISC-V Instruction Set Manual, Volume II: CSR listing (src/priv/csrs.adoc)
- riscv-opcodes csrs.csv
- riscv-unified-db: spec/std/isa/csr/mcontext.yaml
- csrrw, csrrs, csrrc (Zicsr instructions that access CSRs)