x86/microcode/AMD: Move the no-revision fixup to get_patch_level()
Subsystems (2)
PATCH 1/1 x86/microcode/AMD: Move the no-revision fixup to get_patch_level()
From: "Borislav Petkov (AMD)" <[email protected]>
On machines which don't have microcode applied yet, the revision is 0. However, this doesn't work with the Zen family/model/stepping patch arithmetic. So move the fixup to the patch level getter function and this way make sure the patch level is always proper and thus the arithmetic always works.
--- arch/x86/kernel/cpu/microcode/amd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +4 -5
@@ -233,11 +233,6 @@ static bool need_sha_check(u32 cur_rev) {u32 cutoff; -if (!cur_rev) { - cur_rev =cpuid_to_ucode_rev (bsp_cpuid_1_eax); -pr_info_once ("No current revision, generating the lowest one: 0x%x\n" , cur_rev); - } - cutoff =get_cutoff_revision (cur_rev);if (cutoff)return cur_rev <= cutoff;
@@ -338,6 +333,10 @@ static u32 get_patch_level(void) }native_rdmsr (MSR_AMD64_PATCH_LEVEL , rev, dummy); +if (!rev) { + rev =cpuid_to_ucode_rev (bsp_cpuid_1_eax); +pr_info_once ("No current revision, generating the lowest one: 0x%x\n" , rev); + }return rev; }
Signature · 1 line
2.53.0
Borislav Petkov
maintainerPATCH 1/1 x86/microcode/AMD: Move the no-revision fixup to get_patch_level()
Quoted 8 lines · Borislav Petkov
From: "Borislav Petkov (AMD)" <[email protected]>
On machines which don't have microcode applied yet, the revision is 0. However, this doesn't work with the Zen family/model/stepping patch arithmetic. So move the fixup to the patch level getter function and this way make sure the patch level is always proper and thus the arithmetic always works.
Quoted 4 lines
Signed-off-by Borislav Petkov (AMD) <[email protected]>--- arch/x86/kernel/cpu/microcode/amd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
AI review caught something, here's v2:
---
From: "Borislav Petkov (AMD)" <[email protected]>
Date: Fri, 29 May 2026 17:27:24 -0700
Subject: [PATCH -v2] x86/microcode/AMD: Move the no-revision fixup to get_patch_level()
On machines which don't have microcode applied yet, the revision is 0. However, this doesn't work with the Zen family/model/stepping patch arithmetic. So move the fixup to the patch level getter function and this way make sure the patch level is always proper and thus the arithmetic always works.
And now that it can be called on any family, make this Zen-only.
--- arch/x86/kernel/cpu/microcode/amd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/microcode/amd.c +7 -5
@@ -233,11 +233,6 @@ static bool need_sha_check(u32 cur_rev) {u32 cutoff; -if (!cur_rev) { - cur_rev =cpuid_to_ucode_rev (bsp_cpuid_1_eax); -pr_info_once ("No current revision, generating the lowest one: 0x%x\n" , cur_rev); - } - cutoff =get_cutoff_revision (cur_rev);if (cutoff)return cur_rev <= cutoff;
@@ -338,6 +333,13 @@ static u32 get_patch_level(void) }native_rdmsr (MSR_AMD64_PATCH_LEVEL , rev, dummy); +if (!rev) { +if (x86_family (bsp_cpuid_1_eax) <0x17 ) +return rev; + + rev =cpuid_to_ucode_rev (bsp_cpuid_1_eax); +pr_info_once ("No current revision, generating the lowest one: 0x%x\n" , rev); + }return rev; }
Signature · 7 lines
2.53.0
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette