1 The Linux Microcode Loader
3 Authors: Fenghua Yu <fenghua.yu@intel.com>
4 Borislav Petkov <bp@suse.de>
6 The kernel has a x86 microcode loading facility which is supposed to
7 provide microcode loading methods in the OS. Potential use cases are
8 updating the microcode on platforms beyond the OEM End-Of-Life support,
9 and updating the microcode on long-running systems without rebooting.
11 The loader supports three loading methods:
13 1. Early load microcode
14 =======================
16 The kernel can update microcode very early during boot. Loading
17 microcode early can fix CPU issues before they are observed during
20 The microcode is stored in an initrd file. During boot, it is read from
21 it and loaded into the CPU cores.
23 The format of the combined initrd image is microcode in (uncompressed)
24 cpio format followed by the (possibly compressed) initrd image. The
25 loader parses the combined initrd image during boot.
27 The microcode files in cpio name space are:
29 on Intel: /*(DEBLOBBED)*/
30 on AMD : /*(DEBLOBBED)*/
32 During BSP (BootStrapping Processor) boot (pre-SMP), the kernel
33 scans the microcode file in the initrd. If microcode matching the
34 CPU is found, it will be applied in the BSP and later on in all APs
35 (Application Processors).
37 The loader also saves the matching microcode for the CPU in memory.
38 Thus, the cached microcode patch is applied when CPUs resume from a
41 Here's a crude example how to prepare an initrd with microcode (this is
42 normally done automatically by the distribution, when recreating the
43 initrd, so you don't really have to do it yourself. It is documented
44 here for future reference only).
50 echo "You need to supply an initrd file"
56 DSTDIR=kernel/x86/microcode
65 if [ -d /lib/firmware/amd-ucode ]; then
69 if [ -d /lib/firmware/intel-ucode ]; then
73 find . | cpio -o -H newc >../ucode.cpio
75 mv $INITRD $INITRD.orig
76 cat ucode.cpio $INITRD.orig > $INITRD
81 The system needs to have the microcode packages installed into
82 /lib/firmware or you need to fixup the paths above if yours are
83 somewhere else and/or you've downloaded them directly from the processor
89 There are two legacy user space interfaces to load microcode, either through
90 /dev/cpu/microcode or through /sys/devices/system/cpu/microcode/reload file
93 The /dev/cpu/microcode method is deprecated because it needs a special
94 userspace tool for that.
96 The easier method is simply installing the microcode packages your distro
99 # echo 1 > /sys/devices/system/cpu/microcode/reload
103 The loading mechanism looks for microcode blobs in
104 /*(DEBLOBBED)*/. The default distro installation
105 packages already put them there.
110 The loader supports also loading of a builtin microcode supplied through
111 the regular firmware builtin method CONFIG_FIRMWARE_IN_KERNEL. Only
112 64-bit is currently supported.
116 CONFIG_FIRMWARE_IN_KERNEL=y
117 CONFIG_EXTRA_FIRMWARE="/*(DEBLOBBED)*/ /*(DEBLOBBED)*/"
118 CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
120 This basically means, you have the following tree structure locally:
124 so that the build system can find those files and integrate them into
125 the final kernel image. The early loader finds them and applies them.
127 Needless to say, this method is not the most flexible one because it
128 requires rebuilding the kernel each time updated microcode from the CPU