From 66ff1b1dc8960f42020cd30dd1d134a4ccb4fec8 Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Tue, 5 Mar 2019 15:35:41 +0800 Subject: [PATCH] arm64: Provide a command line to disable spectre_v2 mitigation euler inclusion category: feature bugzilla: 11011 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. Signed-off-by: Jeremy Linton Cc: Jonathan Corbet Cc: linux-doc@vger.kernel.org [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 Signed-off-by: Hanjun Guo Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- Documentation/admin-guide/kernel-parameters.txt | 8 ++++---- arch/arm64/kernel/cpu_errata.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b43fbaa919a9..bbc34c039d60 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -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 diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 74e9e8008211..7e5682c282b3 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -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 @@ enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry) 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; -- GitLab