Skip to content

Commit dac3841

Browse files
bp3tk0vopsiff
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> (cherry picked from commit 43be33b8a2f2bab9c110ea08aded85ec4507ee7b)
1 parent 43cf2d1 commit dac3841

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

  • arch/x86/kernel/cpu/microcode

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

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

162+
static u32 cpuid_to_ucode_rev(unsigned int val)
163+
{
164+
union zen_patch_rev p = {};
165+
union cpuid_1_eax c;
166+
167+
c.full = val;
168+
169+
p.stepping = c.stepping;
170+
p.model = c.model;
171+
p.ext_model = c.ext_model;
172+
p.ext_fam = c.ext_fam;
173+
174+
return p.ucode_rev;
175+
}
176+
162177
static bool need_sha_check(u32 cur_rev)
163178
{
179+
if (!cur_rev) {
180+
cur_rev = cpuid_to_ucode_rev(bsp_cpuid_1_eax);
181+
pr_info_once("No current revision, generating the lowest one: 0x%x\n", cur_rev);
182+
}
183+
164184
switch (cur_rev >> 8) {
165185
case 0x80012: return cur_rev <= 0x800126f; break;
166186
case 0x80082: return cur_rev <= 0x800820f; break;
@@ -741,8 +761,6 @@ static struct ucode_patch *cache_find_patch(struct ucode_cpu_info *uci, u16 equi
741761
n.equiv_cpu = equiv_cpu;
742762
n.patch_id = uci->cpu_sig.rev;
743763

744-
WARN_ON_ONCE(!n.patch_id);
745-
746764
list_for_each_entry(p, &microcode_cache, plist)
747765
if (patch_cpus_equivalent(p, &n, false))
748766
return p;

0 commit comments

Comments
 (0)