Webcentive RISC-V Reference

hstatus

Hypervisor status register

Address
0x600
Group
Hypervisor and VS CSRs
Privilege
HRW (privileged spec CSR listing, Hypervisor Trap Setup)
Access
read/write; lowest privilege H (hypervisor, including VS CSRs)
Address range
Standard read/write
Name in riscv-unified-db
Hypervisor Status

Privileged spec: Hypervisor status register

Description

The hstatus register tracks and controls a VS-mode guest.

Unlike fields in sstatus, which are all aliases of fields mstatus, bits in hstatus are independent bits and do not have aliases.

From riscv-unified-db, reformatted.

Fields

FieldBitsTypeDescription
VSXL33-32VS-mode XLen.

Applies when the riscv-unified-db condition holds: return $array_size(VSXLEN) > 1;

Determines the effective XLEN in VS-mode. Valid values are:

ValueVSXLEN
032
164

Applies when the riscv-unified-db condition holds: return $array_size(VSXLEN) == 1 && $array_includes?(VSXLEN, 32);

Because the implementation only supports a single VSXLEN == 32, this field is read-only-0.

Applies when the riscv-unified-db condition holds: return $array_size(VSXLEN) == 1 && $array_includes?(VSXLEN, 64);

Because the implementation only supports a single VSXLEN == 64, this field is read-only-1.

HUKTE24RWHypervisor UKTE.

If the Svukte extension is implemented, the HUKTE field determines whether the HLV, HLVX, and HSV instructions, when executed in U-mode, are Svukte-qualified. When one of these instructions is executed in U-mode, it behaves as though senvcfg.UKTE were set to the value of HUKTE. If Svukte is not implemented, HUKTE is read-only zero.

VTSR22RWVirtual Trap SRET.

When hstatus.VTSR is set, executing the sret instruction in VS-mode raises a Virtual Instruction exception.

When hstatus.VTSR is clear, an sret instruction in VS-mode returns control to the mode stored in vsstatus.SPP.

VTW21RWVirtual Trap WFI.

When hstatus.VTW is set, a wfi instruction executed in VS-mode raises a Virtual Instruction exception after waiting an implementation-defined amount of time (which can be 0).

When both hstatus.VTW and mstatus.TW are clear, a wfi instruction executes in VS-mode without a timeout period.

The wfi instruction is also affected by mstatus.TW, as shown below:

mstatus.TWhstatus.VTWwfi behavior
HS-modeU-modeVS-modeVU-mode
00WaitTrap (I)WaitTrap (V)
01WaitTrap (I)Trap (V)Trap (V)
1-Trap (I)Trap (I)Trap (I)Trap (I)
Trap (I) - Trap with Illegal Instruction code + Trap (V) - Trap with Virtual Instruction code
VTVM20RWVirtual Trap Virtual Memory.

When set, a 'Virtual Instruction` trap occurs when executing an sfence.vma, sinval.vma, or an explicit CSR access of the satp (really vsatp) register when in VS-mode.

When clear, the instructions execute as normal in VS-mode.

Notably, hstatus.VTVM does not cause hfence.vvma, sfence.w.inval, or sfence.inval.ir to trap.

mstatus.TVM does not affect the VS-mode instructions controlled by hstatus.VTVM.

VGEIN17-12Virtual Guest External Interrupt Number.

Selects the guest external interrupt source for VS-level external interrupts.

When hstatus.VGEIN == 0, no external interrupt source is selected.

When hstatus.VGEIN != 0, it selects which bit of hgeip is currently active in VS-mode.

HU9RWHypervisor in U-mode.

When set, the hypervisor load/store instructions (hlv, hlvx, and hsv) can be executed in U-mode.

When clear, the hypervisor load/store instructions cause an Illegal Instruction trap.

SPVP8RWSupervisor Previous Virtual Privilege.

Written by hardware:

  • When taking a trap into HS-mode from VS-mode or VU-mode, hstatus.SPVP is written with the nominal privilege mode

Notably, unlike its analog mstatus.SPP, hstatus.SPVP is not cleared when returning from a trap.

Can also be written by software without immediate side-effect.

Affects execution by:

  • Controls the effective privilege level applied to the hypervisor load/store instructions, hlv, hlvx, and hsv.
SPV7RWSupervisor Previous Virtualization Mode.

Written by hardware:

  • On a trap into HS-mode, hardware writes 1 when the prior mode was VS-mode or VU-mode, and 0 otherwise.

Can also be written by software without immediate side-effect.

Affects execution by:

  • When an sret instruction in executed in HS-mode or M-mode, control returns to VS-mode or VU-mode (as selected by mstatus.SPP) when hstatus.SPV is 1 and to HS-mode or U-mode otherwise.
GVA6RWGuest Virtual Address.

Written by hardware whenever a trap is taken into HS-mode:

  • Writes 1 when a trap causes a guest virtual address to be written into stval (Breakpoint, * Address Misaligned, * Access Fault, * Page Fault, or * Guest-Page Fault).
  • Writes 0 otherwise

Does not affect execution.

VSBE5VS-mode Big Endian.

Controls the endianness of data VS-mode (0 = little, 1 = big). Instructions are always little endian, regardless of the data setting.

Applies when the riscv-unified-db condition holds: return VS_MODE_ENDIANNESS == "little";

Since the CPU does not support big endian in VS-mode, this is hardwired to 0.

Applies when the riscv-unified-db condition holds: return VS_MODE_ENDIANNESS == "big";

Since the CPU does not support little endian in VS-mode, this is hardwired to 1.

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

Specification and related pages