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

Table Of Contents
27-8 Vol. 3
VIRTUALIZATION OF SYSTEM RESOURCES
When guest software first enables paging, the VMM creates an aligned 4-KByte active
page directory that is invalid (all entries marked not-present). This invalid directory
is analogous to an empty TLB.
27.3.5.2 Response to Page Faults
Page faults can occur for a variety of reasons. In some cases, the page fault alerts the
VMM to an inconsistency between the active and guest page-table hierarchy. In such
cases, the VMM can update the former and re-execute the faulting instruction. In
other cases, the hierarchies are already consistent and the fault should be handled
by the guest operating system. The VMM can detect this and use an established
mechanism for raising a page fault to guest software.
The VMM can handle a page fault by following these steps (The steps below assume
the guest is operating in a paging mode without PAE. Analogous steps to handle
address translation using PAE or four-level paging mechanisms can be derived by
VMM developers according to the paging behavior defined in Chapter 3 of the Intel®
64 and IA-32 Architectures Software Developer’s Manual, Volume 3A):
1. First consult the active PDE, which can be located using the upper 10 bits of the
faulting address and the current value of CR3. The active PDE is the source of the
fault if it is marked not present or if its R/W bit and U/S bits are inconsistent with
the attempted guest access (the guest privilege level and the value of CR0:WP
should also be taken into account).
2. If the active PDE is the source of the fault, consult the corresponding guest PDE
using the same 10 bits from the faulting address and the physical address that
corresponds to the guest address in the guest CR3. If the guest PDE would cause
a page fault (for example: it is marked not present), then raise a page fault to the
guest operating system.
The following steps assume that the guest PDE would not have caused a page
fault.
3. If the active PDE is the source of the fault and the guest PDE contains, as page-
table base address (if PS = 0) or page base address (PS = 1), a guest address
that the VMM has chosen not to support; then raise a machine check (or some
other abort) to the guest operating system.
The following steps assume that the guest address in the guest PDE is supported
for the virtual machine.
4. If the active PDE is marked not-present, then set the active PDE to correspond to
guest PDE as follows:
a. If the active PDE contains a page-table base address (if PS = 0), then
allocate an aligned 4-KByte active page table marked completely invalid and
set the page-table base address in the active PDE to be the physical address
of the newly allocated page table.