lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  5 Jan 2018 18:12:21 -0800
From:   Tim Chen <tim.c.chen@...ux.intel.com>
To:     Thomas Gleixner <tglx@...utronix.de>,
        Andy Lutomirski <luto@...nel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Greg KH <gregkh@...uxfoundation.org>
Cc:     Tim Chen <tim.c.chen@...ux.intel.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Arjan Van De Ven <arjan.van.de.ven@...el.com>,
        David Woodhouse <dwmw@...zon.co.uk>,
        linux-kernel@...r.kernel.org
Subject: [PATCH v2 6/8] x86/microcode: Recheck IBRS features on microcode reload

On new microcode write, check whether IBRS
is present by rescanning IBRS feature.

Signed-off-by: Tim Chen <tim.c.chen@...ux.intel.com>
---
 arch/x86/include/asm/spec_ctrl.h     |  1 +
 arch/x86/kernel/cpu/microcode/core.c |  4 ++++
 arch/x86/kernel/cpu/spec_ctrl.c      | 18 ++++++++++--------
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/spec_ctrl.h b/arch/x86/include/asm/spec_ctrl.h
index 62c5dc8..be08ae7 100644
--- a/arch/x86/include/asm/spec_ctrl.h
+++ b/arch/x86/include/asm/spec_ctrl.h
@@ -8,6 +8,7 @@
 #include <asm/microcode.h>
 
 void scan_spec_ctrl_feature(struct cpuinfo_x86 *c);
+void rescan_spec_ctrl_feature(struct cpuinfo_x86 *c);
 bool ibrs_inuse(void);
 
 extern unsigned int dynamic_ibrs;
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index c4fa4a8..848c3e9 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -40,6 +40,7 @@
 #include <asm/processor.h>
 #include <asm/cmdline.h>
 #include <asm/setup.h>
+#include <asm/spec_ctrl.h>
 
 #define DRIVER_VERSION	"2.2"
 
@@ -444,6 +445,9 @@ static ssize_t microcode_write(struct file *file, const char __user *buf,
 	if (ret > 0)
 		perf_check_microcode();
 
+	/* check spec_ctrl capabilities */
+	rescan_spec_ctrl_feature(&boot_cpu_data);
+
 	mutex_unlock(&microcode_mutex);
 	put_online_cpus();
 
diff --git a/arch/x86/kernel/cpu/spec_ctrl.c b/arch/x86/kernel/cpu/spec_ctrl.c
index 1641bec..28107a2 100644
--- a/arch/x86/kernel/cpu/spec_ctrl.c
+++ b/arch/x86/kernel/cpu/spec_ctrl.c
@@ -24,13 +24,18 @@ static bool ibrs_admin_disabled;
 /* mutex to serialize IBRS control changes */
 DEFINE_MUTEX(spec_ctrl_mutex);
 
+static inline void set_ibrs_feature(void)
+{
+	if (!ibrs_admin_disabled) {
+		dynamic_ibrs = 1;
+		ibrs_enabled = IBRS_ENABLED;
+	}
+}
+
 void scan_spec_ctrl_feature(struct cpuinfo_x86 *c)
 {
 	if ((!c->cpu_index) && (boot_cpu_has(X86_FEATURE_SPEC_CTRL))) {
-		if (!ibrs_admin_disabled) {
-			dynamic_ibrs = 1;
-			ibrs_enabled = IBRS_ENABLED;
-		}
+		set_ibrs_feature();
 	}
 }
 EXPORT_SYMBOL_GPL(scan_spec_ctrl_feature);
@@ -43,10 +48,7 @@ void rescan_spec_ctrl_feature(struct cpuinfo_x86 *c)
 {
 	mutex_lock(&spec_ctrl_mutex);
 	if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) {
-		if (!ibrs_admin_disabled) {
-			dynamic_ibrs = 1;
-			ibrs_enabled = IBRS_ENABLED;
-		}
+		set_ibrs_feature();
 	}
 	mutex_unlock(&spec_ctrl_mutex);
 }
-- 
2.9.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