New microcode: How can I check if it is loaded?

This week a new AMD microcode was released: amd-ucode 20220411.705f19a-1
How can I check if that is properly loaded and applied during boot? My CPU is a Ryzen 9 5900X and there should be something new in this update.

I am using dracut + systemd-boot to boot my system. When I create the initrd dracut is telling me that it is using amd_ucode.img:

...
dracut: *** Generating early-microcode cpio image ***
dracut: *** Constructing AuthenticAMD.bin ***
dracut: *** Using microcode found in '/boot/amd-ucode.img' ***
dracut: *** Store current command line parameters ***
...

When I check the journal after boot I see the following microcode information:

# journalctl -b | grep microcode
Apr 15 09:17:37 rakete kernel: microcode: CPU0: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU1: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU2: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU3: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU4: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU5: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU6: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU7: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU8: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU9: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU10: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU11: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU12: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU13: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU14: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU15: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU16: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU17: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU18: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU19: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU20: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU21: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU22: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: CPU23: patch_level=0x0a201016
Apr 15 09:17:37 rakete kernel: microcode: Microcode Update Driver: v2.2.

There is no hint that amd_ucode.img is actually applied. If I hardcode the amd_ucode.img into the systemd-boot config:

initrd=/amd_ucode.img

I get the same result.

But is that the latest and greatest patch level? I want to verify. But I can not find any information how to do that? I could not find information what the latest patch_level is.

sudo dmesg | grep -i micro

My bad, same story:

Summary
[    0.441928] microcode: CPU0: patch_level=0x08001138
[    0.441934] microcode: CPU1: patch_level=0x08001138
[    0.441939] microcode: CPU2: patch_level=0x08001138
[    0.441944] microcode: CPU3: patch_level=0x08001138
[    0.441949] microcode: CPU4: patch_level=0x08001138
[    0.441954] microcode: CPU5: patch_level=0x08001138
[    0.441960] microcode: CPU6: patch_level=0x08001138
[    0.441966] microcode: CPU7: patch_level=0x08001138
[    0.441970] microcode: CPU8: patch_level=0x08001138
[    0.441974] microcode: CPU9: patch_level=0x08001138
[    0.441978] microcode: CPU10: patch_level=0x08001138
[    0.441981] microcode: CPU11: patch_level=0x08001138
[    0.441984] microcode: Microcode Update Driver: v2.2.

I thought so too. Apparently only for certain models.

One would think there is somewhere a list out there with the latest versions per CPU model so you could cross check if really are on the latest version.
Seems AMD does not publish any of this information though.

edit

Actually I could figure out that it definitely loads something:

When reloading the latest FW file with echo 1 > /sys/devices/system/cpu/microcode/reload, I see:

[ 2368.743447] microcode: verify_and_add_patch: Added patch_id: 0x0800820d, proc_id: 0x8082
[ 2368.743457] microcode: verify_and_add_patch: Added patch_id: 0x0800126e, proc_id: 0x8012
[ 2368.743460] microcode: verify_and_add_patch: Added patch_id: 0x08301055, proc_id: 0x8310

When loading the previous version, it is:

[ 2884.393451] microcode: verify_and_add_patch: Added patch_id: 0x08001250, proc_id: 0x8012
[ 2884.393463] microcode: verify_and_add_patch: Added patch_id: 0x0800820d, proc_id: 0x8082

You can try it yourself with:

su
echo 'file amd.c +p' > /sys/kernel/debug/dynamic_debug/control
echo 1 > /sys/devices/system/cpu/microcode/reload
dmesg | grep microcode

It’ll pick up and load firmware files from /usr/lib/firmware/amd-ucode/.
In your case, with a Zen3 CPU that would be microcode_amd_fam19h.bin.xz

2 Likes

This is what that gives me:

Apr 15 13:26:00 rakete kernel: microcode: verify_and_add_patch: Added patch_id: 0x0a001058, proc_id: 0xa010
Apr 15 13:26:00 rakete kernel: microcode: verify_and_add_patch: Added patch_id: 0x0a001173, proc_id: 0xa011
Apr 15 13:26:00 rakete kernel: microcode: verify_and_add_patch: Added patch_id: 0x0a001229, proc_id: 0xa012

What does that tell me? How do these patch_id’s compare to the microcode patch_level=0x0a201016 ?

My guess is that these different patches are for different models, probably broken down further into different steppings/revisions of a specific model.

