Microcode

From ArchWiki
Revision as of 20:28, 10 November 2014 by Graysky (talk | contribs) (Grub: wording)
Jump to navigation Jump to search

zh-CN:Microcode Processor microcode is akin to processor firmware. The kernel is able to update the processor's firmware without the need to update it via a BIOS update.

The microcode data file contains the latest microcode definitions for all Intel processors. Intel releases microcode updates to correct processor behavior as documented in the respective processor specification updates. While the regular approach to getting this microcode update is via a BIOS upgrade, Intel realizes that this can be an administrative hassle. The Linux operating system and VMware ESX products have a mechanism to update the microcode after booting. For example, this file will be used by the operating system mechanism if the file is placed in the /etc/firmware directory of the Linux system. ~Intel

Updating microcode

For Intel processors, install intel-ucode.

For AMD processors the microcode updates are available in linux-firmware, which is installed as part of the base system.

Enabling Intel Microcode Updates

Warning: With linux 3.17-2 and linux-lts 3.14.21-2 and newer versions, Intel microcode updates are not triggered automatically any more. Many AUR kernels have followed the path of the official ARCH kernels in this regard: with linux-ck 3.16.6-3, Intel microcode updates are not triggered automatically any more.

These updates must be enabled by adding /boot/intel-ucode.img as the first initrd in the bootloader config file. This is in addition to the normal initrd file.

Specific Examples

EFI boot stub / EFI handover

Append two initrd= options:

initrd=/intel-ucode.img initrd=/initramfs-linux.img

Gummiboot

Use the initrd option twice in /boot/loader/entries/*.conf:

title   Arch Linux
linux   /vmlinuz-linux
initrd  /intel-ucode.img
initrd  /initramfs-linux.img
options ...

rEFInd

Edit boot options in /boot/refind_linux.conf as per EFI boot stub above, example:

"Boot with standard options" "ro root=UUID=(...) quiet initrd=/intel-ucode.img initrd=/initramfs-linux.img"

Users employing manual stanzas in /boot/refind.conf to define the kernels should simply add initrd=/intel-ucode.img or /boot/intel-ucode.img as required to the options line, and not in the main part of the stanza.

Grub

With the release of grub-1:2.02-beta2-5, /usr/bin/grub-mkconfig will automatically handle the microcode update. Users are directly to regenerate the grub config to activate loading the microcode update by running # grub-mkconfig -o /boot/grub/grub.cfg after installing intel-ucode.

Syslinux

Multiple initrd's can be separated by commas in /boot/syslinux/syslinux.cfg:

LABEL arch
    MENU LABEL Arch Linux
    LINUX ../vmlinuz-linux
    INITRD ../intel-ucode.img,../initramfs-linux.img
    APPEND ...

Verifying that microcode got updated on boot

Use /usr/bin/dmesg to see if the microcode has been updated: dmesg | grep microcode

On Intel systems one should see something similar to the following, indicating that microcode is updated early:

[    0.000000] CPU0 microcode updated early to revision 0x1b, date = 2014-05-29
[    0.221951] CPU1 microcode updated early to revision 0x1b, date = 2014-05-29
[    0.242064] CPU2 microcode updated early to revision 0x1b, date = 2014-05-29
[    0.262349] CPU3 microcode updated early to revision 0x1b, date = 2014-05-29
[    0.507267] microcode: CPU0 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507272] microcode: CPU1 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507276] microcode: CPU2 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507281] microcode: CPU3 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507286] microcode: CPU4 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507292] microcode: CPU5 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507296] microcode: CPU6 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507300] microcode: CPU7 sig=0x306a9, pf=0x2, revision=0x1b
[    0.507335] microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba

It is entirely possible, particularly with newer hardware, that there is no microcode update for the CPU. In that case, the output may look like this:

[    0.292893] microcode: CPU0 sig=0x306c3, pf=0x2, revision=0x1c
[    0.292899] microcode: CPU1 sig=0x306c3, pf=0x2, revision=0x1c
[    0.292906] microcode: CPU2 sig=0x306c3, pf=0x2, revision=0x1c
[    0.292912] microcode: CPU3 sig=0x306c3, pf=0x2, revision=0x1c
[    0.292956] microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba

On AMD systems microcode is updated a bit later in the boot process, so the output would look something like this:

[    0.807879] microcode: CPU0: patch_level=0x01000098
[    0.807888] microcode: CPU1: patch_level=0x01000098
[    0.807983] microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
[   16.150642] microcode: CPU0: new patch_level=0x010000c7
[   16.150682] microcode: CPU1: new patch_level=0x010000c7
Note: The date outputted does not correspond to the version of the intel-ucode package installed. It does show the last time Intel updated the microcode that corresponds to the specific hardware being updated.

Which CPUs accept microcode updates

Users may consult either Intel or AMD at the following links to see if a particular model is supported:

Detecting available microcode update

It is possible to find out if the intel-ucode.img contains a microcode image for the running cpu with iucode-toolAUR.

  • Install intel-ucode (changing initrd is not required for detection)
  • Install iucode-toolAUR from the AUR
  • # modprobe cpuid
  • # bsdtar -Oxf /boot/intel-ucode.img | iucode_tool -tb -lS -
    (Extract microcode image and search it for your cpuid)
  • If an update is available, it should show up below selected microcodes

Enabling Intel Early Microcode Loading in Custom Kernels

In order for early loading to work in custom kernels, "CPU microcode loading support" needs to be compiled into the kernel NOT compiled as a module. This will enable the "Early load microcode" prompt which should be set to "Y".

CONFIG_MICROCODE=y
CONFIG_MICROCODE_INTEL=y
CONFIG_MICROCODE_INTEL_EARLY=y
CONFIG_MICROCODE_EARLY=y