首页 > 代码库 > IA-32平台的Control Register(控制寄存器)

IA-32平台的Control Register(控制寄存器)

A control register is a processor register which changes or controls the general behavior of a CPU or other digital device. Common tasks performed by control registers include interrupt control, switching the addressing mode, paging control, and coprocessor control.

控制寄存器(Control Register)是用来修改或控制CPU特性的寄存器。它通常的功能包括:中断控制,地址模式转换,页面控制和并行控制。例如cr0寄存器的第0位(PE位)置位,系统将运行在保护模型下,否则运行在实模式下。

cr0

BitNameFull NameDescription
31PGPagingIf 1, enable paging and use the CR3 register, else disable paging(是否允许内存分页)
30CDCache disableGlobally enables/disable the memory cache
29NWNot-write throughGlobally enables/disable write-back caching
18AMAlignment maskAlignment check enabled if AM set, AC flag (in EFLAGS register) set, and privilege level is 3
16WPWrite protectDetermines whether the CPU can write to pages marked read-only(root是否可写用户空间)
5NENumeric errorEnable internal x87 floating point error reporting when set, else enables PC style x87 error detection
4ETExtension typeOn the 386, it allowed to specify whether the external math coprocessor was an80287 or 80387
3TSTask switchedAllows saving x87 task context upon a task switch only after x87 instruction used
2EMEmulationIf set, no x87 floating point unit present, if clear, x87 FPU present
1MPMonitor co-processorControls interaction of WAIT/FWAIT instructions with TS flag in CR0
0PEProtected Mode EnableIf 1, system is in protected mode, else system is in real mode(实模式or保护模式)

cr1

保留

cr2

Used when virtual addressing is enabled, hence when the PG bit is set in CR0. CR3 enables the processor to translate linear addresses into physical addresses by locating the page directory and page tables for the current task. Typically, the upper 20 bits of CR3 become the page directory base register (PDBR), which stores the physical address of the first page directory entry.

cr3

Used in protected mode to control operations such as virtual-8086 support, enabling I/O breakpoints, page size extension and machine check exceptions.

BitNameFull NameDescription
21SMAPSupervisor Mode Access Protection EnableIf set, access of data in a higher ring generates a fault
20SMEPSupervisor Mode Execution Protection EnableIf set, execution of code in a higher ring generates a fault
18OSXSAVEXSAVE and Processor Extended States Enable 
17PCIDEPCID EnableIf set, enables process-context identifiers (PCIDs).
14SMXESafer Mode Extensions Enablesee Trusted Execution Technology (TXT)
13VMXEVirtual Machine Extensions Enablesee Intel VT-x
10OSXMMEXCPTOperating System Support for Unmasked SIMD Floating-Point ExceptionsIf set, enables unmasked SSE exceptions.
9OSFXSROperating system support for FXSAVE and FXRSTOR instructionsIf set, enables SSE instructions and fast FPU save & restore
8PCEPerformance-Monitoring Counter enableIf set, RDPMC can be executed at any privilege level, else RDPMC can only be used in ring 0.
7PGEPage Global EnabledIf set, address translations (PDE or PTE records) may be shared between address spaces.
6MCEMachine Check ExceptionIf set, enables machine check interrupts to occur.
5PAEPhysical Address ExtensionIf set, changes page table layout to translate 32-bit virtual addresses into extended 36-bit physical addresses.
4PSEPage Size ExtensionIf unset, page size is 4 KiB, else page size is increased to 4 MiB (or 2 MiB with PAE set).
3DEDebugging ExtensionsIf set, enables debug register based breaks on I/O space access
2TSDTime Stamp DisableIf set, RDTSC instruction can only be executed when in ring 0, otherwise RDTSC can be used at any privilege level.
1PVIProtected-mode Virtual InterruptsIf set, enables support for the virtual interrupt flag (VIF) in protected mode.
0VMEVirtual 8086 Mode ExtensionsIf set, enables support for the virtual interrupt flag (VIF) in virtual-8086 mode.