Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp790966imm; Mon, 21 May 2018 14:31:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrN0XV1f5/G8KdWT0XYJ+WDSSjOD7vH5DrXZPSLtyUjq6qvboNWw2ih4ZN/mbwkNVsXIWC6 X-Received: by 2002:a62:6756:: with SMTP id b83-v6mr21630131pfc.76.1526938287097; Mon, 21 May 2018 14:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526938287; cv=none; d=google.com; s=arc-20160816; b=GjOoMFnOtm71Ic0RMesAHiKAw9seL5jqq3jmDPGpcvtiOT10BCQYkiNYKFohQoZabP qqqLDg2kb2OP1C7/DbrokmWS90J999yP20YzLSQpQwVpRPoybaNfthI9D+K+fIbrbLWu 2SElRCX2PyqgSPkFTTA7D8m5ntejuG6JplnNIvC4oYf5gaUsdSjU8tL7pIXYKrsWdQQD afh/1QLX2o87aViQrleo908xnnBK5kbcnvKpFjbIMaAUohCs7dXEtZxeWuOYMO89tatx fPW+e92awSyInmnUtapomJWlIbSG1wvuo87OuUnCHKZqhqbcHGlIRCJ/4AZqCCM5fiiX JMIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=2L+lScfIQu3P/dDRO45yYIsZM1UfFapfjkCumux88DQ=; b=MLQEP9B9m1b4T863D5gJlThNIP1l6n5pkqHvRjY5H6QMd7swRU6/eU323cAVVzSigr fg7YYBbpIQ6v4pAjTfFBIg1VZL7PEOpOnCDT073UbjSqHqe+U1Nzj8vwHI/5iSM8QzXh c4olIP4f9I+W0EPW4b02/N5GOjXLGWS8VNXwK2YqUJ5N9X0Cg4p3R6mxj0nDZQcUTMob npN+QivY54H3YZXfqarXfS+wuNMPtpmd/ObhmurLMgORvIWR6QhX5sPuIJjUkQtH5rqZ 6Qt+62q/YzTUFqiMWD/jhd8PitOH3LEkbgGHo1ZrWzvV48qSqStLsPe17jn4QQwoHjmd biAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OIh5M2+W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e129-v6si15239697pfa.217.2018.05.21.14.31.12; Mon, 21 May 2018 14:31:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OIh5M2+W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932625AbeEUV0p (ORCPT + 99 others); Mon, 21 May 2018 17:26:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:41456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932536AbeEUV0h (ORCPT ); Mon, 21 May 2018 17:26:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73BFC20872; Mon, 21 May 2018 21:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937997; bh=erpURNMaRf+wUOFePl6N2bHaJZeMx9mC9FYuDdcD9yI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIh5M2+WuQSSDwLkhsh4HUOm7UJKvel2c173N852dZT+i4nFbgj1OHNjBmChlIrKl sXWdU58nf5EbY7ck5JaQGWg3Zu8eCznWnQPOrjt4kTRlSpK9qbp1JuZ99rqZjV2G1h 4BmLNPj4aIwsh9GzXJf4p9wxP5udECgAnDc8akhA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konrad Rzeszutek Wilk , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.16 071/110] x86/bugs: Whitelist allowed SPEC_CTRL MSR values Date: Mon, 21 May 2018 23:12:08 +0200 Message-Id: <20180521210512.449085078@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konrad Rzeszutek Wilk commit 1115a859f33276fe8afb31c60cf9d8e657872558 upstream 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 a run-time mechanism is required to whitelist the appropriate MSR values. [ tglx: Made the variable __ro_after_init ] Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -35,6 +35,12 @@ static void __init ssb_select_mitigation */ static u64 __ro_after_init x86_spec_ctrl_base; +/* + * The vendor and possibly platform specific bits which can be modified in + * x86_spec_ctrl_base. + */ +static u64 __ro_after_init x86_spec_ctrl_mask = ~SPEC_CTRL_IBRS; + void __init check_bugs(void) { identify_boot_cpu(); @@ -117,7 +123,7 @@ static enum spectre_v2_mitigation spectr void x86_spec_ctrl_set(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); @@ -459,6 +465,7 @@ static enum ssb_mitigation_cmd __init __ switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_INTEL: x86_spec_ctrl_base |= SPEC_CTRL_RDS; + x86_spec_ctrl_mask &= ~SPEC_CTRL_RDS; x86_spec_ctrl_set(SPEC_CTRL_RDS); break; case X86_VENDOR_AMD: @@ -482,7 +489,7 @@ static void ssb_select_mitigation() void x86_spec_ctrl_setup_ap(void) { if (boot_cpu_has(X86_FEATURE_IBRS)) - x86_spec_ctrl_set(x86_spec_ctrl_base & (SPEC_CTRL_IBRS | SPEC_CTRL_RDS)); + x86_spec_ctrl_set(x86_spec_ctrl_base & ~x86_spec_ctrl_mask); } #ifdef CONFIG_SYSFS