Blame linux-kernel-patches/03-42ca8082e260dcfd8afa2afa6ec1940b9d41724c.patch

Packit 863535
From 42ca8082e260dcfd8afa2afa6ec1940b9d41724c Mon Sep 17 00:00:00 2001
Packit 863535
From: Borislav Petkov <bp@suse.de>
Packit 863535
Date: Fri, 16 Feb 2018 12:26:40 +0100
Packit 863535
Subject: x86/CPU: Check CPU feature bits after microcode upgrade
Packit 863535

Packit 863535
With some microcode upgrades, new CPUID features can become visible on
Packit 863535
the CPU. Check what the kernel has mirrored now and issue a warning
Packit 863535
hinting at possible things the user/admin can do to make use of the
Packit 863535
newly visible features.
Packit 863535

Packit 863535
Originally-by: Ashok Raj <ashok.raj@intel.com>
Packit 863535
Tested-by: Ashok Raj <ashok.raj@intel.com>
Packit 863535
Signed-off-by: Borislav Petkov <bp@suse.de>
Packit 863535
Reviewed-by: Ashok Raj <ashok.raj@intel.com>
Packit 863535
Cc: Andy Lutomirski <luto@kernel.org>
Packit 863535
Cc: Arjan van de Ven <arjan@linux.intel.com>
Packit 863535
Cc: Borislav Petkov <bp@alien8.de>
Packit 863535
Cc: Dan Williams <dan.j.williams@intel.com>
Packit 863535
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Packit 863535
Cc: David Woodhouse <dwmw2@infradead.org>
Packit 863535
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Packit 863535
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Packit 863535
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Packit 863535
Cc: Peter Zijlstra <peterz@infradead.org>
Packit 863535
Cc: Thomas Gleixner <tglx@linutronix.de>
Packit 863535
Link: http://lkml.kernel.org/r/20180216112640.11554-4-bp@alien8.de
Packit 863535
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Packit 863535
---
Packit 863535
 arch/x86/kernel/cpu/common.c | 20 ++++++++++++++++++++
Packit 863535
 1 file changed, 20 insertions(+)
Packit 863535

Packit 863535
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
Packit 863535
index 84f1cd8..348cf48 100644
Packit 863535
--- a/arch/x86/kernel/cpu/common.c
Packit 863535
+++ b/arch/x86/kernel/cpu/common.c
Packit 863535
@@ -1757,5 +1757,25 @@ core_initcall(init_cpu_syscore);
Packit 863535
  */
Packit 863535
 void microcode_check(void)
Packit 863535
 {
Packit 863535
+	struct cpuinfo_x86 info;
Packit 863535
+
Packit 863535
 	perf_check_microcode();
Packit 863535
+
Packit 863535
+	/* Reload CPUID max function as it might've changed. */
Packit 863535
+	info.cpuid_level = cpuid_eax(0);
Packit 863535
+
Packit 863535
+	/*
Packit 863535
+	 * Copy all capability leafs to pick up the synthetic ones so that
Packit 863535
+	 * memcmp() below doesn't fail on that. The ones coming from CPUID will
Packit 863535
+	 * get overwritten in get_cpu_cap().
Packit 863535
+	 */
Packit 863535
+	memcpy(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability));
Packit 863535
+
Packit 863535
+	get_cpu_cap(&info;;
Packit 863535
+
Packit 863535
+	if (!memcmp(&info.x86_capability, &boot_cpu_data.x86_capability, sizeof(info.x86_capability)))
Packit 863535
+		return;
Packit 863535
+
Packit 863535
+	pr_warn("x86/CPU: CPU features have changed after loading microcode, but might not take effect.\n");
Packit 863535
+	pr_warn("x86/CPU: Please consider either early loading through initrd/built-in or a potential BIOS update.\n");
Packit 863535
 }
Packit 863535
-- 
Packit 863535
cgit v1.1
Packit 863535