03.03.2013 Views

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.3 PAGING-MODE ACCESS ENHANCEMENT<br />

ADDITIONAL NEW INSTRUCTIONS<br />

Intel 64 architecture provided two paging mode modifiers that regulate instruction fetches from linear memory<br />

address spaces: Execute-Disable (XD) and supervisor mode execution prevention (SMEP) are described in Chapter<br />

4 of <strong>Intel®</strong> 64 and IA-32 <strong>Architecture</strong>s Software Developer’s Manual, Volume 3A.<br />

A third paging mode modifier is introduced to regulate data accesses, referred to as supervisor mode access<br />

prevention (SMAP).<br />

When SMAP is enabled, the processor disallows supervisor data accesses to pages that are accessible in user<br />

mode. Disallowed accesses result in page-fault exceptions. Software may find it necessary to allow certain supervisor<br />

accesses to user-accessible pages. For this reason, the SMAP architecture allows software to disable the<br />

SMAP protections temporarily.<br />

SMAP applies in all paging modes (32-bit paging, PAE paging, and IA-32e paging) and to all page sizes (4-KByte,<br />

2-MByte, 4-MByte, and 1-GByte). SMAP has no effect on processor operation if paging is disabled. SMAP has no<br />

effect on the address translation provided by EPT. SMAP has no effect in operating modes that paging is not used.<br />

9.3.1 Enumeration and Enabling<br />

System software enables SMAP by setting the SMAP flag in control register CR4 (bit 21).<br />

Processor support for SMAP is enumerated by the CPUID instruction. Specifically, the processor supports SMAP<br />

only if CPUID.(EAX=07H,ECX=0H):EBX.SMAP[bit 20] = 1.<br />

A processor will allow CR4.SMAP to be set only if SMAP is enumerated by CPUID as described above. CR4.SMAP<br />

may be set if paging is disabled (if CR0.PG = 0), but it has no effect on processor operation in that case.<br />

In addition, two new instructions: CLAC and STAC (see Section 9.6) are supported if and only if SMAP is enumerated<br />

by CPUID as described above.<br />

9.3.2 SMAP and Access Rights<br />

Every access to a linear address is either a supervisor-mode access or a user-mode access. All accesses performed<br />

while the current privilege level (CPL) is less than 3 are supervisor-mode accesses. If CPL = 3, accesses are generally<br />

user-mode accesses. However, some operations implicitly access system data structures, and the resulting<br />

accesses to those data structures are supervisor-mode accesses regardless of CPL. Examples of such implicit<br />

supervisor accesses include the following: accesses to the global descriptor table (GDT) or local descriptor table<br />

(LDT) to load a segment descriptor; accesses to the interrupt descriptor table (IDT) when delivering an interrupt or<br />

exception; and accesses to the task-state segment (TSS) as part of a task switch or change of CPL.<br />

If CR4.SMAP = 1, supervisor-mode data accesses are not allowed to linear addresses that are accessible in user<br />

mode. If CPL < 3, SMAP protections are disabled if EFLAGS.AC = 1. If CPL = 3, SMAP applies to all supervisor-mode<br />

data accesses (these are implicit supervisor accesses) regardless of the value of EFLAGS.AC.<br />

The following items detail how paging determines access rights for supervisor-mode data accesses:<br />

• Data reads that are allowed:<br />

— If CR4.SMAP = 0, data may be read from any linear address with a valid translation.<br />

— If CR4.SMAP = 1, access rights depend on CPL and EFLAGS.AC.<br />

• If CPL < 3 and EFLAGS.AC = 1, data may be read from any linear address with a valid translation.<br />

• If CPL = 3 (an implicit supervisor access) or EFLAGS.AC = 0, data may be read from any linear address<br />

with a valid translation for which the U/S flag (bit 2) is 0 in at least one of the paging-structure entries<br />

controlling the translation.<br />

• Data writes that are allowed:<br />

— If CR0.WP = 0 and CR4.SMAP = 0, data may be written to any linear address with a valid translation.<br />

— If CR0.WP = 0 and CR4.SMAP = 1, access rights depend on CPL and EFLAGS.AC.<br />

• If CPL < 3 and EFLAGS.AC = 1, data may be written to any linear address with a valid translation.<br />

Ref. # 319433-014 9-3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!