Return-path: Received: from aserp2130.oracle.com ([141.146.126.79]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fBWL5-0003EH-6Y for speck@linutronix.de; Thu, 26 Apr 2018 04:08:53 +0200 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3Q26j9p048178 for ; Thu, 26 Apr 2018 02:08:44 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2hftty99sg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 Apr 2018 02:08:44 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w3Q28hce030301 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 Apr 2018 02:08:43 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w3Q28hqc006928 for ; Thu, 26 Apr 2018 02:08:43 GMT Message-Id: <20180426020546.273176033@localhost.localdomain> Date: Wed, 25 Apr 2018 22:04:23 -0400 From: konrad.wilk@oracle.com Subject: [MODERATED] [PATCH v5 08/11] [PATCH v5 08/10] Linux Patch #8 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: Intel and AMD SPEC_CTRL (0x48) MSR semantics may differ in the future (or in fact use different MSRs for the same functionality). As such we need a run-time way to whitelist the appropiate MSR values. Signed-off-by: Konrad Rzeszutek Wilk --- v5: New patch --- arch/x86/kernel/cpu/bugs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 99cdd44c20bc..7c704bc36968 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -35,6 +35,12 @@ static void __init ssb_select_mitigation(void); */ u64 __read_mostly x86_spec_ctrl_base; +/* + * Sane bits that can written in x86_spec_ctrl_base. They may differ + * on different platforms. + */ +u64 __read_mostly x86_spec_ctrl_mask = ~(SPEC_CTRL_IBRS); + void __init check_bugs(void) { /* @@ -122,7 +128,7 @@ static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE; void x86_set_spec_ctrl(u64 val) { - if (val & ~(SPEC_CTRL_IBRS | SPEC_CTRL_RDS)) + if (val & x86_spec_ctrl_mask) WARN_ONCE(1, "SPEC_CTRL MSR value 0x%16llx is unknown.\n", val); else wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base | val); @@ -469,8 +475,10 @@ static void __init ssb_select_mitigation(void) /* * Intel uses the SPEC CTRL MSR Bit(2) for this. */ - if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) + if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) { x86_spec_ctrl_base |= SPEC_CTRL_RDS; + x86_spec_ctrl_mask &= ~(SPEC_CTRL_RDS); + } } } -- 2.14.3