AMD microcode
This article describes updating the microcode for AMD processors.
For AMD GPU firmware see the corresponding GPU driver article instead.
Installation
Emerge
Microcode updates for AMD processors are provided by sys-kernel/linux-firmware package. Install the package via:
root #
emerge --ask sys-kernel/linux-firmware
Configuration (initramfs)
There are 2 different approaches to update the AMD CPU microcode:
- microcode is build into the linux kernel
- microcode is contained in the initramfs
Initramfs
The microcode is in the initrd. This way the microcode is not build-in to the the kernel.
Firmware files preparation
linux-firmware method
Enable the initramfs USE flag for sys-kernel/linux-firmware to get /boot/amd-uc.img and re-generate the initramfs.
Manual initramfs
Create the specified directory and cd into it. It might be a different dir than /tmp. The kernel/x86/microcode part is important.
user $
mkdir -p /tmp/amd-ucode/kernel/x86/microcode
user $
cd /tmp/amd-ucode
Concatenate the AMD firmware files into a single file. The path and filename of the output file must not be altered.
user $
cat /lib/firmware/amd-ucode/microcode_amd*.bin > kernel/x86/microcode/AuthenticAMD.bin
Create a cpio archive in /boot/amd-uc.img using bsdcpio from app-arch/libarchive:
root #
echo kernel/x86/microcode/AuthenticAMD.bin | bsdcpio -o -H newc -R 0:0 > /boot/amd-uc.img
GRUB2 configuration
The image file /boot/amd-uc.img is in a file path recognized by GRUB2 by default.
Regenerate the grub config using following command:
root #
grub-mkconfig -o /boot/grub/grub.cfg
Found linux image: /boot/vmlinuz-4.18.12 Found initrd image: /boot/amd-uc.img /boot/initramfs-4.18.12.img
The command output should show it found the /boot/amd-uc.img file.
Kernel (Initrd)
Verify the kernel option is enabled:
General setup ---> [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
Configuration (built into kernel)
Built-in firmware
This way the firmware files will be built directly into the kernel.
Kernel (built-in)
In order to load the CPU microcode the following kernel options should be enabled:
Processor type and features ---> [*] CPU microcode loading support [ ] Intel microcode loading support [*] AMD microcode loading support
Modules do not work for early microcode, so make sure microcode loading is built-in.
Firmware blob files selection
Either include all the available AMD firmware files in the kernel or select just the specific one for the system's CPU.
All firmware files
Another option is to simply build all the firmware blobs into the kernel. This can be achieved by the following kernel optionsː
Device Drivers ---> Generic Driver Options Firmware loader ---> {*} Firmware loading facility (amd-ucode/microcode_amd.bin amd-ucode/microcode_amd_fam15h.bin amd-ucode/microcode_amd_fam16h.bin amd-ucode/microcode_amd_fam17h.bin amd/amd_sev_fam17h_model0xh.sbin) External firmware blobs to build into the kernel binary (/lib/firmware) Firmware blobs root directory
The CONFIG_FW_LOADER Firmware loading facility must be set as built into the kernel, not as a kernel module.
The CONFIG_EXTRA_FIRMWARE option allows specifying multiple firmware files by listing them space-separated.
The CONFIG_EXTRA_FIRMWARE_DIR is set to
/lib/firmware
, this is the default directory.Specific firmware only
This section will only include the firmware suitable to the current system's CPU family. The CPU family identification can be obtained from /proc/cpuinfo:
user $
grep -F -m 1 "cpu family" /proc/cpuinfo
cpu family : 22
In this example the CPU belongs to the AMD CPU family 22.
The CPU family identificator listed in /proc/cpuinfo uses the decimal numeral system.
Note that after the K8 AMD has started to refer to the various microarchitectures as "AMD Family xxh", where "xxh" is the hexadecimal CPU family value from the CPUID. For example, AMD Family 10h really is the official AMD name for the K10 microarchitecture. Following this convention AMD is even using AMD Family 0Fh for the previous K8 microarchitecture (CPUID
0F
hexadecimal or 15 decimal).The following table helps to identify the right firmware blob file for given CPU family identificator:
Firmware blob file | Decimal | Hexadecimal | Family name | Year | Examples |
---|---|---|---|---|---|
amd-ucode/microcode_amd.bin | 16 | 10h
|
K10 | 2007 | Phenom, Phenom II, Athlon II |
17 | 11h
|
Turion | 2008 | Athlon X2, Sempron X2, Turion X2 | |
18 | 12h
|
Llano, Fusion | 2009 | A- and E2-Series APU with Radeon HD graphics, Athlon II, Sempron X2 | |
20 | 14h
|
Bobcat | 2011 | C- and E-Series APU with Radeon HD graphics | |
amd-ucode/microcode_amd_fam15h.bin | 21 | 15h
|
Bulldozer, Piledriver, Steamroller, Excavator | 2011 | FX series, A-Series APU with Radeon HD graphics, Opteron 6200/6300 |
amd-ucode/microcode_amd_fam16h.bin | 22 | 16h
|
Jaguar, Puma | 2013 | A-series and E-Series APU with Radeon HD graphics |
amd-ucode/microcode_amd_fam17h.bin | 23 | 17h
|
Zen, Zen+, Zen 2 | 2017 | Ryzen 1000-4000 series, Threadripper, EPYC 7xx1/7xx2 |
amd/amd_sev_fam17h_model0xh.sbin | EPYC 7xx1[1] (Zen 1) | 2017 | SEV (Secure Encrypted Virtualization) firmware update for models in the range 00h to 0fh [2]
| ||
amd/amd_sev_fam17h_model3xh.sbin | EPYC 7xx2[3] (Zen 2) | 2019 | SEV firmware update for models in the range 30h to 3fh [4]
| ||
amd-ucode/microcode_amd_fam19h.bin | 25 | 19h
|
Zen 3 | 2021 | Ryzen 5000 series (not all models), EPYC 7xx3 |
amd/amd_sev_fam19h_model0xh.sbin | EPYC 7xx3[5] (Zen 3) | 2021 | SEV firmware update for models in the range 00h to 0fh [6]
|
The previously identified CPU specific firmware blob file (in this example CPU family 22) needs to be built into the kernelː
Device Drivers ---> Generic Driver Options Firmware loader ---> {*} Firmware loading facility (amd-ucode/microcode_amd_fam16h.bin) External firmware blobs to build into the kernel binary (/lib/firmware) Firmware blobs root directory
The CONFIG_FW_LOADER Firmware loading facility must be set as built into the kernel, not as a kernel module.
Rebuild the kernel
Rebuild and install the kernel as usual.
Verification
After the next reboot with the new kernel, output similar to the following should be observed:
user $
dmesg | grep microcode
[ 0.584603] microcode: microcode: updated early to new patch_level=0x06000832 [ 0.868036] microcode: CPU0: patch_level=0x06000832 [ 0.868116] microcode: CPU1: patch_level=0x06000832 [ 0.868196] microcode: CPU2: patch_level=0x06000832 [ 0.868277] microcode: CPU3: patch_level=0x06000832 [ 0.868360] microcode: CPU4: patch_level=0x06000832 [ 0.868451] microcode: CPU5: patch_level=0x06000832 [ 0.868538] microcode: CPU6: patch_level=0x06000832 [ 0.868619] microcode: CPU7: patch_level=0x06000832 [ 0.868718] microcode: Microcode Update Driver: v2.01 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
The first line contains the microcode: updated early
log message in case a microcode update was performed during the boot.
It is possible the microcode has already been fully updated by the system's BIOS vendor. In that case the dmesg output does not contain the update log message.
References
- ↑ Revision Guide for AMD Family 17h Models 00h-0Fh Processors (PDF, page 6)
- ↑ [PATCH] linux-firmware: Update AMD SEV firmware (LKML, John Allen, commit pushed, 18 Jun 2019)
- ↑ Revision Guide for AMD Family 17h Models 30h-3Fh Processors (PDF, page 6)
- ↑ [PATCH] linux-firmware: Update AMD SEV firmware (LKML, Josh Boyer, signed-off, 20 Jul 2020)
- ↑ Revision Guide for AMD Family 19h Models 00h-0Fh Processors (PDF, page 6)
- ↑ [PATCH v2] linux-firmware: Update AMD SEV firmware (LKML, John Allen, signed-off, 10 Sep 2021)