Intel microcode is microcode that runs inside x86 processors made by Intel. Since the P6 microarchitecture introduced in the mid-1990s, the microcode programs can be patched by the operating system or BIOS firmware to work around bugs found in the CPU after release.[1] Intel had originally designed microcode updates for processor debugging under its design for testing (DFT) initiative.[2]

Following the Pentium FDIV bug, the patchable microcode function took on a wider purpose to allow in-field updating without needing to do a product recall.[1]

In the P6 and later microarchitectures, x86 instructions are internally converted into simpler RISC-style micro-operations that are specific to a particular processor and stepping level.[1]

Pre-P6 microcode

On the Intel 80486 and AMD Am486 there are approximately 5000 lines of microcode assembly, totalling approximately 240 Kbits stored in the microcode ROM.[3]

P6 and later micro-operations

Starting with the Pentium Pro, in most Intel x86 processors, instructions are converted by the instruction fetch and decode unit to sequences of processor-specific micro-operations that are directly executed by the processor. For the instructions that are implemented in microcode, the microcode consists of micro-operations fetched from on-chip memory.[4]

On the Pentium Pro, each micro-operation is 72-bits wide,[5]:43 or 118-bits wide.[6]:2[7]:14 This includes an opcode, two source fields, and one destination field,[8]:7 with the ability to hold a 32-bit immediate value.[6][7]:14 The Pentium Pro is able to detect parity errors in its internal microcode ROM and report these via the Machine Check Architecture.[9]

Micro-operations have a consistent format with up to three source inputs, and two destination outputs.[10] The processor performs register renaming to map these inputs to and from the real register file (RRF) before and after their execution.[10] Out-of-order execution is used, so the micro-operations and instructions they represent may not appear in the same order.

During development of the Pentium Pro, several microcode fixes were included between the A2 and B0 steppings.[11] For the Pentium II (based on the P6 Pentium Pro), additional micro-operations were added to support the MMX instruction set.[12] In several cases, "microcode assists" were added to handle rare corner-cases in a reliable way.[12]

The Pentium 4 can have 126 micro-operations in flight at the same time.[13]:10 Micro-operations are decoded and stored in an Execution Trace Cache with 12,000 entries, to avoid repeated decoding of the same x86 instructions.[13]:5 Groups of six micro-operations are packed into a trace line.[13]:5 Micro-operations can borrow extra immediate data space within the same cache-line.[14]:49 Complex instructions, such as exception handling, result in jumping to the microcode ROM.[13]:6 During development of the Pentium 4, microcode accounted for 14% of processor bugs versus 30% of processor bugs during development of the Pentium Pro.[15]:35

The Intel Core microarchitecture introduced in 2006 added "macro-operations fusion" for some common pairs of instructions including comparison followed by a jump.[16] The instruction decoders in the Core convert x86 instructions into microcode in three different ways:

More information x86 instructions, x86 decoders ...
Conversion of x86 instructions to micro-operations on Core[16]
x86 instructionsx86 decodersmicro-operations
commonsimple decoder × 31–3
most otherscomplex decoder × 1≤4
very complexmicrocode sequencermany
Close

For Intel's hyper-threading implementation of simultaneous multithreading, the microcode ROM, trace cache, and instruction decoders are shared, but the micro-operation queue is not shared.[17]

Update facility

In the mid-1990s, a facility for supplying new microcode was initially referred to as the Pentium Pro BIOS Update Feature.[18][19] It was intended that user-mode applications should make a BIOS interrupt call to supply a new "BIOS Update Data Block", which the BIOS would partially validate and save to nonvolatile BIOS memory; this could be supplied to the installed processors on next boot.[18]

Intel distributed a program called BUP_UTIL.EXE, renamed CHECKUP3.EXE that could be run under DOS. Collections of multiple microcode updates were concatenated together and numerically numbered with the extension .PDB, such as PEP6.PDB.[20]:79

Processor interface

The processor boots up using a set of microcode held inside the processor and stored in an internal ROM.[1] A microcode update populates a separate SRAM and set of "match registers" that act as breakpoints within the microcode ROM, to allow jumping to the updated list of micro-operations in the SRAM.[1] A match is performed between the Microcode Instruction Pointer (UIP) all of the match registers, with any match resulting in a jump to the corresponding destination microcode address.[2]:3 In the original P6 architecture there is space in the SRAM for 60 micro-operations, and multiple match/destination register pairs.[1][2]:3 It takes one processor instruction cycle to jump from ROM microcode to patched microcode held in SRAM.[1] Match registers consist of a microcode match address, and a microcode destination address.[21]

The processor must be in protection ring zero ("Ring 0") in order to initiate a microcode update.[21]:1 Each CPU in a symmetric multiprocessing arrangement needs to be updated individually.[21]:1

