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:00 +1000
4 Subject: powerpc/64s: Enhance the information in cpu_show_meltdown()
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-16-mpe@ellerman.id.au>
9 From: Michael Ellerman <mpe@ellerman.id.au>
11 commit ff348355e9c72493947be337bb4fae4fc1a41eba upstream.
13 Now that we have the security feature flags we can make the
14 information displayed in the "meltdown" file more informative.
16 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 arch/powerpc/include/asm/security_features.h | 1
20 arch/powerpc/kernel/security.c | 30 +++++++++++++++++++++++++--
21 2 files changed, 29 insertions(+), 2 deletions(-)
23 --- a/arch/powerpc/include/asm/security_features.h
24 +++ b/arch/powerpc/include/asm/security_features.h
28 extern unsigned long powerpc_security_features;
29 +extern bool rfi_flush;
31 static inline void security_ftr_set(unsigned long feature)
33 --- a/arch/powerpc/kernel/security.c
34 +++ b/arch/powerpc/kernel/security.c
37 #include <linux/kernel.h>
38 #include <linux/device.h>
39 +#include <linux/seq_buf.h>
41 #include <asm/security_features.h>
43 @@ -19,8 +20,33 @@ unsigned long powerpc_security_features
45 ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf)
48 - return sprintf(buf, "Mitigation: RFI Flush\n");
51 + thread_priv = security_ftr_enabled(SEC_FTR_L1D_THREAD_PRIV);
53 + if (rfi_flush || thread_priv) {
55 + seq_buf_init(&s, buf, PAGE_SIZE - 1);
57 + seq_buf_printf(&s, "Mitigation: ");
60 + seq_buf_printf(&s, "RFI Flush");
62 + if (rfi_flush && thread_priv)
63 + seq_buf_printf(&s, ", ");
66 + seq_buf_printf(&s, "L1D private per thread");
68 + seq_buf_printf(&s, "\n");
73 + if (!security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV) &&
74 + !security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR))
75 + return sprintf(buf, "Not affected\n");
77 return sprintf(buf, "Vulnerable\n");