Control register


A control register is a processor register that 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.

History

The early CPU lacked dedicated control registers, and relied on a limited set of internal signals and flags. When IBM developed a paging version of the System/360, they added 16 control registers to the design for what became the 360/67. IBM did not provide control registers on other S/360 models, but made them a standard part of System/370, although with different register and bit assignments. As IBM added new features to the architecture, e.g., DAS, S/370-XA, S/370-ESA, ESA/390, they added additional fields to the control registers. With z/Architecture, IBM doubled the control register size to 64 bits.

Control registers in IBM 360/67

On the 360/67, CR0 and CR2 are used by address translation, CR 4-6 contain miscellaneous flags including interrupt masks and Extended Control Mode, and CR 8-14 contain the switch settings on the 2167 Configuration Unit.

M67 CR0

Control Register 0 contains the address of the segment table for dynamic address translation.

M67 CR2

Control register 2 is the Relocation exception address register.

M67 [|CR4]

CR4 is the extended mask register for channels 0-31.
Each bit is the 1/0 channel mask for the corresponding channel.

M67 CR5

CR5 is reserved for the extended mask register for channels 32–63.
Each bit is the 1/0 channel mask for the corresponding channel.

M67 CR6

CR6 contains two mode flags plus extensions to the PSW mask bits.
FieldBitDescription
00Machine Check Mask Extension for Channel Controller o
11Machine Check Mask Extension for Channel Controller 1
2-3Reserved for channel controllers 2-3
4-7Unassigned
88Extended Control Mode
99Configuration Control Bit
10-23Unassigned
24-31External interrupt masking
24Timer
25Interrupt Key
26Malfunction Alert - CPU 1
27Malfunction Alert - CPU 2
28Reserved
29Reserved
30External Interrupt - CPU 1, 2
31Reserved

M67 CR8

Control Register 8 contains the assignments of Processor Storage units 1–4 to central processing units and channel controllers.
BitDescription
0Processor Storage Unit 1 to CPU 1
1Processor Storage Unit 1 to CPU 2
2-3Reserved for CPU 3-4
4Processor Storage Unit 1 to CC 0
5Processor Storage Unit 1 to CC 1
6-7Reserved for CC 3-4
8Processor Storage Unit 2 to CPU 1
9Processor Storage Unit 2 to CPU 2
10-11Reserved for CPU 3-4
12Processor Storage Unit 2 to CC 0
13Processor Storage Unit 2 to CC 1
14-15Reserved for CC 3-4
16Processor Storage Unit 3 to CPU 1
17Processor Storage Unit 3 to CPU 2
18-19Reserved for CPU 3-4
20Processor Storage Unit 3 to CC 0
21Processor Storage Unit 3 to CC 1
22-23Reserved for CC 3-4
24Processor Storage Unit 4 to CPU 1
25Processor Storage Unit 4 to CPU 2
26-27Reserved for CPU 3-4
28Processor Storage Unit 4 to CC 0
29Processor Storage Unit 4 to CC 1
30-31Reserved for CC 3-4

M67 CR9

Control Register 9 contains the assignments of Processor Storage units 5–8 to central processing units and channel controllers.
BitDescription
0Processor Storage Unit 5 to CPU 1
1Processor Storage Unit 5 to CPU 2
2-3Reserved for CPU 3-4
4Processor Storage Unit 5 to CC 0
5Processor Storage Unit 5 to CC 1
6-7Reserved for CC 3-4
8Processor Storage Unit 6 to CPU 66
9Processor Storage Unit 6 to CPU 2
10-11Reserved for CPU 3-4
12Processor Storage Unit 6 to CC 0
13Processor Storage Unit 6 to CC 1
14-15Reserved for CC 3-4
16Processor Storage Unit 7 to CPU 1
17Processor Storage Unit 7 to CPU 2
18-19Reserved for CPU 3-4
20Processor Storage Unit 7 to CC 0
21Processor Storage Unit 7 to CC 1
22-23Reserved for CC 3-4
24Processor Storage Unit 8 to CPU 1
25Processor Storage Unit 8 to CPU 2
26-27Reserved for CPU 3-4
28Processor Storage Unit 8 to CC 0
29Processor Storage Unit 8 to CC 1
30-31Reserved for CC 3-4

