stages/*: change license to Apache 2.0
[dragora.git] / patches / kernel / linux-4.14.7_lzip-1.diff
blobc10fe20651c362a1de9f07f7c7c9fe4c404e745a
1 diff -urdN linux-4.14.7/.gitignore linux-4.14.7.new/.gitignore
2 --- linux-4.14.7/.gitignore 2017-12-17 15:08:14.000000000 +0100
3 +++ linux-4.14.7.new/.gitignore 2017-12-18 20:58:51.000000000 +0100
4 @@ -27,6 +27,7 @@
5 *.tar
6 *.gz
7 *.bz2
8 +*.lz
9 *.lzma
10 *.xz
11 *.lz4
12 diff -urdN linux-4.14.7/Documentation/00-INDEX linux-4.14.7.new/Documentation/00-INDEX
13 --- linux-4.14.7/Documentation/00-INDEX 2017-12-17 15:08:14.000000000 +0100
14 +++ linux-4.14.7.new/Documentation/00-INDEX 2017-12-19 01:46:42.000000000 +0100
15 @@ -260,6 +260,8 @@
16 - info on creator of above logo & site to get additional images from.
17 lsm.txt
18 - Linux Security Modules: General Security Hooks for Linux
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.14.7/Documentation/dontdiff linux-4.14.7.new/Documentation/dontdiff
25 --- linux-4.14.7/Documentation/dontdiff 2017-12-17 16:28:38.000000000 +0100
26 +++ linux-4.14.7.new/Documentation/dontdiff 2017-12-18 20:58:51.000000000 +0100
27 @@ -26,6 +26,7 @@
28 *.ll
29 *.log
30 *.lst
31 +*.lz
32 *.lzma
33 *.lzo
34 *.mo
35 diff -urdN linux-4.14.7/Documentation/lzip.txt linux-4.14.7.new/Documentation/lzip.txt
36 --- linux-4.14.7/Documentation/lzip.txt 1970-01-01 01:00:00.000000000 +0100
37 +++ linux-4.14.7.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.14.7/Documentation/x86/boot.txt linux-4.14.7.new/Documentation/x86/boot.txt
86 --- linux-4.14.7/Documentation/x86/boot.txt 2017-12-17 15:08:14.000000000 +0100
87 +++ linux-4.14.7.new/Documentation/x86/boot.txt 2017-12-18 20:58:51.000000000 +0100
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.14.7/Makefile linux-4.14.7.new/Makefile
104 --- linux-4.14.7/Makefile 2017-12-17 16:27:04.000000000 +0100
105 +++ linux-4.14.7.new/Makefile 2017-12-18 20:58:51.000000000 +0100
106 @@ -893,14 +893,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 @@ -912,6 +915,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.14.7/arch/arm/Kconfig linux-4.14.7.new/arch/arm/Kconfig
135 --- linux-4.14.7/arch/arm/Kconfig 2017-12-17 15:08:14.000000000 +0100
136 +++ linux-4.14.7.new/arch/arm/Kconfig 2017-12-18 20:58:51.000000000 +0100
137 @@ -72,6 +72,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.14.7/arch/arm/boot/compressed/Makefile linux-4.14.7.new/arch/arm/boot/compressed/Makefile
146 --- linux-4.14.7/arch/arm/boot/compressed/Makefile 2017-12-17 15:08:14.000000000 +0100
147 +++ linux-4.14.7.new/arch/arm/boot/compressed/Makefile 2017-12-18 20:58:51.000000000 +0100
148 @@ -68,6 +68,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.14.7/arch/arm/boot/compressed/decompress.c linux-4.14.7.new/arch/arm/boot/compressed/decompress.c
157 --- linux-4.14.7/arch/arm/boot/compressed/decompress.c 2017-12-17 15:08:14.000000000 +0100
158 +++ linux-4.14.7.new/arch/arm/boot/compressed/decompress.c 2017-12-18 20:58:51.000000000 +0100
159 @@ -40,6 +40,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.14.7/arch/blackfin/Kconfig linux-4.14.7.new/arch/blackfin/Kconfig
171 --- linux-4.14.7/arch/blackfin/Kconfig 2017-12-17 15:08:14.000000000 +0100
172 +++ linux-4.14.7.new/arch/blackfin/Kconfig 2017-12-18 20:58:51.000000000 +0100
173 @@ -22,6 +22,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.14.7/arch/blackfin/Makefile linux-4.14.7.new/arch/blackfin/Makefile
182 --- linux-4.14.7/arch/blackfin/Makefile 2017-12-17 15:08:14.000000000 +0100
183 +++ linux-4.14.7.new/arch/blackfin/Makefile 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/blackfin/boot/Makefile linux-4.14.7.new/arch/blackfin/boot/Makefile
203 --- linux-4.14.7/arch/blackfin/boot/Makefile 2017-12-17 15:08:14.000000000 +0100
204 +++ linux-4.14.7.new/arch/blackfin/boot/Makefile 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/m32r/Kconfig linux-4.14.7.new/arch/m32r/Kconfig
247 --- linux-4.14.7/arch/m32r/Kconfig 2017-12-17 15:08:14.000000000 +0100
248 +++ linux-4.14.7.new/arch/m32r/Kconfig 2017-12-18 20:58:51.000000000 +0100
249 @@ -7,6 +7,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.14.7/arch/m32r/boot/compressed/Makefile linux-4.14.7.new/arch/m32r/boot/compressed/Makefile
258 --- linux-4.14.7/arch/m32r/boot/compressed/Makefile 2017-12-17 15:08:14.000000000 +0100
259 +++ linux-4.14.7.new/arch/m32r/boot/compressed/Makefile 2017-12-18 20:58:51.000000000 +0100
260 @@ -5,8 +5,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 @@ -30,6 +30,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 @@ -45,6 +48,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.14.7/arch/m32r/boot/compressed/misc.c linux-4.14.7.new/arch/m32r/boot/compressed/misc.c
290 --- linux-4.14.7/arch/m32r/boot/compressed/misc.c 2017-12-17 15:08:14.000000000 +0100
291 +++ linux-4.14.7.new/arch/m32r/boot/compressed/misc.c 2017-12-18 20:58:51.000000000 +0100
292 @@ -39,7 +39,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 @@ -49,7 +49,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 @@ -59,6 +61,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.14.7/arch/metag/Kconfig linux-4.14.7.new/arch/metag/Kconfig
324 --- linux-4.14.7/arch/metag/Kconfig 2017-12-17 15:08:14.000000000 +0100
325 +++ linux-4.14.7.new/arch/metag/Kconfig 2017-12-18 20:58:51.000000000 +0100
326 @@ -17,6 +17,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.14.7/arch/metag/Makefile linux-4.14.7.new/arch/metag/Makefile
335 --- linux-4.14.7/arch/metag/Makefile 2017-12-17 15:08:14.000000000 +0100
336 +++ linux-4.14.7.new/arch/metag/Makefile 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/metag/boot/Makefile linux-4.14.7.new/arch/metag/boot/Makefile
354 --- linux-4.14.7/arch/metag/boot/Makefile 2017-12-17 15:08:14.000000000 +0100
355 +++ linux-4.14.7.new/arch/metag/boot/Makefile 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/mips/Kconfig linux-4.14.7.new/arch/mips/Kconfig
401 --- linux-4.14.7/arch/mips/Kconfig 2017-12-17 15:08:14.000000000 +0100
402 +++ linux-4.14.7.new/arch/mips/Kconfig 2017-12-18 20:58:51.000000000 +0100
403 @@ -1820,6 +1820,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.14.7/arch/mips/Makefile linux-4.14.7.new/arch/mips/Makefile
412 --- linux-4.14.7/arch/mips/Makefile 2017-12-17 15:08:14.000000000 +0100
413 +++ linux-4.14.7.new/arch/mips/Makefile 2017-12-18 20:58:51.000000000 +0100
414 @@ -338,12 +338,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 @@ -454,6 +456,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 ' uzImage.bin - U-Boot image (self-extracting)'
437 diff -urdN linux-4.14.7/arch/mips/boot/Makefile linux-4.14.7.new/arch/mips/boot/Makefile
438 --- linux-4.14.7/arch/mips/boot/Makefile 2017-12-17 15:08:14.000000000 +0100
439 +++ linux-4.14.7.new/arch/mips/boot/Makefile 2017-12-19 01:46:42.000000000 +0100
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 @@ -143,6 +153,9 @@
493 $(obj)/vmlinux.bz2.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
494 $(call if_changed_dep,cpp_its_S,bzip2,vmlinux.bin.bz2)
496 +$(obj)/vmlinux.lz.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
497 + $(call if_changed_dep,cpp_its_S,lzip,vmlinux.bin.lz)
499 $(obj)/vmlinux.lzma.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
500 $(call if_changed_dep,cpp_its_S,lzma,vmlinux.bin.lzma)
502 @@ -167,6 +180,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.14.7/arch/mips/boot/compressed/Makefile linux-4.14.7.new/arch/mips/boot/compressed/Makefile
513 --- linux-4.14.7/arch/mips/boot/compressed/Makefile 2017-12-17 15:08:14.000000000 +0100
514 +++ linux-4.14.7.new/arch/mips/boot/compressed/Makefile 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/mips/boot/compressed/decompress.c linux-4.14.7.new/arch/mips/boot/compressed/decompress.c
524 --- linux-4.14.7/arch/mips/boot/compressed/decompress.c 2017-12-17 15:08:14.000000000 +0100
525 +++ linux-4.14.7.new/arch/mips/boot/compressed/decompress.c 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/s390/Kconfig linux-4.14.7.new/arch/s390/Kconfig
538 --- linux-4.14.7/arch/s390/Kconfig 2017-12-17 15:08:14.000000000 +0100
539 +++ linux-4.14.7.new/arch/s390/Kconfig 2017-12-18 20:58:51.000000000 +0100
540 @@ -151,6 +151,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.14.7/arch/s390/boot/compressed/Makefile linux-4.14.7.new/arch/s390/boot/compressed/Makefile
549 --- linux-4.14.7/arch/s390/boot/compressed/Makefile 2017-12-17 15:08:14.000000000 +0100
550 +++ linux-4.14.7.new/arch/s390/boot/compressed/Makefile 2017-12-18 20:58:51.000000000 +0100
551 @@ -7,9 +7,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__ -O2
563 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
564 @@ -51,6 +51,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 @@ -61,6 +62,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.14.7/arch/s390/boot/compressed/misc.c linux-4.14.7.new/arch/s390/boot/compressed/misc.c
582 --- linux-4.14.7/arch/s390/boot/compressed/misc.c 2017-12-17 15:08:14.000000000 +0100
583 +++ linux-4.14.7.new/arch/s390/boot/compressed/misc.c 2017-12-18 20:58:51.000000000 +0100
584 @@ -53,6 +53,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.14.7/arch/sh/Kconfig linux-4.14.7.new/arch/sh/Kconfig
596 --- linux-4.14.7/arch/sh/Kconfig 2017-12-17 15:08:14.000000000 +0100
597 +++ linux-4.14.7.new/arch/sh/Kconfig 2017-12-18 20:58:51.000000000 +0100
598 @@ -24,6 +24,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.14.7/arch/sh/Makefile linux-4.14.7.new/arch/sh/Makefile
607 --- linux-4.14.7/arch/sh/Makefile 2017-12-17 15:08:14.000000000 +0100
608 +++ linux-4.14.7.new/arch/sh/Makefile 2017-12-18 20:58:51.000000000 +0100
609 @@ -205,9 +205,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: $(notdir $(KBUILD_IMAGE))
622 @@ -234,6 +234,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.14.7/arch/sh/boot/Makefile linux-4.14.7.new/arch/sh/boot/Makefile
631 --- linux-4.14.7/arch/sh/boot/Makefile 2017-12-17 15:08:14.000000000 +0100
632 +++ linux-4.14.7.new/arch/sh/boot/Makefile 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/sh/boot/compressed/Makefile linux-4.14.7.new/arch/sh/boot/compressed/Makefile
673 --- linux-4.14.7/arch/sh/boot/compressed/Makefile 2017-12-17 15:08:14.000000000 +0100
674 +++ linux-4.14.7.new/arch/sh/boot/compressed/Makefile 2017-12-18 20:58:51.000000000 +0100
675 @@ -5,10 +5,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 @@ -66,6 +65,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.14.7/arch/sh/boot/compressed/misc.c linux-4.14.7.new/arch/sh/boot/compressed/misc.c
699 --- linux-4.14.7/arch/sh/boot/compressed/misc.c 2017-12-17 15:08:14.000000000 +0100
700 +++ linux-4.14.7.new/arch/sh/boot/compressed/misc.c 2017-12-18 20:58:51.000000000 +0100
701 @@ -58,6 +58,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.14.7/arch/unicore32/.gitignore linux-4.14.7.new/arch/unicore32/.gitignore
713 --- linux-4.14.7/arch/unicore32/.gitignore 2017-12-17 15:08:14.000000000 +0100
714 +++ linux-4.14.7.new/arch/unicore32/.gitignore 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/unicore32/Kconfig linux-4.14.7.new/arch/unicore32/Kconfig
726 --- linux-4.14.7/arch/unicore32/Kconfig 2017-12-17 15:08:14.000000000 +0100
727 +++ linux-4.14.7.new/arch/unicore32/Kconfig 2017-12-18 20:58:51.000000000 +0100
728 @@ -8,6 +8,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.14.7/arch/unicore32/boot/compressed/Makefile linux-4.14.7.new/arch/unicore32/boot/compressed/Makefile
737 --- linux-4.14.7/arch/unicore32/boot/compressed/Makefile 2017-12-17 15:08:14.000000000 +0100
738 +++ linux-4.14.7.new/arch/unicore32/boot/compressed/Makefile 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/unicore32/boot/compressed/misc.c linux-4.14.7.new/arch/unicore32/boot/compressed/misc.c
761 --- linux-4.14.7/arch/unicore32/boot/compressed/misc.c 2017-12-17 15:08:14.000000000 +0100
762 +++ linux-4.14.7.new/arch/unicore32/boot/compressed/misc.c 2017-12-18 20:58:51.000000000 +0100
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.14.7/arch/x86/Kconfig linux-4.14.7.new/arch/x86/Kconfig
775 --- linux-4.14.7/arch/x86/Kconfig 2017-12-17 15:08:14.000000000 +0100
776 +++ linux-4.14.7.new/arch/x86/Kconfig 2017-12-18 20:58:51.000000000 +0100
777 @@ -148,6 +148,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.14.7/arch/x86/boot/compressed/Makefile linux-4.14.7.new/arch/x86/boot/compressed/Makefile
786 --- linux-4.14.7/arch/x86/boot/compressed/Makefile 2017-12-17 15:08:14.000000000 +0100
787 +++ linux-4.14.7.new/arch/x86/boot/compressed/Makefile 2017-12-18 20:58:51.000000000 +0100
788 @@ -23,8 +23,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__ -O2
798 KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
799 @@ -126,6 +126,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 @@ -137,6 +139,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.14.7/arch/x86/boot/compressed/misc.c linux-4.14.7.new/arch/x86/boot/compressed/misc.c
817 --- linux-4.14.7/arch/x86/boot/compressed/misc.c 2017-12-17 15:08:14.000000000 +0100
818 +++ linux-4.14.7.new/arch/x86/boot/compressed/misc.c 2017-12-18 20:58:51.000000000 +0100
819 @@ -60,6 +60,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.14.7/include/linux/decompress/lunzip.h linux-4.14.7.new/include/linux/decompress/lunzip.h
831 --- linux-4.14.7/include/linux/decompress/lunzip.h 1970-01-01 01:00:00.000000000 +0100
832 +++ linux-4.14.7.new/include/linux/decompress/lunzip.h 2016-08-24 18:49:48.000000000 +0200
833 @@ -0,0 +1,10 @@
834 +#ifndef LINUX_DECOMPRESS_LUNZIP_H
835 +#define LINUX_DECOMPRESS_LUNZIP_H
837 +int lunzip(unsigned char *inbuf, long in_len,
838 + long (*fill)(void*, unsigned long),
839 + long (*flush)(void*, unsigned long),
840 + unsigned char *outbuf,
841 + long *in_posp,
842 + void (*error)(char *x));
843 +#endif
844 diff -urdN linux-4.14.7/init/Kconfig linux-4.14.7.new/init/Kconfig
845 --- linux-4.14.7/init/Kconfig 2017-12-17 15:08:14.000000000 +0100
846 +++ linux-4.14.7.new/init/Kconfig 2017-12-18 20:58:51.000000000 +0100
847 @@ -115,6 +115,9 @@
848 config HAVE_KERNEL_BZIP2
849 bool
851 +config HAVE_KERNEL_LZIP
852 + bool
854 config HAVE_KERNEL_LZMA
855 bool
857 @@ -130,7 +133,7 @@
858 choice
859 prompt "Kernel compression mode"
860 default KERNEL_GZIP
861 - depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
862 + depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZIP || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
863 help
864 The linux kernel is a kind of self-extracting executable.
865 Several compression algorithms are available, which differ
866 @@ -166,6 +169,15 @@
867 Bzip2 uses a large amount of memory. For modern kernels you
868 will need at least 8MB RAM or more for booting.
870 +config KERNEL_LZIP
871 + bool "Lzip"
872 + depends on HAVE_KERNEL_LZIP
873 + help
874 + Lzip's compression ratio is better than that of gzip and bzip2.
875 + Decompression speed is between gzip and bzip2. Compression can
876 + be as fast as gzip or slower than bzip2 depending on compression
877 + level. Lzip can produce a kernel about a 16% smaller than gzip.
879 config KERNEL_LZMA
880 bool "LZMA"
881 depends on HAVE_KERNEL_LZMA
882 @@ -1827,8 +1839,8 @@
883 depends on MODULES
884 help
886 - Compresses kernel modules when 'make modules_install' is run; gzip or
887 - xz depending on "Compression algorithm" below.
888 + Compresses kernel modules when 'make modules_install' is run; gzip,
889 + lzip or xz are used depending on "Compression algorithm" below.
891 module-init-tools MAY support gzip, and kmod MAY support gzip and xz.
893 @@ -1850,11 +1862,14 @@
894 This determines which sort of compression will be used during
895 'make modules_install'.
897 - GZIP (default) and XZ are supported.
898 + GZIP (default), LZIP and XZ are supported.
900 config MODULE_COMPRESS_GZIP
901 bool "GZIP"
903 +config MODULE_COMPRESS_LZIP
904 + bool "LZIP"
906 config MODULE_COMPRESS_XZ
907 bool "XZ"
909 diff -urdN linux-4.14.7/init/do_mounts_rd.c linux-4.14.7.new/init/do_mounts_rd.c
910 --- linux-4.14.7/init/do_mounts_rd.c 2017-12-17 15:08:14.000000000 +0100
911 +++ linux-4.14.7.new/init/do_mounts_rd.c 2017-12-18 20:58:51.000000000 +0100
912 @@ -59,6 +59,7 @@
913 * squashfs
914 * gzip
915 * bzip2
916 + * lzip
917 * lzma
918 * xz
919 * lzo
920 diff -urdN linux-4.14.7/lib/Kconfig linux-4.14.7.new/lib/Kconfig
921 --- linux-4.14.7/lib/Kconfig 2017-12-17 15:08:14.000000000 +0100
922 +++ linux-4.14.7.new/lib/Kconfig 2017-12-18 20:58:51.000000000 +0100
923 @@ -270,6 +270,9 @@
924 config DECOMPRESS_BZIP2
925 tristate
927 +config DECOMPRESS_LZIP
928 + tristate
930 config DECOMPRESS_LZMA
931 tristate
933 diff -urdN linux-4.14.7/lib/Makefile linux-4.14.7.new/lib/Makefile
934 --- linux-4.14.7/lib/Makefile 2017-12-17 15:08:14.000000000 +0100
935 +++ linux-4.14.7.new/lib/Makefile 2017-12-18 20:58:51.000000000 +0100
936 @@ -125,6 +125,7 @@
938 lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
939 lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
940 +lib-$(CONFIG_DECOMPRESS_LZIP) += decompress_lunzip.o
941 lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
942 lib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
943 lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
944 diff -urdN linux-4.14.7/lib/decompress.c linux-4.14.7.new/lib/decompress.c
945 --- linux-4.14.7/lib/decompress.c 2017-12-17 15:08:14.000000000 +0100
946 +++ linux-4.14.7.new/lib/decompress.c 2017-12-18 20:58:51.000000000 +0100
947 @@ -8,6 +8,7 @@
948 #include <linux/decompress/generic.h>
950 #include <linux/decompress/bunzip2.h>
951 +#include <linux/decompress/lunzip.h>
952 #include <linux/decompress/unlzma.h>
953 #include <linux/decompress/unxz.h>
954 #include <linux/decompress/inflate.h>
955 @@ -25,6 +26,9 @@
956 #ifndef CONFIG_DECOMPRESS_BZIP2
957 # define bunzip2 NULL
958 #endif
959 +#ifndef CONFIG_DECOMPRESS_LZIP
960 +# define lunzip NULL
961 +#endif
962 #ifndef CONFIG_DECOMPRESS_LZMA
963 # define unlzma NULL
964 #endif
965 @@ -48,6 +52,7 @@
966 { {0x1f, 0x8b}, "gzip", gunzip },
967 { {0x1f, 0x9e}, "gzip", gunzip },
968 { {0x42, 0x5a}, "bzip2", bunzip2 },
969 + { {0x4c, 0x5a}, "lzip", lunzip },
970 { {0x5d, 0x00}, "lzma", unlzma },
971 { {0xfd, 0x37}, "xz", unxz },
972 { {0x89, 0x4c}, "lzo", unlzo },
973 diff -urdN linux-4.14.7/lib/decompress_lunzip.c linux-4.14.7.new/lib/decompress_lunzip.c
974 --- linux-4.14.7/lib/decompress_lunzip.c 1970-01-01 01:00:00.000000000 +0100
975 +++ linux-4.14.7.new/lib/decompress_lunzip.c 2017-04-21 19:28:30.000000000 +0200
976 @@ -0,0 +1,795 @@
978 + * lunzip implementation for linux
980 + * Copyright (C) 2016, 2017 Antonio Diaz Diaz.
982 + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
983 + */
985 +#ifdef STATIC
986 +#define PREBOOT
987 +#else
988 +#include <linux/decompress/lunzip.h>
989 +#endif
991 +#include <linux/decompress/mm.h>
993 +typedef int State;
995 +enum { states = 12 };
997 +static inline bool St_is_char(const State st) { return st < 7; }
999 +static inline State St_set_char(const State st)
1001 + static const State next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
1002 + return next[st];
1005 +static inline State St_set_match(const State st)
1007 + return ((st < 7) ? 7 : 10);
1010 +static inline State St_set_rep(const State st)
1012 + return ((st < 7) ? 8 : 11);
1015 +static inline State St_set_short_rep(const State st)
1017 + return ((st < 7) ? 9 : 11);
1021 +enum {
1022 + min_dictionary_bits = 12,
1023 + min_dictionary_size = 1 << min_dictionary_bits,
1024 + max_dictionary_bits = 29,
1025 + max_dictionary_size = 1 << max_dictionary_bits,
1026 + literal_context_bits = 3,
1027 + pos_state_bits = 2,
1028 + pos_states = 1 << pos_state_bits,
1029 + pos_state_mask = pos_states - 1,
1031 + len_states = 4,
1032 + dis_slot_bits = 6,
1033 + start_dis_model = 4,
1034 + end_dis_model = 14,
1035 + modeled_distances = 1 << (end_dis_model / 2), /* 128 */
1036 + dis_align_bits = 4,
1037 + dis_align_size = 1 << dis_align_bits,
1039 + len_low_bits = 3,
1040 + len_mid_bits = 3,
1041 + len_high_bits = 8,
1042 + len_low_symbols = 1 << len_low_bits,
1043 + len_mid_symbols = 1 << len_mid_bits,
1044 + len_high_symbols = 1 << len_high_bits,
1045 + max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols,
1047 + min_match_len = 2, /* must be 2 */
1048 + max_match_len = min_match_len + max_len_symbols - 1, /* 273 */
1049 + min_match_len_limit = 5
1052 +static inline int get_len_state(const int len)
1054 + return min(len - min_match_len, len_states - 1);
1057 +static inline int get_lit_state(const uint8_t prev_byte)
1059 + return (prev_byte >> (8 - literal_context_bits));
1063 +enum { bit_model_move_bits = 5,
1064 + bit_model_total_bits = 11,
1065 + bit_model_total = 1 << bit_model_total_bits
1068 +typedef uint16_t Bit_model;
1070 +static inline void Bm_init(Bit_model * const probability)
1072 + *probability = bit_model_total / 2;
1075 +static inline void Bm_array_init(Bit_model * const p, const int size)
1077 + int i = 0;
1079 + while (i < size)
1080 + p[i++] = bit_model_total / 2;
1083 +struct Len_model {
1084 + Bit_model choice1;
1085 + Bit_model choice2;
1086 + Bit_model bm_low[pos_states][len_low_symbols];
1087 + Bit_model bm_mid[pos_states][len_mid_symbols];
1088 + Bit_model bm_high[len_high_symbols];
1091 +static inline void Lm_init(struct Len_model * const lm)
1093 + Bm_init(&lm->choice1);
1094 + Bm_init(&lm->choice2);
1095 + Bm_array_init(lm->bm_low[0], pos_states * len_low_symbols);
1096 + Bm_array_init(lm->bm_mid[0], pos_states * len_mid_symbols);
1097 + Bm_array_init(lm->bm_high, len_high_symbols);
1101 +typedef uint32_t CRC32[256]; /* Table of CRCs of all 8-bit messages. */
1103 +static CRC32 crc32;
1105 +static inline void CRC32_init(void)
1107 + unsigned n;
1109 + for (n = 0; n < 256; ++n) {
1110 + unsigned c = n;
1111 + int k;
1113 + for (k = 0; k < 8; ++k) {
1114 + if (c & 1)
1115 + c = 0xEDB88320U ^ (c >> 1);
1116 + else
1117 + c >>= 1;
1119 + crc32[n] = c;
1123 +static inline void CRC32_update_buf(uint32_t * const crc,
1124 + const uint8_t * const buffer,
1125 + const long size)
1127 + long i;
1128 + uint32_t c = *crc;
1130 + for (i = 0; i < size; ++i)
1131 + c = crc32[(c^buffer[i])&0xFF] ^ (c >> 8);
1132 + *crc = c;
1136 +static const uint8_t magic_string[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
1138 +typedef uint8_t File_header[6]; /* 0-3 magic bytes */
1139 + /* 4 version */
1140 + /* 5 coded_dict_size */
1141 +enum { Fh_size = 6 };
1143 +static inline bool Fh_verify_magic(const File_header data)
1145 + int i;
1147 + for (i = 0; i < 4; ++i)
1148 + if (data[i] != magic_string[i])
1149 + return false;
1150 + return (data[4] == 1);
1153 +static inline unsigned Fh_get_dictionary_size(const File_header data)
1155 + unsigned sz = (1 << (data[5] & 0x1F));
1157 + if (sz > min_dictionary_size)
1158 + sz -= (sz / 16) * ((data[5] >> 5) & 7);
1159 + return sz;
1163 +typedef uint8_t File_trailer[20];
1164 + /* 0-3 CRC32 of the uncompressed data */
1165 + /* 4-11 size of the uncompressed data */
1166 + /* 12-19 member size including header and trailer */
1168 +enum { Ft_size = 20 };
1170 +static inline unsigned Ft_get_data_crc(const File_trailer data)
1172 + unsigned tmp = 0;
1173 + int i;
1175 + for (i = 3; i >= 0; --i) {
1176 + tmp <<= 8;
1177 + tmp += data[i];
1179 + return tmp;
1182 +static inline unsigned long long Ft_get_data_size(const File_trailer data)
1184 + unsigned long long tmp = 0;
1185 + int i;
1187 + for (i = 11; i >= 4; --i) {
1188 + tmp <<= 8;
1189 + tmp += data[i];
1191 + return tmp;
1194 +static inline unsigned long long Ft_get_member_size(const File_trailer data)
1196 + unsigned long long tmp = 0;
1197 + int i;
1199 + for (i = 19; i >= 12; --i) {
1200 + tmp <<= 8;
1201 + tmp += data[i];
1203 + return tmp;
1207 +struct Range_decoder {
1208 + unsigned long long partial_member_pos;
1209 + uint8_t *buffer; /* input buffer */
1210 + long buffer_size;
1211 + long pos; /* current pos in buffer */
1212 + long stream_pos; /* when reached, a new block must be read */
1213 + uint32_t code;
1214 + uint32_t range;
1215 + long (*fill)(void*, unsigned long);
1216 + bool at_stream_end;
1217 + bool buffer_given;
1221 +static bool Rd_read_block(struct Range_decoder * const rdec)
1223 + if (!rdec->at_stream_end) {
1224 + rdec->stream_pos = rdec->fill ?
1225 + rdec->fill(rdec->buffer, rdec->buffer_size) : 0;
1226 + rdec->at_stream_end = (rdec->stream_pos < rdec->buffer_size);
1227 + rdec->partial_member_pos += rdec->pos;
1228 + rdec->pos = 0;
1230 + return rdec->pos < rdec->stream_pos;
1234 +static bool Rd_init(struct Range_decoder * const rdec, uint8_t * const inbuf,
1235 + const long in_len, long (*fill)(void*, unsigned long))
1237 + rdec->partial_member_pos = 0;
1238 + rdec->buffer_size = (inbuf && in_len > 0) ? in_len : 16384;
1239 + rdec->buffer = inbuf ? inbuf : malloc(rdec->buffer_size);
1240 + if (!rdec->buffer)
1241 + return false;
1242 + rdec->pos = 0;
1243 + rdec->stream_pos = (inbuf && in_len > 0) ? in_len : 0;
1244 + rdec->code = 0;
1245 + rdec->range = 0xFFFFFFFFU;
1246 + rdec->fill = fill;
1247 + rdec->at_stream_end = false;
1248 + rdec->buffer_given = (inbuf != 0);
1249 + return true;
1252 +static inline void Rd_free(struct Range_decoder * const rdec)
1254 + if (!rdec->buffer_given)
1255 + free(rdec->buffer);
1258 +static inline bool Rd_finished(struct Range_decoder * const rdec)
1260 + return rdec->pos >= rdec->stream_pos && !Rd_read_block(rdec);
1263 +static inline unsigned long long
1264 +Rd_member_position(const struct Range_decoder * const rdec)
1266 + return rdec->partial_member_pos + rdec->pos;
1269 +static inline void Rd_reset_member_position(struct Range_decoder * const rdec)
1271 + rdec->partial_member_pos = 0; rdec->partial_member_pos -= rdec->pos;
1274 +static inline uint8_t Rd_get_byte(struct Range_decoder * const rdec)
1276 + /* 0xFF avoids decoder error if member is truncated at EOS marker */
1277 + if (Rd_finished(rdec))
1278 + return 0xFF;
1279 + return rdec->buffer[rdec->pos++];
1282 +static void Rd_load(struct Range_decoder * const rdec)
1284 + int i;
1286 + rdec->code = 0;
1287 + for (i = 0; i < 5; ++i)
1288 + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
1289 + rdec->range = 0xFFFFFFFFU;
1292 +static inline void Rd_normalize(struct Range_decoder * const rdec)
1294 + if (rdec->range <= 0x00FFFFFFU) {
1295 + rdec->range <<= 8;
1296 + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
1300 +static uint32_t Rd_decode(struct Range_decoder * const rdec,
1301 + const uint32_t num_bits)
1303 + uint32_t symbol = 0;
1304 + uint32_t i;
1306 + for (i = num_bits; i > 0; --i) {
1307 + bool bit;
1309 + Rd_normalize(rdec);
1310 + rdec->range >>= 1;
1311 + /* symbol <<= 1; */
1312 + /* if(rdec->code >= rdec->range) { rdec->code -= rdec->range; symbol |= 1; } */
1313 + bit = (rdec->code >= rdec->range);
1314 + symbol = (symbol << 1) + bit;
1315 + rdec->code -= rdec->range & (0U - bit);
1317 + return symbol;
1320 +static inline uint32_t Rd_decode_bit(struct Range_decoder * const rdec,
1321 + Bit_model * const probability)
1323 + uint32_t bound;
1325 + Rd_normalize(rdec);
1326 + bound = (rdec->range >> bit_model_total_bits) * *probability;
1327 + if (rdec->code < bound) {
1328 + rdec->range = bound;
1329 + *probability += (bit_model_total - *probability) >> bit_model_move_bits;
1330 + return 0;
1331 + } else {
1332 + rdec->range -= bound;
1333 + rdec->code -= bound;
1334 + *probability -= *probability >> bit_model_move_bits;
1335 + return 1;
1339 +static inline uint32_t Rd_decode_tree(struct Range_decoder * const rdec,
1340 + Bit_model bm[], const uint32_t num_bits)
1342 + uint32_t symbol = 1;
1343 + uint32_t i;
1345 + for (i = num_bits; i > 0; --i)
1346 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1347 + return symbol - (1 << num_bits);
1350 +static inline uint32_t Rd_decode_tree_reversed(struct Range_decoder * const rdec,
1351 + Bit_model bm[], const uint32_t num_bits)
1353 + uint32_t model = 1;
1354 + uint32_t symbol = 0;
1355 + uint32_t i;
1357 + for (i = 0; i < num_bits; ++i) {
1358 + const uint32_t bit = Rd_decode_bit(rdec, &bm[model]);
1360 + model = (model << 1) + bit;
1361 + symbol |= (bit << i);
1363 + return symbol;
1366 +static uint32_t Rd_decode_matched(struct Range_decoder * const rdec,
1367 + Bit_model bm[], uint32_t match_byte)
1369 + uint32_t symbol = 1;
1370 + uint32_t mask = 0x100;
1372 + while (true) {
1373 + const uint32_t match_bit = (match_byte <<= 1) & mask;
1374 + const uint32_t bit = Rd_decode_bit(rdec, &bm[symbol+match_bit+mask]);
1376 + symbol = (symbol << 1) + bit;
1377 + if (symbol > 0xFF)
1378 + return symbol & 0xFF;
1379 + mask &= ~(match_bit ^ (bit << 8)); /* if( match_bit != bit ) mask = 0; */
1383 +static inline uint32_t Rd_decode_len(struct Range_decoder * const rdec,
1384 + struct Len_model * const lm,
1385 + const int pos_state)
1387 + if (Rd_decode_bit(rdec, &lm->choice1) == 0)
1388 + return Rd_decode_tree(rdec, lm->bm_low[pos_state], len_low_bits);
1389 + if (Rd_decode_bit(rdec, &lm->choice2) == 0)
1390 + return len_low_symbols +
1391 + Rd_decode_tree(rdec, lm->bm_mid[pos_state], len_mid_bits);
1392 + return len_low_symbols + len_mid_symbols +
1393 + Rd_decode_tree(rdec, lm->bm_high, len_high_bits);
1397 +struct LZ_decoder {
1398 + unsigned long long partial_data_pos;
1399 + struct Range_decoder *rdec;
1400 + /* Don't move bm_* to LZd_decode_member; makes frame too large. */
1401 + Bit_model bm_literal[1 << literal_context_bits][0x300];
1402 + Bit_model bm_match[states][pos_states];
1403 + Bit_model bm_rep[states];
1404 + Bit_model bm_rep0[states];
1405 + Bit_model bm_rep1[states];
1406 + Bit_model bm_rep2[states];
1407 + Bit_model bm_len[states][pos_states];
1408 + Bit_model bm_dis_slot[len_states][1 << dis_slot_bits];
1409 + Bit_model bm_dis[modeled_distances-end_dis_model+1];
1410 + Bit_model bm_align[dis_align_size];
1411 + struct Len_model match_len_model;
1412 + struct Len_model rep_len_model;
1414 + unsigned long buffer_size;
1415 + uint32_t dictionary_size;
1416 + uint8_t *buffer; /* output buffer */
1417 + unsigned long pos; /* current pos in buffer */
1418 + unsigned long stream_pos; /* first byte not yet written to file */
1419 + uint32_t crc;
1420 + long (*flush)(void*, unsigned long);
1421 + bool pos_wrapped;
1422 + bool buffer_given;
1423 + bool write_error;
1426 +static void LZd_flush_data(struct LZ_decoder * const d)
1428 + if (d->pos > d->stream_pos) {
1429 + const long size = d->pos - d->stream_pos;
1431 + CRC32_update_buf(&d->crc, d->buffer + d->stream_pos, size);
1432 + if ((d->flush &&
1433 + d->flush(d->buffer + d->stream_pos, size) != size) ||
1434 + (!d->flush && d->pos_wrapped))
1435 + d->write_error = true;
1436 + if (d->pos >= d->buffer_size) {
1437 + d->partial_data_pos += d->pos;
1438 + d->pos = 0;
1439 + d->pos_wrapped = true;
1441 + d->stream_pos = d->pos;
1445 +static inline uint8_t LZd_peek_prev(const struct LZ_decoder * const d)
1447 + if (d->pos > 0)
1448 + return d->buffer[d->pos-1];
1449 + if (d->pos_wrapped)
1450 + return d->buffer[d->buffer_size-1];
1451 + return 0; /* prev_byte of first byte */
1454 +static inline uint8_t LZd_peek(const struct LZ_decoder * const d,
1455 + const uint32_t distance)
1457 + const unsigned long i = ((d->pos > distance) ? 0 : d->buffer_size) +
1458 + d->pos - distance - 1;
1459 + return d->buffer[i];
1462 +static inline void LZd_put_byte(struct LZ_decoder * const d, const uint8_t b)
1464 + d->buffer[d->pos] = b;
1465 + if (++d->pos >= d->buffer_size)
1466 + LZd_flush_data(d);
1469 +static void LZd_copy_block(struct LZ_decoder * const d,
1470 + const uint32_t distance, uint32_t len)
1472 + unsigned long lpos = d->pos, i = lpos - distance - 1;
1473 + bool fast, fast2;
1475 + if (lpos > distance) {
1476 + fast = (len < d->buffer_size - lpos);
1477 + fast2 = (fast && len <= lpos - i);
1478 + } else {
1479 + i += d->buffer_size;
1480 + fast = (len < d->buffer_size - i); /* (i == pos) may happen */
1481 + fast2 = (fast && len <= i - lpos);
1483 + if (fast) { /* no wrap */
1484 + d->pos += len;
1485 + if (fast2) /* no wrap, no overlap */
1486 + memcpy(d->buffer + lpos, d->buffer + i, len);
1487 + else
1488 + for (; len > 0; --len)
1489 + d->buffer[lpos++] = d->buffer[i++];
1490 + } else
1491 + for (; len > 0; --len) {
1492 + d->buffer[d->pos] = d->buffer[i];
1493 + if (++d->pos >= d->buffer_size)
1494 + LZd_flush_data(d);
1495 + if (++i >= d->buffer_size)
1496 + i = 0;
1500 +static bool LZd_init(struct LZ_decoder * const d,
1501 + struct Range_decoder * const rde,
1502 + const uint32_t dict_size, uint8_t * const outbuf,
1503 + long out_size, long (*flush)(void*, unsigned long))
1505 + d->partial_data_pos = 0;
1506 + d->rdec = rde;
1507 + Bm_array_init(d->bm_literal[0], (1 << literal_context_bits) * 0x300);
1508 + Bm_array_init(d->bm_match[0], states * pos_states);
1509 + Bm_array_init(d->bm_rep, states);
1510 + Bm_array_init(d->bm_rep0, states);
1511 + Bm_array_init(d->bm_rep1, states);
1512 + Bm_array_init(d->bm_rep2, states);
1513 + Bm_array_init(d->bm_len[0], states * pos_states);
1514 + Bm_array_init(d->bm_dis_slot[0], len_states * (1 << dis_slot_bits));
1515 + Bm_array_init(d->bm_dis, modeled_distances - end_dis_model + 1);
1516 + Bm_array_init(d->bm_align, dis_align_size);
1517 + Lm_init(&d->match_len_model);
1518 + Lm_init(&d->rep_len_model);
1520 + d->buffer_size = (outbuf && out_size > 0) ? out_size : dict_size;
1521 + d->dictionary_size = min_t(unsigned long, d->buffer_size, dict_size);
1522 + d->buffer = outbuf ? outbuf : large_malloc(d->buffer_size);
1523 + if (!d->buffer)
1524 + return false;
1525 + d->pos = 0;
1526 + d->stream_pos = 0;
1527 + d->crc = 0xFFFFFFFFU;
1528 + d->flush = flush;
1529 + d->pos_wrapped = false;
1530 + d->buffer_given = (outbuf != 0);
1531 + d->write_error = false;
1532 + return true;
1535 +static inline void LZd_free(struct LZ_decoder * const d)
1537 + if (!d->buffer_given)
1538 + large_free(d->buffer);
1541 +static inline uint32_t LZd_crc(const struct LZ_decoder * const d)
1543 + return d->crc ^ 0xFFFFFFFFU;
1546 +static inline unsigned long long
1547 +LZd_data_position(const struct LZ_decoder * const d)
1549 + return d->partial_data_pos + d->pos;
1553 +static bool LZd_verify_trailer(struct LZ_decoder * const d)
1555 + File_trailer trailer;
1556 + int i = 0;
1558 + while (i < Ft_size)
1559 + trailer[i++] = Rd_get_byte(d->rdec);
1561 + return (Ft_get_data_crc(trailer) == LZd_crc(d) &&
1562 + Ft_get_data_size(trailer) == LZd_data_position(d) &&
1563 + Ft_get_member_size(trailer) == Rd_member_position(d->rdec));
1567 +/* Return value: -1 = write error, 0 = OK, 1 = data error. */
1568 +static int LZd_decode_member(struct LZ_decoder * const d)
1570 + struct Range_decoder * const rdec = d->rdec;
1571 + uint32_t rep0 = 0; /* rep[0-3] latest four distances */
1572 + uint32_t rep1 = 0; /* used for efficient coding of */
1573 + uint32_t rep2 = 0; /* repeated distances */
1574 + uint32_t rep3 = 0;
1575 + State state = 0;
1577 + Rd_load(rdec);
1578 + while (!Rd_finished(rdec)) {
1579 + const int pos_state = LZd_data_position(d) & pos_state_mask;
1581 + if (Rd_decode_bit(rdec, &d->bm_match[state][pos_state]) == 0) {
1582 + Bit_model * const bm = d->bm_literal[get_lit_state(LZd_peek_prev(d))];
1584 + if (St_is_char(state)) {
1585 + state -= (state < 4) ? state : 3;
1586 + LZd_put_byte(d, Rd_decode_tree(rdec, bm, 8));
1587 + } else {
1588 + state -= (state < 10) ? 3 : 6;
1589 + LZd_put_byte(d, Rd_decode_matched(rdec, bm, LZd_peek(d, rep0)));
1591 + } else { /* match or repeated match */
1592 + uint32_t len;
1594 + if (Rd_decode_bit(rdec, &d->bm_rep[state]) != 0) {
1595 + if (Rd_decode_bit(rdec, &d->bm_rep0[state]) == 0) {
1596 + if (Rd_decode_bit(rdec, &d->bm_len[state][pos_state]) == 0) {
1597 + state = St_set_short_rep(state);
1598 + LZd_put_byte(d, LZd_peek(d, rep0));
1599 + continue;
1601 + } else {
1602 + uint32_t distance;
1604 + if (Rd_decode_bit(rdec, &d->bm_rep1[state]) == 0)
1605 + distance = rep1;
1606 + else {
1607 + if (Rd_decode_bit(rdec, &d->bm_rep2[state]) == 0)
1608 + distance = rep2;
1609 + else {
1610 + distance = rep3;
1611 + rep3 = rep2;
1613 + rep2 = rep1;
1615 + rep1 = rep0;
1616 + rep0 = distance;
1618 + state = St_set_rep(state);
1619 + len = min_match_len + Rd_decode_len(rdec, &d->rep_len_model, pos_state);
1620 + } else { /* match */
1621 + uint32_t distance;
1623 + len = min_match_len + Rd_decode_len(rdec, &d->match_len_model, pos_state);
1624 + distance = Rd_decode_tree(rdec, d->bm_dis_slot[get_len_state(len)], 6);
1625 + if (distance >= start_dis_model) {
1626 + const uint32_t dis_slot = distance;
1627 + const uint32_t direct_bits = (dis_slot >> 1) - 1;
1629 + distance = (2 | (dis_slot & 1)) << direct_bits;
1630 + if (dis_slot < end_dis_model)
1631 + distance += Rd_decode_tree_reversed(rdec,
1632 + d->bm_dis + (distance - dis_slot), direct_bits);
1633 + else {
1634 + distance += Rd_decode(rdec, direct_bits - dis_align_bits) << dis_align_bits;
1635 + distance += Rd_decode_tree_reversed(rdec, d->bm_align, dis_align_bits);
1636 + if (distance == 0xFFFFFFFFU) { /* marker found */
1637 + Rd_normalize(rdec);
1638 + LZd_flush_data(d);
1639 + if (d->write_error)
1640 + return -1;
1641 + if (len == min_match_len && /* End Of Stream marker */
1642 + LZd_verify_trailer(d))
1643 + return 0;
1644 + if (len == min_match_len + 1) { /* Sync Flush marker */
1645 + Rd_load(rdec);
1646 + continue;
1648 + return 1;
1652 + rep3 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance;
1653 + state = St_set_match(state);
1654 + if (rep0 >= d->dictionary_size ||
1655 + (rep0 >= d->pos && !d->pos_wrapped)) {
1656 + LZd_flush_data(d);
1657 + return 1;
1660 + LZd_copy_block(d, rep0, len);
1663 + LZd_flush_data(d);
1664 + return 1;
1668 +STATIC int INIT __lunzip(unsigned char *inbuf, long in_len,
1669 + long (*fill)(void*, unsigned long),
1670 + long (*flush)(void*, unsigned long),
1671 + unsigned char *outbuf, long out_len,
1672 + long *in_posp,
1673 + void (*error)(char *x))
1675 + unsigned char *outptr = outbuf;
1676 + long out_size = out_len;
1677 + int retval = 0;
1678 + struct Range_decoder rdec;
1679 + struct LZ_decoder *decoder = 0;
1680 + bool first_member;
1682 + if (in_posp)
1683 + *in_posp = 0;
1684 + CRC32_init();
1686 + if (!Rd_init(&rdec, inbuf, in_len, fill)) {
1687 + error("Out of memory while allocating input buffer");
1688 + return -1;
1691 + for (first_member = true;; first_member = false) {
1692 + int result, size;
1693 + unsigned dictionary_size;
1694 + File_header header;
1696 + Rd_reset_member_position(&rdec);
1697 + for (size = 0; size < Fh_size; ++size)
1698 + header[size] = Rd_get_byte(&rdec);
1699 + if (Rd_finished(&rdec)) { /* End Of File */
1700 + if (first_member) {
1701 + error("File ends unexpectedly at member header");
1702 + retval = -1;
1704 + break;
1706 + if (!Fh_verify_magic(header)) {
1707 + if (first_member) {
1708 + error("Bad magic number (file not in lzip format)");
1709 + retval = -1;
1711 + break;
1713 + dictionary_size = Fh_get_dictionary_size(header);
1714 + if (dictionary_size < min_dictionary_size ||
1715 + dictionary_size > max_dictionary_size) {
1716 + error("Invalid dictionary size in member header");
1717 + retval = -1;
1718 + break;
1721 + if (!decoder)
1722 + decoder = malloc(sizeof *decoder);
1723 + if (!decoder || !LZd_init(decoder, &rdec, dictionary_size, outptr, out_size, flush)) {
1724 + error("Out of memory while allocating output buffer");
1725 + retval = -1;
1726 + break;
1728 + result = LZd_decode_member(decoder);
1729 + if (in_posp)
1730 + *in_posp += Rd_member_position(&rdec);
1731 + if (outptr)
1732 + outptr += LZd_data_position(decoder);
1733 + if (out_size > 0)
1734 + out_size -= LZd_data_position(decoder);
1735 + LZd_free(decoder);
1736 + if (result != 0) {
1737 + if (result < 0)
1738 + error("write error");
1739 + else
1740 + error("LZIP-compressed data is corrupt");
1741 + retval = -1;
1742 + break;
1745 + if (decoder)
1746 + free(decoder);
1747 + Rd_free(&rdec);
1748 + return retval;
1751 +#ifndef PREBOOT
1752 +STATIC int INIT lunzip(unsigned char *inbuf, long in_len,
1753 + long (*fill)(void*, unsigned long),
1754 + long (*flush)(void*, unsigned long),
1755 + unsigned char *outbuf,
1756 + long *in_posp,
1757 + void (*error)(char *x))
1759 + return __lunzip(inbuf, in_len, fill, flush, outbuf, 0, in_posp, error);
1761 +#else
1762 +STATIC int INIT __decompress(unsigned char *inbuf, long in_len,
1763 + long (*fill)(void*, unsigned long),
1764 + long (*flush)(void*, unsigned long),
1765 + unsigned char *outbuf, long out_len,
1766 + long *in_posp,
1767 + void (*error)(char *x))
1769 + return __lunzip(inbuf, in_len - 4, fill, flush, outbuf, out_len, in_posp, error);
1771 +#endif
1772 diff -urdN linux-4.14.7/scripts/Makefile.lib linux-4.14.7.new/scripts/Makefile.lib
1773 --- linux-4.14.7/scripts/Makefile.lib 2017-12-17 15:08:14.000000000 +0100
1774 +++ linux-4.14.7.new/scripts/Makefile.lib 2017-12-18 20:58:51.000000000 +0100
1775 @@ -343,6 +343,21 @@
1776 bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
1777 (rm -f $@ ; false)
1779 +# Lzip
1780 +# ---------------------------------------------------------------------------
1781 +# The .lz format has the uncompressed size available at the end of the
1782 +# file, but at offset (member_size - 16). So we append a gzip-style size.
1783 +# Use klzip to compress the kernel image and lzip to compress other things.
1785 +quiet_cmd_klzip = LZIP $@
1786 +cmd_klzip = (cat $(filter-out FORCE,$^) | \
1787 + lzip -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
1788 + (rm -f $@ ; false)
1790 +quiet_cmd_lzip = LZIP $@
1791 +cmd_lzip = (cat $(filter-out FORCE,$^) | lzip -9) > $@ || \
1792 + (rm -f $@ ; false)
1794 # Lzma
1795 # ---------------------------------------------------------------------------
1797 diff -urdN linux-4.14.7/scripts/extract-ikconfig linux-4.14.7.new/scripts/extract-ikconfig
1798 --- linux-4.14.7/scripts/extract-ikconfig 2017-12-17 15:08:14.000000000 +0100
1799 +++ linux-4.14.7.new/scripts/extract-ikconfig 2017-12-18 20:58:51.000000000 +0100
1800 @@ -59,6 +59,7 @@
1801 try_decompress '\037\213\010' xy gunzip
1802 try_decompress '\3757zXZ\000' abcde unxz
1803 try_decompress 'BZh' xy bunzip2
1804 +try_decompress 'LZIP' xyz 'lzip -d'
1805 try_decompress '\135\0\0\0' xxx unlzma
1806 try_decompress '\211\114\132' xy 'lzop -d'
1807 try_decompress '\002\041\114\030' xyy 'lz4 -d -l'
1808 diff -urdN linux-4.14.7/scripts/extract-vmlinux linux-4.14.7.new/scripts/extract-vmlinux
1809 --- linux-4.14.7/scripts/extract-vmlinux 2017-12-17 15:08:14.000000000 +0100
1810 +++ linux-4.14.7.new/scripts/extract-vmlinux 2017-12-18 20:58:51.000000000 +0100
1811 @@ -55,6 +55,7 @@
1812 try_decompress '\037\213\010' xy gunzip
1813 try_decompress '\3757zXZ\000' abcde unxz
1814 try_decompress 'BZh' xy bunzip2
1815 +try_decompress 'LZIP' xyz 'lzip -d'
1816 try_decompress '\135\0\0\0' xxx unlzma
1817 try_decompress '\211\114\132' xy 'lzop -d'
1819 diff -urdN linux-4.14.7/scripts/gen_initramfs_list.sh linux-4.14.7.new/scripts/gen_initramfs_list.sh
1820 --- linux-4.14.7/scripts/gen_initramfs_list.sh 2017-12-17 15:08:14.000000000 +0100
1821 +++ linux-4.14.7.new/scripts/gen_initramfs_list.sh 2017-12-18 20:58:51.000000000 +0100
1822 @@ -249,6 +249,9 @@
1823 echo "$output_file" | grep -q "\.bz2$" \
1824 && [ -x "`which bzip2 2> /dev/null`" ] \
1825 && compr="bzip2 -9 -f"
1826 + echo "$output_file" | grep -q "\.lz$" \
1827 + && [ -x "`which lzip 2> /dev/null`" ] \
1828 + && compr="lzip -9 -f"
1829 echo "$output_file" | grep -q "\.lzma$" \
1830 && [ -x "`which lzma 2> /dev/null`" ] \
1831 && compr="lzma -9 -f"
1832 diff -urdN linux-4.14.7/scripts/package/Makefile linux-4.14.7.new/scripts/package/Makefile
1833 --- linux-4.14.7/scripts/package/Makefile 2017-12-17 15:08:14.000000000 +0100
1834 +++ linux-4.14.7.new/scripts/package/Makefile 2017-12-18 20:58:51.000000000 +0100
1835 @@ -123,8 +123,9 @@
1836 $(if $(findstring tar-src,$@),, \
1837 $(if $(findstring bz2,$@),bzip2, \
1838 $(if $(findstring gz,$@),gzip, \
1839 +$(if $(findstring lz,$@),lzip, \
1840 $(if $(findstring xz,$@),xz, \
1841 -$(error unknown target $@)))) \
1842 +$(error unknown target $@))))) \
1843 -f -9 $(perf-tar).tar)
1845 perf-%pkg: FORCE
1846 @@ -140,8 +141,10 @@
1847 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
1848 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
1849 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
1850 + @echo ' tarlz-pkg - Build the kernel as a lzip compressed tarball'
1851 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
1852 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
1853 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
1854 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
1855 + @echo ' perf-tarlz-src-pkg - Build $(perf-tar).tar.lz source tarball'
1856 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
1857 diff -urdN linux-4.14.7/scripts/package/buildtar linux-4.14.7.new/scripts/package/buildtar
1858 --- linux-4.14.7/scripts/package/buildtar 2017-12-17 15:08:14.000000000 +0100
1859 +++ linux-4.14.7.new/scripts/package/buildtar 2017-12-19 14:03:42.000000000 +0100
1860 @@ -35,6 +35,10 @@
1861 opts=--bzip2
1862 tarball=${tarball}.bz2
1864 + tarlz-pkg)
1865 + opts=--lzip
1866 + tarball=${tarball}.lz
1867 + ;;
1868 tarxz-pkg)
1869 opts=--xz
1870 tarball=${tarball}.xz
1871 diff -urdN linux-4.14.7/scripts/patch-kernel linux-4.14.7.new/scripts/patch-kernel
1872 --- linux-4.14.7/scripts/patch-kernel 2017-12-17 15:08:14.000000000 +0100
1873 +++ linux-4.14.7.new/scripts/patch-kernel 2017-12-18 20:58:51.000000000 +0100
1874 @@ -117,6 +117,10 @@
1875 ext=".bz2"
1876 name="bzip2"
1877 uncomp="bunzip2 -dc"
1878 + elif [ -r ${filebase}.lz ]; then
1879 + ext=".lz"
1880 + name="lzip"
1881 + uncomp="lzip -dc"
1882 elif [ -r ${filebase}.xz ]; then
1883 ext=".xz"
1884 name="xz"
1885 diff -urdN linux-4.14.7/tools/testing/selftests/gen_kselftest_tar.sh linux-4.14.7.new/tools/testing/selftests/gen_kselftest_tar.sh
1886 --- linux-4.14.7/tools/testing/selftests/gen_kselftest_tar.sh 2017-12-17 15:08:14.000000000 +0100
1887 +++ linux-4.14.7.new/tools/testing/selftests/gen_kselftest_tar.sh 2017-12-18 20:58:51.000000000 +0100
1888 @@ -29,6 +29,10 @@
1889 copts="cvjf"
1890 ext=".tar.bz2"
1892 + tarlz)
1893 + copts="cv --lzip -f"
1894 + ext=".tar.lz"
1895 + ;;
1896 tarxz)
1897 copts="cvJf"
1898 ext=".tar.xz"
1899 diff -urdN linux-4.14.7/usr/.gitignore linux-4.14.7.new/usr/.gitignore
1900 --- linux-4.14.7/usr/.gitignore 2017-12-17 15:08:14.000000000 +0100
1901 +++ linux-4.14.7.new/usr/.gitignore 2017-12-18 20:58:51.000000000 +0100
1902 @@ -5,6 +5,7 @@
1903 initramfs_data.cpio
1904 initramfs_data.cpio.gz
1905 initramfs_data.cpio.bz2
1906 +initramfs_data.cpio.lz
1907 initramfs_data.cpio.lzma
1908 initramfs_list
1909 include
1910 diff -urdN linux-4.14.7/usr/Kconfig linux-4.14.7.new/usr/Kconfig
1911 --- linux-4.14.7/usr/Kconfig 2017-12-17 15:08:14.000000000 +0100
1912 +++ linux-4.14.7.new/usr/Kconfig 2017-12-19 01:46:42.000000000 +0100
1913 @@ -70,6 +70,15 @@
1914 Support loading of a bzip2 encoded initial ramdisk or cpio buffer
1915 If unsure, say N.
1917 +config RD_LZIP
1918 + bool "Support initial ramdisk/ramfs compressed using lzip"
1919 + default y
1920 + depends on BLK_DEV_INITRD
1921 + select DECOMPRESS_LZIP
1922 + help
1923 + Support loading of a lzip encoded initial ramdisk or cpio buffer.
1924 + If unsure, say N.
1926 config RD_LZMA
1927 bool "Support initial ramdisk/ramfs compressed using LZMA"
1928 default y
1929 @@ -165,6 +174,18 @@
1930 If you choose this, keep in mind that you need to have the bzip2 tool
1931 available to be able to compress the initram.
1933 +config INITRAMFS_COMPRESSION_LZIP
1934 + bool "Lzip"
1935 + depends on RD_LZIP
1936 + help
1937 + Lzip's compression ratio is better than that of gzip and bzip2.
1938 + Decompression speed is between gzip and bzip2. Compression can
1939 + be as fast as gzip or slower than bzip2 depending on compression
1940 + level. Lzip can produce a initramfs about a 16% smaller than gzip.
1942 + If you choose this, keep in mind that you need to have the lzip tool
1943 + available to be able to compress the initram.
1945 config INITRAMFS_COMPRESSION_LZMA
1946 bool "LZMA"
1947 depends on RD_LZMA
1948 @@ -222,12 +243,14 @@
1949 default "" if INITRAMFS_COMPRESSION_NONE
1950 default ".gz" if INITRAMFS_COMPRESSION_GZIP
1951 default ".bz2" if INITRAMFS_COMPRESSION_BZIP2
1952 + default ".lz" if INITRAMFS_COMPRESSION_LZIP
1953 default ".lzma" if INITRAMFS_COMPRESSION_LZMA
1954 default ".xz" if INITRAMFS_COMPRESSION_XZ
1955 default ".lzo" if INITRAMFS_COMPRESSION_LZO
1956 default ".lz4" if INITRAMFS_COMPRESSION_LZ4
1957 default ".gz" if RD_GZIP
1958 default ".lz4" if RD_LZ4
1959 + default ".lz" if RD_LZIP
1960 default ".lzo" if RD_LZO
1961 default ".xz" if RD_XZ
1962 default ".lzma" if RD_LZMA