From patchwork Thu Aug 31 13:01:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Jiahao X-Patchwork-Id: 13371505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 744D6C83F01 for ; Thu, 31 Aug 2023 13:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=qsNUlhhg1XW7+XOoqsnx6jMy3+SV+URHkS9l4b8chkg=; b=K4Jsse69owgYqt qlk7uUThYvBf1/d/chQWon0Gton3PvbGvN5yqACl5DvtkSgyeXrITr6HnBSYlw/xgc5Hbz+LA5o1Q KsRg9E+PNeeeBqV1OYmgFA2HDv5rfKHceIxbM+pl8qnrQW0w8MHMQ6/OfooHMtcaG7KfresnMfI76 HT5DG88fMTtnIwAugEQ6y9G07SkI4rOtE9KraxRYI+m5w20yErJkBWIjHjcIFyQ0uMJTe5glAEG20 JDupd5oUj5Bi1jKquzuGRSMS3hPh+arpSUu+Mvo1yp5G0eZjd3hUa6kfQLD8dFQpNp0TtsOCvCmHd oUCFAtg1TVBJXtNhdwBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbhJP-00FKCs-1L; Thu, 31 Aug 2023 13:02:15 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qbhJL-00FKAb-0a for linux-arm-kernel@lists.infradead.org; Thu, 31 Aug 2023 13:02:13 +0000 Received: from dggpemm500016.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Rc1V86mHXz1L9BN; Thu, 31 Aug 2023 21:00:16 +0800 (CST) Received: from huawei.com (10.67.174.58) by dggpemm500016.china.huawei.com (7.185.36.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 31 Aug 2023 21:01:56 +0800 From: Chen Jiahao To: , , , , , , , , CC: Subject: [PATCH -next] ARM: spectre-bhb: expand boot cmdline param to turn off mitigation on ARM32 Date: Thu, 31 Aug 2023 21:01:40 +0800 Message-ID: <20230831130140.291250-1-chenjiahao16@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500016.china.huawei.com (7.185.36.25) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230831_060211_493243_5F5EE476 X-CRM114-Status: GOOD ( 12.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org spectre-bhb mitigation is enabled by default on ARM32, which may cause performance regression. To offer an option to turn off the mitigation, here expand an existing cmdline parameter 'nospectre_bhb' to ARM32, which sets up a switch to skip the mitigation code entry and bhb workarounds in mitigation method handler. Signed-off-by: Chen Jiahao --- Documentation/admin-guide/kernel-parameters.txt | 2 +- arch/arm/mm/proc-v7-bugs.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0a1731a0f0ef..856edb4403fb 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3902,7 +3902,7 @@ nospec_store_bypass_disable [HW] Disable all mitigations for the Speculative Store Bypass vulnerability - nospectre_bhb [ARM64] Disable all mitigations for Spectre-BHB (branch + nospectre_bhb [ARM,ARM64] Disable all mitigations for Spectre-BHB (branch history injection) vulnerability. System may allow data leaks with this option. diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c index 8bc7a2d6d6c7..dd2ddece714f 100644 --- a/arch/arm/mm/proc-v7-bugs.c +++ b/arch/arm/mm/proc-v7-bugs.c @@ -9,6 +9,15 @@ #include #include +static int nospectre_bhb __read_mostly; + +static int __init nospectre_bhb_setup(char *str) +{ + nospectre_bhb = 1; + return 0; +} +early_param("nospectre_bhb", nospectre_bhb_setup); + #ifdef CONFIG_ARM_PSCI static int __maybe_unused spectre_v2_get_cpu_fw_mitigation_state(void) { @@ -226,6 +235,11 @@ static void cpu_v7_spectre_bhb_init(void) { unsigned int state, method = 0; + if (nospectre_bhb) { + pr_info_once("Spectre bhb: hardening is disabled\n"); + return; + } + switch (read_cpuid_part()) { case ARM_CPU_PART_CORTEX_A15: case ARM_CPU_PART_BRAHMA_B15: