background image

6-40 Vol. 3A


Interrupt 14—Page-Fault Exception (#PF)

Exception Class



Indicates that, with paging enabled (the PG flag in the CR0 register is set), the processor detected one of the 
following conditions while using the page-translation mechanism to translate a linear address to a physical 

The P (present) flag in a page-directory or page-table entry needed for the address translation is clear, 
indicating that a page table or the page containing the operand is not present in physical memory.

The procedure does not have sufficient privilege to access the indicated page (that is, a procedure running in 
user mode attempts to access a supervisor-mode page). If the SMAP flag is set in CR4, a page fault may also 
be triggered by code running in supervisor mode that tries to access data at a user-mode address. If the PKE 
flag is set in CR4, the PKRU register may cause page faults on data accesses to user-mode addresses with 
certain protection keys.

Code running in user mode attempts to write to a read-only page. If the WP flag is set in CR0, the page fault 
will also be triggered by code running in supervisor mode that tries to write to a read-only page.

An instruction fetch to a linear address that translates to a physical address in a memory page with the 
execute-disable bit set (for information about the execute-disable bit, see Chapter 4, “Paging”). If the SMEP 
flag is set in CR4, a page fault will also be triggered by code running in supervisor mode that tries to fetch an 
instruction from a user-mode address.

One or more reserved bits in paging-structure entry are set to 1. See description below of RSVD error code flag.

An enclave access violates one of the specified access-control requirements. See Section 38.3, “Access-control 
and Section 38.19, “Enclave Page Cache Map (EPCM)” in Chapter 38, “Enclave Access Control 
and Data Structures.”
 In this case, the exception is called an SGX-induced page fault. The processor uses the 
error code (below) to distinguish SGX-induced page faults from ordinary page faults.

The exception handler can recover from page-not-present conditions and restart the program or task without any 
loss of program continuity. It can also restart the program or task after a privilege violation, but the problem that 
caused the privilege violation may be uncorrectable.
See also: Section 4.7, “Page-Fault Exceptions.”

Exception Error Code

Yes (special format). The processor provides the page-fault handler with two items of information to aid in diag-
nosing the exception and recovering from it:

An error code on the stack. The error code for a page fault has a format different from that for other exceptions 
(see Figure 6-9). The processor establishes the bits in the error code as follows:
— P  flag  (bit 0).

This flag is 0 if there is no translation for the linear address because the P flag was 0 in one of the paging-
structure entries used to translate that address.

— W/R (bit 1).

If the access causing the page-fault exception was a write, this flag is 1; otherwise, it is 0. This flag 
describes the access causing the page-fault exception, not the access rights specified by paging.

— U/S (bit 2).

If a user-mode access caused the page-fault exception, this flag is 1; it is 0 if a supervisor-mode access did 
so. This flag describes the access causing the page-fault exception, not the access rights specified by 

— RSVD  flag  (bit 3).

This flag is 1 if there is no translation for the linear address because a reserved bit was set in one of the 
paging-structure entries used to translate that address.