| 1 |
From 42ca8082e260dcfd8afa2afa6ec1940b9d41724c Mon Sep 17 00:00:00 2001 |
| 2 |
From: Borislav Petkov <[email protected]> |
| 3 |
Date: Fri, 16 Feb 2018 12:26:40 +0100 |
| 4 |
Subject: x86/CPU: Check CPU feature bits after microcode upgrade |
| 5 |
|
| 6 |
With some microcode upgrades, new CPUID features can become visible on |
| 7 |
the CPU. Check what the kernel has mirrored now and issue a warning |
| 8 |
hinting at possible things the user/admin can do to make use of the |
| 9 |
newly visible features. |
| 10 |
|
| 11 |
Originally-by: Ashok Raj <[email protected]> |
| 12 |
Tested-by: Ashok Raj <[email protected]> |
| 13 |
Signed-off-by: Borislav Petkov <[email protected]> |
| 14 |
Reviewed-by: Ashok Raj <[email protected]> |
| 15 |
Cc: Andy Lutomirski <[email protected]> |
| 16 |
Cc: Arjan van de Ven <[email protected]> |
| 17 |
Cc: Borislav Petkov <[email protected]> |
| 18 |
Cc: Dan Williams <[email protected]> |
| 19 |
Cc: Dave Hansen <[email protected]> |
| 20 |
Cc: David Woodhouse <[email protected]> |
| 21 |
Cc: Greg Kroah-Hartman <[email protected]> |
| 22 |
Cc: Josh Poimboeuf <[email protected]> |
| 23 |
Cc: Linus Torvalds <[email protected]> |
| 24 |
Cc: Peter Zijlstra <[email protected]> |
| 25 |
Cc: Thomas Gleixner <[email protected]> |
| 26 |
Link: http://lkml.kernel.org/r/[email protected] |
| 27 |
Signed-off-by: Ingo Molnar <[email protected]> |
| 28 |
--- |
| 29 |
arch/x86/kernel/cpu/common.c | 20 ++++++++++++++++++++ |
| 30 |
1 file changed, 20 insertions(+) |
| 31 |
|
| 32 |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c |
| 33 |
index 84f1cd8..348cf48 100644 |
| 34 |
--- a/arch/x86/kernel/cpu/common.c |
| 35 |
+++ b/arch/x86/kernel/cpu/common.c |
| 36 |
@@ -1757,5 +1757,25 @@ core_initcall(init_cpu_syscore); |
| 37 |
*/ |
| 38 |
void microcode_check(void) |
| 39 |
{ |
| 40 |
+ struct cpuinfo_x86 info; |
| 41 |
+ |
| 42 |
perf_check_microcode(); |
| 43 |
+ |
| 44 |
+ /* Reload CPUID max function as it might've changed. */ |
| 45 |
+ info.cpuid_level = cpuid_eax(0); |
| 46 |
+ |
| 47 |
+ /* |
| 48 |
+ * Copy all capability leafs to pick up the synthetic ones so that |
| 49 |
+ * memcmp() below doesn't fail on that. The ones coming from CPUID will |
| 50 |
+ * get overwritten in get_cpu_cap(). |
| 51 |
+ */ |
| 52 |
+ memcpy(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability)); |
| 53 |
+ |
| 54 |
+ get_cpu_cap(&info); |
| 55 |
+ |
| 56 |
+ if (!memcmp(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability))) |
| 57 |
+ return; |
| 58 |
+ |
| 59 |
+ pr_warn("x86/CPU: CPU features have changed after loading microcode, but might not take effect.\n"); |
| 60 |
+ pr_warn("x86/CPU: Please consider either early loading through initrd/built-in or a potential BIOS update.\n"); |
| 61 |
} |
| 62 |
-- |
| 63 |
cgit v1.1 |
| 64 |
|