M67 CR10

Control Register 10 contains the Processor storage address assignment codes.
BitStarting Address Code for
0-3Processor Storage Unit 1
4-7Processor Storage Unit 2
8-11Processor Storage Unit 3
12-15Processor Storage Unit 4
16-19Processor Storage Unit 5
20-23Processor Storage Unit 6
24-27Processor Storage Unit 7
28-31Processor Storage Unit 8

M67 CR11

Control Register 11 contains channel controller assignments.
BitDescription
0CC 0 available on CPU 1
1CC 0 available on CPU 2
2-3Reserved for CPUs 3-4
4CC 1 available on CPU 1
5CC 1 available on CPU 2
6-7Reserved for CPUs 3-4
8-15Unassigned
16CPU 1 to only CC 0
17CPU 1 to only CC 1
18-19Reserved for CC 2-3
20CPU 2 to only CC 0
21CPU 2 to only CC 1
22-23Reserved for CC 2-3
24-31Unassigned

M67 CR12

CR12 contains I/O Control Unit Partitioning.
BitI/O Control UnitInterface
011
112
221
322
431
532
641
742
851
952
1061
1162
1271
1372
1481
1582
1691
1792
18101
19102
20111
21112
22121
23122
24131
25132
26141
27142
28151
29152
30161
31162

M67 CR13

CR13 contains I/O Control Unit Partitioning.
BitI/O Control UnitInterface
0171
1172
2181
3182
4191
5192
6201
7202
8211
9212
10221
11222
12231
13232
14241
15242
16251
17252
18261
19262
20271
21272
22281
23282
24291
25292
26301
27302
28311
29312
30321
31322

M67 CR14

CR14 contains indicators.
BitIndicator
0-27Unassigned
222167 Power On
23Unassigned
24Direct Control, CPU 1
25Direct Control, CPU 2
26-27Unassigned
28Prefix, CPU 1
29Prefix, CPU 2
30-31Unassigned

Control registers in IBM S/390

The control registers of ESA/390 on the IBM S/390 are an evolutionary enhancement to the control registers on the earlier ESA/370, S/370-XA and S/370 processors. For details on which fields are dependent on specific features, consult the Principles of Operation.
CRbitsField
01SSM-suppression
02TOD-clock-sync control
03Low-address-protection control
04Extraction-authority control
05Secondary-space control
06Fetch-protection-override control
07Storage-protection-override control
08-12Translation format
013AFP-register control
014Vector control
015Address-space-function control
016Malfunction-alert subclass mask
017Emergency-signal subclass mask
018External-call subclass mask
019TOD-clock sync-check subclass mask
020Clock-comparator subclass mask
021CPU-timer subclass mask
022Service-signal subclass mask
024Set to 1
025Interrupt-key subclass mask
026Set to 1
027ETR subclass mask
028Program-call-fast
029Crypto control
10Primary space-switch-event control
11-19Primary segment-table origin
122Primary subspace-group control
123Primary private-space control
124Primary storage-alteration-event control
125-31Primary segment-table length
21-25Dispatchable-unit-control-table origin
30-15PSW-key mask
316-31Secondary ASN
40-15Authorization index
416-31Primary ASN
50Subsystem-linkage control
51-24Linkage-table origin
525-31Linkage-table length
51-25When the address-space-function control is one,
Primary-ASN-second-table-entry
60-7I/O-interruption subclass mask
71-19Secondary segment-table origin
722Secondary subspace-group control
723Secondary private-space control
724Secondary storage-alteration-event control
725-31Secondary segment-table length
80-15Extended authorization index
816-31Monitor masks
90Successful-branching-event mask
91Instruction-fetching-event mask
92Storage-alteration-event mask
93GR-alteration-event mask
94Store-using-real-address-event mask
98Branch-address control
910Storage-alteration-space control
916-31PER general-register masks
101-31PER starting address
111-31PER ending address
120Branch-trace control
121-29Trace-entry address
1230ASN-trace control
1231Explicit-trace control
130Home space-switch-event control
131-19Home segment-table origin
1323Home private-space control
1324Home storage-alteration-event control
1325-31Home segment-table length
140Set to 1
141Set to 1
142Extended-save-area control
143Channel-report-pending subclass mask
144Recovery subclass mask
145Degradation subclass mask
146External-damage subclass mask
147Warning subclass mask
1410TOD-clock-control-override control
1412ASN-translation control
1413-31ASN-first-table origin
151-28Linkage-stack-entry address

