From a1cae31c1c34661bbd172d9e555e71521ce863cd Mon Sep 17 00:00:00 2001
From: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Date: Wed, 10 Jan 2018 23:40:07 +0530
Subject: [PATCH 16/26] UBUNTU: SAUCE: rfi-flush: Fix kernel package build
 using bootmem

CVE-2017-5754

This introduces functional changes, see comment in file.

Build error:

    arch/powerpc/kernel/setup_64.c: In function 'init_fallback_flush':
    arch/powerpc/kernel/setup_64.c:823:6: error: the address of 'l1d_flush_fallback_area' will always evaluate as 'true' [-Werror=address]
      if (l1d_flush_fallback_area)
          ^
    cc1: all warnings being treated as errors
    make[1]: *** [arch/powerpc/kernel/setup_64.o] Error 1

Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 arch/powerpc/kernel/setup_64.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index d9ca1c6..f7956b3 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -778,16 +778,16 @@ static bool init_fallback_flush(void)
 	u64 l1d_size;
 	int cpu;
 
-	if (l1d_flush_fallback_area)
-		return true;
-
 	/*
-	 * Once the slab allocator is up it's too late to allocate the fallback
-	 * flush area, so return an error. This could happen if we migrated from
-	 * a patched machine to an unpatched machine.
+	 * On distros using bootmem, l1d_flush_fallback area is always allocated
+	 * (in BSS) and valid, so skip the checks for l1d_flush_fallback_area and
+	 * slab_is_available().
+	 *
+	 * Possibly it's not even needed to do any of the rest of this function
+	 *  _again_ (can anything set below can changed after LPM/other system?),
+	 * but keep it simple and don't try to different first from future calls,
+	 * just run it again in that case.
 	 */
-	if (slab_is_available())
-		return false;
 
 	l1d_size = ppc64_caches.dsize;
 
-- 
2.7.4

