Skip to content

Commit 1f161f6

Browse files
suryasaimadhuIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: <[email protected]> # 4.11.. Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://bugzilla.suse.com/show_bug.cgi?id=1061396 Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent b956575 commit 1f161f6

File tree

1 file changed

+18
-9
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+18
-9
lines changed

arch/x86/kernel/cpu/microcode/core.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ static bool __init check_loader_disabled_bsp(void)
122122
bool *res = &dis_ucode_ldr;
123123
#endif
124124

125-
if (!have_cpuid_p())
126-
return *res;
127-
128125
/*
129126
* CPUID(1).ECX[31]: reserved for hypervisor use. This is still not
130127
* 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)
166163
void __init load_ucode_bsp(void)
167164
{
168165
unsigned int cpuid_1_eax;
166+
bool intel = true;
169167

170-
if (check_loader_disabled_bsp())
168+
if (!have_cpuid_p())
171169
return;
172170

173171
cpuid_1_eax = native_cpuid_eax(1);
174172

175173
switch (x86_cpuid_vendor()) {
176174
case X86_VENDOR_INTEL:
177-
if (x86_family(cpuid_1_eax) >= 6)
178-
load_ucode_intel_bsp();
175+
if (x86_family(cpuid_1_eax) < 6)
176+
return;
179177
break;
178+
180179
case X86_VENDOR_AMD:
181-
if (x86_family(cpuid_1_eax) >= 0x10)
182-
load_ucode_amd_bsp(cpuid_1_eax);
180+
if (x86_family(cpuid_1_eax) < 0x10)
181+
return;
182+
intel = false;
183183
break;
184+
184185
default:
185-
break;
186+
return;
186187
}
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);
187196
}
188197

189198
static bool check_loader_disabled_ap(void)

0 commit comments

Comments
 (0)