Skip to content

Commit 6cdce95

Browse files
committed
x86/microcode/AMD: Simplify patch family detection
Instead of traversing the equivalence table, compute the family a patch is for, from the processor revision ID in the microcode header. Signed-off-by: Borislav Petkov <bp@suse.de> Cc: x86@kernel.org Link: https://lkml.kernel.org/r/20181107170218.7596-8-bp@alien8.de
1 parent 2b8d34b commit 6cdce95

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

  • arch/x86/kernel/cpu/microcode

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

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -540,20 +540,6 @@ static u16 __find_equiv_id(unsigned int cpu)
540540
return find_equiv_id(equiv_cpu_table, uci->cpu_sig.sig);
541541
}
542542

543-
static u32 find_cpu_family_by_equiv_cpu(u16 equiv_cpu)
544-
{
545-
int i = 0;
546-
547-
BUG_ON(!equiv_cpu_table);
548-
549-
while (equiv_cpu_table[i].equiv_cpu != 0) {
550-
if (equiv_cpu == equiv_cpu_table[i].equiv_cpu)
551-
return equiv_cpu_table[i].installed_cpu;
552-
i++;
553-
}
554-
return 0;
555-
}
556-
557543
/*
558544
* a small, trivial cache of per-family ucode patches
559545
*/
@@ -732,7 +718,7 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)
732718
struct microcode_header_amd *mc_hdr;
733719
unsigned int patch_size, crnt_size;
734720
struct ucode_patch *patch;
735-
u32 proc_fam;
721+
u8 patch_fam;
736722
u16 proc_id;
737723

738724
patch_size = verify_patch(family, fw, leftover, false);
@@ -746,15 +732,8 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)
746732
mc_hdr = (struct microcode_header_amd *)(fw + SECTION_HDR_SIZE);
747733
proc_id = mc_hdr->processor_rev_id;
748734

749-
proc_fam = find_cpu_family_by_equiv_cpu(proc_id);
750-
if (!proc_fam) {
751-
pr_err("No patch family for equiv ID: 0x%04x\n", proc_id);
752-
return crnt_size;
753-
}
754-
755-
/* check if patch is for the current family */
756-
proc_fam = ((proc_fam >> 8) & 0xf) + ((proc_fam >> 20) & 0xff);
757-
if (proc_fam != family)
735+
patch_fam = 0xf + (proc_id >> 12);
736+
if (patch_fam != family)
758737
return crnt_size;
759738

760739
if (mc_hdr->nb_dev_id || mc_hdr->sb_dev_id) {

0 commit comments

Comments
 (0)