Now your specific revision apparently did not get any update, otherwise you should see either microcode updated early to new patch_level... during early load while booting, or reload patch_level... when reloading (echo 1 > /sys/devices/system/cpu/microcode/reload).

So my guess is that these microcode updates that have been published a few days back are supposed to fix bugs in early revisions of some CPU’s.

3 Likes

Wow. You digged deep into it. Thank you!

I don’t know enough to dig, but here is SOME info :grin:

┌06:57:16 WD= [~]
└───freebird@nest ─▶$ yay amd-ucode
3 aur/amd-ucode-uncompressed 20220411.705f19a-1 (+2 0.37) 
    Microcode update image for AMD CPUs
2 aur/amd-ucode-git 20220124.eb8ea1b-1 (+69 0.63) 
    Microcode update image for AMD CPUs
1 core/amd-ucode 20220309.cd01f85-1 (36.1 KiB 53.7 KiB) (Installed)
    Microcode update image for AMD CPUs
==> Packages to install (eg: 1 2 3, 1-3 or ^4)
==> 

so at least you get a date for it!

Or He/She Bios is up to date.

According to phoronix AMD published the new microcode on the 8. April 2022:

It is now 8 days later and I assume that no BIOS has this included so quickly.

The amd-ucode package is from 11. April: amd-ucode 20220411.705f19a-1
Does this include the new microcode?

And, to my initial question, how can I tell that the amd firmware from the amd-ucode package is actually loaded? The jorunal is not telling me and the microcode version information from /proc/cpuinfo is useless because there is no reference anywhere.

Yes, it does.

The 20220411 tag was created after the ucodes were added.

Looking at the PKGBUILD it references the source with that tag.

The fact that the “Microcode updater” is loaded during boot does not convince you?
Apr 15 09:17:37 rakete kernel: microcode: Microcode Update Driver: v2.2.

btw. Here the list of all microcode updates contained in the latest amd-ucode package:

# K10
patch_id=0x01000083, proc_id=0x1022, fam=0x10
patch_id=0x01000084, proc_id=0x1020, fam=0x10
patch_id=0x010000c7, proc_id=0x1062, fam=0x10
patch_id=0x010000c8, proc_id=0x1043, fam=0x10
patch_id=0x010000d9, proc_id=0x1081, fam=0x10
patch_id=0x010000da, proc_id=0x1080, fam=0x10
patch_id=0x010000db, proc_id=0x1041, fam=0x10
patch_id=0x010000dc, proc_id=0x10a0, fam=0x10

# Turion X2 Ultra
patch_id=0x02000032, proc_id=0x2031, fam=0x11

# Llano
patch_id=0x03000027, proc_id=0x3010, fam=0x12

# Bobcat
patch_id=0x05000029, proc_id=0x5010, fam=0x14
patch_id=0x05000119, proc_id=0x5020, fam=0x14

# Bulldozer, Piledriver, Steamroller, Excavator
patch_id=0x0600063e, proc_id=0x6012, fam=0x15
patch_id=0x06000852, proc_id=0x6020, fam=0x15
patch_id=0x06001119, proc_id=0x6101, fam=0x15

# Jaguar, Puma
patch_id=0x0700010f, proc_id=0x7001, fam=0x16

# Zen1, Zen+, Zen2
patch_id=0x0800820d, proc_id=0x8082, fam=0x17
patch_id=0x0800126e, proc_id=0x8012, fam=0x17
patch_id=0x08301055, proc_id=0x8310, fam=0x17

# Zen3
patch_id=0x0a001058, proc_id=0xa010, fam=0x19
patch_id=0x0a001173, proc_id=0xa011, fam=0x19
patch_id=0x0a001229, proc_id=0xa012, fam=0x19

#############################################

fam = extended family + base family
e.g. 0xA + 0xF = 0x19

proc id is composed the following way:

Example: 0x8310 -> Zen2 - Rome/Castle Peak
8 = Extended family
3 = Extended model
1 = Base model
0 = Stepping (most likely)

See
https://en.wikichip.org/wiki/amd/cpuid
https://en.wikipedia.org/wiki/List_of_AMD_CPU_microarchitectures

Conclusion:
There is no microcode update for your specific CPU in this package, otherwise there should have been a line with proc_id = 0xa21_. Hence there is nothing to apply for the “Microcode updater”…