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

Table Of Contents
Vol. 3 20-29
VIRTUAL-MACHINE CONTROL STRUCTURES
20.10 SOFTWARE ACCESS TO THE VMCS AND RELATED
STRUCTURES
This section details guidelines that software should observe when accessing a VMCS
and related structures. It also provides descriptions of consequences for failing to
follow guidelines.
20.10.1 Software Access to the Virtual-Machine Control Structure
To ensure proper processor behavior, software should observe certain guidelines
when accessing an active VMCS.
No VMCS should ever be active on more than one logical processor. If a VMCS is to be
“migrated” from one logical processor to another, the first logical processor should
execute VMCLEAR for the VMCS (to make it inactive on that logical processor and to
ensure that all VMCS data are in memory) before the other logical processor
executes VMPTRLD for the VMCS (to make it active on the second logical processor).
Software should never access or modify the VMCS data of an active VMCS using ordi-
nary memory operations, in part because the format used to store the VMCS data is
implementation-specific and not architecturally defined, and also because a logical
processor may maintain some VMCS data of an active VMCS on the processor and not
in the VMCS region. The following items detail some of the hazards of performing
such accesses:
Any data read from a VMCS with an ordinary memory read does not reliably
reflect the state of the VMCS. Results may vary from time to time or from logical
processor to logical processor.
Writing to a VMCS with an ordinary memory write is not guaranteed to have a
deterministic effect on the VMCS. Doing so may lead to unpredictable behavior.
Any or all of the following may occur: (1) VM entries may fail for unexplained
reasons or may load undesired processor state; (2) the processor may not
correctly support VMX non-root operation as documented in Chapter 21 and may
generate unexpected VM exits; and (3) VM exits may load undesired processor
state, save incorrect state into the VMCS, or cause the logical processor to
transition to a shutdown state.
Software can avoid such problems by removing any linear-address mappings to a
VMCS region before executing a VMPTRLD for that region and by not remapping it
until after executing VMCLEAR for that region.
Software should use the VMREAD and VMWRITE instructions to access the different
fields in the current VMCS (see Section 20.10.2).
Software should initialize all fields in a VMCS (using VMWRITE) before using the
VMCS for VM entry. Failure to do so may result in unpredictable behavior; for
example, a VM entry may fail for unexplained reasons, or a successful transition
(VM entry or VM exit) may load processor state with unexpected values.