An update is initiated by placing its address in eax register, setting ecx = 0x79, and executing a wrmsr (Write model-specific register).[22]:435

Microcode update format

Intel distributes microcode updates as a 2,048 (2 kilobyte) binary blob.[1] The update contains information about which processors it is designed for, so that this can be checked against the result of the CPUID instruction.[1] The structure is a 48-byte header, followed by 2,000 bytes intended to be read directly by the processor to be updated:[1]

  1. A microcode program that is executed by the processor during the microcode update process.[1] This microcode is able to reconfigure and enable or disable components using a special register, and it must update the breakpoint match registers.[1]
  2. Up to sixty patched micro-operations to be populated into the SRAM.[1]
  3. Padding consisting of random values, to obfuscate understanding of the format of the microcode update.[1]

Each block is encoded differently, and the majority of the 2,000 bytes are not used as configuration program and SRAM micro-operation contents themselves are much smaller.[1] Final determination and validation of whether an update can be applied to a processor is performed during decryption via the processor.[18] Each microcode update is specific to a particular CPU revision, and is designed to be rejected by CPUs with a different stepping level. Microcode updates are encrypted to prevent tampering and to enable validation.[23]

With the Pentium there are two layers of encryption and the precise details explicitly not documented by Intel, instead being only known to fewer than ten employees.[24]

Microcode updates for Intel Atom, Nehalem and Sandy Bridge additionally contain an extra 520-byte header containing a 2048-bit RSA modulus with an exponent of 17 decimal.[21]:7,8

More information Micro architecture, Example processors ...
Observed Intel microcode data-block lengths (in bytes)[21]:16
Micro architectureExample processorsSupplied lengthFunctional lengthSuspected encoding
P6Pentium Pro2000864; 872; 944; 196864-bit block cipher
CorePIII … Core 240483096
NetburstP4, Pentium D, Celeron2000–71202000 + N*1024chained block cipher
Atom, Nehalem, Sandy BridgeCore i3/i5/i7976–16336976 + N*1024; 5120AES + RSA signature
Close

Debugging

Special debugging-specific microcode can be loaded to enable Extended Execution Trace, which then outputs extra information via the Breakpoint Monitor Pins.[25] On the Pentium 4, loading special microcode can give access to Microcode Extended Execution Trace mode.[25] When using the JTAG Test Access Port (TAP), a pair of Breakpoint Control registers allow breaking on microcode addresses.[25]

During the mid-1980s NEC and Intel had a long-running US federal court case about microcode copyright.[26] NEC had been acting as a second source for Intel 8086 CPUs with its NEC μPD8086, and held long-term patent and copyright cross-licensing agreements with Intel. In August 1982 Intel sued NEC for copyright infringement over the microcode implementation.[27][28] NEC prevailed by demonstrating via cleanroom software engineering that the similarities in the implementation of microcode on its V20 and V30 processors was the result of the restrictions demanded by the architecture, rather than via copying.[26]

The Intel 386 can perform a built-in self-test of the microcode and programmable logic arrays, with the value of the self-test placed in the EAX register.[29] During the BIST, the microprogram counter is re-used to walk through all of the ROMs, with the results being collated via a network of multiple-input signature registers (MISRs) and linear-feedback shift registers.[30] On start up of the Intel 486, a hardware-controlled BIST runs for 220 clock cycles to check various arrays including the microcode ROM, after which control is transferred to the microcode for further self-testing of registers and computation units.[31] The Intel 486 microcode ROM has 250,000 transistors.[31]

AMD had a long-term contract to reuse Intel's 286, 386 and 486 microcode.[32] In October 2004, a court ruled that the agreement did not cover AMD distributing Intel's 486 in-circuit emulation (ICE) microcode.[32]

Direct Access Testing

Direct Access Testing (DAT) is included in Intel CPUs as part of the design for testing (DFT) and Design for Debug (DFD) initiatives allow full coverage testing of individual CPUs prior to sale.[33]

In May 2020, a script reading directly from the Control Register Bus (CRBUS)[34] (after exploiting "Red Unlock" in JTAG USB-A to USB-A 3.0 with Debugging Capabilities, without D+, D− and Vcc[35]) was used to read from the Local Direct Access Test (LDAT) port of the Intel Goldmont CPU and the loaded microcode and patch arrays were read.[36] These arrays are only accessible after the CPU has been put into a specific mode, and consist of five arrays accessed through offset 0x6a0:[37]

  1. ROM: Microcode triads
  2. ROM: Sequence Words
  3. RAM: Sequence Words (updatable)
  4. RAM: Match/Patch pairs (updatable)
  5. RAM: Microcode triads (updatable)

References

Further reading

Wikiwand in your browser!

Seamless Wikipedia browsing. On steroids.

Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.

Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.