Control registers in IBM z/Architecture

The control registers of z/Architecture are an evolutionary enhancement to the control registers of the earlier ESA/390 on the IBM S/390 processors. For details on which fields are dependent on specific features, consult the Principles of Operation.
Because z/Architecture expands the control registers from 32 bits to 64, the bit numbering differs from that in ESA/390.
CRbitsField
08Transactional-execution control
09Transactional-execution program-interruption filtering override
010Clock-comparator sign control
013Cryptography counter control
014Processor-activity-instrumentation-extension control
015Measurement-counter-extraction-authorization control
030Warning-track subclass mask
032TRACE TOD-clock control
033SSM-suppression
034TOD-clock-sync control
035Low-address-protection control
036Extraction-authority control
037Secondary-space control
038Fetch-protection-override control
039Storage-protection-override control
040Enhanced-DAT-enablement control
043Instruction-execution-protection-enablement control
044ASN-and-LX-reuse control
045AFP-register control
046Vector enablement control
048Malfunction-alert subclass mask
048Malfunction-alert subclass mask
049Emergency-signal subclass mask
050External-call subclass mask
052Clock-comparator subclass mask
053CPU-timer subclass mask
054Service-signal subclass mask
056Initialized to 1
057Interrupt-key subclass mask
058Measurement-alert subclass mask
059Timing-alert subclass mask
061Crypto control
10-51Primary Address-Space Control Element
Primary region-table origin
Primary segment-table origin
Primary real-space token origin
154Primary subspace-group control
155Primary private-space control
156Primary storage-alteration-event
157Primary space-switch-event control
158Primary real-space control
160-61Primary designation-type control
162-63Primary table length
233-57Dispatchable-unit-control-table origin
259Guarded-storage-facility enablement control
261Transaction diagnostic scope
262-63Transaction diagnostic control
30-31Secondary ASN-second-table-entry instance number
332-47PSW-key mask
348-63Secondary ASN
40-31Primary ASN-second-table-entry instance number
432-47Authorization index
448-63Primary ASN
533-57Primary-ASN-second-table-entry origin
632-39I/O-interruption subclass mask
70-51Secondary Address-Space Control Element
Secondary region-table origin
Secondary segment-table origin
Secondary real-space token origin
754Secondary subspace-group control
755Secondary private-space control
756Secondary storage-alteration-event control
758Secondary real-space control
760-61Secondary designation-type control
762-63Secondary table length
816-31Enhanced-monitor masks
832-47Extended authorization index
848-63Monitor masks
932Successful-branching-event mask
933Instruction-fetching-event mask
934Storage-alteration-event mask
935Storage-key-alteration-event mask
936Store-using-real-address-event mask
937Zero-address-detection-event mask
938Transaction-end event mask
939Instruction-fetching-nullification-event mask
940Branch-address control
941PER-event-suppression control
943Storage-alteration-space control
100-63PER starting address
110-63PER ending address
120Branch-trace control
121Mode-trace control
122-61Trace-entry address
1262ASN-trace control
1263Explicit-trace control
130-51Home Address-Space Control Element
Home region-table origin
Home segment-table origin
Home real-space token origin
1355Home private-space control
1356Home storage-alteration-eventl
1357Home space-switch-event control
1358Secondary real-space control
1360-61Home designation-type control
1362-63Home table length
1432Set to 1
1433Set to 1
1434Extended save-area control
1435Channel-report-pending subclass mask
1436Recovery subclass mask
1437Degradation subclass mask
1438External-damage subclass mask
1439Warning subclass mask
1442TOD-clock-control-override control
1444ASN-translation control
1445-63ASN-first-table origin
150-60Linkage-stack-entry address

