Intel 64 and IA-32 Architectures Software Developers Manual Volume 3B, System Programming Guide Part 2

Table Of Contents
Vol. 3 26-11
VIRTUAL-MACHINE MONITOR PROGRAMMING CONSIDERATIONS
26.7 HANDLING OF VM EXITS
This section provides examples of software steps involved in a VMM’s handling of VM-
exit conditions:
Determine the exit reason through a VMREAD of the exit-reason field in the
working-VMCS. Appendix I describes exit reasons and their encodings.
VMREAD the exit-qualification from the VMCS if the exit-reason field provides a
valid qualification. The exit-qualification field provides additional details on the
VM-exit condition. For example, in case of page faults, the exit-qualification field
provides the guest linear address that caused the page fault.
Depending on the exit reason, fetch other relevant fields from the VMCS.
Appendix I lists the various exit reasons.
Handle the VM-exit condition appropriately in the VMM. This may involve the
VMM emulating one or more guest instructions, programming the underlying
host hardware resources, and then re-entering the VM to continue execution.
26.7.1 Handling VM Exits Due to Exceptions
As noted in Section 21.3, an exception causes a VM exit if the bit corresponding to
the exception’s vector is set in the exception bitmap. (For page faults, the error code
also determines whether a VM exit occurs.) This section provide some guidelines of
how a VMM might handle such exceptions.
Exceptions result when a logical processor encounters an unusual condition that soft-
ware may not have expected. When guest software encounters an exception, it may
be the case that the condition was caused by the guest software. For example, a
guest application may attempt to access a page that is restricted to supervisor
access. Alternatively, the condition causing the exception may have been established
by the VMM. For example, a guest OS may attempt to access a page that the VMM
has chosen to make not present.
When the condition causing an exception was established by guest software, the
VMM may choose to reflect the exception to guest software. When the condition was
established by the VMM itself, the VMM may choose to resume guest software after
removing the condition.
26.7.1.1 Reflecting Exceptions to Guest Software
If the VMM determines that a VM exit was caused by an exception due to a condition
established by guest software, it may reflect that exception to guest software. The
VMM would cause the exception to be delivered to guest software, where it can be
handled as it would be if the guest were running on a physical machine. This section
describes how that may be done.
In general, the VMM can deliver the exception to guest software using VM-entry
event injection as described in Section 22.5. The VMM can copy (using VMREAD and