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

Table Of Contents
26-20 Vol. 3
VIRTUAL-MACHINE MONITOR PROGRAMMING CONSIDERATIONS
On a VMM teardown, VMX operation should be exited before deactivating IA-32e
mode if the latter is required.
26.9.4 IA-32e Mode Guests
A 32-bit guest can be launched by either IA-32e-mode hosts or non-IA-32e-mode
hosts. A 64-bit guests can only be launched by a IA-32e-mode host.
In addition to the steps outlined in Section 26.6, VMM writers need to:
Set the “IA-32e-mode guest” VM-entry control to 1 in the VMCS to assure
VM-entry (VMLAUNCH or VMRESUME) will establish a 64-bit (or 32-bit
compatible) guest operating environment.
Enable paging (CR0.PG) and PAE mode (CR4.PAE) to assure VM-entry to a 64-bit
guest will succeed.
Ensure that the host to be in IA-32e mode (the IA32_EFER.LMA must be set to 1)
and the setting of the VM-exit “host address-space size” control bit in the VMCS
must also be set to 1.
If each of the above conditions holds true, then VM-entry will copy the value of the
VM-entry “IA-32e-mode guest” control bit into the guests IA32_EFER.LME bit, which
will result in subsequent activation of IA-32e mode. If any of the above conditions is
false, the VM-entry will fail and load state from the host-state area of the working
VMCS as if a VM exit had occurred (see Section 22.7).
The following VMCS controls determine the value of IA32_EFER on a VM entry: the
“IA-32e-mode guest” VM-entry control (described above), the “load IA32_EFER” VM-
entry control, the “VM-entry MSR-load count,” and the “VM-entry MSR-load address”
(see Section 22.4).
If the “load IA32_EFER” VM-entry control is 1, the value of the LME and LMA bits in
the IA32_EFER field in the guest-state area must be the value of the “IA-32e-mode
guest” VM-exit control. Otherwise, the VM entry fails.
The loading of IA32_EFER.LME bit (described above) precedes any loading of the
IA32_EFER MSR from the VM-entry MSR-load area of the VMCS. If loading of
IA32_EFER is specified in the VM-entry MSR-load area, the value of the LME bit in the
load image should be match the setting of the “IA-32e-mode guest” VM-entry
control. Otherwise, the attempt to modify the LME bit (while paging is enabled)
results in a failed VM entry. However, IA32_EFER.LMA is always set by the processor
to equal IA32_EFER.LME & CR0.PG; the value specified for LMA in the load image of
the IA32_EFER MSR is ignored. For these and performance reasons, VMM writers
may choose to not use the VM-exit/entry MSR-load/save areas for IA32_EFER MSR.
Note that the VMM can control the processor’s architectural state when transferring
control to a VM. VMM writers may choose to launch guests in protected mode and
subsequently allow the guest to activate IA-32e mode or they may allow guests to
toggle in and out of IA-32e mode. In this case, the VMM should require VM exit on
accesses to the IA32_EFER MSR to detect changes in the operating mode and modify
the VM-entry “IA-32e-mode guest” control accordingly.