Control registers in Intel [x86] series

CR0

The CR0 register is 32 bits long on the 386 and higher processors. On x64 processors in long mode, it is 64 bits long. CR0 has various control flags that modify the basic operation of the processor. Register CR0 is the 32 Bit version of the old Machine Status Word register. The MSW register was expanded to the Control Register with the appearance of the i386 processor.
BitNameFull NameDescription
0PEProtected Mode EnableIf 1, system is in protected mode, else, system is in real mode
1MPMonitor co-processorControls interaction of WAIT/FWAIT instructions with TS flag in CR0
2EMEmulationIf set, no x87 floating-point unit present, if clear, x87 FPU present
3TSTask switchedAllows saving x87 task context upon a task switch only after x87 instruction used
4ETExtension typeOn the 386, it allowed to specify whether the external math coprocessor was an 80287 or 80387
5NENumeric errorOn the 486 and later, enable internal x87 floating point error reporting when set, else enable PC-style error reporting from the internal floating-point unit using external logic
16WPWrite protectWhen set, the CPU cannot write to read-only pages when privilege level is 0
18AMAlignment maskAlignment check enabled if AM set, AC flag set, and privilege level is 3
29NWNot-write throughGlobally enables/disable write-through caching
30CDCache disableGlobally enables/disable the memory cache
31PGPagingIf 1, enable paging and use the register, else disable paging.

CR1

Reserved, the CPU will throw a #UD exception when trying to access it.

CR2

Contains a value called Page Fault Linear Address. When a page fault occurs, the address the program attempted to access is stored in the CR2 register.

CR3

Image:X86 Paging 4K.svg|thumb|Typical use of CR3 in address translation with 4 KiB pages
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, which stores the physical address of the first page directory. If the PCIDE bit in CR4 is set, the lowest 12 bits are used for the process-context identifier.

CR4

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
0VMEVirtual 8086 Mode ExtensionsIf set, enables support for the virtual interrupt flag in virtual-8086 mode.
1PVIProtected-mode Virtual InterruptsIf set, enables support for the virtual interrupt flag in protected mode.
2TSDTime Stamp DisableIf set, RDTSC instruction can only be executed when in ring 0, otherwise RDTSC can be used at any privilege level.
3DEDebugging ExtensionsIf set, enables debug register based breaks on I/O space access.
4PSEPage Size ExtensionIf set, enables 32-bit paging mode to use 4 MiB huge pages in addition to 4 KiB pages.
If PAE is enabled or the processor is in x86-64 long mode this bit is ignored.
5PAEPhysical Address ExtensionIf set, changes page table layout to translate 32-bit virtual addresses into extended 36-bit physical addresses.
6MCEMachine Check ExceptionIf set, enables machine check interrupts to occur.
7PGEPage Global EnabledIf set, address translations may be shared between address spaces.
8PCEPerformance-Monitoring Counter enableIf set, RDPMC can be executed at any privilege level, else RDPMC can only be used in ring 0.
9OSFXSROperating system support for FXSAVE and FXRSTOR instructionsIf set, enables Streaming SIMD Extensions instructions and fast FPU save & restore.
10OSXMMEXCPTOperating System Support for Unmasked SIMD Floating-Point ExceptionsIf set, enables unmasked SSE exceptions.
11UMIPUser-Mode Instruction PreventionIf set, the SGDT, SIDT, SLDT, SMSW and STR instructions cannot be executed if CPL > 0.
12LA5757-Bit Linear AddressesIf set, enables 5-Level Paging.
13VMXEVirtual Machine Extensions Enablesee Intel VT-x x86 virtualization.
14SMXESafer Mode Extensions Enablesee Trusted Execution Technology
15
16FSGSBASEFSGSBASE EnableIf set, enables the instructions RDFSBASE, RDGSBASE, WRFSBASE, and WRGSBASE.
17PCIDEPCID EnableIf set, enables process-context identifiers.
18OSXSAVEXSAVE and Processor Extended States Enable
19KLKey Locker EnableIf set, enables the AES Key Locker instructions.
20Supervisor Mode Execution Protection EnableIf set, execution of code in a higher ring generates a fault.
21SMAPSupervisor Mode Access Prevention EnableIf set, access of data in a higher ring generates a fault.
22PKEProtection Key EnableSee Intel 64 and IA-32 Architectures Software Developer's Manual.
23CETControl-flow Enforcement TechnologyIf set, enables control-flow enforcement technology.
24PKSEnable Protection Keys for Supervisor-Mode PagesIf set, each supervisor-mode linear address is associated with a protection key when 4-level or 5-level paging is in use.
25UINTRUser Interrupts EnableIf set, enables user-mode inter-processor interrupts and their associated instructions and data structures.
63-26

