4 ms·
How does a microcode update work? My sparse understanding is that instructions are physically encoded in the chips. That you could take a microscope and look at
by Waterluvian 9y ago
How does a microcode update work? My sparse understanding is that instructions are physically encoded in the chips. That you could take a microscope and look at the different instructions.
- TomV1971 9y agoThat was a very long time ago. Microcode can be loaded by the BIOS.
- Operyl 9y agoCan also be loaded at boot time by the kernel, etc.
- cjbprime 9y agoOr even after boot time, I think -- you shut down one CPU at a time to load it.
- xxs 9y agoMost of the microcode nowadays is loaded by the OS (not BIOS)
- chopin 9y agoToday I learned something. Doesn't that open a huge attack surface? This code would run super-privileged isn't it?
- 0x0 9y agoCPUs will only accept uploads of microcode if they can verify the digital signature, of which the private keys are only known to the CPU manufacturer (i.e. Intel or AMD). Probably it will also only allow upgrades, not downgrades, on a running system. So the only "attack" you can perform if you've gained root is to patch CPU security vulnerabilities by upgrading to a newer valid microcode, and then also only until the next reboot.
- paulddraper 9y agoYes, except that processors are now incredibly complex beasts that have all sorts of optimizations and other features (hence....a lurking, unobvious bug). So there is this layer of software that operates with this x86 interface on a hardware implementation of different instructions.
- prewett 9y agoBack when people were mostly programming in assembly it was convenient for one instruction to do a lot of stuff, but it hardwiring a large instruction set poses design difficulties. So CISC chips have some special microcode memory that runs a program that converts the larger instruction set into the actual hardware instruction set. Intel's CPUs since the Pentium Pro allow writing to the microcode memory (with severe restrictions). According to Wikipedia [1], CPUs have had microcode since the 1960s! However, this is mostly an artifact of CISC architectures. Since most programmers these mass-produce their instructions with a compiler rather than with artisinal, hand-crafted assembly code, CISC fell out of favor compared to RISC. Since the RISC instruction sets are simple (by design), there isn't much need for microcode. ARM chips typically don't have microcode (although they do break things into smaller instructions) [2]. But since Intel has to keep compatibility with 40 years of CISC instructions, they need microcode. [1] https://en.wikipedia.org/wiki/Microcode https://en.wikipedia.org/wiki/Microcode [2] https://superuser.com/questions/934752/do-arm-processors-like-cortex-a9-use-microcode https://superuser.com/questions/934752/do-arm-processors-lik...
- SAI_Peregrinus 9y agoMicrocode is essentially a program that runs on the CPU below the level of the normal instruction set (machine code). It's firmware, and stored in some memory on the die (or in the EFI/BIOS, or loaded at or after boot time, depending on the system.) It allows for mapping a large set of complex instructions to short programs of fundamental microinstructions. A CPU without a hardware multiplier might still have an assembly (and machine code) multiply instruction, and simply implement a shift-and-add multiplication algorithm in the microcode. I suggest Tanenbaum and Austin's "Structured Computer Organization" for a pretty good book about this (and other aspects of CPU design).
- JdeBP 9y agoSee also discussion and hyperlinks at https://news.ycombinator.com/item?id=16086519 https://news.ycombinator.com/item?id=16086519 .