What is really CPU micro codes?

drjackool

Distinguished
Dec 5, 2013
284
1
18,795
Hi
Mother-board vendors release some BIOS update that in it's description writes "Update CPU MicroCode". What is CPU microcode? unless CPU instructions are hardwired or CPU has internal Firmware? if has internal F/W the INTEL should release updates for it!!!
 
Solution
The instructions run in the CPU are micro-ops, because no CPU today works directly on the CISC x86 instruction set. Each x86 instruction is broken down (decoded) into simpler tasks, and in fact this used to be called RISC translation.

The microcode tells the CPU how to process these small RISC-like steps, hence its name. Generally, the hardware defaults to the fastest way but if an error is found in that path, the microcode tells the CPU to use a slower/longer workaround method instead. The microcode is like a table in RAM the CPU checks before doing anything to look up how, kind of like how a File Allocation Table in RAM is first checked by the disk controller to look up where.

The microcode table is loaded into RAM on...
cpu microcode is firmware released by intel/amd/or any other cpu maker, has nothing to do with cpu instructions set, u can call it a software which knows what your cpu is going to do (cpu support/ hardware bug fixes)
cpu doesnt have firmware built in, its stored in bios
if u have linux u can load it directly without waiting for bios makers
 
There are, indeed hardwired instructions in the CPU. Over time, even before the processor is released for sale, errors ("errata") are found and corrected by microcodes. Think of them as an interpretation layer in RAM that prevents the errors from occurring by intervening in any situation where one might occur, kind of like how scandisk marks sectors bad so they will never be used.

The CPU manufacturer is, in fact the only party to release microcodes. They send them to motherboard manufacturers and OS developers. If flashed into the BIOS they will load when the computer POSTs and will work even if you run an old unpatched OS, like DOS.

Linux embeds the latest microcodes right into the kernel so if you are running the latest kernel then it doesn't matter if you have updated your BIOS or not. Microsoft is a bit more reluctant to insert them but has released microcode in WindowsUpdates as well.

Note that not all errors can be fixed in microcode. Intel had to recall thousands of CPUs for the Pentium FDIV bug. Note also that the built-in Hardwired-Control-Unit logic circuitry is faster than microcode which runs in software, so is a large reason why patches that greatly change the operation of the processor (such as for Meltdown/Spectre) impact performance so much.
 

drjackool

Distinguished
Dec 5, 2013
284
1
18,795
i am confused, CPU runs instruction and programmers writes instructions (NOT microcodes).
You say some instruction are implemented as microcodes? OK
But if microcodes can be rewritable CPU must have a re-writable internal memory or microcodes are saved in part of RAM and BIOS writes them when system boots like interrupt table?
 
The instructions run in the CPU are micro-ops, because no CPU today works directly on the CISC x86 instruction set. Each x86 instruction is broken down (decoded) into simpler tasks, and in fact this used to be called RISC translation.

The microcode tells the CPU how to process these small RISC-like steps, hence its name. Generally, the hardware defaults to the fastest way but if an error is found in that path, the microcode tells the CPU to use a slower/longer workaround method instead. The microcode is like a table in RAM the CPU checks before doing anything to look up how, kind of like how a File Allocation Table in RAM is first checked by the disk controller to look up where.

The microcode table is loaded into RAM on POST and when the OS loads, if it has a table too it simply overwrites the first one in RAM. The old one stays in the BIOS so both load again on next bootup.

No programmer can see these micro-ops, but Intel's compiler is designed to optimize code to make best use of them. The compiler obviously has to be designed for specific chips, and some designs such as P4 had terrible performance if code wasn't optimized just for them--note Prescott had a hardware integer multiplier unit which Northwood lacked (it used the floating point unit instead!) so compilers have to be that specific.
 
Solution

larrycumming

Prominent
Aug 15, 2018
422
0
410


BIOS also writes other data to RAM during POST boot, such as ACPI tables. These data allows the OS to interact with BIOS and firmware level instructions thru an event-based mechanism. So you can do stuff like overclocking your CPU from an application under Windows or read the temperature of your components.

I don't think the exact mechanism is published, but yes you can logically conclude that microcodes are stored on a RAM on the CPU itself (not to be confused with system RAM). If it were stored on system RAM, it would become a huge bottleneck.