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>
9 From: Michael Ellerman <mpe@ellerman.id.au>
11 commit 2e4a16161fcd324b1f9bf6cb6856529f7eaf0689 upstream.
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
17 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 arch/powerpc/platforms/pseries/setup.c | 27 ++++++++++++---------------
21 1 file changed, 12 insertions(+), 15 deletions(-)
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)
29 - /* Enable by default */
31 - types = L1D_FLUSH_FALLBACK;
33 rc = plpar_get_cpu_characteristics(&result);
34 - if (rc == H_SUCCESS) {
35 + if (rc == H_SUCCESS)
36 init_cpu_char_feature_flags(&result);
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;
43 - if ((!(result.behaviour & H_CPU_BEHAV_L1D_FLUSH_PR)) ||
44 - (!(result.behaviour & H_CPU_BEHAV_FAVOUR_SECURITY)))
49 * We're the guest so this doesn't apply to us, clear it to simplify
50 * handling of it elsewhere.
52 security_ftr_clear(SEC_FTR_L1D_FLUSH_HV);
54 + types = L1D_FLUSH_FALLBACK;
56 + if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_TRIG2))
57 + types |= L1D_FLUSH_MTTRIG;
59 + if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_ORI30))
60 + types |= L1D_FLUSH_ORI;
62 + enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && \
63 + security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR);
65 setup_rfi_flush(types, enable);