Skip to content

Commit

Permalink
x86, microcode, AMD: Add reverse equiv table search
Browse files Browse the repository at this point in the history
We search the equivalence table using the CPUID(1) signature of the
CPU in order to get the equivalence ID of the patch which we need to
apply. Add a function which does the reverse - it will be needed in
later patches.

While at it, pull the other equiv table function up in the file so that
it can be used by other functionality without forward declarations.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Link: http://lkml.kernel.org/r/1344361461-10076-11-git-send-email-bp@amd64.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Borislav Petkov authored and H. Peter Anvin committed Aug 22, 2012
1 parent 48e3068 commit c96d2c0
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions arch/x86/kernel/microcode_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,36 @@ static struct equiv_cpu_entry *equiv_cpu_table;
/* page-sized ucode patch buffer */
void *patch;

static u16 find_equiv_id(unsigned int cpu)
{
struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
int i = 0;

BUG_ON(equiv_cpu_table == NULL);

while (equiv_cpu_table[i].installed_cpu != 0) {
if (uci->cpu_sig.sig == equiv_cpu_table[i].installed_cpu)
return equiv_cpu_table[i].equiv_cpu;

i++;
}
return 0;
}

static u32 find_cpu_family_by_equiv_cpu(u16 equiv_cpu)
{
int i = 0;

BUG_ON(!equiv_cpu_table);

while (equiv_cpu_table[i].equiv_cpu != 0) {
if (equiv_cpu == equiv_cpu_table[i].equiv_cpu)
return equiv_cpu_table[i].installed_cpu;
i++;
}
return 0;
}

static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
{
struct cpuinfo_x86 *c = &cpu_data(cpu);
Expand Down Expand Up @@ -119,22 +149,6 @@ static unsigned int verify_ucode_size(int cpu, u32 patch_size,
return patch_size;
}

static u16 find_equiv_id(unsigned int cpu)
{
struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
int i = 0;

BUG_ON(equiv_cpu_table == NULL);

while (equiv_cpu_table[i].installed_cpu != 0) {
if (uci->cpu_sig.sig == equiv_cpu_table[i].installed_cpu)
return equiv_cpu_table[i].equiv_cpu;

i++;
}
return 0;
}

/*
* we signal a good patch is found by returning its size > 0
*/
Expand Down

0 comments on commit c96d2c0

Please sign in to comment.