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

Table Of Contents
27-4 Vol. 3
VIRTUALIZATION OF SYSTEM RESOURCES
present. The VMM may handle these VM exits by invoking appropriate virtual
device emulation code.
27.3.3 Virtualizing Virtual Memory by Brute Force
VMX provides the hardware features required to fully virtualize guest virtual memory
accesses. VMX allows the VMM to trap guest accesses to the PAT (Page Attribute
Table) MSR and the MTRR (Memory Type Range Registers). This control allows the
VMM to virtualize the specific memory type of a guest memory. The VMM may control
caching by controlling the guest CR0.CRD and CR0.NW bits, as well as by trapping
guest execution of the INVD instruction. The VMM can trap guest CR3 loads and
stores, and it may trap guest execution of INVLPG.
Because a VMM must retain control of physical memory, it must also retain control
over the processor’s address-translation mechanisms. Specifically, this means that
only the VMM can access CR3 (which contains the base of the page directory) and can
execute INVLPG (the only other instruction that directly manipulates the TLB).
At the same time that the VMM controls address translation, a guest operating
system will also expect to perform normal memory management functions. It will
access CR3, execute INVLPG, and modify (what it believes to be) page directories
and page tables. Virtualization of address translation must tolerate and support
guest attempts to control address translation.
A simple-minded way to do this would be to ensure that all guest attempts to access
address-translation hardware trap to the VMM where such operations can be properly
emulated. It must ensure that accesses to page directories and page tables also get
trapped. This may be done by protecting these in-memory structures with conven-
tional page-based protection. The VMM can do this because it can locate the page
directory because its base address is in CR3 and the VMM receives control on any
change to CR3; it can locate the page tables because their base addresses are in the
page directory.
Such a straightforward approach is not necessarily desirable. Protection of the in-
memory translation structures may be cumbersome. The VMM may maintain these
structures with different values (e.g., different page base addresses) than guest soft-
ware. This means that there must be traps on guest attempt to read these structures
and that the VMM must maintain, in auxiliary data structures, the values to return to
these reads. There must also be traps on modifications to these structures even if the
translations they effect are never used. All this implies considerable overhead that
should be avoided.
27.3.4 Alternate Approach to Memory Virtualization
Guest software is allowed to freely modify the guest page-table hierarchy without
causing traps to the VMM. Because of this, the active page-table hierarchy might not
always be consistent with the guest hierarchy. Any potential problems arising from