stages/2: 03-iso: exclude more source directories
[dragora.git] / patches / kernel / linux-4.9.36_lzip-1.diff
blob502ccf83a881f478b7df2c7234edbbaa034412aa
1 diff -urdN linux-4.9.36/.gitignore linux-4.9.36.new/.gitignore
2 --- linux-4.9.36/.gitignore 2017-07-05 14:40:44.000000000 +0200
3 +++ linux-4.9.36.new/.gitignore 2017-07-11 12:26:28.000000000 +0200
4 @@ -27,6 +27,7 @@
5 *.tar
6 *.gz
7 *.bz2
8 +*.lz
9 *.lzma
10 *.xz
11 *.lz4
12 diff -urdN linux-4.9.36/Documentation/00-INDEX linux-4.9.36.new/Documentation/00-INDEX
13 --- linux-4.9.36/Documentation/00-INDEX 2017-07-05 14:40:44.000000000 +0200
14 +++ linux-4.9.36.new/Documentation/00-INDEX 2017-07-11 12:26:28.000000000 +0200
15 @@ -294,6 +294,8 @@
16 - full colour GIF image of Linux logo (penguin - Tux).
17 logo.txt
18 - info on creator of above logo & site to get additional images from.
19 +lzip.txt
20 + - info on lzip compression for the linux kernel.
21 lzo.txt
22 - kernel LZO decompressor input formats
23 m68k/
24 diff -urdN linux-4.9.36/Documentation/dontdiff linux-4.9.36.new/Documentation/dontdiff
25 --- linux-4.9.36/Documentation/dontdiff 2017-07-05 14:40:44.000000000 +0200
26 +++ linux-4.9.36.new/Documentation/dontdiff 2017-07-11 12:26:28.000000000 +0200
27 @@ -26,6 +26,7 @@
28 *.ll
29 *.log
30 *.lst
31 +*.lz
32 *.lzma
33 *.lzo
34 *.mo
35 diff -urdN linux-4.9.36/Documentation/lzip.txt linux-4.9.36.new/Documentation/lzip.txt
36 --- linux-4.9.36/Documentation/lzip.txt 1970-01-01 01:00:00.000000000 +0100
37 +++ linux-4.9.36.new/Documentation/lzip.txt 2017-04-19 18:57:52.000000000 +0200
38 @@ -0,0 +1,46 @@
40 +Lzip data compression in Linux
41 +==============================
43 +Linux already offers a lot of compression formats. Then, why lzip?
45 +Because lzip is the only gzip-like LZMA compressor featuring a
46 +well-designed format:
48 + * Lzma-alone is a toy format lacking integrity checking or even a
49 + proper header.
51 + * Xz has a complex and not properly designed format[1]. It can
52 + compress the kernel image a little more than lzip on some
53 + architectures (about 4% on x86) by using a different binary filter
54 + for each architecture. But this increase in complexity does not
55 + improve the decompression time (much less the boot time) compared
56 + with lzip.
58 + Also the xz compressor is the only one needing special options to
59 + compress data for linux, and xz decompression is the only one that
60 + may fail because of wrong options used at compression time.
62 + [1] See http://www.nongnu.org/lzip/xz_inadequate.html
64 +I have the hope that lzma-alone and xz will be eventually abandoned in
65 +favor of lzip.
67 +Lzip-compressed kernel images of multiple linux versions since 2.6.30.10
68 +have been built and tested, even on machines as modest as an AMD 486-DX2
69 +at 66 MHz with 64 MiB of RAM. In the worst case (on the slow machine
70 +above), lzip just increased the boot time a 15% compared with gzip. On
71 +more modern machines, lzip may boot slightly faster than gzip. It just
72 +takes 0.2 seconds for lzip to decompress vmlinuz-4.4.16 on my machine.
74 +One little-publicized fact is that, except on embedded systems with fast
75 +boot setups, decompression speed is not important in booting linux.
76 +Decompression time is usually a small fraction of the total boot time.
77 +For example, using lz4 on a desktop machine in order to save 0.05
78 +seconds of a total boot time of 20 seconds is probably not worth the
79 +increased image size.
81 +Learn more about lzip at http://www.nongnu.org/lzip/lzip.html
83 +Author: Antonio Diaz Diaz
84 +Updated: 2017-04-19
85 diff -urdN linux-4.9.36/Documentation/x86/boot.txt linux-4.9.36.new/Documentation/x86/boot.txt
86 --- linux-4.9.36/Documentation/x86/boot.txt 2017-07-05 14:40:44.000000000 +0200
87 +++ linux-4.9.36.new/Documentation/x86/boot.txt 2017-07-11 12:26:28.000000000 +0200
88 @@ -665,10 +665,10 @@
89 The payload may be compressed. The format of both the compressed and
90 uncompressed data should be determined using the standard magic
91 numbers. The currently supported compression formats are gzip
92 - (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), LZMA
93 - (magic number 5D 00), XZ (magic number FD 37), and LZ4 (magic number
94 - 02 21). The uncompressed payload is currently always ELF (magic
95 - number 7F 45 4C 46).
96 + (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), lzip
97 + (magic number 4C 5A), LZMA (magic number 5D 00), XZ (magic number FD
98 + 37), and LZ4 (magic number 02 21). The uncompressed payload is
99 + currently always ELF (magic number 7F 45 4C 46).
101 Field name: payload_length
102 Type: read
103 diff -urdN linux-4.9.36/Makefile linux-4.9.36.new/Makefile
104 --- linux-4.9.36/Makefile 2017-07-05 14:40:44.000000000 +0200
105 +++ linux-4.9.36.new/Makefile 2017-07-11 12:26:28.000000000 +0200
106 @@ -872,14 +872,17 @@
107 export mod_strip_cmd
109 # CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed
110 -# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP
111 -# or CONFIG_MODULE_COMPRESS_XZ.
112 +# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP,
113 +# CONFIG_MODULE_COMPRESS_LZIP or CONFIG_MODULE_COMPRESS_XZ.
115 mod_compress_cmd = true
116 ifdef CONFIG_MODULE_COMPRESS
117 ifdef CONFIG_MODULE_COMPRESS_GZIP
118 mod_compress_cmd = gzip -n -f
119 endif # CONFIG_MODULE_COMPRESS_GZIP
120 + ifdef CONFIG_MODULE_COMPRESS_LZIP
121 + mod_compress_cmd = lzip -f
122 + endif # CONFIG_MODULE_COMPRESS_LZIP
123 ifdef CONFIG_MODULE_COMPRESS_XZ
124 mod_compress_cmd = xz -f
125 endif # CONFIG_MODULE_COMPRESS_XZ
126 @@ -891,6 +894,7 @@
128 INITRD_COMPRESS-y := gzip
129 INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2
130 +INITRD_COMPRESS-$(CONFIG_RD_LZIP) := lzip
131 INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma
132 INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz
133 INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo
134 diff -urdN linux-4.9.36/arch/arm/Kconfig linux-4.9.36.new/arch/arm/Kconfig
135 --- linux-4.9.36/arch/arm/Kconfig 2017-07-05 14:40:44.000000000 +0200
136 +++ linux-4.9.36.new/arch/arm/Kconfig 2017-07-11 12:26:28.000000000 +0200
137 @@ -62,6 +62,7 @@
138 select HAVE_IRQ_TIME_ACCOUNTING
139 select HAVE_KERNEL_GZIP
140 select HAVE_KERNEL_LZ4
141 + select HAVE_KERNEL_LZIP
142 select HAVE_KERNEL_LZMA
143 select HAVE_KERNEL_LZO
144 select HAVE_KERNEL_XZ
145 diff -urdN linux-4.9.36/arch/arm/boot/compressed/Makefile linux-4.9.36.new/arch/arm/boot/compressed/Makefile
146 --- linux-4.9.36/arch/arm/boot/compressed/Makefile 2017-07-05 14:40:44.000000000 +0200
147 +++ linux-4.9.36.new/arch/arm/boot/compressed/Makefile 2017-07-11 12:26:28.000000000 +0200
148 @@ -67,6 +67,7 @@
149 CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
151 compress-$(CONFIG_KERNEL_GZIP) = gzip
152 +compress-$(CONFIG_KERNEL_LZIP) = klzip
153 compress-$(CONFIG_KERNEL_LZO) = lzo
154 compress-$(CONFIG_KERNEL_LZMA) = lzma
155 compress-$(CONFIG_KERNEL_XZ) = xzkern
156 diff -urdN linux-4.9.36/arch/arm/boot/compressed/decompress.c linux-4.9.36.new/arch/arm/boot/compressed/decompress.c
157 --- linux-4.9.36/arch/arm/boot/compressed/decompress.c 2017-07-05 14:40:44.000000000 +0200
158 +++ linux-4.9.36.new/arch/arm/boot/compressed/decompress.c 2017-07-11 12:26:28.000000000 +0200
159 @@ -37,6 +37,10 @@
160 #include "../../../../lib/decompress_inflate.c"
161 #endif
163 +#ifdef CONFIG_KERNEL_LZIP
164 +#include "../../../../lib/decompress_lunzip.c"
165 +#endif
167 #ifdef CONFIG_KERNEL_LZO
168 #include "../../../../lib/decompress_unlzo.c"
169 #endif
170 diff -urdN linux-4.9.36/arch/blackfin/Kconfig linux-4.9.36.new/arch/blackfin/Kconfig
171 --- linux-4.9.36/arch/blackfin/Kconfig 2017-07-05 14:40:44.000000000 +0200
172 +++ linux-4.9.36.new/arch/blackfin/Kconfig 2017-07-11 12:26:28.000000000 +0200
173 @@ -21,6 +21,7 @@
174 select HAVE_IDE
175 select HAVE_KERNEL_GZIP if RAMKERNEL
176 select HAVE_KERNEL_BZIP2 if RAMKERNEL
177 + select HAVE_KERNEL_LZIP if RAMKERNEL
178 select HAVE_KERNEL_LZMA if RAMKERNEL
179 select HAVE_KERNEL_LZO if RAMKERNEL
180 select HAVE_OPROFILE
181 diff -urdN linux-4.9.36/arch/blackfin/Makefile linux-4.9.36.new/arch/blackfin/Makefile
182 --- linux-4.9.36/arch/blackfin/Makefile 2017-07-05 14:40:44.000000000 +0200
183 +++ linux-4.9.36.new/arch/blackfin/Makefile 2017-07-11 12:26:28.000000000 +0200
184 @@ -141,7 +141,8 @@
186 INSTALL_PATH ?= /tftpboot
187 boot := arch/$(ARCH)/boot
188 -BOOT_TARGETS = uImage uImage.bin uImage.bz2 uImage.gz uImage.lzma uImage.lzo uImage.xip
189 +BOOT_TARGETS = uImage uImage.bin uImage.bz2 uImage.gz uImage.lz uImage.lzma \
190 + uImage.lzo uImage.xip
191 PHONY += $(BOOT_TARGETS) install
192 KBUILD_IMAGE := $(boot)/uImage
194 @@ -158,6 +159,7 @@
195 echo ' vmImage.bin - Uncompressed Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.bin)'
196 echo ' vmImage.bz2 - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.bz2)'
197 echo '* vmImage.gz - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.gz)'
198 + echo ' vmImage.lz - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.lz)'
199 echo ' vmImage.lzma - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.lzma)'
200 echo ' vmImage.lzo - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.lzo)'
201 echo ' vmImage.xip - XIP Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.xip)'
202 diff -urdN linux-4.9.36/arch/blackfin/boot/Makefile linux-4.9.36.new/arch/blackfin/boot/Makefile
203 --- linux-4.9.36/arch/blackfin/boot/Makefile 2017-07-05 14:40:44.000000000 +0200
204 +++ linux-4.9.36.new/arch/blackfin/boot/Makefile 2017-07-11 12:26:28.000000000 +0200
205 @@ -6,8 +6,10 @@
206 # for more details.
209 -targets := uImage uImage.bin uImage.bz2 uImage.gz uImage.lzma uImage.lzo uImage.xip
210 -extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.xip
211 +targets := uImage uImage.bin uImage.bz2 uImage.gz uImage.lz uImage.lzma \
212 + uImage.lzo uImage.xip
213 +extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
214 + vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.xip
216 ifeq ($(CONFIG_RAMKERNEL),y)
217 UIMAGE_LOADADDR = $(CONFIG_BOOT_LOAD)
218 @@ -27,6 +29,9 @@
219 $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
220 $(call if_changed,bzip2)
222 +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
223 + $(call if_changed,klzip)
225 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
226 $(call if_changed,lzma)
228 @@ -48,6 +53,9 @@
229 $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz
230 $(call if_changed,uimage,gzip)
232 +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz
233 + $(call if_changed,uimage,lzip)
235 $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma
236 $(call if_changed,uimage,lzma)
238 @@ -60,6 +68,7 @@
239 suffix-y := bin
240 suffix-$(CONFIG_KERNEL_GZIP) := gz
241 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
242 +suffix-$(CONFIG_KERNEL_LZIP) := lz
243 suffix-$(CONFIG_KERNEL_LZMA) := lzma
244 suffix-$(CONFIG_KERNEL_LZO) := lzo
245 suffix-$(CONFIG_ROMKERNEL) := xip
246 diff -urdN linux-4.9.36/arch/m32r/Kconfig linux-4.9.36.new/arch/m32r/Kconfig
247 --- linux-4.9.36/arch/m32r/Kconfig 2017-07-05 14:40:44.000000000 +0200
248 +++ linux-4.9.36.new/arch/m32r/Kconfig 2017-07-11 12:26:28.000000000 +0200
249 @@ -6,6 +6,7 @@
250 select INIT_ALL_POSSIBLE
251 select HAVE_KERNEL_GZIP
252 select HAVE_KERNEL_BZIP2
253 + select HAVE_KERNEL_LZIP
254 select HAVE_KERNEL_LZMA
255 select ARCH_WANT_IPC_PARSE_VERSION
256 select HAVE_DEBUG_BUGVERBOSE
257 diff -urdN linux-4.9.36/arch/m32r/boot/compressed/Makefile linux-4.9.36.new/arch/m32r/boot/compressed/Makefile
258 --- linux-4.9.36/arch/m32r/boot/compressed/Makefile 2017-07-05 14:40:44.000000000 +0200
259 +++ linux-4.9.36.new/arch/m32r/boot/compressed/Makefile 2017-07-11 12:26:28.000000000 +0200
260 @@ -4,8 +4,8 @@
261 # create a compressed vmlinux image from the original vmlinux
264 -targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
265 - vmlinux.bin.lzma head.o misc.o piggy.o vmlinux.lds
266 +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
267 + vmlinux.bin.lz vmlinux.bin.lzma head.o misc.o piggy.o vmlinux.lds
269 OBJECTS = $(obj)/head.o $(obj)/misc.o
271 @@ -29,6 +29,9 @@
272 $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
273 $(call if_changed,bzip2)
275 +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
276 + $(call if_changed,klzip)
278 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
279 $(call if_changed,lzma)
281 @@ -44,6 +47,7 @@
283 suffix-$(CONFIG_KERNEL_GZIP) = gz
284 suffix-$(CONFIG_KERNEL_BZIP2) = bz2
285 +suffix-$(CONFIG_KERNEL_LZIP) = lz
286 suffix-$(CONFIG_KERNEL_LZMA) = lzma
288 $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
289 diff -urdN linux-4.9.36/arch/m32r/boot/compressed/misc.c linux-4.9.36.new/arch/m32r/boot/compressed/misc.c
290 --- linux-4.9.36/arch/m32r/boot/compressed/misc.c 2017-07-05 14:40:44.000000000 +0200
291 +++ linux-4.9.36.new/arch/m32r/boot/compressed/misc.c 2017-07-11 12:26:28.000000000 +0200
292 @@ -38,7 +38,7 @@
294 #endif
296 -#ifdef CONFIG_KERNEL_GZIP
297 +#if defined(CONFIG_KERNEL_GZIP) || defined(CONFIG_KERNEL_LZIP)
298 void *memcpy(void *dest, const void *src, size_t n)
300 char *d = dest;
301 @@ -48,7 +48,9 @@
303 return dest;
305 +#endif
307 +#ifdef CONFIG_KERNEL_GZIP
308 #define BOOT_HEAP_SIZE 0x10000
309 #include "../../../../lib/decompress_inflate.c"
310 #endif
311 @@ -58,6 +60,11 @@
312 #include "../../../../lib/decompress_bunzip2.c"
313 #endif
315 +#ifdef CONFIG_KERNEL_LZIP
316 +#define BOOT_HEAP_SIZE 0x10000
317 +#include "../../../../lib/decompress_lunzip.c"
318 +#endif
320 #ifdef CONFIG_KERNEL_LZMA
321 #define BOOT_HEAP_SIZE 0x10000
322 #include "../../../../lib/decompress_unlzma.c"
323 diff -urdN linux-4.9.36/arch/metag/Kconfig linux-4.9.36.new/arch/metag/Kconfig
324 --- linux-4.9.36/arch/metag/Kconfig 2017-07-05 14:40:44.000000000 +0200
325 +++ linux-4.9.36.new/arch/metag/Kconfig 2017-07-11 12:26:28.000000000 +0200
326 @@ -16,6 +16,7 @@
327 select HAVE_FUNCTION_TRACER
328 select HAVE_KERNEL_BZIP2
329 select HAVE_KERNEL_GZIP
330 + select HAVE_KERNEL_LZIP
331 select HAVE_KERNEL_LZO
332 select HAVE_KERNEL_XZ
333 select HAVE_MEMBLOCK
334 diff -urdN linux-4.9.36/arch/metag/Makefile linux-4.9.36.new/arch/metag/Makefile
335 --- linux-4.9.36/arch/metag/Makefile 2017-07-05 14:40:44.000000000 +0200
336 +++ linux-4.9.36.new/arch/metag/Makefile 2017-07-11 12:26:28.000000000 +0200
337 @@ -56,6 +56,7 @@
338 boot_targets += uImage
339 boot_targets += uImage.gz
340 boot_targets += uImage.bz2
341 +boot_targets += uImage.lz
342 boot_targets += uImage.xz
343 boot_targets += uImage.lzo
344 boot_targets += uImage.bin
345 @@ -83,6 +84,7 @@
346 @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
347 @echo ' uImage.gz - Kernel-only image for U-Boot (gzip)'
348 @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
349 + @echo ' uImage.lz - Kernel-only image for U-Boot (lzip)'
350 @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
351 @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
352 @echo ' dtbs - Build device tree blobs for enabled boards'
353 diff -urdN linux-4.9.36/arch/metag/boot/Makefile linux-4.9.36.new/arch/metag/boot/Makefile
354 --- linux-4.9.36/arch/metag/boot/Makefile 2017-07-05 14:40:44.000000000 +0200
355 +++ linux-4.9.36.new/arch/metag/boot/Makefile 2017-07-11 12:26:28.000000000 +0200
356 @@ -9,6 +9,7 @@
357 suffix-y := bin
358 suffix-$(CONFIG_KERNEL_GZIP) := gz
359 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
360 +suffix-$(CONFIG_KERNEL_LZIP) := lz
361 suffix-$(CONFIG_KERNEL_XZ) := xz
362 suffix-$(CONFIG_KERNEL_LZO) := lzo
364 @@ -16,6 +17,7 @@
365 targets += uImage
366 targets += uImage.gz
367 targets += uImage.bz2
368 +targets += uImage.lz
369 targets += uImage.xz
370 targets += uImage.lzo
371 targets += uImage.bin
372 @@ -23,6 +25,7 @@
373 extra-y += vmlinux.bin
374 extra-y += vmlinux.bin.gz
375 extra-y += vmlinux.bin.bz2
376 +extra-y += vmlinux.bin.lz
377 extra-y += vmlinux.bin.xz
378 extra-y += vmlinux.bin.lzo
380 @@ -42,6 +45,9 @@
381 $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
382 $(call if_changed,bzip2)
384 +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
385 + $(call if_changed,klzip)
387 $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
388 $(call if_changed,xzkern)
390 @@ -54,6 +60,9 @@
391 $(obj)/uImage.bz2: $(obj)/vmlinux.bin.bz2 FORCE
392 $(call if_changed,uimage,bzip2)
394 +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz FORCE
395 + $(call if_changed,uimage,lzip)
397 $(obj)/uImage.xz: $(obj)/vmlinux.bin.xz FORCE
398 $(call if_changed,uimage,xz)
400 diff -urdN linux-4.9.36/arch/mips/Kconfig linux-4.9.36.new/arch/mips/Kconfig
401 --- linux-4.9.36/arch/mips/Kconfig 2017-07-05 14:40:44.000000000 +0200
402 +++ linux-4.9.36.new/arch/mips/Kconfig 2017-07-11 12:26:28.000000000 +0200
403 @@ -1815,6 +1815,7 @@
404 select HAVE_KERNEL_GZIP
405 select HAVE_KERNEL_BZIP2
406 select HAVE_KERNEL_LZ4
407 + select HAVE_KERNEL_LZIP
408 select HAVE_KERNEL_LZMA
409 select HAVE_KERNEL_LZO
410 select HAVE_KERNEL_XZ
411 diff -urdN linux-4.9.36/arch/mips/Makefile linux-4.9.36.new/arch/mips/Makefile
412 --- linux-4.9.36/arch/mips/Makefile 2017-07-05 14:40:44.000000000 +0200
413 +++ linux-4.9.36.new/arch/mips/Makefile 2017-07-11 12:26:28.000000000 +0200
414 @@ -306,12 +306,14 @@
415 boot-y += uImage.bin
416 boot-y += uImage.bz2
417 boot-y += uImage.gz
418 +boot-y += uImage.lz
419 boot-y += uImage.lzma
420 boot-y += uImage.lzo
421 endif
422 boot-y += vmlinux.itb
423 boot-y += vmlinux.gz.itb
424 boot-y += vmlinux.bz2.itb
425 +boot-y += vmlinux.lz.itb
426 boot-y += vmlinux.lzma.itb
427 boot-y += vmlinux.lzo.itb
429 @@ -431,6 +433,7 @@
430 echo ' uImage.bin - U-Boot image (uncompressed)'
431 echo ' uImage.bz2 - U-Boot image (bz2)'
432 echo ' uImage.gz - U-Boot image (gzip)'
433 + echo ' uImage.lz - U-Boot image (lzip)'
434 echo ' uImage.lzma - U-Boot image (lzma)'
435 echo ' uImage.lzo - U-Boot image (lzo)'
436 echo ' dtbs - Device-tree blobs for enabled boards'
437 diff -urdN linux-4.9.36/arch/mips/boot/Makefile linux-4.9.36.new/arch/mips/boot/Makefile
438 --- linux-4.9.36/arch/mips/boot/Makefile 2017-07-05 14:40:44.000000000 +0200
439 +++ linux-4.9.36.new/arch/mips/boot/Makefile 2017-07-06 23:19:25.000000000 +0200
440 @@ -26,6 +26,7 @@
441 suffix-y := bin
442 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
443 suffix-$(CONFIG_KERNEL_GZIP) := gz
444 +suffix-$(CONFIG_KERNEL_LZIP) := lz
445 suffix-$(CONFIG_KERNEL_LZMA) := lzma
446 suffix-$(CONFIG_KERNEL_LZO) := lzo
448 @@ -56,6 +57,7 @@
450 extra-y += vmlinux.bin.bz2
451 extra-y += vmlinux.bin.gz
452 +extra-y += vmlinux.bin.lz
453 extra-y += vmlinux.bin.lzma
454 extra-y += vmlinux.bin.lzo
456 @@ -65,6 +67,9 @@
457 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
458 $(call if_changed,gzip)
460 +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
461 + $(call if_changed,klzip)
463 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
464 $(call if_changed,lzma)
466 @@ -79,6 +84,7 @@
467 targets += uImage.bin
468 targets += uImage.bz2
469 targets += uImage.gz
470 +targets += uImage.lz
471 targets += uImage.lzma
472 targets += uImage.lzo
474 @@ -91,6 +97,9 @@
475 $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz FORCE
476 $(call if_changed,uimage,gzip)
478 +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz FORCE
479 + $(call if_changed,uimage,lzip)
481 $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma FORCE
482 $(call if_changed,uimage,lzma)
484 @@ -108,6 +117,7 @@
485 targets += vmlinux.itb
486 targets += vmlinux.gz.itb
487 targets += vmlinux.bz2.itb
488 +targets += vmlinux.lz.itb
489 targets += vmlinux.lzma.itb
490 targets += vmlinux.lzo.itb
492 @@ -137,6 +147,9 @@
493 $(obj)/vmlinux.bz2.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S $(VMLINUX) FORCE
494 $(call if_changed_dep,cpp_its_S,bzip2,vmlinux.bin.bz2)
496 +$(obj)/vmlinux.lz.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S $(VMLINUX) FORCE
497 + $(call if_changed_dep,cpp_its_S,lzip,vmlinux.bin.lz)
499 $(obj)/vmlinux.lzma.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S $(VMLINUX) FORCE
500 $(call if_changed_dep,cpp_its_S,lzma,vmlinux.bin.lzma)
502 @@ -161,6 +174,9 @@
503 $(obj)/vmlinux.bz2.itb: $(obj)/vmlinux.bz2.its $(obj)/vmlinux.bin.bz2 FORCE
504 $(call if_changed,itb-image,$<)
506 +$(obj)/vmlinux.lz.itb: $(obj)/vmlinux.lz.its $(obj)/vmlinux.bin.lz FORCE
507 + $(call if_changed,itb-image,$<)
509 $(obj)/vmlinux.lzma.itb: $(obj)/vmlinux.lzma.its $(obj)/vmlinux.bin.lzma FORCE
510 $(call if_changed,itb-image,$<)
512 diff -urdN linux-4.9.36/arch/mips/boot/compressed/Makefile linux-4.9.36.new/arch/mips/boot/compressed/Makefile
513 --- linux-4.9.36/arch/mips/boot/compressed/Makefile 2017-07-05 14:40:44.000000000 +0200
514 +++ linux-4.9.36.new/arch/mips/boot/compressed/Makefile 2017-07-11 12:26:28.000000000 +0200
515 @@ -61,6 +61,7 @@
516 tool_$(CONFIG_KERNEL_GZIP) = gzip
517 tool_$(CONFIG_KERNEL_BZIP2) = bzip2
518 tool_$(CONFIG_KERNEL_LZ4) = lz4
519 +tool_$(CONFIG_KERNEL_LZIP) = klzip
520 tool_$(CONFIG_KERNEL_LZMA) = lzma
521 tool_$(CONFIG_KERNEL_LZO) = lzo
522 tool_$(CONFIG_KERNEL_XZ) = xzkern
523 diff -urdN linux-4.9.36/arch/mips/boot/compressed/decompress.c linux-4.9.36.new/arch/mips/boot/compressed/decompress.c
524 --- linux-4.9.36/arch/mips/boot/compressed/decompress.c 2017-07-05 14:40:44.000000000 +0200
525 +++ linux-4.9.36.new/arch/mips/boot/compressed/decompress.c 2017-07-11 12:26:28.000000000 +0200
526 @@ -64,6 +64,10 @@
527 #include "../../../../lib/decompress_unlz4.c"
528 #endif
530 +#ifdef CONFIG_KERNEL_LZIP
531 +#include "../../../../lib/decompress_lunzip.c"
532 +#endif
534 #ifdef CONFIG_KERNEL_LZMA
535 #include "../../../../lib/decompress_unlzma.c"
536 #endif
537 diff -urdN linux-4.9.36/arch/s390/Kconfig linux-4.9.36.new/arch/s390/Kconfig
538 --- linux-4.9.36/arch/s390/Kconfig 2017-07-05 14:40:44.000000000 +0200
539 +++ linux-4.9.36.new/arch/s390/Kconfig 2017-07-11 12:26:28.000000000 +0200
540 @@ -147,6 +147,7 @@
541 select HAVE_KERNEL_BZIP2
542 select HAVE_KERNEL_GZIP
543 select HAVE_KERNEL_LZ4
544 + select HAVE_KERNEL_LZIP
545 select HAVE_KERNEL_LZMA
546 select HAVE_KERNEL_LZO
547 select HAVE_KERNEL_XZ
548 diff -urdN linux-4.9.36/arch/s390/boot/compressed/Makefile linux-4.9.36.new/arch/s390/boot/compressed/Makefile
549 --- linux-4.9.36/arch/s390/boot/compressed/Makefile 2017-07-05 14:40:44.000000000 +0200
550 +++ linux-4.9.36.new/arch/s390/boot/compressed/Makefile 2017-07-11 12:26:28.000000000 +0200
551 @@ -6,9 +6,9 @@
553 KCOV_INSTRUMENT := n
555 -targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
556 -targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
557 -targets += misc.o piggy.o sizes.h head.o
558 +targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
559 +targets += vmlinux.bin.lz vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo
560 +targets += vmlinux.bin.lz4 misc.o piggy.o sizes.h head.o
562 KBUILD_CFLAGS := -m64 -D__KERNEL__ $(LINUX_INCLUDE) -O2
563 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
564 @@ -49,6 +49,7 @@
565 suffix-$(CONFIG_KERNEL_GZIP) := gz
566 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
567 suffix-$(CONFIG_KERNEL_LZ4) := lz4
568 +suffix-$(CONFIG_KERNEL_LZIP) := lz
569 suffix-$(CONFIG_KERNEL_LZMA) := lzma
570 suffix-$(CONFIG_KERNEL_LZO) := lzo
571 suffix-$(CONFIG_KERNEL_XZ) := xz
572 @@ -59,6 +60,8 @@
573 $(call if_changed,bzip2)
574 $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
575 $(call if_changed,lz4)
576 +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y)
577 + $(call if_changed,klzip)
578 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
579 $(call if_changed,lzma)
580 $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
581 diff -urdN linux-4.9.36/arch/s390/boot/compressed/misc.c linux-4.9.36.new/arch/s390/boot/compressed/misc.c
582 --- linux-4.9.36/arch/s390/boot/compressed/misc.c 2017-07-05 14:40:44.000000000 +0200
583 +++ linux-4.9.36.new/arch/s390/boot/compressed/misc.c 2017-07-11 12:26:28.000000000 +0200
584 @@ -52,6 +52,10 @@
585 #include "../../../../lib/decompress_unlz4.c"
586 #endif
588 +#ifdef CONFIG_KERNEL_LZIP
589 +#include "../../../../lib/decompress_lunzip.c"
590 +#endif
592 #ifdef CONFIG_KERNEL_LZMA
593 #include "../../../../lib/decompress_unlzma.c"
594 #endif
595 diff -urdN linux-4.9.36/arch/sh/Kconfig linux-4.9.36.new/arch/sh/Kconfig
596 --- linux-4.9.36/arch/sh/Kconfig 2017-07-05 14:40:44.000000000 +0200
597 +++ linux-4.9.36.new/arch/sh/Kconfig 2017-07-11 12:26:28.000000000 +0200
598 @@ -22,6 +22,7 @@
599 select HAVE_KERNEL_GZIP
600 select CPU_NO_EFFICIENT_FFS
601 select HAVE_KERNEL_BZIP2
602 + select HAVE_KERNEL_LZIP
603 select HAVE_KERNEL_LZMA
604 select HAVE_KERNEL_XZ
605 select HAVE_KERNEL_LZO
606 diff -urdN linux-4.9.36/arch/sh/Makefile linux-4.9.36.new/arch/sh/Makefile
607 --- linux-4.9.36/arch/sh/Makefile 2017-07-05 14:40:44.000000000 +0200
608 +++ linux-4.9.36.new/arch/sh/Makefile 2017-07-11 12:26:28.000000000 +0200
609 @@ -206,9 +206,9 @@
610 libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
611 libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
613 -BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
614 - uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
615 - romImage
616 +BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lz uImage.lzma uImage.xz \
617 + uImage.lzo uImage.srec uImage.bin zImage vmlinux.bin \
618 + vmlinux.srec romImage
619 PHONY += $(BOOT_TARGETS)
621 all: $(KBUILD_IMAGE)
622 @@ -235,6 +235,7 @@
623 @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
624 @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)'
625 @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
626 + @echo ' uImage.lz - Kernel-only image for U-Boot (lzip)'
627 @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)'
628 @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
629 @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
630 diff -urdN linux-4.9.36/arch/sh/boot/Makefile linux-4.9.36.new/arch/sh/boot/Makefile
631 --- linux-4.9.36/arch/sh/boot/Makefile 2017-07-05 14:40:44.000000000 +0200
632 +++ linux-4.9.36.new/arch/sh/boot/Makefile 2017-07-11 12:26:28.000000000 +0200
633 @@ -22,14 +22,15 @@
634 suffix-y := bin
635 suffix-$(CONFIG_KERNEL_GZIP) := gz
636 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
637 +suffix-$(CONFIG_KERNEL_LZIP) := lz
638 suffix-$(CONFIG_KERNEL_LZMA) := lzma
639 suffix-$(CONFIG_KERNEL_XZ) := xz
640 suffix-$(CONFIG_KERNEL_LZO) := lzo
642 targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz \
643 - uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin
644 -extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
645 - vmlinux.bin.xz vmlinux.bin.lzo
646 + uImage.bz2 uImage.lz uImage.lzma uImage.xz uImage.lzo uImage.bin
647 +extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
648 + vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo
649 subdir- := compressed romimage
651 $(obj)/zImage: $(obj)/compressed/vmlinux FORCE
652 @@ -71,6 +72,9 @@
653 $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
654 $(call if_changed,bzip2)
656 +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
657 + $(call if_changed,klzip)
659 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
660 $(call if_changed,lzma)
662 @@ -86,6 +90,9 @@
663 $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz
664 $(call if_changed,uimage,gzip)
666 +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz
667 + $(call if_changed,uimage,lzip)
669 $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma
670 $(call if_changed,uimage,lzma)
672 diff -urdN linux-4.9.36/arch/sh/boot/compressed/Makefile linux-4.9.36.new/arch/sh/boot/compressed/Makefile
673 --- linux-4.9.36/arch/sh/boot/compressed/Makefile 2017-07-05 14:40:44.000000000 +0200
674 +++ linux-4.9.36.new/arch/sh/boot/compressed/Makefile 2017-07-11 12:26:28.000000000 +0200
675 @@ -4,10 +4,9 @@
676 # create a compressed vmlinux image from the original vmlinux
679 -targets := vmlinux vmlinux.bin vmlinux.bin.gz \
680 - vmlinux.bin.bz2 vmlinux.bin.lzma \
681 - vmlinux.bin.xz vmlinux.bin.lzo \
682 - head_$(BITS).o misc.o piggy.o
683 +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
684 + vmlinux.bin.lz vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo \
685 + head_$(BITS).o misc.o piggy.o
687 OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/cache.o
689 @@ -65,6 +64,8 @@
690 $(call if_changed,gzip)
691 $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
692 $(call if_changed,bzip2)
693 +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y) FORCE
694 + $(call if_changed,klzip)
695 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
696 $(call if_changed,lzma)
697 $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
698 diff -urdN linux-4.9.36/arch/sh/boot/compressed/misc.c linux-4.9.36.new/arch/sh/boot/compressed/misc.c
699 --- linux-4.9.36/arch/sh/boot/compressed/misc.c 2017-07-05 14:40:44.000000000 +0200
700 +++ linux-4.9.36.new/arch/sh/boot/compressed/misc.c 2017-07-11 12:26:28.000000000 +0200
701 @@ -57,6 +57,10 @@
702 #include "../../../../lib/decompress_bunzip2.c"
703 #endif
705 +#ifdef CONFIG_KERNEL_LZIP
706 +#include "../../../../lib/decompress_lunzip.c"
707 +#endif
709 #ifdef CONFIG_KERNEL_LZMA
710 #include "../../../../lib/decompress_unlzma.c"
711 #endif
712 diff -urdN linux-4.9.36/arch/unicore32/.gitignore linux-4.9.36.new/arch/unicore32/.gitignore
713 --- linux-4.9.36/arch/unicore32/.gitignore 2017-07-05 14:40:44.000000000 +0200
714 +++ linux-4.9.36.new/arch/unicore32/.gitignore 2017-07-11 12:26:28.000000000 +0200
715 @@ -17,5 +17,9 @@
717 boot/compressed/piggy.S
718 boot/compressed/piggy.gzip
719 +boot/compressed/piggy.bz2
720 +boot/compressed/piggy.lzip
721 +boot/compressed/piggy.lzma
722 +boot/compressed/piggy.lzo
723 boot/compressed/vmlinux
724 boot/compressed/vmlinux.lds
725 diff -urdN linux-4.9.36/arch/unicore32/Kconfig linux-4.9.36.new/arch/unicore32/Kconfig
726 --- linux-4.9.36/arch/unicore32/Kconfig 2017-07-05 14:40:44.000000000 +0200
727 +++ linux-4.9.36.new/arch/unicore32/Kconfig 2017-07-11 12:26:28.000000000 +0200
728 @@ -7,6 +7,7 @@
729 select HAVE_GENERIC_DMA_COHERENT
730 select HAVE_KERNEL_GZIP
731 select HAVE_KERNEL_BZIP2
732 + select HAVE_KERNEL_LZIP
733 select GENERIC_ATOMIC64
734 select HAVE_KERNEL_LZO
735 select HAVE_KERNEL_LZMA
736 diff -urdN linux-4.9.36/arch/unicore32/boot/compressed/Makefile linux-4.9.36.new/arch/unicore32/boot/compressed/Makefile
737 --- linux-4.9.36/arch/unicore32/boot/compressed/Makefile 2017-07-05 14:40:44.000000000 +0200
738 +++ linux-4.9.36.new/arch/unicore32/boot/compressed/Makefile 2017-07-11 12:26:28.000000000 +0200
739 @@ -23,6 +23,7 @@
740 # piggy.S and piggy.o
741 suffix_$(CONFIG_KERNEL_GZIP) := gzip
742 suffix_$(CONFIG_KERNEL_BZIP2) := bz2
743 +suffix_$(CONFIG_KERNEL_LZIP) := lzip
744 suffix_$(CONFIG_KERNEL_LZO) := lzo
745 suffix_$(CONFIG_KERNEL_LZMA) := lzma
747 @@ -36,10 +37,10 @@
748 $(obj)/piggy.o: $(obj)/piggy.$(suffix_y) $(obj)/piggy.S FORCE
750 targets := vmlinux vmlinux.lds font.o font.c head.o misc.o \
751 - piggy.$(suffix_y) piggy.o piggy.S \
752 + piggy.$(suffix_y) piggy.o piggy.S
754 # Make sure files are removed during clean
755 -extra-y += piggy.gzip piggy.bz2 piggy.lzo piggy.lzma
756 +extra-y += piggy.gzip piggy.bz2 piggy.lzip piggy.lzo piggy.lzma
759 LDFLAGS_vmlinux += -p
760 diff -urdN linux-4.9.36/arch/unicore32/boot/compressed/misc.c linux-4.9.36.new/arch/unicore32/boot/compressed/misc.c
761 --- linux-4.9.36/arch/unicore32/boot/compressed/misc.c 2017-07-05 14:40:44.000000000 +0200
762 +++ linux-4.9.36.new/arch/unicore32/boot/compressed/misc.c 2017-07-11 12:26:28.000000000 +0200
763 @@ -95,6 +95,10 @@
764 #include "../../../../lib/decompress_bunzip2.c"
765 #endif
767 +#ifdef CONFIG_KERNEL_LZIP
768 +#include "../../../../lib/decompress_lunzip.c"
769 +#endif
771 #ifdef CONFIG_KERNEL_LZO
772 #include "../../../../lib/decompress_unlzo.c"
773 #endif
774 diff -urdN linux-4.9.36/arch/x86/Kconfig linux-4.9.36.new/arch/x86/Kconfig
775 --- linux-4.9.36/arch/x86/Kconfig 2017-07-05 14:40:44.000000000 +0200
776 +++ linux-4.9.36.new/arch/x86/Kconfig 2017-07-11 12:26:28.000000000 +0200
777 @@ -122,6 +122,7 @@
778 select HAVE_KERNEL_BZIP2
779 select HAVE_KERNEL_GZIP
780 select HAVE_KERNEL_LZ4
781 + select HAVE_KERNEL_LZIP
782 select HAVE_KERNEL_LZMA
783 select HAVE_KERNEL_LZO
784 select HAVE_KERNEL_XZ
785 diff -urdN linux-4.9.36/arch/x86/boot/compressed/Makefile linux-4.9.36.new/arch/x86/boot/compressed/Makefile
786 --- linux-4.9.36/arch/x86/boot/compressed/Makefile 2017-07-05 14:40:44.000000000 +0200
787 +++ linux-4.9.36.new/arch/x86/boot/compressed/Makefile 2017-07-11 12:26:28.000000000 +0200
788 @@ -22,8 +22,8 @@
789 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
790 KCOV_INSTRUMENT := n
792 -targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
793 - vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
794 +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
795 + vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
797 KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
798 KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
799 @@ -124,6 +124,8 @@
800 $(call if_changed,gzip)
801 $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
802 $(call if_changed,bzip2)
803 +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y) FORCE
804 + $(call if_changed,klzip)
805 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
806 $(call if_changed,lzma)
807 $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
808 @@ -135,6 +137,7 @@
810 suffix-$(CONFIG_KERNEL_GZIP) := gz
811 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
812 +suffix-$(CONFIG_KERNEL_LZIP) := lz
813 suffix-$(CONFIG_KERNEL_LZMA) := lzma
814 suffix-$(CONFIG_KERNEL_XZ) := xz
815 suffix-$(CONFIG_KERNEL_LZO) := lzo
816 diff -urdN linux-4.9.36/arch/x86/boot/compressed/misc.c linux-4.9.36.new/arch/x86/boot/compressed/misc.c
817 --- linux-4.9.36/arch/x86/boot/compressed/misc.c 2017-07-05 14:40:44.000000000 +0200
818 +++ linux-4.9.36.new/arch/x86/boot/compressed/misc.c 2017-07-11 12:26:28.000000000 +0200
819 @@ -59,6 +59,10 @@
820 #include "../../../../lib/decompress_bunzip2.c"
821 #endif
823 +#ifdef CONFIG_KERNEL_LZIP
824 +#include "../../../../lib/decompress_lunzip.c"
825 +#endif
827 #ifdef CONFIG_KERNEL_LZMA
828 #include "../../../../lib/decompress_unlzma.c"
829 #endif
830 diff -urdN linux-4.9.36/arch/x86/boot/header.S linux-4.9.36.new/arch/x86/boot/header.S
831 --- linux-4.9.36/arch/x86/boot/header.S 2017-07-05 14:40:44.000000000 +0200
832 +++ linux-4.9.36.new/arch/x86/boot/header.S 2017-07-11 12:26:28.000000000 +0200
833 @@ -521,8 +521,22 @@
834 # the description in lib/decompressor_xxx.c for specific information.
836 # extra_bytes = (uncompressed_size >> 12) + 65536 + 128
838 +# Above analyses for decompressing gzip and xz compressed kernels do not
839 +# take into account the possibility of parallel compression creating
840 +# multimember (multistream) files. In the worst practical case for lzip
841 +# files (compressing with plzip and using the minimum block size of 8192
842 +# bytes), the safety margin needed is:
844 +# extra_bytes = (compressed_size >> 5) + 72
846 +# As (compressed_size >> 5) > (uncompressed_size >> 12) for compression
847 +# ratios below 128:1, the following safety margin should cover all
848 +# decompressors:
850 +# extra_bytes = (compressed_size >> 5) + 65536 + 128
852 -#define ZO_z_extra_bytes ((ZO_z_output_len >> 12) + 65536 + 128)
853 +#define ZO_z_extra_bytes ((ZO_z_input_len >> 5) + 65536 + 128)
854 #if ZO_z_output_len > ZO_z_input_len
855 # define ZO_z_extract_offset (ZO_z_output_len + ZO_z_extra_bytes - \
856 ZO_z_input_len)
857 diff -urdN linux-4.9.36/include/linux/decompress/lunzip.h linux-4.9.36.new/include/linux/decompress/lunzip.h
858 --- linux-4.9.36/include/linux/decompress/lunzip.h 1970-01-01 01:00:00.000000000 +0100
859 +++ linux-4.9.36.new/include/linux/decompress/lunzip.h 2016-08-24 18:49:48.000000000 +0200
860 @@ -0,0 +1,10 @@
861 +#ifndef LINUX_DECOMPRESS_LUNZIP_H
862 +#define LINUX_DECOMPRESS_LUNZIP_H
864 +int lunzip(unsigned char *inbuf, long in_len,
865 + long (*fill)(void*, unsigned long),
866 + long (*flush)(void*, unsigned long),
867 + unsigned char *outbuf,
868 + long *in_posp,
869 + void (*error)(char *x));
870 +#endif
871 diff -urdN linux-4.9.36/init/Kconfig linux-4.9.36.new/init/Kconfig
872 --- linux-4.9.36/init/Kconfig 2017-07-05 14:40:44.000000000 +0200
873 +++ linux-4.9.36.new/init/Kconfig 2017-07-11 12:26:28.000000000 +0200
874 @@ -115,6 +115,9 @@
875 config HAVE_KERNEL_BZIP2
876 bool
878 +config HAVE_KERNEL_LZIP
879 + bool
881 config HAVE_KERNEL_LZMA
882 bool
884 @@ -130,7 +133,7 @@
885 choice
886 prompt "Kernel compression mode"
887 default KERNEL_GZIP
888 - depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
889 + depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZIP || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
890 help
891 The linux kernel is a kind of self-extracting executable.
892 Several compression algorithms are available, which differ
893 @@ -166,6 +169,15 @@
894 Bzip2 uses a large amount of memory. For modern kernels you
895 will need at least 8MB RAM or more for booting.
897 +config KERNEL_LZIP
898 + bool "Lzip"
899 + depends on HAVE_KERNEL_LZIP
900 + help
901 + Lzip's compression ratio is better than that of gzip and bzip2.
902 + Decompression speed is between gzip and bzip2. Compression can
903 + be as fast as gzip or slower than bzip2 depending on compression
904 + level. Lzip can produce a kernel about a 16% smaller than gzip.
906 config KERNEL_LZMA
907 bool "LZMA"
908 depends on HAVE_KERNEL_LZMA
909 @@ -2046,8 +2058,8 @@
910 depends on MODULES
911 help
913 - Compresses kernel modules when 'make modules_install' is run; gzip or
914 - xz depending on "Compression algorithm" below.
915 + Compresses kernel modules when 'make modules_install' is run; gzip,
916 + lzip or xz are used depending on "Compression algorithm" below.
918 module-init-tools MAY support gzip, and kmod MAY support gzip and xz.
920 @@ -2069,11 +2081,14 @@
921 This determines which sort of compression will be used during
922 'make modules_install'.
924 - GZIP (default) and XZ are supported.
925 + GZIP (default), LZIP and XZ are supported.
927 config MODULE_COMPRESS_GZIP
928 bool "GZIP"
930 +config MODULE_COMPRESS_LZIP
931 + bool "LZIP"
933 config MODULE_COMPRESS_XZ
934 bool "XZ"
936 diff -urdN linux-4.9.36/init/do_mounts_rd.c linux-4.9.36.new/init/do_mounts_rd.c
937 --- linux-4.9.36/init/do_mounts_rd.c 2017-07-05 14:40:44.000000000 +0200
938 +++ linux-4.9.36.new/init/do_mounts_rd.c 2017-07-11 12:26:28.000000000 +0200
939 @@ -58,6 +58,7 @@
940 * squashfs
941 * gzip
942 * bzip2
943 + * lzip
944 * lzma
945 * xz
946 * lzo
947 diff -urdN linux-4.9.36/lib/Kconfig linux-4.9.36.new/lib/Kconfig
948 --- linux-4.9.36/lib/Kconfig 2017-07-05 14:40:44.000000000 +0200
949 +++ linux-4.9.36.new/lib/Kconfig 2017-07-11 12:26:28.000000000 +0200
950 @@ -252,6 +252,9 @@
951 config DECOMPRESS_BZIP2
952 tristate
954 +config DECOMPRESS_LZIP
955 + tristate
957 config DECOMPRESS_LZMA
958 tristate
960 diff -urdN linux-4.9.36/lib/Makefile linux-4.9.36.new/lib/Makefile
961 --- linux-4.9.36/lib/Makefile 2017-07-05 14:40:44.000000000 +0200
962 +++ linux-4.9.36.new/lib/Makefile 2017-07-11 12:26:28.000000000 +0200
963 @@ -111,6 +111,7 @@
965 lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
966 lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
967 +lib-$(CONFIG_DECOMPRESS_LZIP) += decompress_lunzip.o
968 lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
969 lib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
970 lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
971 diff -urdN linux-4.9.36/lib/decompress.c linux-4.9.36.new/lib/decompress.c
972 --- linux-4.9.36/lib/decompress.c 2017-07-05 14:40:44.000000000 +0200
973 +++ linux-4.9.36.new/lib/decompress.c 2017-07-11 12:26:28.000000000 +0200
974 @@ -7,6 +7,7 @@
975 #include <linux/decompress/generic.h>
977 #include <linux/decompress/bunzip2.h>
978 +#include <linux/decompress/lunzip.h>
979 #include <linux/decompress/unlzma.h>
980 #include <linux/decompress/unxz.h>
981 #include <linux/decompress/inflate.h>
982 @@ -24,6 +25,9 @@
983 #ifndef CONFIG_DECOMPRESS_BZIP2
984 # define bunzip2 NULL
985 #endif
986 +#ifndef CONFIG_DECOMPRESS_LZIP
987 +# define lunzip NULL
988 +#endif
989 #ifndef CONFIG_DECOMPRESS_LZMA
990 # define unlzma NULL
991 #endif
992 @@ -47,6 +51,7 @@
993 { {0x1f, 0x8b}, "gzip", gunzip },
994 { {0x1f, 0x9e}, "gzip", gunzip },
995 { {0x42, 0x5a}, "bzip2", bunzip2 },
996 + { {0x4c, 0x5a}, "lzip", lunzip },
997 { {0x5d, 0x00}, "lzma", unlzma },
998 { {0xfd, 0x37}, "xz", unxz },
999 { {0x89, 0x4c}, "lzo", unlzo },
1000 diff -urdN linux-4.9.36/lib/decompress_lunzip.c linux-4.9.36.new/lib/decompress_lunzip.c
1001 --- linux-4.9.36/lib/decompress_lunzip.c 1970-01-01 01:00:00.000000000 +0100
1002 +++ linux-4.9.36.new/lib/decompress_lunzip.c 2017-04-21 19:28:30.000000000 +0200
1003 @@ -0,0 +1,795 @@
1005 + * lunzip implementation for linux
1007 + * Copyright (C) 2016, 2017 Antonio Diaz Diaz.
1009 + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
1010 + */
1012 +#ifdef STATIC
1013 +#define PREBOOT
1014 +#else
1015 +#include <linux/decompress/lunzip.h>
1016 +#endif
1018 +#include <linux/decompress/mm.h>
1020 +typedef int State;
1022 +enum { states = 12 };
1024 +static inline bool St_is_char(const State st) { return st < 7; }
1026 +static inline State St_set_char(const State st)
1028 + static const State next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
1029 + return next[st];
1032 +static inline State St_set_match(const State st)
1034 + return ((st < 7) ? 7 : 10);
1037 +static inline State St_set_rep(const State st)
1039 + return ((st < 7) ? 8 : 11);
1042 +static inline State St_set_short_rep(const State st)
1044 + return ((st < 7) ? 9 : 11);
1048 +enum {
1049 + min_dictionary_bits = 12,
1050 + min_dictionary_size = 1 << min_dictionary_bits,
1051 + max_dictionary_bits = 29,
1052 + max_dictionary_size = 1 << max_dictionary_bits,
1053 + literal_context_bits = 3,
1054 + pos_state_bits = 2,
1055 + pos_states = 1 << pos_state_bits,
1056 + pos_state_mask = pos_states - 1,
1058 + len_states = 4,
1059 + dis_slot_bits = 6,
1060 + start_dis_model = 4,
1061 + end_dis_model = 14,
1062 + modeled_distances = 1 << (end_dis_model / 2), /* 128 */
1063 + dis_align_bits = 4,
1064 + dis_align_size = 1 << dis_align_bits,
1066 + len_low_bits = 3,
1067 + len_mid_bits = 3,
1068 + len_high_bits = 8,
1069 + len_low_symbols = 1 << len_low_bits,
1070 + len_mid_symbols = 1 << len_mid_bits,
1071 + len_high_symbols = 1 << len_high_bits,
1072 + max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols,
1074 + min_match_len = 2, /* must be 2 */
1075 + max_match_len = min_match_len + max_len_symbols - 1, /* 273 */
1076 + min_match_len_limit = 5
1079 +static inline int get_len_state(const int len)
1081 + return min(len - min_match_len, len_states - 1);
1084 +static inline int get_lit_state(const uint8_t prev_byte)
1086 + return (prev_byte >> (8 - literal_context_bits));
1090 +enum { bit_model_move_bits = 5,
1091 + bit_model_total_bits = 11,
1092 + bit_model_total = 1 << bit_model_total_bits
1095 +typedef uint16_t Bit_model;
1097 +static inline void Bm_init(Bit_model * const probability)
1099 + *probability = bit_model_total / 2;
1102 +static inline void Bm_array_init(Bit_model * const p, const int size)
1104 + int i = 0;
1106 + while (i < size)
1107 + p[i++] = bit_model_total / 2;
1110 +struct Len_model {
1111 + Bit_model choice1;
1112 + Bit_model choice2;
1113 + Bit_model bm_low[pos_states][len_low_symbols];
1114 + Bit_model bm_mid[pos_states][len_mid_symbols];
1115 + Bit_model bm_high[len_high_symbols];
1118 +static inline void Lm_init(struct Len_model * const lm)
1120 + Bm_init(&lm->choice1);
1121 + Bm_init(&lm->choice2);
1122 + Bm_array_init(lm->bm_low[0], pos_states * len_low_symbols);
1123 + Bm_array_init(lm->bm_mid[0], pos_states * len_mid_symbols);
1124 + Bm_array_init(lm->bm_high, len_high_symbols);
1128 +typedef uint32_t CRC32[256]; /* Table of CRCs of all 8-bit messages. */
1130 +static CRC32 crc32;
1132 +static inline void CRC32_init(void)
1134 + unsigned n;
1136 + for (n = 0; n < 256; ++n) {
1137 + unsigned c = n;
1138 + int k;
1140 + for (k = 0; k < 8; ++k) {
1141 + if (c & 1)
1142 + c = 0xEDB88320U ^ (c >> 1);
1143 + else
1144 + c >>= 1;
1146 + crc32[n] = c;
1150 +static inline void CRC32_update_buf(uint32_t * const crc,
1151 + const uint8_t * const buffer,
1152 + const long size)
1154 + long i;
1155 + uint32_t c = *crc;
1157 + for (i = 0; i < size; ++i)
1158 + c = crc32[(c^buffer[i])&0xFF] ^ (c >> 8);
1159 + *crc = c;
1163 +static const uint8_t magic_string[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
1165 +typedef uint8_t File_header[6]; /* 0-3 magic bytes */
1166 + /* 4 version */
1167 + /* 5 coded_dict_size */
1168 +enum { Fh_size = 6 };
1170 +static inline bool Fh_verify_magic(const File_header data)
1172 + int i;
1174 + for (i = 0; i < 4; ++i)
1175 + if (data[i] != magic_string[i])
1176 + return false;
1177 + return (data[4] == 1);
1180 +static inline unsigned Fh_get_dictionary_size(const File_header data)
1182 + unsigned sz = (1 << (data[5] & 0x1F));
1184 + if (sz > min_dictionary_size)
1185 + sz -= (sz / 16) * ((data[5] >> 5) & 7);
1186 + return sz;
1190 +typedef uint8_t File_trailer[20];
1191 + /* 0-3 CRC32 of the uncompressed data */
1192 + /* 4-11 size of the uncompressed data */
1193 + /* 12-19 member size including header and trailer */
1195 +enum { Ft_size = 20 };
1197 +static inline unsigned Ft_get_data_crc(const File_trailer data)
1199 + unsigned tmp = 0;
1200 + int i;
1202 + for (i = 3; i >= 0; --i) {
1203 + tmp <<= 8;
1204 + tmp += data[i];
1206 + return tmp;
1209 +static inline unsigned long long Ft_get_data_size(const File_trailer data)
1211 + unsigned long long tmp = 0;
1212 + int i;
1214 + for (i = 11; i >= 4; --i) {
1215 + tmp <<= 8;
1216 + tmp += data[i];
1218 + return tmp;
1221 +static inline unsigned long long Ft_get_member_size(const File_trailer data)
1223 + unsigned long long tmp = 0;
1224 + int i;
1226 + for (i = 19; i >= 12; --i) {
1227 + tmp <<= 8;
1228 + tmp += data[i];
1230 + return tmp;
1234 +struct Range_decoder {
1235 + unsigned long long partial_member_pos;
1236 + uint8_t *buffer; /* input buffer */
1237 + long buffer_size;
1238 + long pos; /* current pos in buffer */
1239 + long stream_pos; /* when reached, a new block must be read */
1240 + uint32_t code;
1241 + uint32_t range;
1242 + long (*fill)(void*, unsigned long);
1243 + bool at_stream_end;
1244 + bool buffer_given;
1248 +static bool Rd_read_block(struct Range_decoder * const rdec)
1250 + if (!rdec->at_stream_end) {
1251 + rdec->stream_pos = rdec->fill ?
1252 + rdec->fill(rdec->buffer, rdec->buffer_size) : 0;
1253 + rdec->at_stream_end = (rdec->stream_pos < rdec->buffer_size);
1254 + rdec->partial_member_pos += rdec->pos;
1255 + rdec->pos = 0;
1257 + return rdec->pos < rdec->stream_pos;
1261 +static bool Rd_init(struct Range_decoder * const rdec, uint8_t * const inbuf,
1262 + const long in_len, long (*fill)(void*, unsigned long))
1264 + rdec->partial_member_pos = 0;
1265 + rdec->buffer_size = (inbuf && in_len > 0) ? in_len : 16384;
1266 + rdec->buffer = inbuf ? inbuf : malloc(rdec->buffer_size);
1267 + if (!rdec->buffer)
1268 + return false;
1269 + rdec->pos = 0;
1270 + rdec->stream_pos = (inbuf && in_len > 0) ? in_len : 0;
1271 + rdec->code = 0;
1272 + rdec->range = 0xFFFFFFFFU;
1273 + rdec->fill = fill;
1274 + rdec->at_stream_end = false;
1275 + rdec->buffer_given = (inbuf != 0);
1276 + return true;
1279 +static inline void Rd_free(struct Range_decoder * const rdec)
1281 + if (!rdec->buffer_given)
1282 + free(rdec->buffer);
1285 +static inline bool Rd_finished(struct Range_decoder * const rdec)
1287 + return rdec->pos >= rdec->stream_pos && !Rd_read_block(rdec);
1290 +static inline unsigned long long
1291 +Rd_member_position(const struct Range_decoder * const rdec)
1293 + return rdec->partial_member_pos + rdec->pos;
1296 +static inline void Rd_reset_member_position(struct Range_decoder * const rdec)
1298 + rdec->partial_member_pos = 0; rdec->partial_member_pos -= rdec->pos;
1301 +static inline uint8_t Rd_get_byte(struct Range_decoder * const rdec)
1303 + /* 0xFF avoids decoder error if member is truncated at EOS marker */
1304 + if (Rd_finished(rdec))
1305 + return 0xFF;
1306 + return rdec->buffer[rdec->pos++];
1309 +static void Rd_load(struct Range_decoder * const rdec)
1311 + int i;
1313 + rdec->code = 0;
1314 + for (i = 0; i < 5; ++i)
1315 + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
1316 + rdec->range = 0xFFFFFFFFU;
1319 +static inline void Rd_normalize(struct Range_decoder * const rdec)
1321 + if (rdec->range <= 0x00FFFFFFU) {
1322 + rdec->range <<= 8;
1323 + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
1327 +static uint32_t Rd_decode(struct Range_decoder * const rdec,
1328 + const uint32_t num_bits)
1330 + uint32_t symbol = 0;
1331 + uint32_t i;
1333 + for (i = num_bits; i > 0; --i) {
1334 + bool bit;
1336 + Rd_normalize(rdec);
1337 + rdec->range >>= 1;
1338 + /* symbol <<= 1; */
1339 + /* if(rdec->code >= rdec->range) { rdec->code -= rdec->range; symbol |= 1; } */
1340 + bit = (rdec->code >= rdec->range);
1341 + symbol = (symbol << 1) + bit;
1342 + rdec->code -= rdec->range & (0U - bit);
1344 + return symbol;
1347 +static inline uint32_t Rd_decode_bit(struct Range_decoder * const rdec,
1348 + Bit_model * const probability)
1350 + uint32_t bound;
1352 + Rd_normalize(rdec);
1353 + bound = (rdec->range >> bit_model_total_bits) * *probability;
1354 + if (rdec->code < bound) {
1355 + rdec->range = bound;
1356 + *probability += (bit_model_total - *probability) >> bit_model_move_bits;
1357 + return 0;
1358 + } else {
1359 + rdec->range -= bound;
1360 + rdec->code -= bound;
1361 + *probability -= *probability >> bit_model_move_bits;
1362 + return 1;
1366 +static inline uint32_t Rd_decode_tree(struct Range_decoder * const rdec,
1367 + Bit_model bm[], const uint32_t num_bits)
1369 + uint32_t symbol = 1;
1370 + uint32_t i;
1372 + for (i = num_bits; i > 0; --i)
1373 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1374 + return symbol - (1 << num_bits);
1377 +static inline uint32_t Rd_decode_tree_reversed(struct Range_decoder * const rdec,
1378 + Bit_model bm[], const uint32_t num_bits)
1380 + uint32_t model = 1;
1381 + uint32_t symbol = 0;
1382 + uint32_t i;
1384 + for (i = 0; i < num_bits; ++i) {
1385 + const uint32_t bit = Rd_decode_bit(rdec, &bm[model]);
1387 + model = (model << 1) + bit;
1388 + symbol |= (bit << i);
1390 + return symbol;
1393 +static uint32_t Rd_decode_matched(struct Range_decoder * const rdec,
1394 + Bit_model bm[], uint32_t match_byte)
1396 + uint32_t symbol = 1;
1397 + uint32_t mask = 0x100;
1399 + while (true) {
1400 + const uint32_t match_bit = (match_byte <<= 1) & mask;
1401 + const uint32_t bit = Rd_decode_bit(rdec, &bm[symbol+match_bit+mask]);
1403 + symbol = (symbol << 1) + bit;
1404 + if (symbol > 0xFF)
1405 + return symbol & 0xFF;
1406 + mask &= ~(match_bit ^ (bit << 8)); /* if( match_bit != bit ) mask = 0; */
1410 +static inline uint32_t Rd_decode_len(struct Range_decoder * const rdec,
1411 + struct Len_model * const lm,
1412 + const int pos_state)
1414 + if (Rd_decode_bit(rdec, &lm->choice1) == 0)
1415 + return Rd_decode_tree(rdec, lm->bm_low[pos_state], len_low_bits);
1416 + if (Rd_decode_bit(rdec, &lm->choice2) == 0)
1417 + return len_low_symbols +
1418 + Rd_decode_tree(rdec, lm->bm_mid[pos_state], len_mid_bits);
1419 + return len_low_symbols + len_mid_symbols +
1420 + Rd_decode_tree(rdec, lm->bm_high, len_high_bits);
1424 +struct LZ_decoder {
1425 + unsigned long long partial_data_pos;
1426 + struct Range_decoder *rdec;
1427 + /* Don't move bm_* to LZd_decode_member; makes frame too large. */
1428 + Bit_model bm_literal[1 << literal_context_bits][0x300];
1429 + Bit_model bm_match[states][pos_states];
1430 + Bit_model bm_rep[states];
1431 + Bit_model bm_rep0[states];
1432 + Bit_model bm_rep1[states];
1433 + Bit_model bm_rep2[states];
1434 + Bit_model bm_len[states][pos_states];
1435 + Bit_model bm_dis_slot[len_states][1 << dis_slot_bits];
1436 + Bit_model bm_dis[modeled_distances-end_dis_model+1];
1437 + Bit_model bm_align[dis_align_size];
1438 + struct Len_model match_len_model;
1439 + struct Len_model rep_len_model;
1441 + unsigned long buffer_size;
1442 + uint32_t dictionary_size;
1443 + uint8_t *buffer; /* output buffer */
1444 + unsigned long pos; /* current pos in buffer */
1445 + unsigned long stream_pos; /* first byte not yet written to file */
1446 + uint32_t crc;
1447 + long (*flush)(void*, unsigned long);
1448 + bool pos_wrapped;
1449 + bool buffer_given;
1450 + bool write_error;
1453 +static void LZd_flush_data(struct LZ_decoder * const d)
1455 + if (d->pos > d->stream_pos) {
1456 + const long size = d->pos - d->stream_pos;
1458 + CRC32_update_buf(&d->crc, d->buffer + d->stream_pos, size);
1459 + if ((d->flush &&
1460 + d->flush(d->buffer + d->stream_pos, size) != size) ||
1461 + (!d->flush && d->pos_wrapped))
1462 + d->write_error = true;
1463 + if (d->pos >= d->buffer_size) {
1464 + d->partial_data_pos += d->pos;
1465 + d->pos = 0;
1466 + d->pos_wrapped = true;
1468 + d->stream_pos = d->pos;
1472 +static inline uint8_t LZd_peek_prev(const struct LZ_decoder * const d)
1474 + if (d->pos > 0)
1475 + return d->buffer[d->pos-1];
1476 + if (d->pos_wrapped)
1477 + return d->buffer[d->buffer_size-1];
1478 + return 0; /* prev_byte of first byte */
1481 +static inline uint8_t LZd_peek(const struct LZ_decoder * const d,
1482 + const uint32_t distance)
1484 + const unsigned long i = ((d->pos > distance) ? 0 : d->buffer_size) +
1485 + d->pos - distance - 1;
1486 + return d->buffer[i];
1489 +static inline void LZd_put_byte(struct LZ_decoder * const d, const uint8_t b)
1491 + d->buffer[d->pos] = b;
1492 + if (++d->pos >= d->buffer_size)
1493 + LZd_flush_data(d);
1496 +static void LZd_copy_block(struct LZ_decoder * const d,
1497 + const uint32_t distance, uint32_t len)
1499 + unsigned long lpos = d->pos, i = lpos - distance - 1;
1500 + bool fast, fast2;
1502 + if (lpos > distance) {
1503 + fast = (len < d->buffer_size - lpos);
1504 + fast2 = (fast && len <= lpos - i);
1505 + } else {
1506 + i += d->buffer_size;
1507 + fast = (len < d->buffer_size - i); /* (i == pos) may happen */
1508 + fast2 = (fast && len <= i - lpos);
1510 + if (fast) { /* no wrap */
1511 + d->pos += len;
1512 + if (fast2) /* no wrap, no overlap */
1513 + memcpy(d->buffer + lpos, d->buffer + i, len);
1514 + else
1515 + for (; len > 0; --len)
1516 + d->buffer[lpos++] = d->buffer[i++];
1517 + } else
1518 + for (; len > 0; --len) {
1519 + d->buffer[d->pos] = d->buffer[i];
1520 + if (++d->pos >= d->buffer_size)
1521 + LZd_flush_data(d);
1522 + if (++i >= d->buffer_size)
1523 + i = 0;
1527 +static bool LZd_init(struct LZ_decoder * const d,
1528 + struct Range_decoder * const rde,
1529 + const uint32_t dict_size, uint8_t * const outbuf,
1530 + long out_size, long (*flush)(void*, unsigned long))
1532 + d->partial_data_pos = 0;
1533 + d->rdec = rde;
1534 + Bm_array_init(d->bm_literal[0], (1 << literal_context_bits) * 0x300);
1535 + Bm_array_init(d->bm_match[0], states * pos_states);
1536 + Bm_array_init(d->bm_rep, states);
1537 + Bm_array_init(d->bm_rep0, states);
1538 + Bm_array_init(d->bm_rep1, states);
1539 + Bm_array_init(d->bm_rep2, states);
1540 + Bm_array_init(d->bm_len[0], states * pos_states);
1541 + Bm_array_init(d->bm_dis_slot[0], len_states * (1 << dis_slot_bits));
1542 + Bm_array_init(d->bm_dis, modeled_distances - end_dis_model + 1);
1543 + Bm_array_init(d->bm_align, dis_align_size);
1544 + Lm_init(&d->match_len_model);
1545 + Lm_init(&d->rep_len_model);
1547 + d->buffer_size = (outbuf && out_size > 0) ? out_size : dict_size;
1548 + d->dictionary_size = min_t(unsigned long, d->buffer_size, dict_size);
1549 + d->buffer = outbuf ? outbuf : large_malloc(d->buffer_size);
1550 + if (!d->buffer)
1551 + return false;
1552 + d->pos = 0;
1553 + d->stream_pos = 0;
1554 + d->crc = 0xFFFFFFFFU;
1555 + d->flush = flush;
1556 + d->pos_wrapped = false;
1557 + d->buffer_given = (outbuf != 0);
1558 + d->write_error = false;
1559 + return true;
1562 +static inline void LZd_free(struct LZ_decoder * const d)
1564 + if (!d->buffer_given)
1565 + large_free(d->buffer);
1568 +static inline uint32_t LZd_crc(const struct LZ_decoder * const d)
1570 + return d->crc ^ 0xFFFFFFFFU;
1573 +static inline unsigned long long
1574 +LZd_data_position(const struct LZ_decoder * const d)
1576 + return d->partial_data_pos + d->pos;
1580 +static bool LZd_verify_trailer(struct LZ_decoder * const d)
1582 + File_trailer trailer;
1583 + int i = 0;
1585 + while (i < Ft_size)
1586 + trailer[i++] = Rd_get_byte(d->rdec);
1588 + return (Ft_get_data_crc(trailer) == LZd_crc(d) &&
1589 + Ft_get_data_size(trailer) == LZd_data_position(d) &&
1590 + Ft_get_member_size(trailer) == Rd_member_position(d->rdec));
1594 +/* Return value: -1 = write error, 0 = OK, 1 = data error. */
1595 +static int LZd_decode_member(struct LZ_decoder * const d)
1597 + struct Range_decoder * const rdec = d->rdec;
1598 + uint32_t rep0 = 0; /* rep[0-3] latest four distances */
1599 + uint32_t rep1 = 0; /* used for efficient coding of */
1600 + uint32_t rep2 = 0; /* repeated distances */
1601 + uint32_t rep3 = 0;
1602 + State state = 0;
1604 + Rd_load(rdec);
1605 + while (!Rd_finished(rdec)) {
1606 + const int pos_state = LZd_data_position(d) & pos_state_mask;
1608 + if (Rd_decode_bit(rdec, &d->bm_match[state][pos_state]) == 0) {
1609 + Bit_model * const bm = d->bm_literal[get_lit_state(LZd_peek_prev(d))];
1611 + if (St_is_char(state)) {
1612 + state -= (state < 4) ? state : 3;
1613 + LZd_put_byte(d, Rd_decode_tree(rdec, bm, 8));
1614 + } else {
1615 + state -= (state < 10) ? 3 : 6;
1616 + LZd_put_byte(d, Rd_decode_matched(rdec, bm, LZd_peek(d, rep0)));
1618 + } else { /* match or repeated match */
1619 + uint32_t len;
1621 + if (Rd_decode_bit(rdec, &d->bm_rep[state]) != 0) {
1622 + if (Rd_decode_bit(rdec, &d->bm_rep0[state]) == 0) {
1623 + if (Rd_decode_bit(rdec, &d->bm_len[state][pos_state]) == 0) {
1624 + state = St_set_short_rep(state);
1625 + LZd_put_byte(d, LZd_peek(d, rep0));
1626 + continue;
1628 + } else {
1629 + uint32_t distance;
1631 + if (Rd_decode_bit(rdec, &d->bm_rep1[state]) == 0)
1632 + distance = rep1;
1633 + else {
1634 + if (Rd_decode_bit(rdec, &d->bm_rep2[state]) == 0)
1635 + distance = rep2;
1636 + else {
1637 + distance = rep3;
1638 + rep3 = rep2;
1640 + rep2 = rep1;
1642 + rep1 = rep0;
1643 + rep0 = distance;
1645 + state = St_set_rep(state);
1646 + len = min_match_len + Rd_decode_len(rdec, &d->rep_len_model, pos_state);
1647 + } else { /* match */
1648 + uint32_t distance;
1650 + len = min_match_len + Rd_decode_len(rdec, &d->match_len_model, pos_state);
1651 + distance = Rd_decode_tree(rdec, d->bm_dis_slot[get_len_state(len)], 6);
1652 + if (distance >= start_dis_model) {
1653 + const uint32_t dis_slot = distance;
1654 + const uint32_t direct_bits = (dis_slot >> 1) - 1;
1656 + distance = (2 | (dis_slot & 1)) << direct_bits;
1657 + if (dis_slot < end_dis_model)
1658 + distance += Rd_decode_tree_reversed(rdec,
1659 + d->bm_dis + (distance - dis_slot), direct_bits);
1660 + else {
1661 + distance += Rd_decode(rdec, direct_bits - dis_align_bits) << dis_align_bits;
1662 + distance += Rd_decode_tree_reversed(rdec, d->bm_align, dis_align_bits);
1663 + if (distance == 0xFFFFFFFFU) { /* marker found */
1664 + Rd_normalize(rdec);
1665 + LZd_flush_data(d);
1666 + if (d->write_error)
1667 + return -1;
1668 + if (len == min_match_len && /* End Of Stream marker */
1669 + LZd_verify_trailer(d))
1670 + return 0;
1671 + if (len == min_match_len + 1) { /* Sync Flush marker */
1672 + Rd_load(rdec);
1673 + continue;
1675 + return 1;
1679 + rep3 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance;
1680 + state = St_set_match(state);
1681 + if (rep0 >= d->dictionary_size ||
1682 + (rep0 >= d->pos && !d->pos_wrapped)) {
1683 + LZd_flush_data(d);
1684 + return 1;
1687 + LZd_copy_block(d, rep0, len);
1690 + LZd_flush_data(d);
1691 + return 1;
1695 +STATIC int INIT __lunzip(unsigned char *inbuf, long in_len,
1696 + long (*fill)(void*, unsigned long),
1697 + long (*flush)(void*, unsigned long),
1698 + unsigned char *outbuf, long out_len,
1699 + long *in_posp,
1700 + void (*error)(char *x))
1702 + unsigned char *outptr = outbuf;
1703 + long out_size = out_len;
1704 + int retval = 0;
1705 + struct Range_decoder rdec;
1706 + struct LZ_decoder *decoder = 0;
1707 + bool first_member;
1709 + if (in_posp)
1710 + *in_posp = 0;
1711 + CRC32_init();
1713 + if (!Rd_init(&rdec, inbuf, in_len, fill)) {
1714 + error("Out of memory while allocating input buffer");
1715 + return -1;
1718 + for (first_member = true;; first_member = false) {
1719 + int result, size;
1720 + unsigned dictionary_size;
1721 + File_header header;
1723 + Rd_reset_member_position(&rdec);
1724 + for (size = 0; size < Fh_size; ++size)
1725 + header[size] = Rd_get_byte(&rdec);
1726 + if (Rd_finished(&rdec)) { /* End Of File */
1727 + if (first_member) {
1728 + error("File ends unexpectedly at member header");
1729 + retval = -1;
1731 + break;
1733 + if (!Fh_verify_magic(header)) {
1734 + if (first_member) {
1735 + error("Bad magic number (file not in lzip format)");
1736 + retval = -1;
1738 + break;
1740 + dictionary_size = Fh_get_dictionary_size(header);
1741 + if (dictionary_size < min_dictionary_size ||
1742 + dictionary_size > max_dictionary_size) {
1743 + error("Invalid dictionary size in member header");
1744 + retval = -1;
1745 + break;
1748 + if (!decoder)
1749 + decoder = malloc(sizeof *decoder);
1750 + if (!decoder || !LZd_init(decoder, &rdec, dictionary_size, outptr, out_size, flush)) {
1751 + error("Out of memory while allocating output buffer");
1752 + retval = -1;
1753 + break;
1755 + result = LZd_decode_member(decoder);
1756 + if (in_posp)
1757 + *in_posp += Rd_member_position(&rdec);
1758 + if (outptr)
1759 + outptr += LZd_data_position(decoder);
1760 + if (out_size > 0)
1761 + out_size -= LZd_data_position(decoder);
1762 + LZd_free(decoder);
1763 + if (result != 0) {
1764 + if (result < 0)
1765 + error("write error");
1766 + else
1767 + error("LZIP-compressed data is corrupt");
1768 + retval = -1;
1769 + break;
1772 + if (decoder)
1773 + free(decoder);
1774 + Rd_free(&rdec);
1775 + return retval;
1778 +#ifndef PREBOOT
1779 +STATIC int INIT lunzip(unsigned char *inbuf, long in_len,
1780 + long (*fill)(void*, unsigned long),
1781 + long (*flush)(void*, unsigned long),
1782 + unsigned char *outbuf,
1783 + long *in_posp,
1784 + void (*error)(char *x))
1786 + return __lunzip(inbuf, in_len, fill, flush, outbuf, 0, in_posp, error);
1788 +#else
1789 +STATIC int INIT __decompress(unsigned char *inbuf, long in_len,
1790 + long (*fill)(void*, unsigned long),
1791 + long (*flush)(void*, unsigned long),
1792 + unsigned char *outbuf, long out_len,
1793 + long *in_posp,
1794 + void (*error)(char *x))
1796 + return __lunzip(inbuf, in_len - 4, fill, flush, outbuf, out_len, in_posp, error);
1798 +#endif
1799 diff -urdN linux-4.9.36/scripts/Makefile.lib linux-4.9.36.new/scripts/Makefile.lib
1800 --- linux-4.9.36/scripts/Makefile.lib 2017-07-05 14:40:44.000000000 +0200
1801 +++ linux-4.9.36.new/scripts/Makefile.lib 2017-07-11 12:26:28.000000000 +0200
1802 @@ -339,6 +339,21 @@
1803 bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
1804 (rm -f $@ ; false)
1806 +# Lzip
1807 +# ---------------------------------------------------------------------------
1808 +# The .lz format has the uncompressed size available at the end of the
1809 +# file, but at offset (member_size - 16). So we append a gzip-style size.
1810 +# Use klzip to compress the kernel image and lzip to compress other things.
1812 +quiet_cmd_klzip = LZIP $@
1813 +cmd_klzip = (cat $(filter-out FORCE,$^) | \
1814 + lzip -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
1815 + (rm -f $@ ; false)
1817 +quiet_cmd_lzip = LZIP $@
1818 +cmd_lzip = (cat $(filter-out FORCE,$^) | lzip -9) > $@ || \
1819 + (rm -f $@ ; false)
1821 # Lzma
1822 # ---------------------------------------------------------------------------
1824 diff -urdN linux-4.9.36/scripts/extract-ikconfig linux-4.9.36.new/scripts/extract-ikconfig
1825 --- linux-4.9.36/scripts/extract-ikconfig 2017-07-05 14:40:44.000000000 +0200
1826 +++ linux-4.9.36.new/scripts/extract-ikconfig 2017-07-11 12:26:28.000000000 +0200
1827 @@ -59,6 +59,7 @@
1828 try_decompress '\037\213\010' xy gunzip
1829 try_decompress '\3757zXZ\000' abcde unxz
1830 try_decompress 'BZh' xy bunzip2
1831 +try_decompress 'LZIP' xyz 'lzip -d'
1832 try_decompress '\135\0\0\0' xxx unlzma
1833 try_decompress '\211\114\132' xy 'lzop -d'
1834 try_decompress '\002\041\114\030' xyy 'lz4 -d -l'
1835 diff -urdN linux-4.9.36/scripts/extract-vmlinux linux-4.9.36.new/scripts/extract-vmlinux
1836 --- linux-4.9.36/scripts/extract-vmlinux 2017-07-05 14:40:44.000000000 +0200
1837 +++ linux-4.9.36.new/scripts/extract-vmlinux 2017-07-11 12:26:28.000000000 +0200
1838 @@ -55,6 +55,7 @@
1839 try_decompress '\037\213\010' xy gunzip
1840 try_decompress '\3757zXZ\000' abcde unxz
1841 try_decompress 'BZh' xy bunzip2
1842 +try_decompress 'LZIP' xyz 'lzip -d'
1843 try_decompress '\135\0\0\0' xxx unlzma
1844 try_decompress '\211\114\132' xy 'lzop -d'
1846 diff -urdN linux-4.9.36/scripts/gen_initramfs_list.sh linux-4.9.36.new/scripts/gen_initramfs_list.sh
1847 --- linux-4.9.36/scripts/gen_initramfs_list.sh 2017-07-05 14:40:44.000000000 +0200
1848 +++ linux-4.9.36.new/scripts/gen_initramfs_list.sh 2017-07-11 12:26:28.000000000 +0200
1849 @@ -249,6 +249,9 @@
1850 echo "$output_file" | grep -q "\.bz2$" \
1851 && [ -x "`which bzip2 2> /dev/null`" ] \
1852 && compr="bzip2 -9 -f"
1853 + echo "$output_file" | grep -q "\.lz$" \
1854 + && [ -x "`which lzip 2> /dev/null`" ] \
1855 + && compr="lzip -9 -f"
1856 echo "$output_file" | grep -q "\.lzma$" \
1857 && [ -x "`which lzma 2> /dev/null`" ] \
1858 && compr="lzma -9 -f"
1859 diff -urdN linux-4.9.36/scripts/package/Makefile linux-4.9.36.new/scripts/package/Makefile
1860 --- linux-4.9.36/scripts/package/Makefile 2017-07-05 14:40:44.000000000 +0200
1861 +++ linux-4.9.36.new/scripts/package/Makefile 2017-07-11 12:26:28.000000000 +0200
1862 @@ -129,8 +129,9 @@
1863 $(if $(findstring tar-src,$@),, \
1864 $(if $(findstring bz2,$@),bzip2, \
1865 $(if $(findstring gz,$@),gzip, \
1866 +$(if $(findstring lz,$@),lzip, \
1867 $(if $(findstring xz,$@),xz, \
1868 -$(error unknown target $@)))) \
1869 +$(error unknown target $@))))) \
1870 -f -9 $(perf-tar).tar)
1872 perf-%pkg: FORCE
1873 @@ -146,8 +147,10 @@
1874 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
1875 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
1876 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
1877 + @echo ' tarlz-pkg - Build the kernel as a lzip compressed tarball'
1878 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
1879 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
1880 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
1881 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
1882 + @echo ' perf-tarlz-src-pkg - Build $(perf-tar).tar.lz source tarball'
1883 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
1884 diff -urdN linux-4.9.36/scripts/package/buildtar linux-4.9.36.new/scripts/package/buildtar
1885 --- linux-4.9.36/scripts/package/buildtar 2017-07-05 14:40:44.000000000 +0200
1886 +++ linux-4.9.36.new/scripts/package/buildtar 2017-07-11 12:26:28.000000000 +0200
1887 @@ -35,6 +35,10 @@
1888 compress="bzip2"
1889 file_ext=".bz2"
1891 + tarlz-pkg)
1892 + compress="lzip"
1893 + file_ext=".lz"
1894 + ;;
1895 tarxz-pkg)
1896 compress="xz"
1897 file_ext=".xz"
1898 diff -urdN linux-4.9.36/scripts/patch-kernel linux-4.9.36.new/scripts/patch-kernel
1899 --- linux-4.9.36/scripts/patch-kernel 2017-07-05 14:40:44.000000000 +0200
1900 +++ linux-4.9.36.new/scripts/patch-kernel 2017-07-11 12:26:28.000000000 +0200
1901 @@ -116,6 +116,10 @@
1902 ext=".bz2"
1903 name="bzip2"
1904 uncomp="bunzip2 -dc"
1905 + elif [ -r ${filebase}.lz ]; then
1906 + ext=".lz"
1907 + name="lzip"
1908 + uncomp="lzip -dc"
1909 elif [ -r ${filebase}.xz ]; then
1910 ext=".xz"
1911 name="xz"
1912 diff -urdN linux-4.9.36/tools/testing/selftests/gen_kselftest_tar.sh linux-4.9.36.new/tools/testing/selftests/gen_kselftest_tar.sh
1913 --- linux-4.9.36/tools/testing/selftests/gen_kselftest_tar.sh 2017-07-05 14:40:44.000000000 +0200
1914 +++ linux-4.9.36.new/tools/testing/selftests/gen_kselftest_tar.sh 2017-07-11 12:26:28.000000000 +0200
1915 @@ -29,6 +29,10 @@
1916 copts="cvjf"
1917 ext=".tar.bz2"
1919 + tarlz)
1920 + copts="cv --lzip -f"
1921 + ext=".tar.lz"
1922 + ;;
1923 tarxz)
1924 copts="cvJf"
1925 ext=".tar.xz"
1926 diff -urdN linux-4.9.36/usr/.gitignore linux-4.9.36.new/usr/.gitignore
1927 --- linux-4.9.36/usr/.gitignore 2017-07-05 14:40:44.000000000 +0200
1928 +++ linux-4.9.36.new/usr/.gitignore 2017-07-11 12:26:28.000000000 +0200
1929 @@ -5,6 +5,7 @@
1930 initramfs_data.cpio
1931 initramfs_data.cpio.gz
1932 initramfs_data.cpio.bz2
1933 +initramfs_data.cpio.lz
1934 initramfs_data.cpio.lzma
1935 initramfs_list
1936 include
1937 diff -urdN linux-4.9.36/usr/Kconfig linux-4.9.36.new/usr/Kconfig
1938 --- linux-4.9.36/usr/Kconfig 2017-07-05 14:40:44.000000000 +0200
1939 +++ linux-4.9.36.new/usr/Kconfig 2017-07-11 12:26:28.000000000 +0200
1940 @@ -63,6 +63,15 @@
1941 Support loading of a bzip2 encoded initial ramdisk or cpio buffer
1942 If unsure, say N.
1944 +config RD_LZIP
1945 + bool "Support initial ramdisks compressed using lzip"
1946 + default y
1947 + depends on BLK_DEV_INITRD
1948 + select DECOMPRESS_LZIP
1949 + help
1950 + Support loading of a lzip encoded initial ramdisk or cpio buffer.
1951 + If unsure, say N.
1953 config RD_LZMA
1954 bool "Support initial ramdisks compressed using LZMA"
1955 default y
1956 diff -urdN linux-4.9.36/usr/Makefile linux-4.9.36.new/usr/Makefile
1957 --- linux-4.9.36/usr/Makefile 2017-07-05 14:40:44.000000000 +0200
1958 +++ linux-4.9.36.new/usr/Makefile 2017-07-11 12:26:28.000000000 +0200
1959 @@ -21,6 +21,9 @@
1960 # Lz4
1961 suffix_$(CONFIG_RD_LZ4) = .lz4
1963 +# Lzip
1964 +suffix_$(CONFIG_RD_LZIP) = .lz
1966 # Gzip
1967 suffix_$(CONFIG_RD_GZIP) = .gz
1969 @@ -57,9 +60,9 @@
1970 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
1972 targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 \
1973 - initramfs_data.cpio.lzma initramfs_data.cpio.xz \
1974 - initramfs_data.cpio.lzo initramfs_data.cpio.lz4 \
1975 - initramfs_data.cpio
1976 + initramfs_data.cpio.lz initramfs_data.cpio.lzma \
1977 + initramfs_data.cpio.xz initramfs_data.cpio.lzo \
1978 + initramfs_data.cpio.lz4 initramfs_data.cpio
1979 # do not try to update files included in initramfs
1980 $(deps_initramfs): ;