Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp75992imu; Wed, 21 Nov 2018 15:40:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/X/P5S8OAyE1hzhg1bwltafOl/94t1SW+trYAY3F68rTo7NuZIPzJgFNHaMCBnxGIkthUaV X-Received: by 2002:a17:902:365:: with SMTP id 92mr8443353pld.327.1542843642866; Wed, 21 Nov 2018 15:40:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542843642; cv=none; d=google.com; s=arc-20160816; b=Z+VzeyqQY+kx4mOhfcPSKhZGDKQE27MNwgMRnV32rPyuerm2/E3OeRu/yapEyBn7OI YTR624IvNs/4y6H72/jB/r3RTH3cXQV+uBa193vaGnEDVMBbOsS93zuxzXZ04o+rZXxY oIEfmN4rm+XvadJbwfV2NqgXYwdX75n4TMxsOBL/Ir6uARb+GhU1V1CGMriAXGGY5Xq2 nKiM/a0ZHnEROF4eiDgWKGHFZppinpQxjGdNIqvSXD49cETRBBM71ya3dPdWb6mTeNFh zVR4of05lCWJMxirHiQRkD/9qz7eCgLdGKtw+ReYd4kLPihtPNY8meIrpEuCRNHPpGvK QOQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9HUZ8Tatl6JJsYTwseha6C3rzy5xTDSU63V0wZiobbU=; b=aZtgmNpZxpBJsDBfBXNmpV+RCe5xQ4WQTdMEbcMExOk+jEHBHGzb7DebNgK2HtQ6oW PS2PLfc/r6XdvXtWackPD4v/BuZYeLxcITbQxlfWLx0Iw3inT1hi9GQ5Jy8hw2MbM+16 oZCCO43nj0t/HOw+BcX+Xr4itHKcSZQ6q0VJ7Qwy5lIpr4l5Lc3DlL5gnKWaV4+u21PZ oF5ywnBjg12bp86qqPYvBIluPPUIWr/R+kRGL2I7ug6rZXx54r7GJx6jN53/8wMmkzM3 tJyLtXipojfWQ5coMMO4drlphYLbFBdObNQiyEpqUo+FPqDtnD9/9o6V8+cFTUFAY+Cr Md/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DUbDEdSe; 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 d77si29359805pfj.124.2018.11.21.15.40.28; Wed, 21 Nov 2018 15:40:42 -0800 (PST) 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=DUbDEdSe; 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 S2388087AbeKVFng (ORCPT + 99 others); Thu, 22 Nov 2018 00:43:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:38386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732097AbeKVFnf (ORCPT ); Thu, 22 Nov 2018 00:43:35 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 B8C8A206BB; Wed, 21 Nov 2018 19:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542827282; bh=AzUlGZjz6i49RjCi+Khr0N+xYlYIvgkH4SJOtDxLiYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DUbDEdSeqZqewJUME4fmdGemYJYFmQeBj+8AE8IJMCnn5EJxfQfJd7oHWFE4t66rR ix76MD1lyjezUOiFxPAXOrfpZg7hPrA0UsEawyLwVTCbtUM45Bk+8qSjbkAkQVzipv Lp+4t16i/kbXyyyMD+94Ync9EYtBklcFRsd4W5fA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Kosina , Thomas Gleixner , Peter Zijlstra , Josh Poimboeuf , Andrea Arcangeli , "WoodhouseDavid" , Andi Kleen , Tim Chen , "SchauflerCasey" Subject: [PATCH 4.19 42/42] Revert "x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation" Date: Wed, 21 Nov 2018 20:06:18 +0100 Message-Id: <20181121183149.785877054@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121183147.869199006@linuxfoundation.org> References: <20181121183147.869199006@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Greg Kroah-Hartman This reverts commit 233b9d7df0e114c7e7c3674559fb0fc41ada3e8f which is commit 53c613fe6349994f023245519265999eed75957f upstream. It's not ready for the stable trees as there are major slowdowns involved with this patch. Reported-by: Jiri Kosina Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Josh Poimboeuf Cc: Andrea Arcangeli Cc: "WoodhouseDavid" Cc: Andi Kleen Cc: Tim Chen Cc: "SchauflerCasey" Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 57 ++++----------------------------------------- kernel/cpu.c | 11 -------- 2 files changed, 7 insertions(+), 61 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -35,10 +35,12 @@ static void __init spectre_v2_select_mit static void __init ssb_select_mitigation(void); static void __init l1tf_select_mitigation(void); -/* The base value of the SPEC_CTRL MSR that always has to be preserved. */ -u64 x86_spec_ctrl_base; +/* + * Our boot-time value of the SPEC_CTRL MSR. We read it once so that any + * writes to SPEC_CTRL contain whatever reserved bits have been set. + */ +u64 __ro_after_init x86_spec_ctrl_base; EXPORT_SYMBOL_GPL(x86_spec_ctrl_base); -static DEFINE_MUTEX(spec_ctrl_mutex); /* * The vendor and possibly platform specific bits which can be modified in @@ -323,46 +325,6 @@ static enum spectre_v2_mitigation_cmd __ return cmd; } -static bool stibp_needed(void) -{ - if (spectre_v2_enabled == SPECTRE_V2_NONE) - return false; - - if (!boot_cpu_has(X86_FEATURE_STIBP)) - return false; - - return true; -} - -static void update_stibp_msr(void *info) -{ - wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base); -} - -void arch_smt_update(void) -{ - u64 mask; - - if (!stibp_needed()) - return; - - mutex_lock(&spec_ctrl_mutex); - mask = x86_spec_ctrl_base; - if (cpu_smt_control == CPU_SMT_ENABLED) - mask |= SPEC_CTRL_STIBP; - else - mask &= ~SPEC_CTRL_STIBP; - - if (mask != x86_spec_ctrl_base) { - pr_info("Spectre v2 cross-process SMT mitigation: %s STIBP\n", - cpu_smt_control == CPU_SMT_ENABLED ? - "Enabling" : "Disabling"); - x86_spec_ctrl_base = mask; - on_each_cpu(update_stibp_msr, NULL, 1); - } - mutex_unlock(&spec_ctrl_mutex); -} - static void __init spectre_v2_select_mitigation(void) { enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline(); @@ -462,9 +424,6 @@ specv2_set_mode: setup_force_cpu_cap(X86_FEATURE_USE_IBRS_FW); pr_info("Enabling Restricted Speculation for firmware calls\n"); } - - /* Enable STIBP if appropriate */ - arch_smt_update(); } #undef pr_fmt @@ -855,8 +814,6 @@ static ssize_t l1tf_show_state(char *buf static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr, char *buf, unsigned int bug) { - int ret; - if (!boot_cpu_has_bug(bug)) return sprintf(buf, "Not affected\n"); @@ -874,12 +831,10 @@ static ssize_t cpu_show_common(struct de return sprintf(buf, "Mitigation: __user pointer sanitization\n"); case X86_BUG_SPECTRE_V2: - ret = sprintf(buf, "%s%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled], + return sprintf(buf, "%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled], boot_cpu_has(X86_FEATURE_USE_IBPB) ? ", IBPB" : "", boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "", - (x86_spec_ctrl_base & SPEC_CTRL_STIBP) ? ", STIBP" : "", spectre_v2_module_string()); - return ret; case X86_BUG_SPEC_STORE_BYPASS: return sprintf(buf, "%s\n", ssb_strings[ssb_mode]); --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2026,12 +2026,6 @@ static void cpuhp_online_cpu_device(unsi kobject_uevent(&dev->kobj, KOBJ_ONLINE); } -/* - * Architectures that need SMT-specific errata handling during SMT hotplug - * should override this. - */ -void __weak arch_smt_update(void) { }; - static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { int cpu, ret = 0; @@ -2058,10 +2052,8 @@ static int cpuhp_smt_disable(enum cpuhp_ */ cpuhp_offline_cpu_device(cpu); } - if (!ret) { + if (!ret) cpu_smt_control = ctrlval; - arch_smt_update(); - } cpu_maps_update_done(); return ret; } @@ -2072,7 +2064,6 @@ static int cpuhp_smt_enable(void) cpu_maps_update_begin(); cpu_smt_control = CPU_SMT_ENABLED; - arch_smt_update(); for_each_present_cpu(cpu) { /* Skip online CPUs and CPUs on offline nodes */ if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))