]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.43/0025-powerpc-speculation-Support-mitigations-cmdline-opti.patch
Linux 5.0.16
[thirdparty/kernel/stable-queue.git] / releases / 4.19.43 / 0025-powerpc-speculation-Support-mitigations-cmdline-opti.patch
1 From 1caa66c02b21ad771c6bfa38327c68ba308a633d Mon Sep 17 00:00:00 2001
2 From: Josh Poimboeuf <jpoimboe@redhat.com>
3 Date: Fri, 12 Apr 2019 15:39:30 -0500
4 Subject: [PATCH 25/30] powerpc/speculation: Support 'mitigations=' cmdline
5 option
6
7 commit 782e69efb3dfed6e8360bc612e8c7827a901a8f9 upstream
8
9 Configure powerpc CPU runtime speculation bug mitigations in accordance
10 with the 'mitigations=' cmdline option. This affects Meltdown, Spectre
11 v1, Spectre v2, and Speculative Store Bypass.
12
13 The default behavior is unchanged.
14
15 Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
16 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
17 Tested-by: Jiri Kosina <jkosina@suse.cz> (on x86)
18 Reviewed-by: Jiri Kosina <jkosina@suse.cz>
19 Cc: Borislav Petkov <bp@alien8.de>
20 Cc: "H . Peter Anvin" <hpa@zytor.com>
21 Cc: Andy Lutomirski <luto@kernel.org>
22 Cc: Peter Zijlstra <peterz@infradead.org>
23 Cc: Jiri Kosina <jikos@kernel.org>
24 Cc: Waiman Long <longman@redhat.com>
25 Cc: Andrea Arcangeli <aarcange@redhat.com>
26 Cc: Jon Masters <jcm@redhat.com>
27 Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
28 Cc: Paul Mackerras <paulus@samba.org>
29 Cc: Michael Ellerman <mpe@ellerman.id.au>
30 Cc: linuxppc-dev@lists.ozlabs.org
31 Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
32 Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
33 Cc: linux-s390@vger.kernel.org
34 Cc: Catalin Marinas <catalin.marinas@arm.com>
35 Cc: Will Deacon <will.deacon@arm.com>
36 Cc: linux-arm-kernel@lists.infradead.org
37 Cc: linux-arch@vger.kernel.org
38 Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
39 Cc: Tyler Hicks <tyhicks@canonical.com>
40 Cc: Linus Torvalds <torvalds@linux-foundation.org>
41 Cc: Randy Dunlap <rdunlap@infradead.org>
42 Cc: Steven Price <steven.price@arm.com>
43 Cc: Phil Auld <pauld@redhat.com>
44 Link: https://lkml.kernel.org/r/245a606e1a42a558a310220312d9b6adb9159df6.1555085500.git.jpoimboe@redhat.com
45 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
46 ---
47 Documentation/admin-guide/kernel-parameters.txt | 9 +++++----
48 arch/powerpc/kernel/security.c | 6 +++---
49 arch/powerpc/kernel/setup_64.c | 2 +-
50 3 files changed, 9 insertions(+), 8 deletions(-)
51
52 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
53 index 31c17532c219..49aa191979c1 100644
54 --- a/Documentation/admin-guide/kernel-parameters.txt
55 +++ b/Documentation/admin-guide/kernel-parameters.txt
56 @@ -2503,7 +2503,7 @@
57 http://repo.or.cz/w/linux-2.6/mini2440.git
58
59 mitigations=
60 - [X86] Control optional mitigations for CPU
61 + [X86,PPC] Control optional mitigations for CPU
62 vulnerabilities. This is a set of curated,
63 arch-independent options, each of which is an
64 aggregation of existing arch-specific options.
65 @@ -2512,10 +2512,11 @@
66 Disable all optional CPU mitigations. This
67 improves system performance, but it may also
68 expose users to several CPU vulnerabilities.
69 - Equivalent to: nopti [X86]
70 - nospectre_v2 [X86]
71 + Equivalent to: nopti [X86,PPC]
72 + nospectre_v1 [PPC]
73 + nospectre_v2 [X86,PPC]
74 spectre_v2_user=off [X86]
75 - spec_store_bypass_disable=off [X86]
76 + spec_store_bypass_disable=off [X86,PPC]
77 l1tf=off [X86]
78
79 auto (default)
80 diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
81 index 1341325599a7..4ccbf611a3c5 100644
82 --- a/arch/powerpc/kernel/security.c
83 +++ b/arch/powerpc/kernel/security.c
84 @@ -56,7 +56,7 @@ void setup_barrier_nospec(void)
85 enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) &&
86 security_ftr_enabled(SEC_FTR_BNDS_CHK_SPEC_BAR);
87
88 - if (!no_nospec)
89 + if (!no_nospec && !cpu_mitigations_off())
90 enable_barrier_nospec(enable);
91 }
92
93 @@ -115,7 +115,7 @@ static int __init handle_nospectre_v2(char *p)
94 early_param("nospectre_v2", handle_nospectre_v2);
95 void setup_spectre_v2(void)
96 {
97 - if (no_spectrev2)
98 + if (no_spectrev2 || cpu_mitigations_off())
99 do_btb_flush_fixups();
100 else
101 btb_flush_enabled = true;
102 @@ -299,7 +299,7 @@ void setup_stf_barrier(void)
103
104 stf_enabled_flush_types = type;
105
106 - if (!no_stf_barrier)
107 + if (!no_stf_barrier && !cpu_mitigations_off())
108 stf_barrier_enable(enable);
109 }
110
111 diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
112 index faf00222b324..eaf7300be5ab 100644
113 --- a/arch/powerpc/kernel/setup_64.c
114 +++ b/arch/powerpc/kernel/setup_64.c
115 @@ -955,7 +955,7 @@ void setup_rfi_flush(enum l1d_flush_type types, bool enable)
116
117 enabled_flush_types = types;
118
119 - if (!no_rfi_flush)
120 + if (!no_rfi_flush && !cpu_mitigations_off())
121 rfi_flush_enable(enable);
122 }
123
124 --
125 2.21.0
126