Skip to content

Commit fcf8239

Browse files
committed
x86/microcode/AMD: Handle the case of no BIOS microcode
Machines can be shipped without any microcode in the BIOS. Which means, the microcode patch revision is 0. Handle that gracefully. Fixes: 94838d2 ("x86/microcode/AMD: Use the family,model,stepping encoded in the patch ID") Reported-by: Vítek Vávra <vit.vavra.kh@gmail.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Cc: <stable@kernel.org>
1 parent 24963ae commit fcf8239

File tree

1 file changed

+20
-2
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+20
-2
lines changed

arch/x86/kernel/cpu/microcode/amd.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,28 @@ static int cmp_id(const void *key, const void *elem)
171171
return 1;
172172
}
173173

174+
static u32 cpuid_to_ucode_rev(unsigned int val)
175+
{
176+
union zen_patch_rev p = {};
177+
union cpuid_1_eax c;
178+
179+
c.full = val;
180+
181+
p.stepping = c.stepping;
182+
p.model = c.model;
183+
p.ext_model = c.ext_model;
184+
p.ext_fam = c.ext_fam;
185+
186+
return p.ucode_rev;
187+
}
188+
174189
static bool need_sha_check(u32 cur_rev)
175190
{
191+
if (!cur_rev) {
192+
cur_rev = cpuid_to_ucode_rev(bsp_cpuid_1_eax);
193+
pr_info_once("No current revision, generating the lowest one: 0x%x\n", cur_rev);
194+
}
195+
176196
switch (cur_rev >> 8) {
177197
case 0x80012: return cur_rev <= 0x800126f; break;
178198
case 0x80082: return cur_rev <= 0x800820f; break;
@@ -749,8 +769,6 @@ static struct ucode_patch *cache_find_patch(struct ucode_cpu_info *uci, u16 equi
749769
n.equiv_cpu = equiv_cpu;
750770
n.patch_id = uci->cpu_sig.rev;
751771

752-
WARN_ON_ONCE(!n.patch_id);
753-
754772
list_for_each_entry(p, &microcode_cache, plist)
755773
if (patch_cpus_equivalent(p, &n, false))
756774
return p;

0 commit comments

Comments
 (0)