Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5999503ybc; Wed, 27 Nov 2019 13:09:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwSsLsk/6pO71tvmb7ziEJGLGQAMG8aH6pySvg5hBcGmP0VirKdhxQTOLWZ/YBGD1I9ppJn X-Received: by 2002:a17:906:f90e:: with SMTP id lc14mr2732803ejb.70.1574888998240; Wed, 27 Nov 2019 13:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888998; cv=none; d=google.com; s=arc-20160816; b=TfcKYS2fWOxBO2l0k9hdt5dRZap2IYhKeTWJu4gpXWC4wGCE70+iW5jHGJpVSCOQEM 3WmmJEDusiI0F8X6gdzTp9VBxPi3iIZ9wytf6n7xiyOPRrjo5OxXGDMkoCiEng24upV1 lCo9slzcR76jm+yEZogeId7e0l44muUI+Hyi/ECLDcv0/evHZon89DD5omXVniTuFes/ iF3fc3b7wGD1aglP1tT/IM1WBN8XPKw9UMr0HHAwJ1i98g3+p/sHoYNlYcLYd7jXkolK Z/SZX41BUvBQG+oZamvYu8nKigHnyTqsRG6uahmvCR9dbPUBi4srCKNS9KJqFv8Ky4iF IyKw== 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=Tly+93Glc3pOcIFoPwkT/D/2k9gal/2nj78c8wnsz46xKBspp49RTnQR57iGUVJRwD R92hVOvn7G3hq1tHhNAFVAz8GmMMvuze0P6KvI6PEsx///1WapSMLoAKhj7XIgJvAZi8 gBhGMWWjMD4X0eWzmPPN4ReqQ4mUdg5qYShQ9vU2pp02pbpz9VufjjM2gqpy/l2g9eXU q5eUNTywqgg083GER4uuj9Owj9tqY49wWsJ2OgqoBNCNwoaqOI1xnE2L3jWbQ5pmTJUl HXD06zcuGWfZ8BRUNHRjIv7Lq7jMHRGm6EMUxSd3fAZRRArN+nzNuhI352O5URRfiUeY yGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g1J+7Eqh; 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 o14si12960216edi.116.2019.11.27.13.09.34; Wed, 27 Nov 2019 13:09:58 -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=g1J+7Eqh; 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 S1732681AbfK0VH6 (ORCPT + 99 others); Wed, 27 Nov 2019 16:07:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:34258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732674AbfK0VH5 (ORCPT ); Wed, 27 Nov 2019 16:07:57 -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 B2CA920637; Wed, 27 Nov 2019 21:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888876; bh=TjK6ymxqY67uPx9haMeBRwGjjLaIwExRBNJ32pxvHWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1J+7Eqh/YTbvYSErPSvDgIQdtcNrc1sKhecfBt6cy66N41CZtMIUdrnAA3gZyPPy gjVOCPJ2PyAklSP0gdzAP7QhZm9HmodqjqrdJG/ROTchgQaGdrJX2DhT9nPVkrUFxN fkwkuEpsF0E8TKg0EeyFBA1pMeleg5PB7Cm1Xp/k= 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.19 304/306] powerpc/64s: support nospectre_v2 cmdline option Date: Wed, 27 Nov 2019 21:32:34 +0100 Message-Id: <20191127203136.927449924@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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