Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/boot: Add support for XZ compression

This patch adds an option to use XZ compression for the kernel image.

Currently this is only enabled for 64-bit Book3S targets, which is
roughly equivalent to the platforms that use the kernel's zImage
wrapper, and that have been tested.

The bulk of the 32-bit platforms and 64-bit BookE use uboot images,
which relies on uboot implementing XZ. In future we can enable XZ
support for those targets once someone has tested it.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Oliver O'Halloran and committed by
Michael Ellerman
c762c69e f1e510bb

+89
+3
arch/powerpc/boot/Makefile
··· 20 20 all: $(obj)/zImage 21 21 22 22 compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP 23 + compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ 23 24 24 25 BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 25 26 -fno-strict-aliasing -Os -msoft-float -pipe \ ··· 227 226 endif 228 227 229 228 compressor-$(CONFIG_KERNEL_GZIP) := gz 229 + compressor-$(CONFIG_KERNEL_XZ) := xz 230 230 231 231 # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd 232 232 quiet_cmd_wrap = WRAP $@ ··· 435 433 # clean up files cached by wrapper 436 434 clean-kernel-base := vmlinux.strip vmlinux.bin 437 435 clean-kernel := $(addsuffix .gz,$(clean-kernel-base)) 436 + clean-kernel += $(addsuffix .xz,$(clean-kernel-base)) 438 437 # If not absolute clean-files are relative to $(obj). 439 438 clean-files += $(addprefix $(objtree)/, $(clean-kernel)) 440 439
+5
arch/powerpc/boot/decompress.c
··· 37 37 # include "decompress_inflate.c" 38 38 #endif 39 39 40 + #ifdef CONFIG_KERNEL_XZ 41 + # include "xz_config.h" 42 + # include "../../../lib/decompress_unxz.c" 43 + #endif 44 + 40 45 /* globals for tracking the state of the decompression */ 41 46 static unsigned long decompressed_bytes; 42 47 static unsigned long limit;
+14
arch/powerpc/boot/stdbool.h
··· 1 + /* 2 + * Copyright (C) IBM Corporation 2016. 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License 6 + * as published by the Free Software Foundation; either version 7 + * 2 of the License, or (at your option) any later version. 8 + * 9 + * This file is only necessary because some of the pre-boot decompressors 10 + * expect stdbool.h to be available. 11 + * 12 + */ 13 + 14 + #include "types.h"
+13
arch/powerpc/boot/stdint.h
··· 1 + /* 2 + * Copyright (C) IBM Corporation 2016. 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License 6 + * as published by the Free Software Foundation; either version 7 + * 2 of the License, or (at your option) any later version. 8 + * 9 + * This file is only necessary because some of the pre-boot decompressors 10 + * expect stdint.h to be available. 11 + */ 12 + 13 + #include "types.h"
+14
arch/powerpc/boot/types.h
··· 1 1 #ifndef _TYPES_H_ 2 2 #define _TYPES_H_ 3 3 4 + #include <stdbool.h> 5 + 4 6 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 5 7 6 8 typedef unsigned char u8; ··· 36 34 (void) (&_x == &_y); \ 37 35 _x > _y ? _x : _y; }) 38 36 37 + #define min_t(type, a, b) min(((type) a), ((type) b)) 38 + #define max_t(type, a, b) max(((type) a), ((type) b)) 39 + 40 + typedef int bool; 41 + 42 + #ifndef true 43 + #define true 1 44 + #endif 45 + 46 + #ifndef false 47 + #define false 0 48 + #endif 39 49 #endif /* _TYPES_H_ */
+39
arch/powerpc/boot/xz_config.h
··· 1 + #ifndef __XZ_CONFIG_H__ 2 + #define __XZ_CONFIG_H__ 3 + 4 + /* 5 + * most of this is copied from lib/xz/xz_private.h, we can't use their defines 6 + * since the boot wrapper is not built in the same environment as the rest of 7 + * the kernel. 8 + */ 9 + 10 + #include "types.h" 11 + #include "swab.h" 12 + 13 + static inline uint32_t swab32p(void *p) 14 + { 15 + uint32_t *q = p; 16 + 17 + return swab32(*q); 18 + } 19 + 20 + #ifdef __LITTLE_ENDIAN__ 21 + #define get_le32(p) (*((uint32_t *) (p))) 22 + #else 23 + #define get_le32(p) swab32p(p) 24 + #endif 25 + 26 + #define memeq(a, b, size) (memcmp(a, b, size) == 0) 27 + #define memzero(buf, size) memset(buf, 0, size) 28 + 29 + /* prevent the inclusion of the xz-preboot MM headers */ 30 + #define DECOMPR_MM_H 31 + #define memmove memmove 32 + #define XZ_EXTERN static 33 + 34 + /* xz.h needs to be included directly since we need enum xz_mode */ 35 + #include "../../../include/linux/xz.h" 36 + 37 + #undef XZ_EXTERN 38 + 39 + #endif
+1
arch/powerpc/platforms/Kconfig.cputype
··· 74 74 select HAVE_ARCH_TRANSPARENT_HUGEPAGE 75 75 select ARCH_SUPPORTS_NUMA_BALANCING 76 76 select IRQ_WORK 77 + select HAVE_KERNEL_XZ 77 78 78 79 config PPC_BOOK3E_64 79 80 bool "Embedded processors"