CR5–7

Reserved, same case as CR1.

Additional Control registers in Intel [x86-64] series

EFER

Extended Feature Enable Register is a model-specific register added in the AMD K6 processor, to allow enabling the SYSCALL/SYSRET instruction, and later for entering and exiting long mode. This register becomes architectural in AMD64 and has been adopted by Intel as IA32_EFER. Its MSR number is 0xC0000080.
BitPurpose
0SCE
1DPE
2SEWBED
3GEWBED
4L2D
5-7Reserved, Read as Zero
8LME
9Reserved
10LMA
11NXE
12SVME
13LMSLE
14FFXSR
15TCE
16Reserved
17MCOMMIT
18INTWB
19Reserved
20UAIE
21AIBRSE
22–63Reserved

CR8

CR8 is a new register accessible in 64-bit mode using the REX prefix. CR8 is used to prioritize external interrupts and is referred to as the task-priority register.
The AMD64 architecture allows software to define up to 15 external interrupt-priority classes. Priority classes are numbered from 1 to 15, with priority-class 1 being the lowest and priority-class 15 the highest. CR8 uses the four low-order bits for specifying a task priority and the remaining 60 bits are reserved and must be written with zeros.
System software can use the TPR register to temporarily block low-priority interrupts from interrupting a high-priority task. This is accomplished by loading TPR with a value corresponding to the highest-priority interrupt that is to be blocked. For example, loading TPR with a value of 9 blocks all interrupts with a priority class of 9 or less, while allowing all interrupts with a priority class of 10 or more to be recognized. Loading TPR with 0 enables all external interrupts. Loading TPR with 15 disables all external interrupts.
The TPR is cleared to 0 on reset.

XCR0 and XSS

XCR0, or Extended Control Register 0, is a control register which is used to toggle the storing or loading of registers related to specific CPU features using the XSAVE/XRSTOR instructions. It is also used with some features to enable or disable the processor's ability to execute their corresponding instructions. It can be changed using the privileged XSETBV read using the unprivileged XGETBV instructions.
There is also the IA32_XSS MSR, which is located at address DA0h. The IA32_XSS MSR controls bits of XCR0 which are considered to be "supervisor" state, and should be invisible to regular programs. It operates with the privileged XSAVES and XRSTORS instructions by adding supervisor state to the data they operate with. Put simply, if the X87 state was enabled in XCR0 and PT state was enabled in IA32_XSS, the XSAVE instruction would only store X87 state, while the privileged XSAVES would store both X87 and PT states. Because it is an MSR, it can be accessed using the RDMSR and WRMSR instructions.
BitPurpose
0–7Reserved; must be 0.
8PT
10Processor Address Space ID state
11Control-flow Enforcement Technology User State
12Control-flow Enforcement Technology Supervisor State
13HDC
14User interrupts state
15Last branch recording state
16HWP
17–63Reserved; must be 0.