Skip to content

Commit c84ba4c

Browse files
bp3tk0vgregkh
authored andcommitted
x86/microcode/AMD: Handle the case of no BIOS microcode
commit fcf8239 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f491616 commit c84ba4c

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
@@ -161,8 +161,28 @@ static int cmp_id(const void *key, const void *elem)
161161
return 1;
162162
}
163163

164+
static u32 cpuid_to_ucode_rev(unsigned int val)
165+
{
166+
union zen_patch_rev p = {};
167+
union cpuid_1_eax c;
168+
169+
c.full = val;
170+
171+
p.stepping = c.stepping;
172+
p.model = c.model;
173+
p.ext_model = c.ext_model;
174+
p.ext_fam = c.ext_fam;
175+
176+
return p.ucode_rev;
177+
}
178+
164179
static bool need_sha_check(u32 cur_rev)
165180
{
181+
if (!cur_rev) {
182+
cur_rev = cpuid_to_ucode_rev(bsp_cpuid_1_eax);
183+
pr_info_once("No current revision, generating the lowest one: 0x%x\n", cur_rev);
184+
}
185+
166186
switch (cur_rev >> 8) {
167187
case 0x80012: return cur_rev <= 0x800126f; break;
168188
case 0x80082: return cur_rev <= 0x800820f; break;
@@ -744,8 +764,6 @@ static struct ucode_patch *cache_find_patch(struct ucode_cpu_info *uci, u16 equi
744764
n.equiv_cpu = equiv_cpu;
745765
n.patch_id = uci->cpu_sig.rev;
746766

747-
WARN_ON_ONCE(!n.patch_id);
748-
749767
list_for_each_entry(p, &microcode_cache, plist)
750768
if (patch_cpus_equivalent(p, &n, false))
751769
return p;

0 commit comments

Comments
 (0)