Skip to content

Commit 3031480

Browse files
Larhzutorvalds
authored andcommitted
x86: support XZ-compressed kernel
This integrates the XZ decompression code to the x86 pre-boot code. mkpiggy.c is updated to reserve about 32 KiB more buffer safety margin for kernel decompression. It is done unconditionally for all decompressors to keep the code simpler. The XZ decompressor needs around 30 KiB of heap, so the heap size is increased to 32 KiB on both x86-32 and x86-64. Documentation/x86/boot.txt is updated to list the XZ magic number. With the x86 BCJ filter in XZ, XZ-compressed x86 kernel tends to be a few percent smaller than the equivalent LZMA-compressed kernel. Signed-off-by: Lasse Collin <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Alain Knaff <[email protected]> Cc: Albin Tonnerre <[email protected]> Cc: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3ebe124 commit 3031480

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

Documentation/x86/boot.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,9 @@ Protocol: 2.08+
622622
The payload may be compressed. The format of both the compressed and
623623
uncompressed data should be determined using the standard magic
624624
numbers. The currently supported compression formats are gzip
625-
(magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A) and LZMA
626-
(magic number 5D 00). The uncompressed payload is currently always ELF
627-
(magic number 7F 45 4C 46).
625+
(magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), LZMA
626+
(magic number 5D 00), and XZ (magic number FD 37). The uncompressed
627+
payload is currently always ELF (magic number 7F 45 4C 46).
628628

629629
Field name: payload_length
630630
Type: read

arch/x86/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ config X86
5151
select HAVE_KERNEL_GZIP
5252
select HAVE_KERNEL_BZIP2
5353
select HAVE_KERNEL_LZMA
54+
select HAVE_KERNEL_XZ
5455
select HAVE_KERNEL_LZO
5556
select HAVE_HW_BREAKPOINT
5657
select HAVE_MIXED_BREAKPOINTS_REGS

arch/x86/boot/compressed/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# create a compressed vmlinux image from the original vmlinux
55
#
66

7-
targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.lzo head_$(BITS).o misc.o string.o cmdline.o early_serial_console.o piggy.o
7+
targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo head_$(BITS).o misc.o string.o cmdline.o early_serial_console.o piggy.o
88

99
KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
1010
KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
@@ -49,12 +49,15 @@ $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
4949
$(call if_changed,bzip2)
5050
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
5151
$(call if_changed,lzma)
52+
$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
53+
$(call if_changed,xzkern)
5254
$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
5355
$(call if_changed,lzo)
5456

5557
suffix-$(CONFIG_KERNEL_GZIP) := gz
5658
suffix-$(CONFIG_KERNEL_BZIP2) := bz2
5759
suffix-$(CONFIG_KERNEL_LZMA) := lzma
60+
suffix-$(CONFIG_KERNEL_XZ) := xz
5861
suffix-$(CONFIG_KERNEL_LZO) := lzo
5962

6063
quiet_cmd_mkpiggy = MKPIGGY $@

arch/x86/boot/compressed/misc.c

+4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ static int lines, cols;
139139
#include "../../../../lib/decompress_unlzma.c"
140140
#endif
141141

142+
#ifdef CONFIG_KERNEL_XZ
143+
#include "../../../../lib/decompress_unxz.c"
144+
#endif
145+
142146
#ifdef CONFIG_KERNEL_LZO
143147
#include "../../../../lib/decompress_unlzo.c"
144148
#endif

arch/x86/boot/compressed/mkpiggy.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
7474

7575
offs = (olen > ilen) ? olen - ilen : 0;
7676
offs += olen >> 12; /* Add 8 bytes for each 32K block */
77-
offs += 32*1024 + 18; /* Add 32K + 18 bytes slack */
77+
offs += 64*1024 + 128; /* Add 64K + 128 bytes slack */
7878
offs = (offs+4095) & ~4095; /* Round to a 4K boundary */
7979

8080
printf(".section \".rodata..compressed\",\"a\",@progbits\n");

arch/x86/include/asm/boot.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@
3232
#define BOOT_HEAP_SIZE 0x400000
3333
#else /* !CONFIG_KERNEL_BZIP2 */
3434

35-
#ifdef CONFIG_X86_64
36-
#define BOOT_HEAP_SIZE 0x7000
37-
#else
38-
#define BOOT_HEAP_SIZE 0x4000
39-
#endif
35+
#define BOOT_HEAP_SIZE 0x8000
4036

4137
#endif /* !CONFIG_KERNEL_BZIP2 */
4238

0 commit comments

Comments
 (0)