]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.169/powerpc-fsl-add-nospectre_v2-command-line-argument.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.169 / powerpc-fsl-add-nospectre_v2-command-line-argument.patch
CommitLineData
45d80ddf
SL
1From 60410df51b980e8706054b9ac33c7f22987301b0 Mon Sep 17 00:00:00 2001
2From: Diana Craciun <diana.craciun@nxp.com>
3Date: Thu, 11 Apr 2019 21:46:22 +1000
4Subject: powerpc/fsl: Add nospectre_v2 command line argument
5
6commit f633a8ad636efb5d4bba1a047d4a0f1ef719aa06 upstream.
7
8When the command line argument is present, the Spectre variant 2
9mitigations are disabled.
10
11Signed-off-by: Diana Craciun <diana.craciun@nxp.com>
12Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
13Signed-off-by: Sasha Levin <sashal@kernel.org>
14---
15 arch/powerpc/include/asm/setup.h | 5 +++++
16 arch/powerpc/kernel/security.c | 21 +++++++++++++++++++++
17 2 files changed, 26 insertions(+)
18
19diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
20index 23ee67e279ae..862ebce3ae54 100644
21--- a/arch/powerpc/include/asm/setup.h
22+++ b/arch/powerpc/include/asm/setup.h
23@@ -65,6 +65,11 @@ void do_barrier_nospec_fixups_range(bool enable, void *start, void *end);
24 static inline void do_barrier_nospec_fixups_range(bool enable, void *start, void *end) { };
25 #endif
26
27+#ifdef CONFIG_PPC_FSL_BOOK3E
28+void setup_spectre_v2(void);
29+#else
30+static inline void setup_spectre_v2(void) {};
31+#endif
32 void do_btb_flush_fixups(void);
33
34 #endif /* !__ASSEMBLY__ */
35diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
36index fc41bccd9ab6..6dc5cdc2b87c 100644
37--- a/arch/powerpc/kernel/security.c
38+++ b/arch/powerpc/kernel/security.c
39@@ -27,6 +27,10 @@ static enum count_cache_flush_type count_cache_flush_type = COUNT_CACHE_FLUSH_NO
40
41 bool barrier_nospec_enabled;
42 static bool no_nospec;
43+static bool btb_flush_enabled;
44+#ifdef CONFIG_PPC_FSL_BOOK3E
45+static bool no_spectrev2;
46+#endif
47
48 static void enable_barrier_nospec(bool enable)
49 {
50@@ -102,6 +106,23 @@ static __init int barrier_nospec_debugfs_init(void)
51 device_initcall(barrier_nospec_debugfs_init);
52 #endif /* CONFIG_DEBUG_FS */
53
54+#ifdef CONFIG_PPC_FSL_BOOK3E
55+static int __init handle_nospectre_v2(char *p)
56+{
57+ no_spectrev2 = true;
58+
59+ return 0;
60+}
61+early_param("nospectre_v2", handle_nospectre_v2);
62+void setup_spectre_v2(void)
63+{
64+ if (no_spectrev2)
65+ do_btb_flush_fixups();
66+ else
67+ btb_flush_enabled = true;
68+}
69+#endif /* CONFIG_PPC_FSL_BOOK3E */
70+
71 #ifdef CONFIG_PPC_BOOK3S_64
72 ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf)
73 {
74--
752.19.1
76