recipes: kernel/kmod: upgraded to version 26
[dragora.git] / patches / kernel / linux-4.18.1_lzip-1.diff
blob02985acfbb12b7f59842fd82a0d036d0be116abe
1 diff -urdN linux-4.18.1/Documentation/00-INDEX linux-4.18.1.new/Documentation/00-INDEX
2 --- linux-4.18.1/Documentation/00-INDEX 2018-08-15 17:37:34.000000000 +0200
3 +++ linux-4.18.1.new/Documentation/00-INDEX 2018-08-16 18:56:17.000000000 +0200
4 @@ -242,6 +242,8 @@
5 - info on creator of above logo & site to get additional images from.
6 lsm.txt
7 - Linux Security Modules: General Security Hooks for Linux
8 +lzip.txt
9 + - info on lzip compression for the linux kernel.
10 lzo.txt
11 - kernel LZO decompressor input formats
12 m68k/
13 diff -urdN linux-4.18.1/Documentation/dontdiff linux-4.18.1.new/Documentation/dontdiff
14 --- linux-4.18.1/Documentation/dontdiff 2018-08-15 17:37:34.000000000 +0200
15 +++ linux-4.18.1.new/Documentation/dontdiff 2018-08-16 18:56:17.000000000 +0200
16 @@ -26,6 +26,7 @@
17 *.ll
18 *.log
19 *.lst
20 +*.lz
21 *.lzma
22 *.lzo
23 *.mo
24 diff -urdN linux-4.18.1/Documentation/filesystems/squashfs.txt linux-4.18.1.new/Documentation/filesystems/squashfs.txt
25 --- linux-4.18.1/Documentation/filesystems/squashfs.txt 2018-08-15 17:37:34.000000000 +0200
26 +++ linux-4.18.1.new/Documentation/filesystems/squashfs.txt 2018-08-16 18:56:17.000000000 +0200
27 @@ -2,7 +2,7 @@
28 =======================
30 Squashfs is a compressed read-only filesystem for Linux.
31 -It uses zlib, lz4, lzo, or xz compression to compress files, inodes and
32 +It uses zlib, lz4, lzip, lzo, or xz compression to compress files, inodes and
33 directories. Inodes in the system are very small and all blocks are packed to
34 minimise data overhead. Block sizes greater than 4K are supported up to a
35 maximum of 1Mbytes (default block size 128K).
36 diff -urdN linux-4.18.1/Documentation/lzip.txt linux-4.18.1.new/Documentation/lzip.txt
37 --- linux-4.18.1/Documentation/lzip.txt 1970-01-01 01:00:00.000000000 +0100
38 +++ linux-4.18.1.new/Documentation/lzip.txt 2018-08-16 18:56:17.000000000 +0200
39 @@ -0,0 +1,59 @@
40 +==============================
41 +Lzip data compression in Linux
42 +==============================
44 +Introduction
45 +============
47 +Lzip is a lossless data compressor with a user interface similar to the
48 +one of gzip or bzip2. Lzip can compress about as fast as gzip (lzip -0),
49 +or compress most files more than bzip2 (lzip -9). Decompression speed is
50 +intermediate between gzip and bzip2. Lzip implements the LZMA algorithm.
52 +Lzip has been designed, written and tested with great care to be the
53 +standard general-purpose compressor for unix-like systems. The lzip
54 +format is as simple as possible (but not simpler). It provides accurate
55 +and robust 3 factor integrity checking.
57 +Learn more about lzip at http://www.nongnu.org/lzip/lzip.html
59 +Lzip related components in the kernel
60 +=====================================
62 +The lzip_decompress module in lib/lzip.c provides a versatile lzip
63 +decompression function able to do buffer to buffer decompression or
64 +stream decompression with fill and flush callback functions. The usage
65 +of the function is documented in include/linux/lzip.h.
67 +For decompressing the kernel image, initramfs, and initrd, there is a
68 +wrapper function in lib/decompress_lunzip.c providing the same common
69 +interface as the other decompress_*.c files, which is defined in
70 +include/linux/decompress/generic.h.
72 +For kernel makefiles, two commands are provided in scripts/Makefile.lib
73 +for use with $(call if_changed). The kernel image must be compressed
74 +with $(call if_changed,klzip) which will append a four-byte trailer
75 +containing the size of the uncompressed data, which is needed by the
76 +boot code. Other things should be compressed with $(call if_changed,lzip).
78 +Testing
79 +=======
81 +Lzip-compressed kernel images of multiple linux versions since 2.6.30.10
82 +have been built and tested, even on machines as modest as an AMD 486-DX2
83 +at 66 MHz with 64 MiB of RAM. In the worst case (on the slow machine
84 +above), lzip just increased the boot time a 15% compared with gzip. On
85 +more modern machines, lzip may boot slightly faster than gzip. It just
86 +takes 0.2 seconds for lzip to decompress vmlinuz-4.4.16 on my machine.
88 +Decompression time is usually a small fraction of the total boot time.
89 +For example, using lz4 on a desktop machine in order to save 0.05
90 +seconds of a total boot time of 20 seconds is probably not worth the
91 +increased image size.
93 +Xlunzip is a test tool for the lzip_decompress module. It is similar to
94 +lunzip, but it uses the lzip_decompress module as a backend. The xlunzip
95 +home page is at http://www.nongnu.org/lzip/xlunzip.html
97 +Author: Antonio Diaz Diaz
98 +Updated: 2018-07-08
99 diff -urdN linux-4.18.1/Documentation/x86/boot.txt linux-4.18.1.new/Documentation/x86/boot.txt
100 --- linux-4.18.1/Documentation/x86/boot.txt 2018-08-15 17:37:34.000000000 +0200
101 +++ linux-4.18.1.new/Documentation/x86/boot.txt 2018-08-16 18:56:17.000000000 +0200
102 @@ -665,10 +665,10 @@
103 The payload may be compressed. The format of both the compressed and
104 uncompressed data should be determined using the standard magic
105 numbers. The currently supported compression formats are gzip
106 - (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), LZMA
107 - (magic number 5D 00), XZ (magic number FD 37), and LZ4 (magic number
108 - 02 21). The uncompressed payload is currently always ELF (magic
109 - number 7F 45 4C 46).
110 + (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), lzip
111 + (magic number 4C 5A), LZMA (magic number 5D 00), XZ (magic number FD
112 + 37), and LZ4 (magic number 02 21). The uncompressed payload is
113 + currently always ELF (magic number 7F 45 4C 46).
115 Field name: payload_length
116 Type: read
117 diff -urdN linux-4.18.1/Makefile linux-4.18.1.new/Makefile
118 --- linux-4.18.1/Makefile 2018-08-15 17:37:34.000000000 +0200
119 +++ linux-4.18.1.new/Makefile 2018-08-16 18:56:17.000000000 +0200
120 @@ -890,14 +890,17 @@
121 export mod_strip_cmd
123 # CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed
124 -# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP
125 -# or CONFIG_MODULE_COMPRESS_XZ.
126 +# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP,
127 +# CONFIG_MODULE_COMPRESS_LZIP or CONFIG_MODULE_COMPRESS_XZ.
129 mod_compress_cmd = true
130 ifdef CONFIG_MODULE_COMPRESS
131 ifdef CONFIG_MODULE_COMPRESS_GZIP
132 mod_compress_cmd = gzip -n -f
133 endif # CONFIG_MODULE_COMPRESS_GZIP
134 + ifdef CONFIG_MODULE_COMPRESS_LZIP
135 + mod_compress_cmd = lzip -f
136 + endif # CONFIG_MODULE_COMPRESS_LZIP
137 ifdef CONFIG_MODULE_COMPRESS_XZ
138 mod_compress_cmd = xz -f
139 endif # CONFIG_MODULE_COMPRESS_XZ
140 @@ -909,6 +912,7 @@
142 INITRD_COMPRESS-y := gzip
143 INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2
144 +INITRD_COMPRESS-$(CONFIG_RD_LZIP) := lzip
145 INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma
146 INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz
147 INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo
148 diff -urdN linux-4.18.1/arch/arm/Kconfig linux-4.18.1.new/arch/arm/Kconfig
149 --- linux-4.18.1/arch/arm/Kconfig 2018-08-15 17:37:34.000000000 +0200
150 +++ linux-4.18.1.new/arch/arm/Kconfig 2018-08-16 18:56:17.000000000 +0200
151 @@ -76,6 +76,7 @@
152 select HAVE_IRQ_TIME_ACCOUNTING
153 select HAVE_KERNEL_GZIP
154 select HAVE_KERNEL_LZ4
155 + select HAVE_KERNEL_LZIP
156 select HAVE_KERNEL_LZMA
157 select HAVE_KERNEL_LZO
158 select HAVE_KERNEL_XZ
159 diff -urdN linux-4.18.1/arch/arm/boot/compressed/Makefile linux-4.18.1.new/arch/arm/boot/compressed/Makefile
160 --- linux-4.18.1/arch/arm/boot/compressed/Makefile 2018-08-15 17:37:34.000000000 +0200
161 +++ linux-4.18.1.new/arch/arm/boot/compressed/Makefile 2018-08-16 18:56:17.000000000 +0200
162 @@ -71,6 +71,7 @@
163 CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
165 compress-$(CONFIG_KERNEL_GZIP) = gzip
166 +compress-$(CONFIG_KERNEL_LZIP) = klzip
167 compress-$(CONFIG_KERNEL_LZO) = lzo
168 compress-$(CONFIG_KERNEL_LZMA) = lzma
169 compress-$(CONFIG_KERNEL_XZ) = xzkern
170 diff -urdN linux-4.18.1/arch/arm/boot/compressed/decompress.c linux-4.18.1.new/arch/arm/boot/compressed/decompress.c
171 --- linux-4.18.1/arch/arm/boot/compressed/decompress.c 2018-08-15 17:37:34.000000000 +0200
172 +++ linux-4.18.1.new/arch/arm/boot/compressed/decompress.c 2018-08-16 18:56:17.000000000 +0200
173 @@ -37,6 +37,10 @@
174 #include "../../../../lib/decompress_inflate.c"
175 #endif
177 +#ifdef CONFIG_KERNEL_LZIP
178 +#include "../../../../lib/decompress_lunzip.c"
179 +#endif
181 #ifdef CONFIG_KERNEL_LZO
182 #include "../../../../lib/decompress_unlzo.c"
183 #endif
184 diff -urdN linux-4.18.1/arch/mips/Kconfig linux-4.18.1.new/arch/mips/Kconfig
185 --- linux-4.18.1/arch/mips/Kconfig 2018-08-15 17:37:34.000000000 +0200
186 +++ linux-4.18.1.new/arch/mips/Kconfig 2018-08-16 18:56:17.000000000 +0200
187 @@ -1813,6 +1813,7 @@
188 select HAVE_KERNEL_GZIP
189 select HAVE_KERNEL_BZIP2
190 select HAVE_KERNEL_LZ4
191 + select HAVE_KERNEL_LZIP
192 select HAVE_KERNEL_LZMA
193 select HAVE_KERNEL_LZO
194 select HAVE_KERNEL_XZ
195 diff -urdN linux-4.18.1/arch/mips/Makefile linux-4.18.1.new/arch/mips/Makefile
196 --- linux-4.18.1/arch/mips/Makefile 2018-08-15 17:37:34.000000000 +0200
197 +++ linux-4.18.1.new/arch/mips/Makefile 2018-08-16 18:56:17.000000000 +0200
198 @@ -336,12 +336,14 @@
199 boot-y += uImage.bin
200 boot-y += uImage.bz2
201 boot-y += uImage.gz
202 +boot-y += uImage.lz
203 boot-y += uImage.lzma
204 boot-y += uImage.lzo
205 endif
206 boot-y += vmlinux.itb
207 boot-y += vmlinux.gz.itb
208 boot-y += vmlinux.bz2.itb
209 +boot-y += vmlinux.lz.itb
210 boot-y += vmlinux.lzma.itb
211 boot-y += vmlinux.lzo.itb
213 @@ -452,6 +454,7 @@
214 echo ' uImage.bin - U-Boot image (uncompressed)'
215 echo ' uImage.bz2 - U-Boot image (bz2)'
216 echo ' uImage.gz - U-Boot image (gzip)'
217 + echo ' uImage.lz - U-Boot image (lzip)'
218 echo ' uImage.lzma - U-Boot image (lzma)'
219 echo ' uImage.lzo - U-Boot image (lzo)'
220 echo ' uzImage.bin - U-Boot image (self-extracting)'
221 diff -urdN linux-4.18.1/arch/mips/boot/Makefile linux-4.18.1.new/arch/mips/boot/Makefile
222 --- linux-4.18.1/arch/mips/boot/Makefile 2018-08-15 17:37:34.000000000 +0200
223 +++ linux-4.18.1.new/arch/mips/boot/Makefile 2018-08-16 18:56:17.000000000 +0200
224 @@ -26,6 +26,7 @@
225 suffix-y := bin
226 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
227 suffix-$(CONFIG_KERNEL_GZIP) := gz
228 +suffix-$(CONFIG_KERNEL_LZIP) := lz
229 suffix-$(CONFIG_KERNEL_LZMA) := lzma
230 suffix-$(CONFIG_KERNEL_LZO) := lzo
232 @@ -56,6 +57,7 @@
234 extra-y += vmlinux.bin.bz2
235 extra-y += vmlinux.bin.gz
236 +extra-y += vmlinux.bin.lz
237 extra-y += vmlinux.bin.lzma
238 extra-y += vmlinux.bin.lzo
240 @@ -65,6 +67,9 @@
241 $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
242 $(call if_changed,gzip)
244 +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
245 + $(call if_changed,klzip)
247 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
248 $(call if_changed,lzma)
250 @@ -79,6 +84,7 @@
251 targets += uImage.bin
252 targets += uImage.bz2
253 targets += uImage.gz
254 +targets += uImage.lz
255 targets += uImage.lzma
256 targets += uImage.lzo
258 @@ -91,6 +97,9 @@
259 $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz FORCE
260 $(call if_changed,uimage,gzip)
262 +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz FORCE
263 + $(call if_changed,uimage,lzip)
265 $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma FORCE
266 $(call if_changed,uimage,lzma)
268 @@ -108,6 +117,7 @@
269 targets += vmlinux.itb
270 targets += vmlinux.gz.itb
271 targets += vmlinux.bz2.itb
272 +targets += vmlinux.lz.itb
273 targets += vmlinux.lzma.itb
274 targets += vmlinux.lzo.itb
276 @@ -144,6 +154,9 @@
277 $(obj)/vmlinux.bz2.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
278 $(call if_changed_dep,cpp_its_S,bzip2,vmlinux.bin.bz2)
280 +$(obj)/vmlinux.lz.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
281 + $(call if_changed_dep,cpp_its_S,lzip,vmlinux.bin.lz)
283 $(obj)/vmlinux.lzma.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
284 $(call if_changed_dep,cpp_its_S,lzma,vmlinux.bin.lzma)
286 @@ -168,6 +181,9 @@
287 $(obj)/vmlinux.bz2.itb: $(obj)/vmlinux.bz2.its $(obj)/vmlinux.bin.bz2 FORCE
288 $(call if_changed,itb-image,$<)
290 +$(obj)/vmlinux.lz.itb: $(obj)/vmlinux.lz.its $(obj)/vmlinux.bin.lz FORCE
291 + $(call if_changed,itb-image,$<)
293 $(obj)/vmlinux.lzma.itb: $(obj)/vmlinux.lzma.its $(obj)/vmlinux.bin.lzma FORCE
294 $(call if_changed,itb-image,$<)
296 diff -urdN linux-4.18.1/arch/mips/boot/compressed/Makefile linux-4.18.1.new/arch/mips/boot/compressed/Makefile
297 --- linux-4.18.1/arch/mips/boot/compressed/Makefile 2018-08-15 17:37:34.000000000 +0200
298 +++ linux-4.18.1.new/arch/mips/boot/compressed/Makefile 2018-08-16 18:56:17.000000000 +0200
299 @@ -64,6 +64,7 @@
300 tool_$(CONFIG_KERNEL_GZIP) = gzip
301 tool_$(CONFIG_KERNEL_BZIP2) = bzip2
302 tool_$(CONFIG_KERNEL_LZ4) = lz4
303 +tool_$(CONFIG_KERNEL_LZIP) = klzip
304 tool_$(CONFIG_KERNEL_LZMA) = lzma
305 tool_$(CONFIG_KERNEL_LZO) = lzo
306 tool_$(CONFIG_KERNEL_XZ) = xzkern
307 diff -urdN linux-4.18.1/arch/mips/boot/compressed/decompress.c linux-4.18.1.new/arch/mips/boot/compressed/decompress.c
308 --- linux-4.18.1/arch/mips/boot/compressed/decompress.c 2018-08-15 17:37:34.000000000 +0200
309 +++ linux-4.18.1.new/arch/mips/boot/compressed/decompress.c 2018-08-16 18:56:17.000000000 +0200
310 @@ -64,6 +64,10 @@
311 #include "../../../../lib/decompress_unlz4.c"
312 #endif
314 +#ifdef CONFIG_KERNEL_LZIP
315 +#include "../../../../lib/decompress_lunzip.c"
316 +#endif
318 #ifdef CONFIG_KERNEL_LZMA
319 #include "../../../../lib/decompress_unlzma.c"
320 #endif
321 diff -urdN linux-4.18.1/arch/s390/Kconfig linux-4.18.1.new/arch/s390/Kconfig
322 --- linux-4.18.1/arch/s390/Kconfig 2018-08-15 17:37:34.000000000 +0200
323 +++ linux-4.18.1.new/arch/s390/Kconfig 2018-08-16 18:56:17.000000000 +0200
324 @@ -143,6 +143,7 @@
325 select HAVE_KERNEL_BZIP2
326 select HAVE_KERNEL_GZIP
327 select HAVE_KERNEL_LZ4
328 + select HAVE_KERNEL_LZIP
329 select HAVE_KERNEL_LZMA
330 select HAVE_KERNEL_LZO
331 select HAVE_KERNEL_XZ
332 diff -urdN linux-4.18.1/arch/s390/boot/compressed/Makefile linux-4.18.1.new/arch/s390/boot/compressed/Makefile
333 --- linux-4.18.1/arch/s390/boot/compressed/Makefile 2018-08-15 17:37:34.000000000 +0200
334 +++ linux-4.18.1.new/arch/s390/boot/compressed/Makefile 2018-08-16 18:56:17.000000000 +0200
335 @@ -7,9 +7,9 @@
337 KCOV_INSTRUMENT := n
339 -targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
340 -targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
341 -targets += misc.o piggy.o sizes.h head.o
342 +targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
343 +targets += vmlinux.bin.lz vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo
344 +targets += vmlinux.bin.lz4 misc.o piggy.o sizes.h head.o
346 KBUILD_CFLAGS := -m64 -D__KERNEL__ -O2
347 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
348 @@ -60,6 +60,7 @@
349 suffix-$(CONFIG_KERNEL_GZIP) := gz
350 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
351 suffix-$(CONFIG_KERNEL_LZ4) := lz4
352 +suffix-$(CONFIG_KERNEL_LZIP) := lz
353 suffix-$(CONFIG_KERNEL_LZMA) := lzma
354 suffix-$(CONFIG_KERNEL_LZO) := lzo
355 suffix-$(CONFIG_KERNEL_XZ) := xz
356 @@ -70,6 +71,8 @@
357 $(call if_changed,bzip2)
358 $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
359 $(call if_changed,lz4)
360 +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y)
361 + $(call if_changed,klzip)
362 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
363 $(call if_changed,lzma)
364 $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
365 diff -urdN linux-4.18.1/arch/s390/boot/compressed/misc.c linux-4.18.1.new/arch/s390/boot/compressed/misc.c
366 --- linux-4.18.1/arch/s390/boot/compressed/misc.c 2018-08-15 17:37:34.000000000 +0200
367 +++ linux-4.18.1.new/arch/s390/boot/compressed/misc.c 2018-08-16 18:56:17.000000000 +0200
368 @@ -53,6 +53,10 @@
369 #include "../../../../lib/decompress_unlz4.c"
370 #endif
372 +#ifdef CONFIG_KERNEL_LZIP
373 +#include "../../../../lib/decompress_lunzip.c"
374 +#endif
376 #ifdef CONFIG_KERNEL_LZMA
377 #include "../../../../lib/decompress_unlzma.c"
378 #endif
379 diff -urdN linux-4.18.1/arch/sh/Kconfig linux-4.18.1.new/arch/sh/Kconfig
380 --- linux-4.18.1/arch/sh/Kconfig 2018-08-15 17:37:34.000000000 +0200
381 +++ linux-4.18.1.new/arch/sh/Kconfig 2018-08-16 18:56:17.000000000 +0200
382 @@ -25,6 +25,7 @@
383 select HAVE_KERNEL_GZIP
384 select CPU_NO_EFFICIENT_FFS
385 select HAVE_KERNEL_BZIP2
386 + select HAVE_KERNEL_LZIP
387 select HAVE_KERNEL_LZMA
388 select HAVE_KERNEL_XZ
389 select HAVE_KERNEL_LZO
390 diff -urdN linux-4.18.1/arch/sh/Makefile linux-4.18.1.new/arch/sh/Makefile
391 --- linux-4.18.1/arch/sh/Makefile 2018-08-15 17:37:34.000000000 +0200
392 +++ linux-4.18.1.new/arch/sh/Makefile 2018-08-16 18:56:17.000000000 +0200
393 @@ -209,9 +209,9 @@
394 libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
395 libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
397 -BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
398 - uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
399 - romImage
400 +BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lz uImage.lzma uImage.xz \
401 + uImage.lzo uImage.srec uImage.bin zImage vmlinux.bin \
402 + vmlinux.srec romImage
403 PHONY += $(BOOT_TARGETS)
405 all: $(notdir $(KBUILD_IMAGE))
406 @@ -238,6 +238,7 @@
407 @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
408 @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)'
409 @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
410 + @echo ' uImage.lz - Kernel-only image for U-Boot (lzip)'
411 @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)'
412 @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
413 @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
414 diff -urdN linux-4.18.1/arch/sh/boot/Makefile linux-4.18.1.new/arch/sh/boot/Makefile
415 --- linux-4.18.1/arch/sh/boot/Makefile 2018-08-15 17:37:34.000000000 +0200
416 +++ linux-4.18.1.new/arch/sh/boot/Makefile 2018-08-16 18:56:17.000000000 +0200
417 @@ -22,14 +22,15 @@
418 suffix-y := bin
419 suffix-$(CONFIG_KERNEL_GZIP) := gz
420 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
421 +suffix-$(CONFIG_KERNEL_LZIP) := lz
422 suffix-$(CONFIG_KERNEL_LZMA) := lzma
423 suffix-$(CONFIG_KERNEL_XZ) := xz
424 suffix-$(CONFIG_KERNEL_LZO) := lzo
426 targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz \
427 - uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin
428 -extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
429 - vmlinux.bin.xz vmlinux.bin.lzo
430 + uImage.bz2 uImage.lz uImage.lzma uImage.xz uImage.lzo uImage.bin
431 +extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
432 + vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo
433 subdir- := compressed romimage
435 $(obj)/zImage: $(obj)/compressed/vmlinux FORCE
436 @@ -71,6 +72,9 @@
437 $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
438 $(call if_changed,bzip2)
440 +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
441 + $(call if_changed,klzip)
443 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
444 $(call if_changed,lzma)
446 @@ -86,6 +90,9 @@
447 $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz
448 $(call if_changed,uimage,gzip)
450 +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz
451 + $(call if_changed,uimage,lzip)
453 $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma
454 $(call if_changed,uimage,lzma)
456 diff -urdN linux-4.18.1/arch/sh/boot/compressed/Makefile linux-4.18.1.new/arch/sh/boot/compressed/Makefile
457 --- linux-4.18.1/arch/sh/boot/compressed/Makefile 2018-08-15 17:37:34.000000000 +0200
458 +++ linux-4.18.1.new/arch/sh/boot/compressed/Makefile 2018-08-16 18:56:17.000000000 +0200
459 @@ -5,10 +5,9 @@
460 # create a compressed vmlinux image from the original vmlinux
463 -targets := vmlinux vmlinux.bin vmlinux.bin.gz \
464 - vmlinux.bin.bz2 vmlinux.bin.lzma \
465 - vmlinux.bin.xz vmlinux.bin.lzo \
466 - head_$(BITS).o misc.o piggy.o
467 +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
468 + vmlinux.bin.lz vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo \
469 + head_$(BITS).o misc.o piggy.o
471 OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/cache.o
473 @@ -66,6 +65,8 @@
474 $(call if_changed,gzip)
475 $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
476 $(call if_changed,bzip2)
477 +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y) FORCE
478 + $(call if_changed,klzip)
479 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
480 $(call if_changed,lzma)
481 $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
482 diff -urdN linux-4.18.1/arch/sh/boot/compressed/misc.c linux-4.18.1.new/arch/sh/boot/compressed/misc.c
483 --- linux-4.18.1/arch/sh/boot/compressed/misc.c 2018-08-15 17:37:34.000000000 +0200
484 +++ linux-4.18.1.new/arch/sh/boot/compressed/misc.c 2018-08-16 18:56:17.000000000 +0200
485 @@ -58,6 +58,10 @@
486 #include "../../../../lib/decompress_bunzip2.c"
487 #endif
489 +#ifdef CONFIG_KERNEL_LZIP
490 +#include "../../../../lib/decompress_lunzip.c"
491 +#endif
493 #ifdef CONFIG_KERNEL_LZMA
494 #include "../../../../lib/decompress_unlzma.c"
495 #endif
496 diff -urdN linux-4.18.1/arch/x86/Kconfig linux-4.18.1.new/arch/x86/Kconfig
497 --- linux-4.18.1/arch/x86/Kconfig 2018-08-15 17:37:34.000000000 +0200
498 +++ linux-4.18.1.new/arch/x86/Kconfig 2018-08-16 18:56:17.000000000 +0200
499 @@ -156,6 +156,7 @@
500 select HAVE_KERNEL_BZIP2
501 select HAVE_KERNEL_GZIP
502 select HAVE_KERNEL_LZ4
503 + select HAVE_KERNEL_LZIP
504 select HAVE_KERNEL_LZMA
505 select HAVE_KERNEL_LZO
506 select HAVE_KERNEL_XZ
507 diff -urdN linux-4.18.1/arch/x86/boot/compressed/Makefile linux-4.18.1.new/arch/x86/boot/compressed/Makefile
508 --- linux-4.18.1/arch/x86/boot/compressed/Makefile 2018-08-15 17:37:34.000000000 +0200
509 +++ linux-4.18.1.new/arch/x86/boot/compressed/Makefile 2018-08-16 18:56:17.000000000 +0200
510 @@ -23,8 +23,8 @@
511 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
512 KCOV_INSTRUMENT := n
514 -targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
515 - vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
516 +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
517 + vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
519 KBUILD_CFLAGS := -m$(BITS) -O2
520 KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
521 @@ -133,6 +133,8 @@
522 $(call if_changed,gzip)
523 $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
524 $(call if_changed,bzip2)
525 +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y) FORCE
526 + $(call if_changed,klzip)
527 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
528 $(call if_changed,lzma)
529 $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
530 @@ -144,6 +146,7 @@
532 suffix-$(CONFIG_KERNEL_GZIP) := gz
533 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
534 +suffix-$(CONFIG_KERNEL_LZIP) := lz
535 suffix-$(CONFIG_KERNEL_LZMA) := lzma
536 suffix-$(CONFIG_KERNEL_XZ) := xz
537 suffix-$(CONFIG_KERNEL_LZO) := lzo
538 diff -urdN linux-4.18.1/arch/x86/boot/compressed/misc.c linux-4.18.1.new/arch/x86/boot/compressed/misc.c
539 --- linux-4.18.1/arch/x86/boot/compressed/misc.c 2018-08-15 17:37:34.000000000 +0200
540 +++ linux-4.18.1.new/arch/x86/boot/compressed/misc.c 2018-08-16 18:56:17.000000000 +0200
541 @@ -61,6 +61,10 @@
542 #include "../../../../lib/decompress_bunzip2.c"
543 #endif
545 +#ifdef CONFIG_KERNEL_LZIP
546 +#include "../../../../lib/decompress_lunzip.c"
547 +#endif
549 #ifdef CONFIG_KERNEL_LZMA
550 #include "../../../../lib/decompress_unlzma.c"
551 #endif
552 diff -urdN linux-4.18.1/fs/squashfs/Kconfig linux-4.18.1.new/fs/squashfs/Kconfig
553 --- linux-4.18.1/fs/squashfs/Kconfig 2018-08-15 17:37:34.000000000 +0200
554 +++ linux-4.18.1.new/fs/squashfs/Kconfig 2018-08-16 18:56:17.000000000 +0200
555 @@ -4,7 +4,7 @@
556 help
557 Saying Y here includes support for SquashFS 4.0 (a Compressed
558 Read-Only File System). Squashfs is a highly compressed read-only
559 - filesystem for Linux. It uses zlib, lzo or xz compression to
560 + filesystem for Linux. It uses zlib, lzip, lzo or xz compression to
561 compress both files, inodes and directories. Inodes in the system
562 are very small and all blocks are packed to minimise data overhead.
563 Block sizes greater than 4K are supported up to a maximum of 1 Mbytes
564 @@ -134,6 +134,21 @@
565 file systems will be readable without selecting this option.
567 If unsure, say N.
569 +config SQUASHFS_LZIP
570 + bool "Include support for LZIP compressed file systems"
571 + depends on SQUASHFS
572 + select LZIP_DECOMPRESS
573 + help
574 + Saying Y here includes support for reading Squashfs file systems
575 + compressed with LZIP compression. LZIP gives better compression
576 + than the default zlib compression, at the expense of greater CPU
577 + and memory overhead.
579 + LZIP is not the standard compression used in Squashfs and so most
580 + file systems will be readable without selecting this option.
582 + If unsure, say N.
584 config SQUASHFS_LZO
585 bool "Include support for LZO compressed file systems"
586 diff -urdN linux-4.18.1/fs/squashfs/Makefile linux-4.18.1.new/fs/squashfs/Makefile
587 --- linux-4.18.1/fs/squashfs/Makefile 2018-08-15 17:37:34.000000000 +0200
588 +++ linux-4.18.1.new/fs/squashfs/Makefile 2018-08-16 18:56:17.000000000 +0200
589 @@ -13,6 +13,7 @@
590 squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) += decompressor_multi_percpu.o
591 squashfs-$(CONFIG_SQUASHFS_XATTR) += xattr.o xattr_id.o
592 squashfs-$(CONFIG_SQUASHFS_LZ4) += lz4_wrapper.o
593 +squashfs-$(CONFIG_SQUASHFS_LZIP) += lzip_wrapper.o
594 squashfs-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
595 squashfs-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
596 squashfs-$(CONFIG_SQUASHFS_ZLIB) += zlib_wrapper.o
597 diff -urdN linux-4.18.1/fs/squashfs/decompressor.c linux-4.18.1.new/fs/squashfs/decompressor.c
598 --- linux-4.18.1/fs/squashfs/decompressor.c 2018-08-15 17:37:34.000000000 +0200
599 +++ linux-4.18.1.new/fs/squashfs/decompressor.c 2018-08-16 18:56:17.000000000 +0200
600 @@ -47,6 +47,12 @@
602 #endif
604 +#ifndef CONFIG_SQUASHFS_LZIP
605 +static const struct squashfs_decompressor squashfs_lzip_comp_ops = {
606 + NULL, NULL, NULL, NULL, LZIP_COMPRESSION, "lzip", 0
608 +#endif
610 #ifndef CONFIG_SQUASHFS_LZO
611 static const struct squashfs_decompressor squashfs_lzo_comp_ops = {
612 NULL, NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0
613 @@ -78,6 +84,7 @@
614 static const struct squashfs_decompressor *decompressor[] = {
615 &squashfs_zlib_comp_ops,
616 &squashfs_lz4_comp_ops,
617 + &squashfs_lzip_comp_ops,
618 &squashfs_lzo_comp_ops,
619 &squashfs_xz_comp_ops,
620 &squashfs_lzma_unsupported_comp_ops,
621 diff -urdN linux-4.18.1/fs/squashfs/decompressor.h linux-4.18.1.new/fs/squashfs/decompressor.h
622 --- linux-4.18.1/fs/squashfs/decompressor.h 2018-08-15 17:37:34.000000000 +0200
623 +++ linux-4.18.1.new/fs/squashfs/decompressor.h 2018-08-16 18:56:17.000000000 +0200
624 @@ -50,6 +50,10 @@
625 extern const struct squashfs_decompressor squashfs_lz4_comp_ops;
626 #endif
628 +#ifdef CONFIG_SQUASHFS_LZIP
629 +extern const struct squashfs_decompressor squashfs_lzip_comp_ops;
630 +#endif
632 #ifdef CONFIG_SQUASHFS_LZO
633 extern const struct squashfs_decompressor squashfs_lzo_comp_ops;
634 #endif
635 diff -urdN linux-4.18.1/fs/squashfs/lzip_wrapper.c linux-4.18.1.new/fs/squashfs/lzip_wrapper.c
636 --- linux-4.18.1/fs/squashfs/lzip_wrapper.c 1970-01-01 01:00:00.000000000 +0100
637 +++ linux-4.18.1.new/fs/squashfs/lzip_wrapper.c 2018-08-16 18:56:17.000000000 +0200
638 @@ -0,0 +1,129 @@
640 + * Squashfs - a compressed read only filesystem for Linux
642 + * Copyright (c) 2014
643 + * Phillip Lougher <phillip@squashfs.org.uk>
644 + * Copyright (C) 2018 Antonio Diaz Diaz
646 + * This program is free software; you can redistribute it and/or
647 + * modify it under the terms of the GNU General Public License
648 + * as published by the Free Software Foundation; either version 2,
649 + * or (at your option) any later version.
651 + * This program is distributed in the hope that it will be useful,
652 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
653 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
654 + * GNU General Public License for more details.
656 + * You should have received a copy of the GNU General Public License
657 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
659 + * lzip_wrapper.c
660 + */
662 +#include <linux/buffer_head.h>
663 +#include <linux/mutex.h>
664 +#include <linux/slab.h>
665 +#include <linux/vmalloc.h>
666 +#include <linux/lzip.h>
668 +#include "squashfs_fs.h"
669 +#include "squashfs_fs_sb.h"
670 +#include "squashfs.h"
671 +#include "decompressor.h"
672 +#include "page_actor.h"
674 +struct squashfs_lzip {
675 + void *input;
676 + void *output;
680 +static void *lzip_init(struct squashfs_sb_info *msblk, void *buff)
682 + int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
683 + struct squashfs_lzip *stream = kzalloc(sizeof(*stream), GFP_KERNEL);
684 + if (stream == NULL)
685 + goto failed;
686 + stream->input = vmalloc(block_size);
687 + if (stream->input == NULL)
688 + goto failed2;
689 + stream->output = vmalloc(block_size);
690 + if (stream->output == NULL)
691 + goto failed3;
693 + return stream;
695 +failed3:
696 + vfree(stream->input);
697 +failed2:
698 + kfree(stream);
699 +failed:
700 + ERROR("Failed to initialise LZIP decompressor\n");
701 + return ERR_PTR(-ENOMEM);
705 +static void lzip_free(void *strm)
707 + struct squashfs_lzip *stream = strm;
709 + if (stream) {
710 + vfree(stream->input);
711 + vfree(stream->output);
713 + kfree(stream);
717 +static int lzip_uncompress(struct squashfs_sb_info *msblk, void *strm,
718 + struct buffer_head **bh, int b, int offset, int length,
719 + struct squashfs_page_actor *output)
721 + struct squashfs_lzip *stream = strm;
722 + void *buff = stream->input, *data;
723 + long out_pos;
724 + int avail, i, bytes = length, res;
726 + for (i = 0; i < b; i++) {
727 + avail = min(bytes, msblk->devblksize - offset);
728 + memcpy(buff, bh[i]->b_data + offset, avail);
729 + buff += avail;
730 + bytes -= avail;
731 + offset = 0;
732 + put_bh(bh[i]);
735 + res = lzip_decompress(stream->input, length, 0, 0, stream->output,
736 + output->length, 0, &out_pos);
737 + if (res < 0) {
738 + ERROR("LZIP error code %d\n", res);
739 + return -EIO;
741 + bytes = out_pos;
742 + data = squashfs_first_page(output);
743 + buff = stream->output;
744 + while (data) {
745 + if (bytes <= PAGE_SIZE) {
746 + memcpy(data, buff, bytes);
747 + break;
749 + memcpy(data, buff, PAGE_SIZE);
750 + buff += PAGE_SIZE;
751 + bytes -= PAGE_SIZE;
752 + data = squashfs_next_page(output);
754 + squashfs_finish_page(output);
756 + return out_pos;
760 +const struct squashfs_decompressor squashfs_lzip_comp_ops = {
761 + .init = lzip_init,
762 + .free = lzip_free,
763 + .decompress = lzip_uncompress,
764 + .id = LZIP_COMPRESSION,
765 + .name = "lzip",
766 + .supported = 1
768 diff -urdN linux-4.18.1/fs/squashfs/squashfs_fs.h linux-4.18.1.new/fs/squashfs/squashfs_fs.h
769 --- linux-4.18.1/fs/squashfs/squashfs_fs.h 2018-08-15 17:37:34.000000000 +0200
770 +++ linux-4.18.1.new/fs/squashfs/squashfs_fs.h 2018-08-16 18:56:17.000000000 +0200
771 @@ -248,6 +248,7 @@
772 #define XZ_COMPRESSION 4
773 #define LZ4_COMPRESSION 5
774 #define ZSTD_COMPRESSION 6
775 +#define LZIP_COMPRESSION 7
777 struct squashfs_super_block {
778 __le32 s_magic;
779 diff -urdN linux-4.18.1/include/linux/decompress/lunzip.h linux-4.18.1.new/include/linux/decompress/lunzip.h
780 --- linux-4.18.1/include/linux/decompress/lunzip.h 1970-01-01 01:00:00.000000000 +0100
781 +++ linux-4.18.1.new/include/linux/decompress/lunzip.h 2018-08-16 18:56:17.000000000 +0200
782 @@ -0,0 +1,11 @@
783 +/* SPDX-License-Identifier: GPL-2.0 */
784 +#ifndef LINUX_DECOMPRESS_LUNZIP_H
785 +#define LINUX_DECOMPRESS_LUNZIP_H
787 +int lunzip(unsigned char *inbuf, long in_len,
788 + long (*fill)(void*, unsigned long),
789 + long (*flush)(void*, unsigned long),
790 + unsigned char *outbuf,
791 + long *in_posp,
792 + void (*error)(char *x));
793 +#endif
794 diff -urdN linux-4.18.1/include/linux/lzip.h linux-4.18.1.new/include/linux/lzip.h
795 --- linux-4.18.1/include/linux/lzip.h 1970-01-01 01:00:00.000000000 +0100
796 +++ linux-4.18.1.new/include/linux/lzip.h 2018-08-16 18:56:17.000000000 +0200
797 @@ -0,0 +1,53 @@
798 +/* SPDX-License-Identifier: GPL-2.0 */
799 +#ifndef __LZIP_H__
800 +#define __LZIP_H__
802 + * LZIP decompressor
804 + * Copyright (C) 2016-2018 Antonio Diaz Diaz.
805 + */
807 +/* Return values (< 0 = Error) */
808 +enum {
809 + LZIP_OOM_INBUF = -1,
810 + LZIP_HEADER1_EOF = -2,
811 + LZIP_HEADER2_EOF = -3,
812 + LZIP_BAD_MAGIC1 = -4,
813 + LZIP_BAD_MAGIC2 = -5,
814 + LZIP_BAD_VERSION = -6,
815 + LZIP_BAD_DICT_SIZE = -7,
816 + LZIP_OOM_OUTBUF = -8,
817 + LZIP_WRITE_ERROR = -9,
818 + LZIP_BAD_DATA = -10,
819 + LZIP_DATA_EOF = -11,
820 + LZIP_BAD_CRC = -12
823 +int lzip_decompress(unsigned char *inbuf, long in_len,
824 + long (*fill)(void*, unsigned long),
825 + long (*flush)(void*, unsigned long),
826 + unsigned char *outbuf, long out_size,
827 + long *in_posp, long *out_posp);
829 +/* inbuf - input buffer. If null or in_len <= 0, fill must be non-null
830 + * in_len - len of pre-read data in inbuf if inbuf is non-null
831 + * fill - if non-null, function to fill inbuf when empty
832 + * flush - if non-null, function to write out outbuf when full
833 + * outbuf - output buffer. If null or out_size <= 0, flush must be non-null
834 + * out_size - size of outbuf if outbuf is non-null
835 + * in_posp - if non-null, the number of bytes consumed will be returned here
836 + * out_posp - if non-null, the number of bytes produced will be returned here
838 + * fill will be called (repeatedly) to read data. in_len bytes will be read
839 + * per call (or 16384 bytes per call if inbuf is null or in_len <= 0).
841 + * If flush is null, outbuf must be large enough to buffer all the expected
842 + * output. Else the flush function will be called to flush the output buffer
843 + * at the appropriate time (stream dependent).
844 + * If out_size > 0 but is not large enough to buffer all the expected output,
845 + * it must be at least as large as the dictionary size of the data.
847 + * inbuf and outbuf may overlap (in-place decompression).
848 + */
850 +#endif
851 diff -urdN linux-4.18.1/init/Kconfig linux-4.18.1.new/init/Kconfig
852 --- linux-4.18.1/init/Kconfig 2018-08-15 17:37:34.000000000 +0200
853 +++ linux-4.18.1.new/init/Kconfig 2018-08-16 18:56:17.000000000 +0200
854 @@ -113,6 +113,9 @@
855 config HAVE_KERNEL_BZIP2
856 bool
858 +config HAVE_KERNEL_LZIP
859 + bool
861 config HAVE_KERNEL_LZMA
862 bool
864 @@ -128,7 +131,7 @@
865 choice
866 prompt "Kernel compression mode"
867 default KERNEL_GZIP
868 - depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
869 + depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZIP || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
870 help
871 The linux kernel is a kind of self-extracting executable.
872 Several compression algorithms are available, which differ
873 @@ -164,6 +167,15 @@
874 Bzip2 uses a large amount of memory. For modern kernels you
875 will need at least 8MB RAM or more for booting.
877 +config KERNEL_LZIP
878 + bool "Lzip"
879 + depends on HAVE_KERNEL_LZIP
880 + help
881 + Lzip's compression ratio is better than that of gzip and bzip2.
882 + Decompression speed is between gzip and bzip2. Compression can
883 + be as fast as gzip or slower than bzip2 depending on compression
884 + level. Lzip can produce a kernel about a 16% smaller than gzip.
886 config KERNEL_LZMA
887 bool "LZMA"
888 depends on HAVE_KERNEL_LZMA
889 @@ -1882,8 +1894,8 @@
890 depends on MODULES
891 help
893 - Compresses kernel modules when 'make modules_install' is run; gzip or
894 - xz depending on "Compression algorithm" below.
895 + Compresses kernel modules when 'make modules_install' is run; gzip,
896 + lzip or xz are used depending on "Compression algorithm" below.
898 module-init-tools MAY support gzip, and kmod MAY support gzip and xz.
900 @@ -1905,11 +1917,14 @@
901 This determines which sort of compression will be used during
902 'make modules_install'.
904 - GZIP (default) and XZ are supported.
905 + GZIP (default), LZIP and XZ are supported.
907 config MODULE_COMPRESS_GZIP
908 bool "GZIP"
910 +config MODULE_COMPRESS_LZIP
911 + bool "LZIP"
913 config MODULE_COMPRESS_XZ
914 bool "XZ"
916 diff -urdN linux-4.18.1/init/do_mounts_rd.c linux-4.18.1.new/init/do_mounts_rd.c
917 --- linux-4.18.1/init/do_mounts_rd.c 2018-08-15 17:37:34.000000000 +0200
918 +++ linux-4.18.1.new/init/do_mounts_rd.c 2018-08-16 18:56:17.000000000 +0200
919 @@ -59,6 +59,7 @@
920 * squashfs
921 * gzip
922 * bzip2
923 + * lzip
924 * lzma
925 * xz
926 * lzo
927 diff -urdN linux-4.18.1/lib/Kconfig linux-4.18.1.new/lib/Kconfig
928 --- linux-4.18.1/lib/Kconfig 2018-08-15 17:37:34.000000000 +0200
929 +++ linux-4.18.1.new/lib/Kconfig 2018-08-16 18:56:17.000000000 +0200
930 @@ -246,6 +246,12 @@
931 tristate
932 select BITREVERSE
934 +config LZIP_DECOMPRESS
935 + tristate "LZIP decompression support"
936 + help
937 + LZMA compression algorithm is supported using the .lz file format.
938 + See Documentation/lzip.txt for more information.
940 config LZO_COMPRESS
941 tristate
943 @@ -282,6 +288,10 @@
944 config DECOMPRESS_BZIP2
945 tristate
947 +config DECOMPRESS_LZIP
948 + select LZIP_DECOMPRESS
949 + tristate
951 config DECOMPRESS_LZMA
952 tristate
954 diff -urdN linux-4.18.1/lib/Makefile linux-4.18.1.new/lib/Makefile
955 --- linux-4.18.1/lib/Makefile 2018-08-15 17:37:34.000000000 +0200
956 +++ linux-4.18.1.new/lib/Makefile 2018-08-16 18:56:17.000000000 +0200
957 @@ -116,6 +116,7 @@
958 obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
959 obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
960 obj-$(CONFIG_BCH) += bch.o
961 +obj-$(CONFIG_LZIP_DECOMPRESS) += lzip.o
962 obj-$(CONFIG_LZO_COMPRESS) += lzo/
963 obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
964 obj-$(CONFIG_LZ4_COMPRESS) += lz4/
965 @@ -128,6 +129,7 @@
967 lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
968 lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
969 +lib-$(CONFIG_DECOMPRESS_LZIP) += decompress_lunzip.o
970 lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
971 lib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
972 lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
973 diff -urdN linux-4.18.1/lib/decompress.c linux-4.18.1.new/lib/decompress.c
974 --- linux-4.18.1/lib/decompress.c 2018-08-15 17:37:34.000000000 +0200
975 +++ linux-4.18.1.new/lib/decompress.c 2018-08-16 18:56:17.000000000 +0200
976 @@ -8,6 +8,7 @@
977 #include <linux/decompress/generic.h>
979 #include <linux/decompress/bunzip2.h>
980 +#include <linux/decompress/lunzip.h>
981 #include <linux/decompress/unlzma.h>
982 #include <linux/decompress/unxz.h>
983 #include <linux/decompress/inflate.h>
984 @@ -25,6 +26,9 @@
985 #ifndef CONFIG_DECOMPRESS_BZIP2
986 # define bunzip2 NULL
987 #endif
988 +#ifndef CONFIG_DECOMPRESS_LZIP
989 +# define lunzip NULL
990 +#endif
991 #ifndef CONFIG_DECOMPRESS_LZMA
992 # define unlzma NULL
993 #endif
994 @@ -48,6 +52,7 @@
995 { {0x1f, 0x8b}, "gzip", gunzip },
996 { {0x1f, 0x9e}, "gzip", gunzip },
997 { {0x42, 0x5a}, "bzip2", bunzip2 },
998 + { {0x4c, 0x5a}, "lzip", lunzip },
999 { {0x5d, 0x00}, "lzma", unlzma },
1000 { {0xfd, 0x37}, "xz", unxz },
1001 { {0x89, 0x4c}, "lzo", unlzo },
1002 diff -urdN linux-4.18.1/lib/decompress_lunzip.c linux-4.18.1.new/lib/decompress_lunzip.c
1003 --- linux-4.18.1/lib/decompress_lunzip.c 1970-01-01 01:00:00.000000000 +0100
1004 +++ linux-4.18.1.new/lib/decompress_lunzip.c 2018-08-16 20:45:12.000000000 +0200
1005 @@ -0,0 +1,100 @@
1007 + * Wrapper for decompressing LZIP-compressed kernel, initramfs, and initrd
1009 + * Copyright (C) 2016-2018 Antonio Diaz Diaz.
1011 + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
1012 + */
1014 +#ifdef STATIC
1015 +#define PREBOOT
1016 +#include "lzip.c"
1017 +#else
1018 +#include <linux/lzip.h>
1019 +#include <linux/decompress/lunzip.h>
1020 +#include <linux/decompress/mm.h>
1021 +#endif
1023 +STATIC int INIT __lunzip(unsigned char *inbuf, long in_len,
1024 + long (*fill)(void*, unsigned long),
1025 + long (*flush)(void*, unsigned long),
1026 + unsigned char *outbuf, long out_size,
1027 + long *in_posp, long *out_posp,
1028 + void (*error)(char *x))
1030 + const int retval = lzip_decompress(inbuf, in_len, fill, flush,
1031 + outbuf, out_size, in_posp, out_posp);
1032 + switch (retval) {
1033 + case 0: break;
1034 + case LZIP_OOM_INBUF:
1035 + error("Out of memory while allocating input buffer.");
1036 + break;
1037 + case LZIP_HEADER1_EOF:
1038 + error("File ends unexpectedly at member header.");
1039 + break;
1040 + case LZIP_HEADER2_EOF:
1041 + error("Truncated header in multimember file.");
1042 + break;
1043 + case LZIP_BAD_MAGIC1:
1044 + error("Bad magic number (file not in lzip format).");
1045 + break;
1046 + case LZIP_BAD_MAGIC2:
1047 + error("Corrupt header in multimember file.");
1048 + break;
1049 + case LZIP_BAD_VERSION:
1050 + error("Version of lzip member format not supported.");
1051 + break;
1052 + case LZIP_BAD_DICT_SIZE:
1053 + error("Invalid dictionary size in member header.");
1054 + break;
1055 + case LZIP_OOM_OUTBUF:
1056 + error("Out of memory while allocating output buffer.");
1057 + break;
1058 + case LZIP_WRITE_ERROR:
1059 + error("Write error.");
1060 + break;
1061 + case LZIP_BAD_DATA:
1062 + error("LZIP-compressed data is corrupt.");
1063 + break;
1064 + case LZIP_DATA_EOF:
1065 + error("LZIP-compressed data ends unexpectedly.");
1066 + break;
1067 + case LZIP_BAD_CRC:
1068 + error("CRC mismatch in LZIP-compressed data.");
1069 + break;
1070 + default:
1071 + error("Bug in the LZIP decompressor.");
1073 + return retval;
1076 +#ifndef PREBOOT
1077 +/* decompress_fn (see linux/decompress/generic.h) should have an out_size
1078 + * argument to prevent overflowing outbuf in case of corruption of the
1079 + * compressed data.
1080 + */
1081 +STATIC int INIT lunzip(unsigned char *inbuf, long in_len,
1082 + long (*fill)(void*, unsigned long),
1083 + long (*flush)(void*, unsigned long),
1084 + unsigned char *outbuf,
1085 + long *in_posp,
1086 + void (*error)(char *x))
1088 + return __lunzip(inbuf, in_len, fill, flush, outbuf, LONG_MAX,
1089 + in_posp, 0, error);
1091 +#else
1092 +STATIC int INIT __decompress(unsigned char *inbuf, long in_len,
1093 + long (*fill)(void*, unsigned long),
1094 + long (*flush)(void*, unsigned long),
1095 + unsigned char *outbuf, long out_size,
1096 + long *in_posp,
1097 + void (*error)(char *x))
1099 +/* Some archs pass out_size = 0 (to mean unlimited size), which is unsafe
1100 + * in case of corruption of the compressed data.
1101 + */
1102 + return __lunzip(inbuf, in_len - 4, fill, flush, outbuf,
1103 + out_size ? out_size : LONG_MAX, in_posp, 0, error);
1105 +#endif
1106 diff -urdN linux-4.18.1/lib/lzip.c linux-4.18.1.new/lib/lzip.c
1107 --- linux-4.18.1/lib/lzip.c 1970-01-01 01:00:00.000000000 +0100
1108 +++ linux-4.18.1.new/lib/lzip.c 2018-08-29 13:47:06.000000000 +0200
1109 @@ -0,0 +1,880 @@
1111 + * LZIP decompressor
1113 + * Copyright (C) 2016-2018 Antonio Diaz Diaz.
1115 + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
1116 + */
1118 +#include <linux/module.h>
1119 +#include <linux/lzip.h>
1120 +#include <linux/decompress/mm.h>
1123 + * STATIC_RW_DATA is used in the pre-boot environment on some architectures.
1124 + * See <linux/decompress/mm.h> for details.
1125 + */
1126 +#ifndef STATIC_RW_DATA
1127 +#define STATIC_RW_DATA static
1128 +#endif
1130 +typedef int State;
1132 +enum { states = 12 };
1134 +static inline bool St_is_char(const State st) { return st < 7; }
1136 +static inline State St_set_char(const State st)
1138 + STATIC_RW_DATA const State next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
1139 + return next[st];
1142 +static inline State St_set_match(const State st)
1144 + return ((st < 7) ? 7 : 10);
1147 +static inline State St_set_rep(const State st)
1149 + return ((st < 7) ? 8 : 11);
1152 +static inline State St_set_short_rep(const State st)
1154 + return ((st < 7) ? 9 : 11);
1158 +enum {
1159 + min_dictionary_bits = 12,
1160 + min_dictionary_size = 1 << min_dictionary_bits,
1161 + max_dictionary_bits = 29,
1162 + max_dictionary_size = 1 << max_dictionary_bits,
1163 + literal_context_bits = 3,
1164 + pos_state_bits = 2,
1165 + pos_states = 1 << pos_state_bits,
1166 + pos_state_mask = pos_states - 1,
1168 + len_states = 4,
1169 + dis_slot_bits = 6,
1170 + start_dis_model = 4,
1171 + end_dis_model = 14,
1172 + modeled_distances = 1 << (end_dis_model / 2), /* 128 */
1173 + dis_align_bits = 4,
1174 + dis_align_size = 1 << dis_align_bits,
1176 + len_low_bits = 3,
1177 + len_mid_bits = 3,
1178 + len_high_bits = 8,
1179 + len_low_symbols = 1 << len_low_bits,
1180 + len_mid_symbols = 1 << len_mid_bits,
1181 + len_high_symbols = 1 << len_high_bits,
1182 + max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols,
1184 + min_match_len = 2, /* must be 2 */
1185 + max_match_len = min_match_len + max_len_symbols - 1, /* 273 */
1186 + min_match_len_limit = 5
1189 +static inline int get_len_state(const int len)
1191 + return min(len - min_match_len, len_states - 1);
1194 +static inline int get_lit_state(const uint8_t prev_byte)
1196 + return (prev_byte >> (8 - literal_context_bits));
1200 +enum { bit_model_move_bits = 5,
1201 + bit_model_total_bits = 11,
1202 + bit_model_total = 1 << bit_model_total_bits
1205 +typedef int Bit_model;
1207 +static inline void Bm_init(Bit_model * const probability)
1209 + *probability = bit_model_total / 2;
1212 +static inline void Bm_array_init(Bit_model bm[], const int size)
1214 + int i;
1216 + for (i = 0; i < size; ++i)
1217 + Bm_init(&bm[i]);
1220 +struct Len_model {
1221 + Bit_model choice1;
1222 + Bit_model choice2;
1223 + Bit_model bm_low[pos_states][len_low_symbols];
1224 + Bit_model bm_mid[pos_states][len_mid_symbols];
1225 + Bit_model bm_high[len_high_symbols];
1228 +static inline void Lm_init(struct Len_model * const lm)
1230 + Bm_init(&lm->choice1);
1231 + Bm_init(&lm->choice2);
1232 + Bm_array_init(lm->bm_low[0], pos_states * len_low_symbols);
1233 + Bm_array_init(lm->bm_mid[0], pos_states * len_mid_symbols);
1234 + Bm_array_init(lm->bm_high, len_high_symbols);
1238 +/* Table of CRCs of all 8-bit messages. */
1239 +STATIC_RW_DATA const uint32_t crc32[256] =
1241 + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
1242 + 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
1243 + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
1244 + 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
1245 + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
1246 + 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
1247 + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
1248 + 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
1249 + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
1250 + 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
1251 + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
1252 + 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
1253 + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
1254 + 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
1255 + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
1256 + 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
1257 + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
1258 + 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
1259 + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
1260 + 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
1261 + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
1262 + 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
1263 + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
1264 + 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
1265 + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
1266 + 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
1267 + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
1268 + 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
1269 + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
1270 + 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
1271 + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
1272 + 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
1273 + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
1274 + 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
1275 + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
1276 + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
1277 + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
1278 + 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
1279 + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
1280 + 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
1281 + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
1282 + 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
1283 + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D };
1286 +static inline void CRC32_update_buf(uint32_t * const crc,
1287 + const uint8_t * const buffer,
1288 + const long size)
1290 + long i;
1291 + uint32_t c = *crc;
1293 + for (i = 0; i < size; ++i)
1294 + c = crc32[(c^buffer[i])&0xFF] ^ (c >> 8);
1295 + *crc = c;
1299 +STATIC_RW_DATA const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
1301 +typedef uint8_t Lzip_header[6]; /* 0-3 magic bytes */
1302 + /* 4 version */
1303 + /* 5 coded_dict_size */
1304 +enum { Lh_size = 6 };
1306 +static inline bool Lh_verify_magic(const Lzip_header data)
1308 + int i;
1310 + for (i = 0; i < 4; ++i)
1311 + if (data[i] != lzip_magic[i])
1312 + return false;
1313 + return true;
1316 +/* detect (truncated) header */
1317 +static inline bool Lh_verify_prefix(const Lzip_header data, const int sz)
1319 + int i;
1320 + for (i = 0; i < sz && i < 4; ++i)
1321 + if (data[i] != lzip_magic[i])
1322 + return false;
1323 + return (sz > 0);
1326 +/* detect corrupt header */
1327 +static inline bool Lh_verify_corrupt(const Lzip_header data)
1329 + int matches = 0;
1330 + int i;
1331 + for (i = 0; i < 4; ++i)
1332 + if (data[i] == lzip_magic[i])
1333 + ++matches;
1334 + return (matches > 1 && matches < 4);
1337 +static inline bool Lh_verify_version(const Lzip_header data)
1339 + return (data[4] == 1);
1342 +static inline unsigned Lh_get_dictionary_size(const Lzip_header data)
1344 + unsigned sz = (1 << (data[5] & 0x1F));
1346 + if (sz > min_dictionary_size)
1347 + sz -= (sz / 16) * ((data[5] >> 5) & 7);
1348 + return sz;
1352 +typedef uint8_t Lzip_trailer[20];
1353 + /* 0-3 CRC32 of the uncompressed data */
1354 + /* 4-11 size of the uncompressed data */
1355 + /* 12-19 member size including header and trailer */
1356 +enum { Lt_size = 20 };
1358 +static inline unsigned Lt_get_data_crc(const Lzip_trailer data)
1360 + unsigned tmp = 0;
1361 + int i;
1363 + for (i = 3; i >= 0; --i) {
1364 + tmp <<= 8;
1365 + tmp += data[i];
1367 + return tmp;
1370 +static inline unsigned long long Lt_get_data_size(const Lzip_trailer data)
1372 + unsigned long long tmp = 0;
1373 + int i;
1375 + for (i = 11; i >= 4; --i) {
1376 + tmp <<= 8;
1377 + tmp += data[i];
1379 + return tmp;
1382 +static inline unsigned long long Lt_get_member_size(const Lzip_trailer data)
1384 + unsigned long long tmp = 0;
1385 + int i;
1387 + for (i = 19; i >= 12; --i) {
1388 + tmp <<= 8;
1389 + tmp += data[i];
1391 + return tmp;
1395 +struct Range_decoder {
1396 + unsigned long long partial_member_pos;
1397 + uint8_t *buffer; /* input buffer */
1398 + long buffer_size;
1399 + long pos; /* current pos in buffer */
1400 + long stream_pos; /* when reached, a new block must be read */
1401 + uint32_t code;
1402 + uint32_t range;
1403 + long (*fill)(void*, unsigned long);
1404 + bool at_stream_end;
1405 + bool buffer_given;
1409 +static bool Rd_read_block(struct Range_decoder * const rdec)
1411 + if (!rdec->at_stream_end) {
1412 + rdec->stream_pos = rdec->fill ?
1413 + rdec->fill(rdec->buffer, rdec->buffer_size) : 0;
1414 + rdec->at_stream_end = (rdec->stream_pos < rdec->buffer_size);
1415 + rdec->partial_member_pos += rdec->pos;
1416 + rdec->pos = 0;
1418 + return rdec->pos < rdec->stream_pos;
1422 +static inline bool Rd_init(struct Range_decoder * const rdec,
1423 + uint8_t * const inbuf, const long in_len,
1424 + long (*fill)(void*, unsigned long))
1426 + rdec->partial_member_pos = 0;
1427 + rdec->buffer_given = (inbuf && in_len > 0);
1428 + rdec->buffer_size = rdec->buffer_given ? in_len : 16384;
1429 + rdec->buffer = rdec->buffer_given ? inbuf : malloc(rdec->buffer_size);
1430 + if (!rdec->buffer)
1431 + return false;
1432 + rdec->pos = 0;
1433 + rdec->stream_pos = rdec->buffer_given ? in_len : 0;
1434 + rdec->code = 0;
1435 + rdec->range = 0xFFFFFFFFU;
1436 + rdec->fill = fill;
1437 + rdec->at_stream_end = false;
1438 + return true;
1441 +static inline void Rd_free(struct Range_decoder * const rdec)
1443 + if (!rdec->buffer_given)
1444 + free(rdec->buffer);
1447 +static inline bool Rd_finished(struct Range_decoder * const rdec)
1449 + return rdec->pos >= rdec->stream_pos && !Rd_read_block(rdec);
1452 +static inline unsigned long long
1453 +Rd_member_position(const struct Range_decoder * const rdec)
1455 + return rdec->partial_member_pos + rdec->pos;
1458 +static inline void Rd_reset_member_position(struct Range_decoder * const rdec)
1460 + rdec->partial_member_pos = 0; rdec->partial_member_pos -= rdec->pos;
1463 +static inline uint8_t Rd_get_byte(struct Range_decoder * const rdec)
1465 + /* 0xFF avoids decoder error if member is truncated at EOS marker */
1466 + if (Rd_finished(rdec))
1467 + return 0xFF;
1468 + return rdec->buffer[rdec->pos++];
1471 +static inline void Rd_load(struct Range_decoder * const rdec)
1473 + int i;
1475 + rdec->code = 0;
1476 + for (i = 0; i < 5; ++i)
1477 + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
1478 + rdec->range = 0xFFFFFFFFU;
1481 +static inline void Rd_normalize(struct Range_decoder * const rdec)
1483 + if (rdec->range <= 0x00FFFFFFU) {
1484 + rdec->range <<= 8;
1485 + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
1489 +static inline unsigned Rd_decode(struct Range_decoder * const rdec,
1490 + const int num_bits)
1492 + unsigned symbol = 0;
1493 + int i;
1495 + for (i = num_bits; i > 0; --i) {
1496 + bool bit;
1498 + Rd_normalize(rdec);
1499 + rdec->range >>= 1;
1500 + /* symbol <<= 1; */
1501 + /* if(rdec->code >= rdec->range) { rdec->code -= rdec->range; symbol |= 1; } */
1502 + bit = (rdec->code >= rdec->range);
1503 + symbol = (symbol << 1) + bit;
1504 + rdec->code -= rdec->range & (0U - bit);
1506 + return symbol;
1509 +static inline unsigned Rd_decode_bit(struct Range_decoder * const rdec,
1510 + Bit_model * const probability)
1512 + uint32_t bound;
1514 + Rd_normalize(rdec);
1515 + bound = (rdec->range >> bit_model_total_bits) * *probability;
1516 + if (rdec->code < bound) {
1517 + rdec->range = bound;
1518 + *probability += (bit_model_total - *probability) >> bit_model_move_bits;
1519 + return 0;
1520 + } else {
1521 + rdec->range -= bound;
1522 + rdec->code -= bound;
1523 + *probability -= *probability >> bit_model_move_bits;
1524 + return 1;
1528 +static inline unsigned Rd_decode_tree3(struct Range_decoder * const rdec,
1529 + Bit_model bm[])
1531 + unsigned symbol = 1;
1533 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1534 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1535 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1536 + return symbol & 7;
1539 +static inline unsigned Rd_decode_tree6(struct Range_decoder * const rdec,
1540 + Bit_model bm[])
1542 + unsigned symbol = 1;
1544 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1545 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1546 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1547 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1548 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1549 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1550 + return symbol & 0x3F;
1553 +static inline unsigned Rd_decode_tree8(struct Range_decoder * const rdec,
1554 + Bit_model bm[])
1556 + unsigned symbol = 1;
1557 + int i;
1559 + for (i = 0; i < 8; ++i)
1560 + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
1561 + return symbol & 0xFF;
1564 +static inline unsigned
1565 +Rd_decode_tree_reversed(struct Range_decoder * const rdec,
1566 + Bit_model bm[], const int num_bits)
1568 + unsigned model = 1;
1569 + unsigned symbol = 0;
1570 + int i;
1572 + for (i = 0; i < num_bits; ++i) {
1573 + const unsigned bit = Rd_decode_bit(rdec, &bm[model]);
1575 + model = (model << 1) + bit;
1576 + symbol |= (bit << i);
1578 + return symbol;
1581 +static inline unsigned
1582 +Rd_decode_tree_reversed4(struct Range_decoder * const rdec, Bit_model bm[])
1584 + unsigned symbol = Rd_decode_bit(rdec, &bm[1]);
1585 + unsigned model = 2 + symbol;
1586 + unsigned bit = Rd_decode_bit(rdec, &bm[model]);
1588 + model = (model << 1) + bit; symbol |= (bit << 1);
1589 + bit = Rd_decode_bit(rdec, &bm[model]);
1590 + model = (model << 1) + bit; symbol |= (bit << 2);
1591 + symbol |= (Rd_decode_bit(rdec, &bm[model]) << 3);
1592 + return symbol;
1595 +static inline unsigned Rd_decode_matched(struct Range_decoder * const rdec,
1596 + Bit_model bm[], unsigned match_byte)
1598 + unsigned symbol = 1;
1599 + unsigned mask = 0x100;
1601 + while (true) {
1602 + const unsigned match_bit = (match_byte <<= 1) & mask;
1603 + const unsigned bit = Rd_decode_bit(rdec, &bm[symbol+match_bit+mask]);
1605 + symbol = (symbol << 1) + bit;
1606 + if (symbol > 0xFF)
1607 + return symbol & 0xFF;
1608 + mask &= ~(match_bit ^ (bit << 8)); /* if( match_bit != bit ) mask = 0; */
1612 +static inline unsigned Rd_decode_len(struct Range_decoder * const rdec,
1613 + struct Len_model * const lm,
1614 + const int pos_state)
1616 + if (Rd_decode_bit(rdec, &lm->choice1) == 0)
1617 + return Rd_decode_tree3(rdec, lm->bm_low[pos_state]);
1618 + if (Rd_decode_bit(rdec, &lm->choice2) == 0)
1619 + return len_low_symbols +
1620 + Rd_decode_tree3(rdec, lm->bm_mid[pos_state]);
1621 + return len_low_symbols + len_mid_symbols +
1622 + Rd_decode_tree8(rdec, lm->bm_high);
1626 +struct LZ_decoder {
1627 + unsigned long long partial_data_pos;
1628 + struct Range_decoder *rdec;
1629 + /* Don't move bm_* to LZd_decode_member; makes frame too large. */
1630 + Bit_model bm_literal[1 << literal_context_bits][0x300];
1631 + Bit_model bm_match[states][pos_states];
1632 + Bit_model bm_rep[states];
1633 + Bit_model bm_rep0[states];
1634 + Bit_model bm_rep1[states];
1635 + Bit_model bm_rep2[states];
1636 + Bit_model bm_len[states][pos_states];
1637 + Bit_model bm_dis_slot[len_states][1 << dis_slot_bits];
1638 + Bit_model bm_dis[modeled_distances-end_dis_model+1];
1639 + Bit_model bm_align[dis_align_size];
1640 + struct Len_model match_len_model;
1641 + struct Len_model rep_len_model;
1643 + unsigned long buffer_size;
1644 + unsigned dictionary_size;
1645 + uint8_t *buffer; /* output buffer */
1646 + unsigned long pos; /* current pos in buffer */
1647 + unsigned long stream_pos; /* first byte not yet written to file */
1648 + uint32_t crc;
1649 + long (*flush)(void*, unsigned long);
1650 + bool pos_wrapped;
1651 + bool buffer_given;
1652 + bool write_error;
1655 +static void LZd_flush_data(struct LZ_decoder * const d)
1657 + if (d->pos > d->stream_pos) {
1658 + const long size = d->pos - d->stream_pos;
1660 + CRC32_update_buf(&d->crc, d->buffer + d->stream_pos, size);
1661 + if ((d->flush &&
1662 + d->flush(d->buffer + d->stream_pos, size) != size) ||
1663 + (!d->flush && d->pos_wrapped))
1664 + d->write_error = true;
1665 + if (d->pos >= d->buffer_size) {
1666 + d->partial_data_pos += d->pos;
1667 + d->pos = 0;
1668 + d->pos_wrapped = true;
1670 + d->stream_pos = d->pos;
1674 +static inline uint8_t LZd_peek_prev(const struct LZ_decoder * const d)
1676 + if (d->pos > 0)
1677 + return d->buffer[d->pos-1];
1678 + if (d->pos_wrapped)
1679 + return d->buffer[d->buffer_size-1];
1680 + return 0; /* prev_byte of first byte */
1683 +static inline uint8_t LZd_peek(const struct LZ_decoder * const d,
1684 + const unsigned distance)
1686 + const unsigned long i = ((d->pos > distance) ? 0 : d->buffer_size) +
1687 + d->pos - distance - 1;
1688 + return d->buffer[i];
1691 +static inline void LZd_put_byte(struct LZ_decoder * const d, const uint8_t b)
1693 + d->buffer[d->pos] = b;
1694 + if (++d->pos >= d->buffer_size)
1695 + LZd_flush_data(d);
1698 +static inline void LZd_copy_block(struct LZ_decoder * const d,
1699 + const unsigned distance, unsigned len)
1701 + unsigned long lpos = d->pos, i = lpos - distance - 1;
1702 + bool fast, fast2;
1704 + if (lpos > distance) {
1705 + fast = (len < d->buffer_size - lpos);
1706 + fast2 = (fast && len <= lpos - i);
1707 + } else {
1708 + i += d->buffer_size;
1709 + fast = (len < d->buffer_size - i); /* (i == pos) may happen */
1710 + fast2 = (fast && len <= i - lpos);
1712 + if (fast) { /* no wrap */
1713 + d->pos += len;
1714 + if (fast2) /* no wrap, no overlap */
1715 + memcpy(d->buffer + lpos, d->buffer + i, len);
1716 + else
1717 + for (; len > 0; --len)
1718 + d->buffer[lpos++] = d->buffer[i++];
1719 + } else
1720 + for (; len > 0; --len) {
1721 + d->buffer[d->pos] = d->buffer[i];
1722 + if (++d->pos >= d->buffer_size)
1723 + LZd_flush_data(d);
1724 + if (++i >= d->buffer_size)
1725 + i = 0;
1729 +static inline bool LZd_init(struct LZ_decoder * const d,
1730 + struct Range_decoder * const rde,
1731 + const unsigned dict_size, uint8_t * const outbuf,
1732 + long out_size, long (*flush)(void*, unsigned long))
1734 + d->partial_data_pos = 0;
1735 + d->rdec = rde;
1736 + Bm_array_init(d->bm_literal[0], (1 << literal_context_bits) * 0x300);
1737 + Bm_array_init(d->bm_match[0], states * pos_states);
1738 + Bm_array_init(d->bm_rep, states);
1739 + Bm_array_init(d->bm_rep0, states);
1740 + Bm_array_init(d->bm_rep1, states);
1741 + Bm_array_init(d->bm_rep2, states);
1742 + Bm_array_init(d->bm_len[0], states * pos_states);
1743 + Bm_array_init(d->bm_dis_slot[0], len_states * (1 << dis_slot_bits));
1744 + Bm_array_init(d->bm_dis, modeled_distances - end_dis_model + 1);
1745 + Bm_array_init(d->bm_align, dis_align_size);
1746 + Lm_init(&d->match_len_model);
1747 + Lm_init(&d->rep_len_model);
1749 + d->buffer_given = (outbuf && out_size > 0);
1750 + d->buffer_size = d->buffer_given ? out_size : dict_size;
1751 + d->dictionary_size = min_t(unsigned long, d->buffer_size, dict_size);
1752 + d->buffer = d->buffer_given ? outbuf : large_malloc(d->buffer_size);
1753 + if (!d->buffer)
1754 + return false;
1755 + d->pos = 0;
1756 + d->stream_pos = 0;
1757 + d->crc = 0xFFFFFFFFU;
1758 + d->flush = flush;
1759 + d->pos_wrapped = false;
1760 + d->write_error = false;
1761 + /* prev_byte of first byte; also for LZd_peek( 0 ) on corrupt file */
1762 + if (!d->buffer_given) /* inbuf and outbuf may overlap */
1763 + d->buffer[d->buffer_size-1] = 0;
1764 + return true;
1767 +static inline void LZd_free(struct LZ_decoder * const d)
1769 + if (!d->buffer_given)
1770 + large_free(d->buffer);
1773 +static inline unsigned LZd_crc(const struct LZ_decoder * const d)
1775 + return d->crc ^ 0xFFFFFFFFU;
1778 +static inline unsigned long long
1779 +LZd_data_position(const struct LZ_decoder * const d)
1781 + return d->partial_data_pos + d->pos;
1785 +static bool LZd_verify_trailer(struct LZ_decoder * const d)
1787 + Lzip_trailer trailer;
1788 + int i = 0;
1790 + while (i < Lt_size)
1791 + trailer[i++] = Rd_get_byte(d->rdec);
1793 + return (Lt_get_data_crc(trailer) == LZd_crc(d) &&
1794 + Lt_get_data_size(trailer) == LZd_data_position(d) &&
1795 + Lt_get_member_size(trailer) == Rd_member_position(d->rdec));
1799 +/* Return value: 0 = OK, < 0 = error (see <linux/lzip.h>). */
1800 +static int LZd_decode_member(struct LZ_decoder * const d)
1802 + struct Range_decoder * const rdec = d->rdec;
1803 + unsigned rep0 = 0; /* rep[0-3] latest four distances */
1804 + unsigned rep1 = 0; /* used for efficient coding of */
1805 + unsigned rep2 = 0; /* repeated distances */
1806 + unsigned rep3 = 0;
1807 + State state = 0;
1809 + Rd_load(rdec);
1810 + while (!Rd_finished(rdec)) {
1811 + int len;
1812 + const int pos_state = LZd_data_position(d) & pos_state_mask;
1814 + if (Rd_decode_bit(rdec, &d->bm_match[state][pos_state]) == 0) {
1815 + /* literal byte */
1816 + Bit_model * const bm = d->bm_literal[get_lit_state(LZd_peek_prev(d))];
1818 + if (St_is_char(state)) {
1819 + state -= (state < 4) ? state : 3;
1820 + LZd_put_byte(d, Rd_decode_tree8(rdec, bm));
1821 + } else {
1822 + state -= (state < 10) ? 3 : 6;
1823 + LZd_put_byte(d, Rd_decode_matched(rdec, bm, LZd_peek(d, rep0)));
1825 + continue;
1827 + /* match or repeated match */
1828 + if (Rd_decode_bit(rdec, &d->bm_rep[state]) != 0) {
1829 + if (Rd_decode_bit(rdec, &d->bm_rep0[state]) == 0) {
1830 + if (Rd_decode_bit(rdec, &d->bm_len[state][pos_state]) == 0) {
1831 + state = St_set_short_rep(state);
1832 + LZd_put_byte(d, LZd_peek(d, rep0));
1833 + continue;
1835 + } else {
1836 + unsigned distance;
1838 + if (Rd_decode_bit(rdec, &d->bm_rep1[state]) == 0)
1839 + distance = rep1;
1840 + else {
1841 + if (Rd_decode_bit(rdec, &d->bm_rep2[state]) == 0)
1842 + distance = rep2;
1843 + else {
1844 + distance = rep3;
1845 + rep3 = rep2;
1847 + rep2 = rep1;
1849 + rep1 = rep0;
1850 + rep0 = distance;
1852 + state = St_set_rep(state);
1853 + len = min_match_len + Rd_decode_len(rdec, &d->rep_len_model, pos_state);
1854 + } else { /* match */
1855 + unsigned distance;
1857 + len = min_match_len + Rd_decode_len(rdec, &d->match_len_model, pos_state);
1858 + distance = Rd_decode_tree6(rdec, d->bm_dis_slot[get_len_state(len)]);
1859 + if (distance >= start_dis_model) {
1860 + const unsigned dis_slot = distance;
1861 + const int direct_bits = (dis_slot >> 1) - 1;
1863 + distance = (2 | (dis_slot & 1)) << direct_bits;
1864 + if (dis_slot < end_dis_model)
1865 + distance += Rd_decode_tree_reversed(rdec,
1866 + d->bm_dis + (distance - dis_slot), direct_bits);
1867 + else {
1868 + distance +=
1869 + Rd_decode(rdec, direct_bits - dis_align_bits) << dis_align_bits;
1870 + distance += Rd_decode_tree_reversed4(rdec, d->bm_align);
1871 + if (distance == 0xFFFFFFFFU) { /* marker found */
1872 + Rd_normalize(rdec);
1873 + LZd_flush_data(d);
1874 + if (d->write_error)
1875 + return LZIP_WRITE_ERROR;
1876 + if (len == min_match_len) { /* End Of Stream marker */
1877 + if (LZd_verify_trailer(d))
1878 + return 0;
1879 + else
1880 + return LZIP_BAD_CRC;
1882 + if (len == min_match_len + 1) { /* Sync Flush marker */
1883 + Rd_load(rdec);
1884 + continue;
1886 + return LZIP_BAD_DATA; /* unknown marker */
1890 + rep3 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance;
1891 + state = St_set_match(state);
1892 + if (rep0 >= d->dictionary_size ||
1893 + (rep0 >= d->pos && !d->pos_wrapped)) {
1894 + LZd_flush_data(d);
1895 + return LZIP_BAD_DATA;
1898 + LZd_copy_block(d, rep0, len);
1900 + LZd_flush_data(d);
1901 + return LZIP_DATA_EOF;
1905 +int lzip_decompress(unsigned char *inbuf, long in_len,
1906 + long (*fill)(void*, unsigned long),
1907 + long (*flush)(void*, unsigned long),
1908 + unsigned char *outbuf, long out_size,
1909 + long *in_posp, long *out_posp)
1911 + unsigned char *outptr = outbuf;
1912 + struct Range_decoder rdec;
1913 + struct LZ_decoder *decoder = 0;
1914 + int retval = 0;
1915 + bool first_member;
1917 + if (in_posp)
1918 + *in_posp = 0;
1919 + if (out_posp)
1920 + *out_posp = 0;
1922 + if (!Rd_init(&rdec, inbuf, in_len, fill))
1923 + return LZIP_OOM_INBUF;
1925 + for (first_member = true;; first_member = false) {
1926 + long data_pos;
1927 + int size;
1928 + unsigned dictionary_size;
1929 + Lzip_header header;
1931 + Rd_reset_member_position(&rdec);
1932 + for (size = 0; size < Lh_size && !Rd_finished(&rdec); ++size)
1933 + header[size] = Rd_get_byte(&rdec);
1934 + if (Rd_finished(&rdec)) { /* End Of File */
1935 + if (first_member)
1936 + retval = LZIP_HEADER1_EOF;
1937 + else if (Lh_verify_prefix(header, size))
1938 + retval = LZIP_HEADER2_EOF;
1939 + break;
1941 + if (!Lh_verify_magic(header)) {
1942 + if (first_member)
1943 + retval = LZIP_BAD_MAGIC1;
1944 + else if (Lh_verify_corrupt(header))
1945 + retval = LZIP_BAD_MAGIC2;
1946 + break;
1948 + if (!Lh_verify_version(header)) {
1949 + retval = LZIP_BAD_VERSION;
1950 + break;
1952 + dictionary_size = Lh_get_dictionary_size(header);
1953 + if (dictionary_size < min_dictionary_size ||
1954 + dictionary_size > max_dictionary_size) {
1955 + retval = LZIP_BAD_DICT_SIZE;
1956 + break;
1959 + if (!decoder)
1960 + decoder = malloc(sizeof *decoder);
1961 + if (!decoder || !LZd_init(decoder, &rdec, dictionary_size,
1962 + outptr, out_size, flush)) {
1963 + retval = LZIP_OOM_OUTBUF;
1964 + break;
1966 + retval = LZd_decode_member(decoder);
1967 + if (in_posp)
1968 + *in_posp += Rd_member_position(&rdec);
1969 + data_pos = LZd_data_position(decoder);
1970 + if (outptr)
1971 + outptr += data_pos;
1972 + if (out_posp)
1973 + *out_posp += data_pos;
1974 + if (out_size > 0)
1975 + out_size -= data_pos;
1976 + LZd_free(decoder);
1977 + if (retval != 0)
1978 + break;
1980 + if (decoder)
1981 + free(decoder);
1982 + Rd_free(&rdec);
1983 + return retval;
1986 +EXPORT_SYMBOL_GPL(lzip_decompress);
1987 +MODULE_DESCRIPTION("LZIP Decompressor");
1988 +MODULE_AUTHOR("Antonio Diaz Diaz <antonio@gnu.org>");
1989 +MODULE_LICENSE("GPL");
1990 diff -urdN linux-4.18.1/scripts/Makefile.lib linux-4.18.1.new/scripts/Makefile.lib
1991 --- linux-4.18.1/scripts/Makefile.lib 2018-08-15 17:37:34.000000000 +0200
1992 +++ linux-4.18.1.new/scripts/Makefile.lib 2018-08-16 18:56:17.000000000 +0200
1993 @@ -320,6 +320,21 @@
1994 bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
1995 (rm -f $@ ; false)
1997 +# Lzip
1998 +# ---------------------------------------------------------------------------
1999 +# The .lz format has the uncompressed size available at the end of the
2000 +# file, but at offset (member_size - 16). So we append a gzip-style size.
2001 +# Use klzip to compress the kernel image and lzip to compress other things.
2003 +quiet_cmd_klzip = LZIP $@
2004 +cmd_klzip = (cat $(filter-out FORCE,$^) | \
2005 + lzip -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
2006 + (rm -f $@ ; false)
2008 +quiet_cmd_lzip = LZIP $@
2009 +cmd_lzip = (cat $(filter-out FORCE,$^) | lzip -9) > $@ || \
2010 + (rm -f $@ ; false)
2012 # Lzma
2013 # ---------------------------------------------------------------------------
2015 diff -urdN linux-4.18.1/scripts/extract-ikconfig linux-4.18.1.new/scripts/extract-ikconfig
2016 --- linux-4.18.1/scripts/extract-ikconfig 2018-08-15 17:37:34.000000000 +0200
2017 +++ linux-4.18.1.new/scripts/extract-ikconfig 2018-08-16 18:56:17.000000000 +0200
2018 @@ -59,6 +59,7 @@
2019 try_decompress '\037\213\010' xy gunzip
2020 try_decompress '\3757zXZ\000' abcde unxz
2021 try_decompress 'BZh' xy bunzip2
2022 +try_decompress 'LZIP' xyz 'lzip -d'
2023 try_decompress '\135\0\0\0' xxx unlzma
2024 try_decompress '\211\114\132' xy 'lzop -d'
2025 try_decompress '\002\041\114\030' xyy 'lz4 -d -l'
2026 diff -urdN linux-4.18.1/scripts/extract-vmlinux linux-4.18.1.new/scripts/extract-vmlinux
2027 --- linux-4.18.1/scripts/extract-vmlinux 2018-08-15 17:37:34.000000000 +0200
2028 +++ linux-4.18.1.new/scripts/extract-vmlinux 2018-08-16 18:56:17.000000000 +0200
2029 @@ -55,6 +55,7 @@
2030 try_decompress '\037\213\010' xy gunzip
2031 try_decompress '\3757zXZ\000' abcde unxz
2032 try_decompress 'BZh' xy bunzip2
2033 +try_decompress 'LZIP' xyz 'lzip -d'
2034 try_decompress '\135\0\0\0' xxx unlzma
2035 try_decompress '\211\114\132' xy 'lzop -d'
2036 try_decompress '\002!L\030' xxx 'lz4 -d'
2037 diff -urdN linux-4.18.1/scripts/gen_initramfs_list.sh linux-4.18.1.new/scripts/gen_initramfs_list.sh
2038 --- linux-4.18.1/scripts/gen_initramfs_list.sh 2018-08-15 17:37:34.000000000 +0200
2039 +++ linux-4.18.1.new/scripts/gen_initramfs_list.sh 2018-08-16 18:56:17.000000000 +0200
2040 @@ -249,6 +249,9 @@
2041 echo "$output_file" | grep -q "\.bz2$" \
2042 && [ -x "`which bzip2 2> /dev/null`" ] \
2043 && compr="bzip2 -9 -f"
2044 + echo "$output_file" | grep -q "\.lz$" \
2045 + && [ -x "`which lzip 2> /dev/null`" ] \
2046 + && compr="lzip -9 -f"
2047 echo "$output_file" | grep -q "\.lzma$" \
2048 && [ -x "`which lzma 2> /dev/null`" ] \
2049 && compr="lzma -9 -f"
2050 diff -urdN linux-4.18.1/scripts/package/Makefile linux-4.18.1.new/scripts/package/Makefile
2051 --- linux-4.18.1/scripts/package/Makefile 2018-08-15 17:37:34.000000000 +0200
2052 +++ linux-4.18.1.new/scripts/package/Makefile 2018-08-16 18:56:17.000000000 +0200
2053 @@ -129,8 +129,9 @@
2054 $(if $(findstring tar-src,$@),, \
2055 $(if $(findstring bz2,$@),bzip2, \
2056 $(if $(findstring gz,$@),gzip, \
2057 +$(if $(findstring lz,$@),lzip, \
2058 $(if $(findstring xz,$@),xz, \
2059 -$(error unknown target $@)))) \
2060 +$(error unknown target $@))))) \
2061 -f -9 $(perf-tar).tar)
2063 perf-%pkg: FORCE
2064 @@ -147,8 +148,10 @@
2065 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
2066 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
2067 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
2068 + @echo ' tarlz-pkg - Build the kernel as a lzip compressed tarball'
2069 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
2070 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
2071 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
2072 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
2073 + @echo ' perf-tarlz-src-pkg - Build $(perf-tar).tar.lz source tarball'
2074 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
2075 diff -urdN linux-4.18.1/scripts/package/buildtar linux-4.18.1.new/scripts/package/buildtar
2076 --- linux-4.18.1/scripts/package/buildtar 2018-08-15 17:37:34.000000000 +0200
2077 +++ linux-4.18.1.new/scripts/package/buildtar 2018-08-16 18:56:17.000000000 +0200
2078 @@ -35,6 +35,10 @@
2079 opts=--bzip2
2080 tarball=${tarball}.bz2
2082 + tarlz-pkg)
2083 + opts=--lzip
2084 + tarball=${tarball}.lz
2085 + ;;
2086 tarxz-pkg)
2087 opts=--xz
2088 tarball=${tarball}.xz
2089 diff -urdN linux-4.18.1/scripts/patch-kernel linux-4.18.1.new/scripts/patch-kernel
2090 --- linux-4.18.1/scripts/patch-kernel 2018-08-15 17:37:34.000000000 +0200
2091 +++ linux-4.18.1.new/scripts/patch-kernel 2018-08-16 18:56:17.000000000 +0200
2092 @@ -117,6 +117,10 @@
2093 ext=".bz2"
2094 name="bzip2"
2095 uncomp="bunzip2 -dc"
2096 + elif [ -r ${filebase}.lz ]; then
2097 + ext=".lz"
2098 + name="lzip"
2099 + uncomp="lzip -dc"
2100 elif [ -r ${filebase}.xz ]; then
2101 ext=".xz"
2102 name="xz"
2103 diff -urdN linux-4.18.1/tools/testing/selftests/gen_kselftest_tar.sh linux-4.18.1.new/tools/testing/selftests/gen_kselftest_tar.sh
2104 --- linux-4.18.1/tools/testing/selftests/gen_kselftest_tar.sh 2018-08-15 17:37:34.000000000 +0200
2105 +++ linux-4.18.1.new/tools/testing/selftests/gen_kselftest_tar.sh 2018-08-16 18:56:17.000000000 +0200
2106 @@ -27,6 +27,10 @@
2107 copts="cvjf"
2108 ext=".tar.bz2"
2110 + tarlz)
2111 + copts="cv --lzip -f"
2112 + ext=".tar.lz"
2113 + ;;
2114 tarxz)
2115 copts="cvJf"
2116 ext=".tar.xz"
2117 diff -urdN linux-4.18.1/usr/.gitignore linux-4.18.1.new/usr/.gitignore
2118 --- linux-4.18.1/usr/.gitignore 2018-08-15 17:37:34.000000000 +0200
2119 +++ linux-4.18.1.new/usr/.gitignore 2018-08-16 18:56:17.000000000 +0200
2120 @@ -5,6 +5,7 @@
2121 initramfs_data.cpio
2122 initramfs_data.cpio.gz
2123 initramfs_data.cpio.bz2
2124 +initramfs_data.cpio.lz
2125 initramfs_data.cpio.lzma
2126 initramfs_list
2127 include
2128 diff -urdN linux-4.18.1/usr/Kconfig linux-4.18.1.new/usr/Kconfig
2129 --- linux-4.18.1/usr/Kconfig 2018-08-15 17:37:34.000000000 +0200
2130 +++ linux-4.18.1.new/usr/Kconfig 2018-08-16 18:56:17.000000000 +0200
2131 @@ -70,6 +70,15 @@
2132 Support loading of a bzip2 encoded initial ramdisk or cpio buffer
2133 If unsure, say N.
2135 +config RD_LZIP
2136 + bool "Support initial ramdisk/ramfs compressed using lzip"
2137 + default y
2138 + depends on BLK_DEV_INITRD
2139 + select DECOMPRESS_LZIP
2140 + help
2141 + Support loading of a lzip encoded initial ramdisk or cpio buffer.
2142 + If unsure, say N.
2144 config RD_LZMA
2145 bool "Support initial ramdisk/ramfs compressed using LZMA"
2146 default y
2147 @@ -165,6 +174,18 @@
2148 If you choose this, keep in mind that you need to have the bzip2 tool
2149 available to be able to compress the initram.
2151 +config INITRAMFS_COMPRESSION_LZIP
2152 + bool "Lzip"
2153 + depends on RD_LZIP
2154 + help
2155 + Lzip's compression ratio is better than that of gzip and bzip2.
2156 + Decompression speed is between gzip and bzip2. Compression can
2157 + be as fast as gzip or slower than bzip2 depending on compression
2158 + level. Lzip can produce a initramfs about a 16% smaller than gzip.
2160 + If you choose this, keep in mind that you need to have the lzip tool
2161 + available to be able to compress the initram.
2163 config INITRAMFS_COMPRESSION_LZMA
2164 bool "LZMA"
2165 depends on RD_LZMA
2166 @@ -222,12 +243,14 @@
2167 default "" if INITRAMFS_COMPRESSION_NONE
2168 default ".gz" if INITRAMFS_COMPRESSION_GZIP
2169 default ".bz2" if INITRAMFS_COMPRESSION_BZIP2
2170 + default ".lz" if INITRAMFS_COMPRESSION_LZIP
2171 default ".lzma" if INITRAMFS_COMPRESSION_LZMA
2172 default ".xz" if INITRAMFS_COMPRESSION_XZ
2173 default ".lzo" if INITRAMFS_COMPRESSION_LZO
2174 default ".lz4" if INITRAMFS_COMPRESSION_LZ4
2175 default ".gz" if RD_GZIP
2176 default ".lz4" if RD_LZ4
2177 + default ".lz" if RD_LZIP
2178 default ".lzo" if RD_LZO
2179 default ".xz" if RD_XZ
2180 default ".lzma" if RD_LZMA