Skip to contentSkip to conversation

x86/microcode/AMD: Warn when a patch is skipped because of the Entrysign cutoff

PATCH New Erwan Velu 1 participant 1 message Nov 25

Subsystems (2)
lore
Share & tools
lore

Erwan Velu

author
#0 lore raw

PATCH 1/1 x86/microcode/AMD: Warn when a patch is skipped because of the Entrysign cutoff

Since commit 8d171045069c ("x86/microcode/AMD: Select which microcode patch to load"), verify_patch() only considers patches which are on the same side of the Entrysign cutoff revision as the microcode currently running on the CPU. On a machine whose BIOS still ships pre-Entrysign microcode, every post-Entrysign patch for that CPU, be it in the initrd or in /lib/firmware, is skipped.

This choice is made silently: nothing is printed, neither at early load nor on late load, where the write to the reload file in /sys/devices/system/cpu/microcode/ even succeeds. The microcode shipped by the distribution is simply never applied and the CPU stays at the BIOS revision, or at the pre-Entrysign fallback patch. Because nothing explains this, it is very hard to understand why the microcode is not
loaded: one has to read the loader source to find out that a BIOS update is what is actually needed.

Print a one-time warning when a patch for the running CPU is skipped because the current revision is at or below the cutoff, naming the patch, the current revision and the cutoff, and pointing at the BIOS update.

Patches below the cutoff are still skipped silently on CPUs which are already past it, as they are older than the running revision anyway.

Tested in a KVM guest with CONFIG_MICROCODE_DBG=y, a guest CPUID of family 0x19, model 0xa0, stepping 2 (EPYC 8004 "Siena", cutoff 0xaa00218), linux-firmware's microcode_amd_fam19h.bin in the early initrd (it carries both 0xaa00215 and 0xaa0021c for that CPU) and the running revision faked with microcode=base_rev=:

- base_rev=0xaa00216: without this patch, only "Current revision:
0x0aa00216" is printed and a late reload succeeds without changing anything. With it, the warning about 0x0aa0021c is printed once.
- base_rev=0xaa00212: 0xaa00215 is applied early and the warning about 0x0aa0021c is printed.
- base_rev=0xaa0021b: 0xaa0021c is applied early and nothing new is printed.

Fixes 8d171045069c ("x86/microcode/AMD: Select which microcode patch to load")
---
 arch/x86/kernel/cpu/microcode/amd.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/kernel/cpu/microcode/amd.c +5 -0
index 6cdc410e7547..ea7a8853d509 100644
@@ -568,6 +568,11 @@ static int verify_patch(const u8 *buf, size_t buf_size, u32 *patch_size)
 	if (cur_rev > cutoff && patch_rev > cutoff)
 		goto ok;
 
+	if (cur_rev <= cutoff &&
+	    ucode_rev_to_cpuid(patch_rev).full == bsp_cpuid_1_eax)
+		pr_warn_once("Patch 0x%08x skipped: current revision 0x%08x is at or below the Entrysign cutoff 0x%08x, a BIOS update is required\n",
+			     patch_rev, cur_rev, cutoff);
+
 	return 1;
 
 ok:
Signature · 1 line
2.55.0