Vol. 3C 31-3
VIRTUAL-MACHINE MONITOR PROGRAMMING CONSIDERATIONS
Processors perform various checks while executing any VMX instruction. They follow well-defined error handling on
failures. VMX instruction execution failures detected before loading of a guest state are handled by the processor
as follows:
•
If the working-VMCS pointer is not valid, the instruction fails by setting RFLAGS.CF to 1.
•
If the working-VMCS pointer is valid, RFLAGS.ZF is set to 1 and the proper error-code is saved in the VM-
instruction error field of the working-VMCS.
Software is required to check RFLAGS.CF and RFLAGS.ZF to determine the success or failure of VMX instruction
executions.
The following items provide details regarding use of the VM-entry instructions (VMLAUNCH and VMRESUME):
•
If the working-VMCS pointer is valid, the state of the working VMCS may cause the VM-entry instruction to fail.
RFLAGS.ZF is set to 1 and one of the following values is saved in the VM-instruction error field:
— 4: VMLAUNCH with non-clear VMCS.
If this error occurs, software can avoid the error by executing VMRESUME.
— 5: VMRESUME with non-launched VMCS.
If this error occurs, software can avoid the error by executing VMLAUNCH.
Figure 31-1. VMX Transitions and States of VMCS in a Logical Processor
(a) VMX Operation and VMX Transitions
(b) State of VMCS and VMX Operation
Processor
Operation
VMXON
VM Entry
VM Entry
VM Entry
VM Entry
VM Exit
VM Exit
VM Exit
VM Exit
VMXOFF
Outside
VMX
Operation
VMX Root
Operation
VMX
Non-Root
Operation
Legend:
Legend:
Inactive
VMCS
Current VMCS
(working)
Active VMCS
(not current)
Current VMCS
(controlling)
VMCS B
VMCS A
VMLAUNCH
VMRESUME
VMPTRLD B
VMCLEAR B
VM Exit
VM Exit
VMPTRLD A
VMPTRLD A
VMCLEAR A
VM Exit
VM Exit
VMLAUNCH
VMRESUME