]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/powerpc-pseries-use-the-security-flags-in-pseries_setup_rfi_flush.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / powerpc-pseries-use-the-security-flags-in-pseries_setup_rfi_flush.patch
1 From foo@baz Mon 29 Apr 2019 11:38:37 AM CEST
2 From: Michael Ellerman <mpe@ellerman.id.au>
3 Date: Mon, 22 Apr 2019 00:20:02 +1000
4 Subject: powerpc/pseries: Use the security flags in pseries_setup_rfi_flush()
5 To: stable@vger.kernel.org, gregkh@linuxfoundation.org
6 Cc: linuxppc-dev@ozlabs.org, diana.craciun@nxp.com, msuchanek@suse.de, npiggin@gmail.com, christophe.leroy@c-s.fr
7 Message-ID: <20190421142037.21881-18-mpe@ellerman.id.au>
8
9 From: Michael Ellerman <mpe@ellerman.id.au>
10
11 commit 2e4a16161fcd324b1f9bf6cb6856529f7eaf0689 upstream.
12
13 Now that we have the security flags we can simplify the code in
14 pseries_setup_rfi_flush() because the security flags have pessimistic
15 defaults.
16
17 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 ---
20 arch/powerpc/platforms/pseries/setup.c | 27 ++++++++++++---------------
21 1 file changed, 12 insertions(+), 15 deletions(-)
22
23 --- a/arch/powerpc/platforms/pseries/setup.c
24 +++ b/arch/powerpc/platforms/pseries/setup.c
25 @@ -541,30 +541,27 @@ void pseries_setup_rfi_flush(void)
26 bool enable;
27 long rc;
28
29 - /* Enable by default */
30 - enable = true;
31 - types = L1D_FLUSH_FALLBACK;
32 -
33 rc = plpar_get_cpu_characteristics(&result);
34 - if (rc == H_SUCCESS) {
35 + if (rc == H_SUCCESS)
36 init_cpu_char_feature_flags(&result);
37
38 - if (result.character & H_CPU_CHAR_L1D_FLUSH_TRIG2)
39 - types |= L1D_FLUSH_MTTRIG;
40 - if (result.character & H_CPU_CHAR_L1D_FLUSH_ORI30)
41 - types |= L1D_FLUSH_ORI;
42 -
43 - if ((!(result.behaviour & H_CPU_BEHAV_L1D_FLUSH_PR)) ||
44 - (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY)))
45 - enable = false;
46 - }
47 -
48 /*
49 * We're the guest so this doesn't apply to us, clear it to simplify
50 * handling of it elsewhere.
51 */
52 security_ftr_clear(SEC_FTR_L1D_FLUSH_HV);
53
54 + types = L1D_FLUSH_FALLBACK;
55 +
56 + if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_TRIG2))
57 + types |= L1D_FLUSH_MTTRIG;
58 +
59 + if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_ORI30))
60 + types |= L1D_FLUSH_ORI;
61 +
62 + enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && \
63 + security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR);
64 +
65 setup_rfi_flush(types, enable);
66 }
67