Skip to content

Commit 2760f45

Browse files
suryasaimadhugregkh
authored andcommitted
x86/microcode: Do the family check first
commit 1f161f6 upstream with adjustments. 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> Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 230ca8f commit 2760f45

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

  • arch/x86/kernel/cpu/microcode

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

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

89-
if (!have_cpuid_p())
90-
return *res;
91-
9289
a = 1;
9390
c = 0;
9491
native_cpuid(&a, &b, &c, &d);
@@ -130,25 +127,37 @@ void __init load_ucode_bsp(void)
130127
{
131128
int vendor;
132129
unsigned int family;
130+
bool intel = true;
133131

134-
if (check_loader_disabled_bsp())
132+
if (!have_cpuid_p())
135133
return;
136134

137135
vendor = x86_cpuid_vendor();
138136
family = x86_cpuid_family();
139137

140138
switch (vendor) {
141139
case X86_VENDOR_INTEL:
142-
if (family >= 6)
143-
load_ucode_intel_bsp();
140+
if (family < 6)
141+
return;
144142
break;
143+
145144
case X86_VENDOR_AMD:
146-
if (family >= 0x10)
147-
load_ucode_amd_bsp(family);
145+
if (family < 0x10)
146+
return;
147+
intel = false;
148148
break;
149+
149150
default:
150-
break;
151+
return;
151152
}
153+
154+
if (check_loader_disabled_bsp())
155+
return;
156+
157+
if (intel)
158+
load_ucode_intel_bsp();
159+
else
160+
load_ucode_amd_bsp(family);
152161
}
153162

154163
static bool check_loader_disabled_ap(void)

0 commit comments

Comments
 (0)