Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6024530ybc; Wed, 27 Nov 2019 13:36:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwduHE8cdzpe3IZLTJP8ez82hLwj04vL9DhGQgLM2zapdhM7KgiHPELiHs56wCApMYReGTx X-Received: by 2002:a17:906:8554:: with SMTP id h20mr3808751ejy.203.1574890569780; Wed, 27 Nov 2019 13:36:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890569; cv=none; d=google.com; s=arc-20160816; b=yKCkcQPzhsj58uW0xlmHN24eq5+pYohJk6I5Jcq3Tc7uiwNyx4KMHvI7zs48sV1ATz 0YtvPIYMztOB37dKvnwcx5LKl/CEO6w4Pc/t4C/jN6U4KaLZafx1YuZ2bElGP5G1swCe I2a9W220ZLMktLkRZoNGUMugsnW4C4sUAdfYDebwFeLOIKEp0Awg6dqpi2gcDun9ZRoX OHsFNz2HP7Vr1qJQQ9Ap9ijFuVPCddCvYt1g79kSxH0XqOd0+1XgA2STgJ1rbNcPXlpz d4TcVMltZ0K8V0+aGqZm7N/k7BSJ4lBIRLv6A7Lv3/7NPYAuXveZtxrT9Qo+ecNWgKJH MI+A== 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=s7By7G1b9W/7UUdSjZg4bi4f28EEuCVk7nSWFTe9Ya0=; b=G4nQiBauQO4L+Iwu0BdJiWgoYIce4S4HUX4d8vPwIZNsUGt3Mvh7xDa0dIHsvGrzjv dQF1qMWzoEgcSv+H6Qn0a6zHBaOk8kxiv85MMTfN+zrV2JLdAsjj1OGCIOhrPG2BMUuK yZeJCLfrU7nb7cQ4/euMbeIHDoiPEo6e1PLwrY9HiMmFemYTMCIOKbPj/QhxjFRkwOW6 oJc+g/n4kAiSWL7+kTAhKrbUtrMQ5pGUBx1xU9aA138v4s34y1NtpYnV9PdovPkAfEhS NLszw8uNiL0YB5hmWB59S3n+MLUBxklUGvkP0c3GR/NO7kEQecQGt/NRSw+lGqEwG3BI WMKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HoXdTob+; 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 b19si11751345edb.40.2019.11.27.13.35.46; Wed, 27 Nov 2019 13:36:09 -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=HoXdTob+; 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 S1731399AbfK0Vb0 (ORCPT + 99 others); Wed, 27 Nov 2019 16:31:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:44846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730861AbfK0Uyl (ORCPT ); Wed, 27 Nov 2019 15:54: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 8DD632086A; Wed, 27 Nov 2019 20:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888080; bh=TjK6ymxqY67uPx9haMeBRwGjjLaIwExRBNJ32pxvHWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HoXdTob+Rr5I2YhRKwdE0nJ1O+ETBn2cVS+j2blkIVJVZrnC6RKH1bnwfGcIHu+ZJ RVZQlmATEj5esdDB+dmyXZUFhzLsrods2b8mmgBBV2YxRr7AK2vtt8UyxSLrVZm722 GA1g1hwN3TzBszWTmh03hbHjWKUEnjP0RB/Oo34g= 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.14 208/211] powerpc/64s: support nospectre_v2 cmdline option Date: Wed, 27 Nov 2019 21:32:21 +0100 Message-Id: <20191127203113.169509874@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@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 @@ -28,7 +28,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 @@ -106,7 +106,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; @@ -114,6 +114,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 || cpu_mitigations_off()) @@ -391,7 +394,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