proposal to add "virtual instruction exception" to the hypervisor extension

John Hauser

Hello tech-privileged guys,

I've created a pull request for the RISC-V privileged spec in response
to requests from our hypervisor software authors:

For those with an interest, please review.

This change would add to the hypervisor extension a new kind of
exception, "virtual instruction exception". The following is copied
from new text added to the hypervisor chapter:


When V = 1, a virtual instruction trap (not an illegal instruction
trap) is taken for:

- attempts to access a counter CSR when the corresponding bit in
hcounteren is 0 and the same bit in mcounteren is 1;

- attempts to execute WFI, unless the instruction completes within an
implementation-specific, bounded time;

- attempts to execute a virtual-machine load/store instruction, HLV,

- in VS-mode, attempts to execute an HFENCE instruction or to access
an implemented hypervisor CSR or VS CSR;

- in VS-mode, attempts to execute SRET when hstatus.VTSR = 1; or

- in VS-mode, attempts to execute an SFENCE instruction or to access
satp, when hstatus.VTVM = 1.

On a virtual instruction trap, mtval or stval is written the same as
for an illegal instruction trap.

When V = 1, circumstances that might otherwise cause an illegal
instruction trap instead cause a virtual instruction trap if a
hypervisor is normally expected to emulate the instruction. Notably,
for VS-mode this includes the hypervisor instructions (HLV, HLVX, HSV,
and HFENCE) and accesses to the hypervisor-level CSRs, all of which
must be emulated for nested hypervisors. A hypervisor that does not
support nested hypervisors should convert many virtual instruction
traps into illegal instruction exceptions for the guest virtual

Machine level is expected ordinarily to delegate virtual instruction
traps directly to HS-level, whereas illegal instruction traps are
likely to be processed first in M-mode before being conditionally
delegated (by software) to HS-level. Consequently, virtual instruction
traps are expected typically to be handled faster than illegal
instruction traps.



- John Hauser

Join to automatically receive all group messages.