hcontext

Hypervisor Context

This optional register may be implemented only if the H extension is implemented. If it is implemented, mcontext must also be implemented.

This register is only accessible in HS-Mode, M-mode and Debug Mode. If Smstateen is implemented, then accessibility of in HS-Mode is controlled by mstateen0[57].

This register is an alias of the mcontext register, providing access to the HCONTEXT field from HS-Mode.

Attributes

Defining Extension

allOf: * Sdtrig, version >= Sdtrig@1.0.0 * H, version >= H@1.0.0

CSR Address

0x6a8

Length

* 32 when (priv_mode() == PrivilegeMode::M && CSR[misa].MXL == 0)

(priv_mode() == PrivilegeMode::S && CSR[mstatus].SXL == %%)

(priv_mode() == PrivilegeMode::VS && CSR[hstatus].VSXL == %%) * 64 when (priv_mode() == PrivilegeMode::M && CSR[misa].MXL == 1)

(priv_mode() == PrivilegeMode::S && CSR[mstatus].SXL == %%)

(priv_mode() == PrivilegeMode::VS && CSR[hstatus].VSXL == %%)

Privilege Mode

S

Format

This CSR format changes dynamically.

hcontext Format when (priv_mode() == PrivilegeMode::M && CSR[misa].MXL == 0) || (priv_mode() == PrivilegeMode::S && CSR[mstatus].SXL == 0) || (priv_mode() == PrivilegeMode::VS && CSR[hstatus].VSXL == 0)
Figure 1. hcontext Format when (priv_mode() == PrivilegeMode::M && CSR[misa].MXL == 0) || (priv_mode() == PrivilegeMode::S && CSR[mstatus].SXL == 0) || (priv_mode() == PrivilegeMode::VS && CSR[hstatus].VSXL == 0)
hcontext Format when (priv_mode() == PrivilegeMode::M && CSR[misa].MXL == 1) || (priv_mode() == PrivilegeMode::S && CSR[mstatus].SXL == 1) || (priv_mode() == PrivilegeMode::VS && CSR[hstatus].VSXL == 1)
Figure 2. hcontext Format when (priv_mode() == PrivilegeMode::M && CSR[misa].MXL == 1) || (priv_mode() == PrivilegeMode::S && CSR[mstatus].SXL == 1) || (priv_mode() == PrivilegeMode::VS && CSR[hstatus].VSXL == 1)

Field Summary

Name Location Type Reset Value

hcontext.HCONTEXT

13:0

RW

0

Fields

HCONTEXT

Location

13:0

Description

Alias of mcontext.HCONTEXT.

Type

RW

Reset value

0

Software write

This CSR may store a value that is different from what software attempts to write.

When a software write occurs (e.g., through csrrw), the following determines the written value:

HCONTEXT = # check if mstateen0 is implemented
if (implemented?(ExtensionName::Smstateen) && CSR[mstateen0].CONTEXT != 0) {
  unimplemented_csr($encoding);
}

# check if HCONTEXT is available
if (!HCONTEXT_AVAILABLE) {
  unimplemented_csr($encoding);
}

# enforce width of HCONTEXT
Bits<14> hcontext_value = csr_value.HCONTEXT & ((14'1 << DBG_HCONTEXT_WIDTH) - 1);
# forward the write to mcontext.HCONTEXT
CSR[mcontext].HCONTEXT = hcontext_value;
return CSR[mcontext].HCONTEXT;

Software read

This CSR may return a value that is different from what is stored in hardware.

if (implemented?(ExtensionName::Smstateen) && mstateen0.CONTEXT != 0) {
  unimplemented_csr($encoding);
}
if (!HCONTEXT_AVAILABLE) {
  unimplemented_csr($encoding);
}
return $bits(mcontext);