aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2017-10-12 07:23:16 -0400
committerIngo Molnar <mingo@kernel.org>2017-10-14 06:55:40 -0400
commit1f161f67a272cc4f29f27934dd3f74cb657eb5c4 (patch)
tree96b6ed193be5696b37ed9f012aa275155681713c
parentb956575bed91ecfb136a8300742ecbbf451471ab (diff)
x86/microcode: Do the family check first
On CPUs like AMD's Geode, for example, we shouldn't even try to load microcode because they do not support the modern microcode loading interface. However, we do the family check *after* the other checks whether the loader has been disabled on the command line or whether we're running in a guest. So move the family checks first in order to exit early if we're being loaded on an unsupported family. Reported-and-tested-by: Sven Glodowski <glodi1@arcor.de> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: <stable@vger.kernel.org> # 4.11.. Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://bugzilla.suse.com/show_bug.cgi?id=1061396 Link: http://lkml.kernel.org/r/20171012112316.977-1-bp@alien8.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/cpu/microcode/core.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 86e8f0b2537b..c4fa4a85d4cb 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -122,9 +122,6 @@ static bool __init check_loader_disabled_bsp(void)
122 bool *res = &dis_ucode_ldr; 122 bool *res = &dis_ucode_ldr;
123#endif 123#endif
124 124
125 if (!have_cpuid_p())
126 return *res;
127
128 /* 125 /*
129 * CPUID(1).ECX[31]: reserved for hypervisor use. This is still not 126 * CPUID(1).ECX[31]: reserved for hypervisor use. This is still not
130 * completely accurate as xen pv guests don't see that CPUID bit set but 127 * completely accurate as xen pv guests don't see that CPUID bit set but
@@ -166,24 +163,36 @@ bool get_builtin_firmware(struct cpio_data *cd, const char *name)
166void __init load_ucode_bsp(void) 163void __init load_ucode_bsp(void)
167{ 164{
168 unsigned int cpuid_1_eax; 165 unsigned int cpuid_1_eax;
166 bool intel = true;
169 167
170 if (check_loader_disabled_bsp()) 168 if (!have_cpuid_p())
171 return; 169 return;
172 170
173 cpuid_1_eax = native_cpuid_eax(1); 171 cpuid_1_eax = native_cpuid_eax(1);
174 172
175 switch (x86_cpuid_vendor()) { 173 switch (x86_cpuid_vendor()) {
176 case X86_VENDOR_INTEL: 174 case X86_VENDOR_INTEL:
177 if (x86_family(cpuid_1_eax) >= 6) 175 if (x86_family(cpuid_1_eax) < 6)
178 load_ucode_intel_bsp(); 176 return;
179 break; 177 break;
178
180 case X86_VENDOR_AMD: 179 case X86_VENDOR_AMD:
181 if (x86_family(cpuid_1_eax) >= 0x10) 180 if (x86_family(cpuid_1_eax) < 0x10)
182 load_ucode_amd_bsp(cpuid_1_eax); 181 return;
182 intel = false;
183 break; 183 break;
184
184 default: 185 default:
185 break; 186 return;
186 } 187 }
188
189 if (check_loader_disabled_bsp())
190 return;
191
192 if (intel)
193 load_ucode_intel_bsp();
194 else
195 load_ucode_amd_bsp(cpuid_1_eax);
187} 196}
188 197
189static bool check_loader_disabled_ap(void) 198static bool check_loader_disabled_ap(void)