Re: [PATCH] lib/xz: Fix powerpc build with KERNEL_XZ

From: Christophe LEROY
Date: Wed Sep 19 2018 - 02:52:42 EST

Le 19/09/2018 Ã 08:44, Oliver a ÃcritÂ:
On Wed, Sep 19, 2018 at 3:52 PM, Christophe LEROY
<christophe.leroy@xxxxxx> wrote:

Le 19/09/2018 Ã 01:07, Joel Stanley a Ãcrit :

This partially reverts faa16bc404d72a5 ("lib: Use existing define with

The cleanup added a dependency on include/linux, which broke the PowerPC
boot wrapper/decompresser when KERNEL_XZ is enabled:

BOOTCC arch/powerpc/boot/decompress.o
In file included from
from arch/powerpc/boot/decompress.c:42:
arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
linux/crc32poly.h: No such file or directory
#include <linux/crc32poly.h>

The powerpc decompressor is a hairy corner of the kernel. Even while
a 64-bit kernel it needs to build a 32-bit binary and therefore avoid
files from include/linux.

Fixes: faa16bc404d7 ("lib: Use existing define with polynomial")
Signed-off-by: Joel Stanley <joel@xxxxxxxxx>
We need to clean up the powerpc boot decompresser but that work will be
more involved than we would include in a late -rc. Please consider
merging this fix for 4.19. Thanks!

lib/xz/xz_crc32.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
index 25a5d87e2e4c..34532d14fd4c 100644
--- a/lib/xz/xz_crc32.c
+++ b/lib/xz/xz_crc32.c
@@ -15,7 +15,6 @@
* but they are bigger and use more memory for the lookup table.
-#include <linux/crc32poly.h>
#include "xz_private.h"
@@ -30,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256];
XZ_EXTERN void xz_crc32_init(void)
- const uint32_t poly = CRC32_POLY_LE;
+ const uint32_t poly = 0xEDB88320;

Maybe avoid capital letters ?

What about adding something like the following in xz_private.h instead:

#define CRC32_POLY_LE 0xedb88320

The problem is that it's pulling in linux/crc32poly.h. To support old
systems with a 32bit Open Firmware we boot wrapper we build the boot
wrapper as a 32bit ELF even for a 64 bit kernel. The headers generated
by Kbuild are only valid for the 64bit kernel so we have to avoid
pulling them into the boot wrapper.

Yes I understood, hence my proposal to redefine CRC32_POLY_LE in xz_private.h instead of including linux/crc32poly.h

It avoids modifying the C code.



uint32_t i;
uint32_t j;