diff options
| author | Borislav Petkov <bp@suse.de> | 2015-11-23 05:12:21 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2015-11-24 03:15:54 -0500 |
| commit | 99f925ce927e4ac313d9af8bd1bf55796e2cdcb1 (patch) | |
| tree | 51a3708791496f4d60f895e6f07a628a8f7a68e3 /arch/x86/kernel/cpu/microcode | |
| parent | 1ec218373b8ebda821aec00bb156a9c94fad9cd4 (diff) | |
x86/cpu: Unify CPU family, model, stepping calculation
Add generic functions which calc family, model and stepping from
the CPUID_1.EAX leaf and stick them into the library we have.
Rename those which do call CPUID with the prefix "x86_cpuid" as
suggested by Paolo Bonzini.
No functionality change.
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1448273546-2567-2-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/cpu/microcode')
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/core.c | 12 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/intel.c | 16 |
2 files changed, 12 insertions, 16 deletions
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 7fc27f1cca58..3aaffb601c91 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c | |||
| @@ -129,8 +129,8 @@ void __init load_ucode_bsp(void) | |||
| 129 | if (!have_cpuid_p()) | 129 | if (!have_cpuid_p()) |
| 130 | return; | 130 | return; |
| 131 | 131 | ||
| 132 | vendor = x86_vendor(); | 132 | vendor = x86_cpuid_vendor(); |
| 133 | family = x86_family(); | 133 | family = x86_cpuid_family(); |
| 134 | 134 | ||
| 135 | switch (vendor) { | 135 | switch (vendor) { |
| 136 | case X86_VENDOR_INTEL: | 136 | case X86_VENDOR_INTEL: |
| @@ -165,8 +165,8 @@ void load_ucode_ap(void) | |||
| 165 | if (!have_cpuid_p()) | 165 | if (!have_cpuid_p()) |
| 166 | return; | 166 | return; |
| 167 | 167 | ||
| 168 | vendor = x86_vendor(); | 168 | vendor = x86_cpuid_vendor(); |
| 169 | family = x86_family(); | 169 | family = x86_cpuid_family(); |
| 170 | 170 | ||
| 171 | switch (vendor) { | 171 | switch (vendor) { |
| 172 | case X86_VENDOR_INTEL: | 172 | case X86_VENDOR_INTEL: |
| @@ -206,8 +206,8 @@ void reload_early_microcode(void) | |||
| 206 | { | 206 | { |
| 207 | int vendor, family; | 207 | int vendor, family; |
| 208 | 208 | ||
| 209 | vendor = x86_vendor(); | 209 | vendor = x86_cpuid_vendor(); |
| 210 | family = x86_family(); | 210 | family = x86_cpuid_family(); |
| 211 | 211 | ||
| 212 | switch (vendor) { | 212 | switch (vendor) { |
| 213 | case X86_VENDOR_INTEL: | 213 | case X86_VENDOR_INTEL: |
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index ce47402eb2f9..ee81c544ee0d 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c | |||
| @@ -145,10 +145,10 @@ matching_model_microcode(struct microcode_header_intel *mc_header, | |||
| 145 | int ext_sigcount, i; | 145 | int ext_sigcount, i; |
| 146 | struct extended_signature *ext_sig; | 146 | struct extended_signature *ext_sig; |
| 147 | 147 | ||
| 148 | fam = __x86_family(sig); | 148 | fam = x86_family(sig); |
| 149 | model = x86_model(sig); | 149 | model = x86_model(sig); |
| 150 | 150 | ||
| 151 | fam_ucode = __x86_family(mc_header->sig); | 151 | fam_ucode = x86_family(mc_header->sig); |
| 152 | model_ucode = x86_model(mc_header->sig); | 152 | model_ucode = x86_model(mc_header->sig); |
| 153 | 153 | ||
| 154 | if (fam == fam_ucode && model == model_ucode) | 154 | if (fam == fam_ucode && model == model_ucode) |
| @@ -163,7 +163,7 @@ matching_model_microcode(struct microcode_header_intel *mc_header, | |||
| 163 | ext_sigcount = ext_header->count; | 163 | ext_sigcount = ext_header->count; |
| 164 | 164 | ||
| 165 | for (i = 0; i < ext_sigcount; i++) { | 165 | for (i = 0; i < ext_sigcount; i++) { |
| 166 | fam_ucode = __x86_family(ext_sig->sig); | 166 | fam_ucode = x86_family(ext_sig->sig); |
| 167 | model_ucode = x86_model(ext_sig->sig); | 167 | model_ucode = x86_model(ext_sig->sig); |
| 168 | 168 | ||
| 169 | if (fam == fam_ucode && model == model_ucode) | 169 | if (fam == fam_ucode && model == model_ucode) |
| @@ -365,7 +365,7 @@ static int collect_cpu_info_early(struct ucode_cpu_info *uci) | |||
| 365 | native_cpuid(&eax, &ebx, &ecx, &edx); | 365 | native_cpuid(&eax, &ebx, &ecx, &edx); |
| 366 | csig.sig = eax; | 366 | csig.sig = eax; |
| 367 | 367 | ||
| 368 | family = __x86_family(csig.sig); | 368 | family = x86_family(csig.sig); |
| 369 | model = x86_model(csig.sig); | 369 | model = x86_model(csig.sig); |
| 370 | 370 | ||
| 371 | if ((model >= 5) || (family > 6)) { | 371 | if ((model >= 5) || (family > 6)) { |
| @@ -521,16 +521,12 @@ static bool __init load_builtin_intel_microcode(struct cpio_data *cp) | |||
| 521 | { | 521 | { |
| 522 | #ifdef CONFIG_X86_64 | 522 | #ifdef CONFIG_X86_64 |
| 523 | unsigned int eax = 0x00000001, ebx, ecx = 0, edx; | 523 | unsigned int eax = 0x00000001, ebx, ecx = 0, edx; |
| 524 | unsigned int family, model, stepping; | ||
| 525 | char name[30]; | 524 | char name[30]; |
| 526 | 525 | ||
| 527 | native_cpuid(&eax, &ebx, &ecx, &edx); | 526 | native_cpuid(&eax, &ebx, &ecx, &edx); |
| 528 | 527 | ||
| 529 | family = __x86_family(eax); | 528 | sprintf(name, "intel-ucode/%02x-%02x-%02x", |
| 530 | model = x86_model(eax); | 529 | x86_family(eax), x86_model(eax), x86_stepping(eax)); |
| 531 | stepping = eax & 0xf; | ||
| 532 | |||
| 533 | sprintf(name, "intel-ucode/%02x-%02x-%02x", family, model, stepping); | ||
| 534 | 530 | ||
| 535 | return get_builtin_firmware(cp, name); | 531 | return get_builtin_firmware(cp, name); |
| 536 | #else | 532 | #else |
