Commit 5f5b7472 authored by Borislav Petkov's avatar Borislav Petkov Committed by H. Peter Anvin

x86, microcode, AMD: Read CPUID(1).EAX on the correct cpu

Read the CPUID(1).EAX leaf at the correct cpu and use it to search the
equivalence table for matching microcode patch. No functionality change.
Signed-off-by: default avatarBorislav Petkov <borislav.petkov@amd.com>
Link: http://lkml.kernel.org/r/1344361461-10076-9-git-send-email-bp@amd64.orgSigned-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 685ca6d7
...@@ -82,6 +82,7 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig) ...@@ -82,6 +82,7 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
{ {
struct cpuinfo_x86 *c = &cpu_data(cpu); struct cpuinfo_x86 *c = &cpu_data(cpu);
csig->sig = cpuid_eax(0x00000001);
csig->rev = c->microcode; csig->rev = c->microcode;
pr_info("CPU%d: patch_level=0x%08x\n", cpu, csig->rev); pr_info("CPU%d: patch_level=0x%08x\n", cpu, csig->rev);
...@@ -118,16 +119,15 @@ static unsigned int verify_ucode_size(int cpu, u32 patch_size, ...@@ -118,16 +119,15 @@ static unsigned int verify_ucode_size(int cpu, u32 patch_size,
return patch_size; return patch_size;
} }
static u16 find_equiv_id(void) static u16 find_equiv_id(unsigned int cpu)
{ {
unsigned int current_cpu_id, i = 0; struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
int i = 0;
BUG_ON(equiv_cpu_table == NULL); BUG_ON(equiv_cpu_table == NULL);
current_cpu_id = cpuid_eax(0x00000001);
while (equiv_cpu_table[i].installed_cpu != 0) { while (equiv_cpu_table[i].installed_cpu != 0) {
if (current_cpu_id == equiv_cpu_table[i].installed_cpu) if (uci->cpu_sig.sig == equiv_cpu_table[i].installed_cpu)
return equiv_cpu_table[i].equiv_cpu; return equiv_cpu_table[i].equiv_cpu;
i++; i++;
...@@ -150,7 +150,7 @@ static int get_matching_microcode(int cpu, const u8 *ucode_ptr, ...@@ -150,7 +150,7 @@ static int get_matching_microcode(int cpu, const u8 *ucode_ptr,
patch_size = *(u32 *)(ucode_ptr + 4); patch_size = *(u32 *)(ucode_ptr + 4);
*current_size = patch_size + SECTION_HDR_SIZE; *current_size = patch_size + SECTION_HDR_SIZE;
equiv_cpu_id = find_equiv_id(); equiv_cpu_id = find_equiv_id(cpu);
if (!equiv_cpu_id) if (!equiv_cpu_id)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment