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

Table Of Contents
26-24 Vol. 3
VIRTUAL-MACHINE MONITOR PROGRAMMING CONSIDERATIONS
uniformly. Further, even if the host intends to support fast system calls during a
VM-exit, some of the MSR values (such as the setting of the SCE bit in IA32_EFER)
may not require modification as they may already be set to the appropriate value in
the guest.
For performance reasons, a VMM may perform lazy save, load, and restore of these
MSR values on certain VM exits when it is determined that this is acceptable. The
lazy-save-load-restore operation can be carried out “manually” using RDMSR and
WRMSR.
26.10.4.4 Handling the SWAPGS Instruction
The SWAPGS instruction is available only in 64-bit mode. It swaps the contents of
two specific MSRs (IA32_GSBASE and IA32_KERNEL_GSBASE). The IA32_GSBASE
MSR shadows the base address portion of the GS descriptor register; the
IA32_KERNEL_GSBASE MSR holds the base address of the GS segment used by the
kernel (typically it houses kernel structures). SWAPGS is intended for use with fast
system calls when in 64-bit mode to allow immediate access to kernel structures on
transition to kernel mode.
Similar to SYSCALL/SYSRET, IA-32e mode hosts which use fast system calls may
need to save, load, and restore these MSR registers on VM exit and VM entry using
the guidelines discussed in previous paragraphs.
26.10.4.5 Implementation Specific Behavior on Writing to Certain MSRs
As noted in Section 22.4 and Section 23.4, a processor may prevent writing to
certain MSRs when loading guest states on VM entries or storing guest states on VM
exits. This is done to ensure consistent operation. The subset and number of MSRs
subject to restrictions are implementation specific. For initial VMX implementations,
there are two MSRs: IA32_BIOS_UPDT_TRIG and IA32_BIOS_SIGN_ID (see
Appendix B).
26.10.5 Handling Accesses to Reserved MSR Addresses
Privileged software (either a VMM or a guest OS) can access a model specific register
by specifying addresses in MSR address space. VMMs, however, must prevent a guest
from accessing reserved MSR addresses in MSR address space.
Consult Appendix B for lists of supported MSRs and their usage. Use the MSR bitmap
control to cause a VM exit when a guest attempts to access a reserved MSR address.
The response to such a VM exit should be to reflect #GP(0) back to the guest.