Webcentive RISC-V Reference

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

FieldBitsTypeDescription
HCONTEXT13-0RW

M-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.

Fields from riscv-unified-db; field types computed by IDL functions there are not shown.

Specification and related pages