1 From stable+bounces-151861-greg=kroah.com@vger.kernel.org Sat Jun 7 17:41:40 2025
2 From: Pu Lehui <pulehui@huaweicloud.com>
3 Date: Sat, 7 Jun 2025 15:25:18 +0000
4 Subject: arm64: spectre: increase parameters that can be used to turn off bhb mitigation individually
5 To: stable@vger.kernel.org
6 Cc: james.morse@arm.com, catalin.marinas@arm.com, daniel@iogearbox.net, ast@kernel.org, andrii@kernel.org, xukuohai@huawei.com, pulehui@huawei.com
7 Message-ID: <20250607152521.2828291-12-pulehui@huaweicloud.com>
9 From: Liu Song <liusong@linux.alibaba.com>
11 [ Upstream commit 877ace9eab7de032f954533afd5d1ecd0cf62eaf ]
13 In our environment, it was found that the mitigation BHB has a great
14 impact on the benchmark performance. For example, in the lmbench test,
15 the "process fork && exit" test performance drops by 20%.
16 So it is necessary to have the ability to turn off the mitigation
17 individually through cmdline, thus avoiding having to compile the
18 kernel by adjusting the config.
20 Signed-off-by: Liu Song <liusong@linux.alibaba.com>
21 Acked-by: Catalin Marinas <catalin.marinas@arm.com>
22 Link: https://lore.kernel.org/r/1661514050-22263-1-git-send-email-liusong@linux.alibaba.com
23 Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
24 Signed-off-by: Pu Lehui <pulehui@huawei.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 Documentation/admin-guide/kernel-parameters.txt | 5 +++++
28 arch/arm64/kernel/proton-pack.c | 9 ++++++++-
29 2 files changed, 13 insertions(+), 1 deletion(-)
31 --- a/Documentation/admin-guide/kernel-parameters.txt
32 +++ b/Documentation/admin-guide/kernel-parameters.txt
34 spec_store_bypass_disable=off [X86,PPC]
35 spectre_v2_user=off [X86]
36 ssbd=force-off [ARM64]
37 + nospectre_bhb [ARM64]
38 tsx_async_abort=off [X86]
41 @@ -3367,6 +3368,10 @@
42 vulnerability. System may allow data leaks with this
45 + nospectre_bhb [ARM64] Disable all mitigations for Spectre-BHB (branch
46 + history injection) vulnerability. System may allow data leaks
49 nospec_store_bypass_disable
50 [HW] Disable all mitigations for the Speculative Store Bypass vulnerability
52 --- a/arch/arm64/kernel/proton-pack.c
53 +++ b/arch/arm64/kernel/proton-pack.c
54 @@ -1088,6 +1088,13 @@ static void kvm_setup_bhb_slot(const cha
55 #endif /* CONFIG_KVM */
57 static bool spectre_bhb_fw_mitigated;
58 +static bool __read_mostly __nospectre_bhb;
59 +static int __init parse_spectre_bhb_param(char *str)
61 + __nospectre_bhb = true;
64 +early_param("nospectre_bhb", parse_spectre_bhb_param);
66 void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)
68 @@ -1100,7 +1107,7 @@ void spectre_bhb_enable_mitigation(const
69 /* No point mitigating Spectre-BHB alone. */
70 } else if (!IS_ENABLED(CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY)) {
71 pr_info_once("spectre-bhb mitigation disabled by compile time option\n");
72 - } else if (cpu_mitigations_off()) {
73 + } else if (cpu_mitigations_off() || __nospectre_bhb) {
74 pr_info_once("spectre-bhb mitigation disabled by command line option\n");
75 } else if (supports_ecbhb(SCOPE_LOCAL_CPU)) {
76 state = SPECTRE_MITIGATED;