From 506c21c9c040adbf5577d0cbc23b21e694b9954e Mon Sep 17 00:00:00 2001
From: Michael Ellerman <mpe@ellerman.id.au>
Date: Wed, 10 Jan 2018 23:37:18 +0530
Subject: [PATCH 13/26] UBUNTU: SAUCE: rfi-flush: Call setup_rfi_flush() after
 LPM migration

CVE-2017-5754

We might have migrated to a machine that uses a different flush type,
or doesn't need flushing at all.

If we migrate to a machine with no flush support, ie. that would use
fallback, we just print an error and switch flushing off. We could
support that, but it would complicate the implementation of the
fallback flush, and we don't expect anyone will ever do it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
[mauricfo:
 - pseries.h: adjust context lines
 - setup.c: hunk 1 adjust context lines, hunk 2 s/overridden/overriden/]
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 arch/powerpc/platforms/pseries/mobility.c | 3 +++
 arch/powerpc/platforms/pseries/pseries.h  | 2 ++
 arch/powerpc/platforms/pseries/setup.c    | 4 ++--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index bf38292..be314fd 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -317,6 +317,9 @@ void post_mobility_fixup(void)
 		return;
 	}
 
+	/* Possibly switch to a new RFI flush type */
+	pseries_setup_rfi_flush();
+
 	return;
 }
 
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 9921953..7e06b531 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -64,4 +64,6 @@ extern int dlpar_detach_node(struct device_node *);
 struct pci_host_bridge;
 int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
 
+void pseries_setup_rfi_flush(void);
+
 #endif /* _PSERIES_PSERIES_H */
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 7cd0e13..4ba19f9 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -468,7 +468,7 @@ static long pseries_little_endian_exceptions(void)
 }
 #endif
 
-static void pSeries_setup_rfi_flush(void)
+void pSeries_setup_rfi_flush(void)
 {
 	unsigned long character, behaviour, rc;
 	enum l1d_flush_type types;
@@ -516,7 +516,7 @@ static void __init pSeries_setup_arch(void)
 
 	fwnmi_init();
 
-	pSeries_setup_rfi_flush();
+	pseries_setup_rfi_flush();
 
 	/* By default, only probe PCI (can be overriden by rtas_pci) */
 	pci_add_flags(PCI_PROBE_ONLY);
-- 
2.7.4

