From 4d877002df95d0d4f47f5cc19f560c5509f97fa9 Mon Sep 17 00:00:00 2001
From: Nicholas Piggin <npiggin@gmail.com>
Date: Mon, 8 Jan 2018 21:40:57 +0530
Subject: [PATCH 04/26] UBUNTU: SAUCE: rfi-flush: Fallback flush add load
 dependency

CVE-2017-5754

Add a data dependency on loads for the fallback flush. This
reduces or eliminates instances of incomplete flushing on P8 and
P9.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 arch/powerpc/kernel/exceptions-64s.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 3b73dbb..5271bee 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -681,8 +681,8 @@ rfi_flush_fallback:
 	.rept	8 /* 8-way set associative */
 	ldx	r11,r10,r8
 	add	r8,r8,r12
+	add	r8,r8,r11 /* r11 will be 0, but this creates a dependency */
 	.endr
-	lwsync	/* Ensure that we do all 8 sets before others */
 	addi	r10,r10,128 /* 128 byte cache line */
 	bdnz	1b
 
@@ -723,8 +723,8 @@ hrfi_flush_fallback:
 	.rept	8 /* 8-way set associative */
 	ldx	r11,r10,r8
 	add	r8,r8,r12
+	add	r8,r8,r11 /* r11 will be 0, but this creates a dependency */
 	.endr
-	lwsync	/* Ensure that we do all 8 sets before others */
 	addi	r10,r10,128 /* 128 byte cache line */
 	bdnz	1b
 
-- 
2.7.4

