Skip to contentSkip to conversation

arm64: Provide a command line to disable spectre_v2 mitigation

PATCH New Hanjun Guo 1 participant 1 message Mar 5, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Hanjun Guo

author
#1 lore raw

PATCH 2/2 arm64: Provide a command line to disable spectre_v2 mitigation

From: Jeremy Linton <[email protected]>

euler inclusion
category: feature
bugzilla: 11011
DTS: NA
CVE: NA

Patch will be in mainlien kernel 5.2
--------------------------------------------------

There are various reasons, including bencmarking, to disable spectrev2 mitigation on a machine. Provide a command-line to do so.

[Hanjun: fix conflicts which we don't have PPC PPC_FSL_BOOK3E
arch spectre-v2 mitigation in 4.19 kernel, so remvoe PPC_FSL_BOOK3E]
Conflicts:
Documentation/admin-guide/kernel-parameters.txt

---
 Documentation/admin-guide/kernel-parameters.txt |  8 ++++----
 arch/arm64/kernel/cpu_errata.c                  | 13 +++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +4 -4
index b43fbaa..bbc34c03 100644
@@ -2828,10 +2828,10 @@
 			check bypass). With this option data leaks are possible
 			in the system.
 
-	nospectre_v2	[X86] Disable all mitigations for the Spectre variant 2
-			(indirect branch prediction) vulnerability. System may
-			allow data leaks with this option, which is equivalent
-			to spectre_v2=off.
+	nospectre_v2	[X86,ARM64] Disable all mitigations for
+			the Spectre variant 2 (indirect branch prediction)
+			vulnerability. System may allow data leaks with this
+			option.
 
 	nospec_store_bypass_disable
 			[HW] Disable all mitigations for the Speculative Store Bypass vulnerability
arch/arm64/kernel/cpu_errata.c +13 -0
index 74e9e80..7e5682c 100644
@@ -210,6 +210,14 @@ static void qcom_link_stack_sanitization(void)
 		     : "=&r" (tmp));
 }
 
+static bool __nospectre_v2;
+static int __init parse_nospectre_v2(char *str)
+{
+	__nospectre_v2 = true;
+	return 0;
+}
+early_param("nospectre_v2", parse_nospectre_v2);
+
 static void
 enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry)
 {
@@ -221,6 +229,11 @@ static void qcom_link_stack_sanitization(void)
 	if (!entry->matches(entry, SCOPE_LOCAL_CPU))
 		return;
 
+	if (__nospectre_v2) {
+		pr_info_once("spectrev2 mitigation disabled by command line option\n");
+		return;
+	}
+
 	if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
 		return;
 
Signature · 1 line
1.7.12.4