Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753834AbeAFCdu (ORCPT + 1 other); Fri, 5 Jan 2018 21:33:50 -0500 Received: from mga03.intel.com ([134.134.136.65]:10717 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753712AbeAFCdH (ORCPT ); Fri, 5 Jan 2018 21:33:07 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,320,1511856000"; d="scan'208";a="190375395" From: Tim Chen To: Thomas Gleixner , Andy Lutomirski , Linus Torvalds , Greg KH Cc: Tim Chen , Dave Hansen , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , David Woodhouse , linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] x86/microcode: Recheck IBRS features on microcode reload Date: Fri, 5 Jan 2018 18:12:21 -0800 Message-Id: X-Mailer: git-send-email 2.9.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On new microcode write, check whether IBRS is present by rescanning IBRS feature. Signed-off-by: Tim Chen --- 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 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 #include #include +#include #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(µcode_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