[PATCH -next] ARM: spectre-bhb: expand boot cmdline param to turn off mitigation on ARM32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <chenjiahao16@xxxxxxxxxx>
---
 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 <asm/spectre.h>
 #include <asm/system_misc.h>
 
+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:
-- 
2.34.1




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux