Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5979601ybc; Wed, 27 Nov 2019 12:48:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwXyMIsP/63+yLlVmDZ7+NVWEhiJYAdLspXcpMFBuzbksqnXzrPfQc9fv7FRybs9vGrBrAq X-Received: by 2002:a17:906:6dcd:: with SMTP id j13mr5629838ejt.275.1574887707447; Wed, 27 Nov 2019 12:48:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574887707; cv=none; d=google.com; s=arc-20160816; b=Mu8JN98sTGJeKjjMhdQ7Umf2Q4YVgsy5tnHWXLR34deGiiFK9hi4oSKLZo+y3cbO1f FQZ7iq0sZx3JT7Jxo9G++zKUY8/fxPNxAbHgn4QA8iZAQkOjCi1qcbCdobSgZs1XnaQ+ amyWzU1BiGLRbYP87t/lB0RtXbqWoV5gwXctLwzUIU59PEyf5b8ziccI1XkReGmekuCT GimmzeaVnRfke/iwU20qcrEGtsrby/11zP52kNh3Zc1IP9QwKnMJnPvXtjCuoSDd7Sx4 imOXXAjAyin3ZJ0Va6/U6Hupq7HumCM7/fimMIRMQiwSHBfRsRh2DcbEoaaVc6sDFgZA wtUQ== 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=LGMWtE7fycRfMpf1kmf4p9UqrAA5DLL/YIMajAqfPqU=; b=nJoXz0jvnvO1erSerRQAfY2lJW8Ir9InRBqVhJGj1SMoQco+2wcTTwTr1YGeuxF3wb e9Y5kO2MJyiipbedAiptCOhl0wgOQBJ7Fk27sDGnWA7JZWcKKAZWTbC04ZuKiwBfUIFy UwL3sh5qa+e7IlLxx5/z/+BEEZrZAokm6ZzIwFVkW9rZth9dOCVNJUPZ/tOxQAuUDUK4 hFHypmixd83bQT//32FYT3YTJ9wfY3DE6cZug83qrVf/cI1pgZ4SaDKVvJ7r9CInWu0z YWPwJaJEJPpQ/IZiZh+xZALUZAvJsWIdMZftu3g9CJTlt4SYdD2ajcjWch/HhPAE9Yi9 6D8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jKOfP3QN; 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 o17si10719733edv.258.2019.11.27.12.48.03; Wed, 27 Nov 2019 12:48:27 -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=jKOfP3QN; 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 S1729776AbfK0Upn (ORCPT + 99 others); Wed, 27 Nov 2019 15:45:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:56804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729308AbfK0Upl (ORCPT ); Wed, 27 Nov 2019 15:45:41 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 5A3B2217BC; Wed, 27 Nov 2019 20:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887540; bh=s6XzFskxKEy/0UPny9gW5Yu4Xr5VQWwj/YGBAcYZ4jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jKOfP3QNUh2wA8S7jZ/6wC7oqp+bfT0R2mwzbhwEoFssx/X14uSMBtutidszjD/0I kMkW75ncE4PBz8V1pbOM8xUaGHSMbU81cDzyf8rs6LJA7QP5z5WpRq6XmXLvgnAD5m 6vyrqxx5J+/Om9F5jcbCqqZjxHIQ4JZTkMpOrubc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , "Christopher M. Riedl" , Andrew Donnellan , Daniel Axtens Subject: [PATCH 4.9 149/151] powerpc/64s: support nospectre_v2 cmdline option Date: Wed, 27 Nov 2019 21:32:12 +0100 Message-Id: <20191127203047.641403632@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203000.773542911@linuxfoundation.org> References: <20191127203000.773542911@linuxfoundation.org> User-Agent: quilt/0.66 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 From: "Christopher M. Riedl" commit d8f0e0b073e1ec52a05f0c2a56318b47387d2f10 upstream. Add support for disabling the kernel implemented spectre v2 mitigation (count cache flush on context switch) via the nospectre_v2 and mitigations=off cmdline options. Suggested-by: Michael Ellerman Signed-off-by: Christopher M. Riedl Reviewed-by: Andrew Donnellan Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20190524024647.381-1-cmr@informatik.wtf Signed-off-by: Daniel Axtens Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/security.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) --- a/arch/powerpc/kernel/security.c +++ b/arch/powerpc/kernel/security.c @@ -29,7 +29,7 @@ static enum count_cache_flush_type count bool barrier_nospec_enabled; static bool no_nospec; static bool btb_flush_enabled; -#ifdef CONFIG_PPC_FSL_BOOK3E +#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64) static bool no_spectrev2; #endif @@ -107,7 +107,7 @@ static __init int barrier_nospec_debugfs device_initcall(barrier_nospec_debugfs_init); #endif /* CONFIG_DEBUG_FS */ -#ifdef CONFIG_PPC_FSL_BOOK3E +#if defined(CONFIG_PPC_FSL_BOOK3E) || defined(CONFIG_PPC_BOOK3S_64) static int __init handle_nospectre_v2(char *p) { no_spectrev2 = true; @@ -115,6 +115,9 @@ static int __init handle_nospectre_v2(ch return 0; } early_param("nospectre_v2", handle_nospectre_v2); +#endif /* CONFIG_PPC_FSL_BOOK3E || CONFIG_PPC_BOOK3S_64 */ + +#ifdef CONFIG_PPC_FSL_BOOK3E void setup_spectre_v2(void) { if (no_spectrev2) @@ -392,7 +395,17 @@ static void toggle_count_cache_flush(boo void setup_count_cache_flush(void) { - toggle_count_cache_flush(true); + bool enable = true; + + if (no_spectrev2 || cpu_mitigations_off()) { + if (security_ftr_enabled(SEC_FTR_BCCTRL_SERIALISED) || + security_ftr_enabled(SEC_FTR_COUNT_CACHE_DISABLED)) + pr_warn("Spectre v2 mitigations not under software control, can't disable\n"); + + enable = false; + } + + toggle_count_cache_flush(enable); } #ifdef CONFIG_DEBUG_FS