linux-4.14.21_lzip-1.diff 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952
  1. diff -urdN linux-4.14.21/Documentation/00-INDEX linux-4.14.21.new/Documentation/00-INDEX
  2. --- linux-4.14.21/Documentation/00-INDEX 2018-02-22 15:42:33.000000000 +0100
  3. +++ linux-4.14.21.new/Documentation/00-INDEX 2018-02-24 17:22:34.000000000 +0100
  4. @@ -260,6 +260,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.14.21/Documentation/dontdiff linux-4.14.21.new/Documentation/dontdiff
  14. --- linux-4.14.21/Documentation/dontdiff 2018-02-22 15:42:33.000000000 +0100
  15. +++ linux-4.14.21.new/Documentation/dontdiff 2018-02-24 17:22:34.000000000 +0100
  16. @@ -26,6 +26,7 @@
  17. *.ll
  18. *.log
  19. *.lst
  20. +*.lz
  21. *.lzma
  22. *.lzo
  23. *.mo
  24. diff -urdN linux-4.14.21/Documentation/lzip.txt linux-4.14.21.new/Documentation/lzip.txt
  25. --- linux-4.14.21/Documentation/lzip.txt 1970-01-01 01:00:00.000000000 +0100
  26. +++ linux-4.14.21.new/Documentation/lzip.txt 2018-02-24 17:22:34.000000000 +0100
  27. @@ -0,0 +1,46 @@
  28. +
  29. +Lzip data compression in Linux
  30. +==============================
  31. +
  32. +Linux already offers a lot of compression formats. Then, why lzip?
  33. +
  34. +Because lzip is the only gzip-like LZMA compressor featuring a
  35. +well-designed format:
  36. +
  37. + * Lzma-alone is a toy format lacking integrity checking or even a
  38. + proper header.
  39. +
  40. + * Xz has a complex and not properly designed format[1]. It can
  41. + compress the kernel image a little more than lzip on some
  42. + architectures (about 4% on x86) by using a different binary filter
  43. + for each architecture. But this increase in complexity does not
  44. + improve the decompression time (much less the boot time) compared
  45. + with lzip.
  46. +
  47. + Also the xz compressor is the only one needing special options to
  48. + compress data for linux, and xz decompression is the only one that
  49. + may fail because of wrong options used at compression time.
  50. +
  51. + [1] See http://www.nongnu.org/lzip/xz_inadequate.html
  52. +
  53. +I have the hope that lzma-alone and xz will be eventually abandoned in
  54. +favor of lzip.
  55. +
  56. +Lzip-compressed kernel images of multiple linux versions since 2.6.30.10
  57. +have been built and tested, even on machines as modest as an AMD 486-DX2
  58. +at 66 MHz with 64 MiB of RAM. In the worst case (on the slow machine
  59. +above), lzip just increased the boot time a 15% compared with gzip. On
  60. +more modern machines, lzip may boot slightly faster than gzip. It just
  61. +takes 0.2 seconds for lzip to decompress vmlinuz-4.4.16 on my machine.
  62. +
  63. +One little-publicized fact is that, except on embedded systems with fast
  64. +boot setups, decompression speed is not important in booting linux.
  65. +Decompression time is usually a small fraction of the total boot time.
  66. +For example, using lz4 on a desktop machine in order to save 0.05
  67. +seconds of a total boot time of 20 seconds is probably not worth the
  68. +increased image size.
  69. +
  70. +Learn more about lzip at http://www.nongnu.org/lzip/lzip.html
  71. +
  72. +Author: Antonio Diaz Diaz
  73. +Updated: 2017-04-19
  74. diff -urdN linux-4.14.21/Documentation/x86/boot.txt linux-4.14.21.new/Documentation/x86/boot.txt
  75. --- linux-4.14.21/Documentation/x86/boot.txt 2018-02-22 15:42:33.000000000 +0100
  76. +++ linux-4.14.21.new/Documentation/x86/boot.txt 2018-02-24 17:22:34.000000000 +0100
  77. @@ -665,10 +665,10 @@
  78. The payload may be compressed. The format of both the compressed and
  79. uncompressed data should be determined using the standard magic
  80. numbers. The currently supported compression formats are gzip
  81. - (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), LZMA
  82. - (magic number 5D 00), XZ (magic number FD 37), and LZ4 (magic number
  83. - 02 21). The uncompressed payload is currently always ELF (magic
  84. - number 7F 45 4C 46).
  85. + (magic numbers 1F 8B or 1F 9E), bzip2 (magic number 42 5A), lzip
  86. + (magic number 4C 5A), LZMA (magic number 5D 00), XZ (magic number FD
  87. + 37), and LZ4 (magic number 02 21). The uncompressed payload is
  88. + currently always ELF (magic number 7F 45 4C 46).
  89. Field name: payload_length
  90. Type: read
  91. diff -urdN linux-4.14.21/Makefile linux-4.14.21.new/Makefile
  92. --- linux-4.14.21/Makefile 2018-02-22 15:42:33.000000000 +0100
  93. +++ linux-4.14.21.new/Makefile 2018-02-24 17:22:34.000000000 +0100
  94. @@ -897,14 +897,17 @@
  95. export mod_strip_cmd
  96. # CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed
  97. -# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP
  98. -# or CONFIG_MODULE_COMPRESS_XZ.
  99. +# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP,
  100. +# CONFIG_MODULE_COMPRESS_LZIP or CONFIG_MODULE_COMPRESS_XZ.
  101. mod_compress_cmd = true
  102. ifdef CONFIG_MODULE_COMPRESS
  103. ifdef CONFIG_MODULE_COMPRESS_GZIP
  104. mod_compress_cmd = gzip -n -f
  105. endif # CONFIG_MODULE_COMPRESS_GZIP
  106. + ifdef CONFIG_MODULE_COMPRESS_LZIP
  107. + mod_compress_cmd = lzip -f
  108. + endif # CONFIG_MODULE_COMPRESS_LZIP
  109. ifdef CONFIG_MODULE_COMPRESS_XZ
  110. mod_compress_cmd = xz -f
  111. endif # CONFIG_MODULE_COMPRESS_XZ
  112. @@ -916,6 +919,7 @@
  113. #
  114. INITRD_COMPRESS-y := gzip
  115. INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2
  116. +INITRD_COMPRESS-$(CONFIG_RD_LZIP) := lzip
  117. INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma
  118. INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz
  119. INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo
  120. diff -urdN linux-4.14.21/arch/arm/Kconfig linux-4.14.21.new/arch/arm/Kconfig
  121. --- linux-4.14.21/arch/arm/Kconfig 2018-02-22 15:42:33.000000000 +0100
  122. +++ linux-4.14.21.new/arch/arm/Kconfig 2018-02-24 17:22:34.000000000 +0100
  123. @@ -72,6 +72,7 @@
  124. select HAVE_IRQ_TIME_ACCOUNTING
  125. select HAVE_KERNEL_GZIP
  126. select HAVE_KERNEL_LZ4
  127. + select HAVE_KERNEL_LZIP
  128. select HAVE_KERNEL_LZMA
  129. select HAVE_KERNEL_LZO
  130. select HAVE_KERNEL_XZ
  131. diff -urdN linux-4.14.21/arch/arm/boot/compressed/Makefile linux-4.14.21.new/arch/arm/boot/compressed/Makefile
  132. --- linux-4.14.21/arch/arm/boot/compressed/Makefile 2018-02-22 15:42:33.000000000 +0100
  133. +++ linux-4.14.21.new/arch/arm/boot/compressed/Makefile 2018-02-24 17:22:34.000000000 +0100
  134. @@ -68,6 +68,7 @@
  135. CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)"
  136. compress-$(CONFIG_KERNEL_GZIP) = gzip
  137. +compress-$(CONFIG_KERNEL_LZIP) = klzip
  138. compress-$(CONFIG_KERNEL_LZO) = lzo
  139. compress-$(CONFIG_KERNEL_LZMA) = lzma
  140. compress-$(CONFIG_KERNEL_XZ) = xzkern
  141. diff -urdN linux-4.14.21/arch/arm/boot/compressed/decompress.c linux-4.14.21.new/arch/arm/boot/compressed/decompress.c
  142. --- linux-4.14.21/arch/arm/boot/compressed/decompress.c 2018-02-22 15:42:33.000000000 +0100
  143. +++ linux-4.14.21.new/arch/arm/boot/compressed/decompress.c 2018-02-24 17:22:34.000000000 +0100
  144. @@ -40,6 +40,10 @@
  145. #include "../../../../lib/decompress_inflate.c"
  146. #endif
  147. +#ifdef CONFIG_KERNEL_LZIP
  148. +#include "../../../../lib/decompress_lunzip.c"
  149. +#endif
  150. +
  151. #ifdef CONFIG_KERNEL_LZO
  152. #include "../../../../lib/decompress_unlzo.c"
  153. #endif
  154. diff -urdN linux-4.14.21/arch/blackfin/Kconfig linux-4.14.21.new/arch/blackfin/Kconfig
  155. --- linux-4.14.21/arch/blackfin/Kconfig 2018-02-22 15:42:33.000000000 +0100
  156. +++ linux-4.14.21.new/arch/blackfin/Kconfig 2018-02-24 17:22:34.000000000 +0100
  157. @@ -22,6 +22,7 @@
  158. select HAVE_IDE
  159. select HAVE_KERNEL_GZIP if RAMKERNEL
  160. select HAVE_KERNEL_BZIP2 if RAMKERNEL
  161. + select HAVE_KERNEL_LZIP if RAMKERNEL
  162. select HAVE_KERNEL_LZMA if RAMKERNEL
  163. select HAVE_KERNEL_LZO if RAMKERNEL
  164. select HAVE_OPROFILE
  165. diff -urdN linux-4.14.21/arch/blackfin/Makefile linux-4.14.21.new/arch/blackfin/Makefile
  166. --- linux-4.14.21/arch/blackfin/Makefile 2018-02-22 15:42:33.000000000 +0100
  167. +++ linux-4.14.21.new/arch/blackfin/Makefile 2018-02-24 17:22:34.000000000 +0100
  168. @@ -141,7 +141,8 @@
  169. INSTALL_PATH ?= /tftpboot
  170. boot := arch/$(ARCH)/boot
  171. -BOOT_TARGETS = uImage uImage.bin uImage.bz2 uImage.gz uImage.lzma uImage.lzo uImage.xip
  172. +BOOT_TARGETS = uImage uImage.bin uImage.bz2 uImage.gz uImage.lz uImage.lzma \
  173. + uImage.lzo uImage.xip
  174. PHONY += $(BOOT_TARGETS) install
  175. KBUILD_IMAGE := $(boot)/uImage
  176. @@ -158,6 +159,7 @@
  177. echo ' vmImage.bin - Uncompressed Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.bin)'
  178. echo ' vmImage.bz2 - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.bz2)'
  179. echo '* vmImage.gz - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.gz)'
  180. + echo ' vmImage.lz - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.lz)'
  181. echo ' vmImage.lzma - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.lzma)'
  182. echo ' vmImage.lzo - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.lzo)'
  183. echo ' vmImage.xip - XIP Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.xip)'
  184. diff -urdN linux-4.14.21/arch/blackfin/boot/Makefile linux-4.14.21.new/arch/blackfin/boot/Makefile
  185. --- linux-4.14.21/arch/blackfin/boot/Makefile 2018-02-22 15:42:33.000000000 +0100
  186. +++ linux-4.14.21.new/arch/blackfin/boot/Makefile 2018-02-24 17:22:34.000000000 +0100
  187. @@ -6,8 +6,10 @@
  188. # for more details.
  189. #
  190. -targets := uImage uImage.bin uImage.bz2 uImage.gz uImage.lzma uImage.lzo uImage.xip
  191. -extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.xip
  192. +targets := uImage uImage.bin uImage.bz2 uImage.gz uImage.lz uImage.lzma \
  193. + uImage.lzo uImage.xip
  194. +extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
  195. + vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.xip
  196. ifeq ($(CONFIG_RAMKERNEL),y)
  197. UIMAGE_LOADADDR = $(CONFIG_BOOT_LOAD)
  198. @@ -27,6 +29,9 @@
  199. $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
  200. $(call if_changed,bzip2)
  201. +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
  202. + $(call if_changed,klzip)
  203. +
  204. $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
  205. $(call if_changed,lzma)
  206. @@ -48,6 +53,9 @@
  207. $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz
  208. $(call if_changed,uimage,gzip)
  209. +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz
  210. + $(call if_changed,uimage,lzip)
  211. +
  212. $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma
  213. $(call if_changed,uimage,lzma)
  214. @@ -60,6 +68,7 @@
  215. suffix-y := bin
  216. suffix-$(CONFIG_KERNEL_GZIP) := gz
  217. suffix-$(CONFIG_KERNEL_BZIP2) := bz2
  218. +suffix-$(CONFIG_KERNEL_LZIP) := lz
  219. suffix-$(CONFIG_KERNEL_LZMA) := lzma
  220. suffix-$(CONFIG_KERNEL_LZO) := lzo
  221. suffix-$(CONFIG_ROMKERNEL) := xip
  222. diff -urdN linux-4.14.21/arch/m32r/Kconfig linux-4.14.21.new/arch/m32r/Kconfig
  223. --- linux-4.14.21/arch/m32r/Kconfig 2018-02-22 15:42:33.000000000 +0100
  224. +++ linux-4.14.21.new/arch/m32r/Kconfig 2018-02-24 17:22:34.000000000 +0100
  225. @@ -7,6 +7,7 @@
  226. select INIT_ALL_POSSIBLE
  227. select HAVE_KERNEL_GZIP
  228. select HAVE_KERNEL_BZIP2
  229. + select HAVE_KERNEL_LZIP
  230. select HAVE_KERNEL_LZMA
  231. select ARCH_WANT_IPC_PARSE_VERSION
  232. select HAVE_DEBUG_BUGVERBOSE
  233. diff -urdN linux-4.14.21/arch/m32r/boot/compressed/Makefile linux-4.14.21.new/arch/m32r/boot/compressed/Makefile
  234. --- linux-4.14.21/arch/m32r/boot/compressed/Makefile 2018-02-22 15:42:33.000000000 +0100
  235. +++ linux-4.14.21.new/arch/m32r/boot/compressed/Makefile 2018-02-24 17:22:34.000000000 +0100
  236. @@ -5,8 +5,8 @@
  237. # create a compressed vmlinux image from the original vmlinux
  238. #
  239. -targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
  240. - vmlinux.bin.lzma head.o misc.o piggy.o vmlinux.lds
  241. +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
  242. + vmlinux.bin.lz vmlinux.bin.lzma head.o misc.o piggy.o vmlinux.lds
  243. OBJECTS = $(obj)/head.o $(obj)/misc.o
  244. @@ -30,6 +30,9 @@
  245. $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
  246. $(call if_changed,bzip2)
  247. +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
  248. + $(call if_changed,klzip)
  249. +
  250. $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
  251. $(call if_changed,lzma)
  252. @@ -45,6 +48,7 @@
  253. suffix-$(CONFIG_KERNEL_GZIP) = gz
  254. suffix-$(CONFIG_KERNEL_BZIP2) = bz2
  255. +suffix-$(CONFIG_KERNEL_LZIP) = lz
  256. suffix-$(CONFIG_KERNEL_LZMA) = lzma
  257. $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
  258. diff -urdN linux-4.14.21/arch/m32r/boot/compressed/misc.c linux-4.14.21.new/arch/m32r/boot/compressed/misc.c
  259. --- linux-4.14.21/arch/m32r/boot/compressed/misc.c 2018-02-22 15:42:33.000000000 +0100
  260. +++ linux-4.14.21.new/arch/m32r/boot/compressed/misc.c 2018-02-24 17:22:34.000000000 +0100
  261. @@ -39,7 +39,7 @@
  262. }
  263. #endif
  264. -#ifdef CONFIG_KERNEL_GZIP
  265. +#if defined(CONFIG_KERNEL_GZIP) || defined(CONFIG_KERNEL_LZIP)
  266. void *memcpy(void *dest, const void *src, size_t n)
  267. {
  268. char *d = dest;
  269. @@ -49,7 +49,9 @@
  270. return dest;
  271. }
  272. +#endif
  273. +#ifdef CONFIG_KERNEL_GZIP
  274. #define BOOT_HEAP_SIZE 0x10000
  275. #include "../../../../lib/decompress_inflate.c"
  276. #endif
  277. @@ -59,6 +61,11 @@
  278. #include "../../../../lib/decompress_bunzip2.c"
  279. #endif
  280. +#ifdef CONFIG_KERNEL_LZIP
  281. +#define BOOT_HEAP_SIZE 0x10000
  282. +#include "../../../../lib/decompress_lunzip.c"
  283. +#endif
  284. +
  285. #ifdef CONFIG_KERNEL_LZMA
  286. #define BOOT_HEAP_SIZE 0x10000
  287. #include "../../../../lib/decompress_unlzma.c"
  288. diff -urdN linux-4.14.21/arch/metag/Kconfig linux-4.14.21.new/arch/metag/Kconfig
  289. --- linux-4.14.21/arch/metag/Kconfig 2018-02-22 15:42:33.000000000 +0100
  290. +++ linux-4.14.21.new/arch/metag/Kconfig 2018-02-24 17:22:34.000000000 +0100
  291. @@ -17,6 +17,7 @@
  292. select HAVE_FUNCTION_TRACER
  293. select HAVE_KERNEL_BZIP2
  294. select HAVE_KERNEL_GZIP
  295. + select HAVE_KERNEL_LZIP
  296. select HAVE_KERNEL_LZO
  297. select HAVE_KERNEL_XZ
  298. select HAVE_MEMBLOCK
  299. diff -urdN linux-4.14.21/arch/metag/Makefile linux-4.14.21.new/arch/metag/Makefile
  300. --- linux-4.14.21/arch/metag/Makefile 2018-02-22 15:42:33.000000000 +0100
  301. +++ linux-4.14.21.new/arch/metag/Makefile 2018-02-24 17:22:34.000000000 +0100
  302. @@ -56,6 +56,7 @@
  303. boot_targets += uImage
  304. boot_targets += uImage.gz
  305. boot_targets += uImage.bz2
  306. +boot_targets += uImage.lz
  307. boot_targets += uImage.xz
  308. boot_targets += uImage.lzo
  309. boot_targets += uImage.bin
  310. @@ -83,6 +84,7 @@
  311. @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
  312. @echo ' uImage.gz - Kernel-only image for U-Boot (gzip)'
  313. @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
  314. + @echo ' uImage.lz - Kernel-only image for U-Boot (lzip)'
  315. @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
  316. @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
  317. @echo ' dtbs - Build device tree blobs for enabled boards'
  318. diff -urdN linux-4.14.21/arch/metag/boot/Makefile linux-4.14.21.new/arch/metag/boot/Makefile
  319. --- linux-4.14.21/arch/metag/boot/Makefile 2018-02-22 15:42:33.000000000 +0100
  320. +++ linux-4.14.21.new/arch/metag/boot/Makefile 2018-02-24 17:22:34.000000000 +0100
  321. @@ -9,6 +9,7 @@
  322. suffix-y := bin
  323. suffix-$(CONFIG_KERNEL_GZIP) := gz
  324. suffix-$(CONFIG_KERNEL_BZIP2) := bz2
  325. +suffix-$(CONFIG_KERNEL_LZIP) := lz
  326. suffix-$(CONFIG_KERNEL_XZ) := xz
  327. suffix-$(CONFIG_KERNEL_LZO) := lzo
  328. @@ -16,6 +17,7 @@
  329. targets += uImage
  330. targets += uImage.gz
  331. targets += uImage.bz2
  332. +targets += uImage.lz
  333. targets += uImage.xz
  334. targets += uImage.lzo
  335. targets += uImage.bin
  336. @@ -23,6 +25,7 @@
  337. extra-y += vmlinux.bin
  338. extra-y += vmlinux.bin.gz
  339. extra-y += vmlinux.bin.bz2
  340. +extra-y += vmlinux.bin.lz
  341. extra-y += vmlinux.bin.xz
  342. extra-y += vmlinux.bin.lzo
  343. @@ -42,6 +45,9 @@
  344. $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
  345. $(call if_changed,bzip2)
  346. +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
  347. + $(call if_changed,klzip)
  348. +
  349. $(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
  350. $(call if_changed,xzkern)
  351. @@ -54,6 +60,9 @@
  352. $(obj)/uImage.bz2: $(obj)/vmlinux.bin.bz2 FORCE
  353. $(call if_changed,uimage,bzip2)
  354. +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz FORCE
  355. + $(call if_changed,uimage,lzip)
  356. +
  357. $(obj)/uImage.xz: $(obj)/vmlinux.bin.xz FORCE
  358. $(call if_changed,uimage,xz)
  359. diff -urdN linux-4.14.21/arch/mips/Kconfig linux-4.14.21.new/arch/mips/Kconfig
  360. --- linux-4.14.21/arch/mips/Kconfig 2018-02-22 15:42:33.000000000 +0100
  361. +++ linux-4.14.21.new/arch/mips/Kconfig 2018-02-24 17:22:34.000000000 +0100
  362. @@ -1820,6 +1820,7 @@
  363. select HAVE_KERNEL_GZIP
  364. select HAVE_KERNEL_BZIP2
  365. select HAVE_KERNEL_LZ4
  366. + select HAVE_KERNEL_LZIP
  367. select HAVE_KERNEL_LZMA
  368. select HAVE_KERNEL_LZO
  369. select HAVE_KERNEL_XZ
  370. diff -urdN linux-4.14.21/arch/mips/Makefile linux-4.14.21.new/arch/mips/Makefile
  371. --- linux-4.14.21/arch/mips/Makefile 2018-02-22 15:42:33.000000000 +0100
  372. +++ linux-4.14.21.new/arch/mips/Makefile 2018-02-24 17:22:34.000000000 +0100
  373. @@ -338,12 +338,14 @@
  374. boot-y += uImage.bin
  375. boot-y += uImage.bz2
  376. boot-y += uImage.gz
  377. +boot-y += uImage.lz
  378. boot-y += uImage.lzma
  379. boot-y += uImage.lzo
  380. endif
  381. boot-y += vmlinux.itb
  382. boot-y += vmlinux.gz.itb
  383. boot-y += vmlinux.bz2.itb
  384. +boot-y += vmlinux.lz.itb
  385. boot-y += vmlinux.lzma.itb
  386. boot-y += vmlinux.lzo.itb
  387. @@ -454,6 +456,7 @@
  388. echo ' uImage.bin - U-Boot image (uncompressed)'
  389. echo ' uImage.bz2 - U-Boot image (bz2)'
  390. echo ' uImage.gz - U-Boot image (gzip)'
  391. + echo ' uImage.lz - U-Boot image (lzip)'
  392. echo ' uImage.lzma - U-Boot image (lzma)'
  393. echo ' uImage.lzo - U-Boot image (lzo)'
  394. echo ' uzImage.bin - U-Boot image (self-extracting)'
  395. diff -urdN linux-4.14.21/arch/mips/boot/Makefile linux-4.14.21.new/arch/mips/boot/Makefile
  396. --- linux-4.14.21/arch/mips/boot/Makefile 2018-02-22 15:42:33.000000000 +0100
  397. +++ linux-4.14.21.new/arch/mips/boot/Makefile 2018-02-24 17:22:34.000000000 +0100
  398. @@ -26,6 +26,7 @@
  399. suffix-y := bin
  400. suffix-$(CONFIG_KERNEL_BZIP2) := bz2
  401. suffix-$(CONFIG_KERNEL_GZIP) := gz
  402. +suffix-$(CONFIG_KERNEL_LZIP) := lz
  403. suffix-$(CONFIG_KERNEL_LZMA) := lzma
  404. suffix-$(CONFIG_KERNEL_LZO) := lzo
  405. @@ -56,6 +57,7 @@
  406. extra-y += vmlinux.bin.bz2
  407. extra-y += vmlinux.bin.gz
  408. +extra-y += vmlinux.bin.lz
  409. extra-y += vmlinux.bin.lzma
  410. extra-y += vmlinux.bin.lzo
  411. @@ -65,6 +67,9 @@
  412. $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
  413. $(call if_changed,gzip)
  414. +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
  415. + $(call if_changed,klzip)
  416. +
  417. $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
  418. $(call if_changed,lzma)
  419. @@ -79,6 +84,7 @@
  420. targets += uImage.bin
  421. targets += uImage.bz2
  422. targets += uImage.gz
  423. +targets += uImage.lz
  424. targets += uImage.lzma
  425. targets += uImage.lzo
  426. @@ -91,6 +97,9 @@
  427. $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz FORCE
  428. $(call if_changed,uimage,gzip)
  429. +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz FORCE
  430. + $(call if_changed,uimage,lzip)
  431. +
  432. $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma FORCE
  433. $(call if_changed,uimage,lzma)
  434. @@ -108,6 +117,7 @@
  435. targets += vmlinux.itb
  436. targets += vmlinux.gz.itb
  437. targets += vmlinux.bz2.itb
  438. +targets += vmlinux.lz.itb
  439. targets += vmlinux.lzma.itb
  440. targets += vmlinux.lzo.itb
  441. @@ -143,6 +153,9 @@
  442. $(obj)/vmlinux.bz2.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
  443. $(call if_changed_dep,cpp_its_S,bzip2,vmlinux.bin.bz2)
  444. +$(obj)/vmlinux.lz.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
  445. + $(call if_changed_dep,cpp_its_S,lzip,vmlinux.bin.lz)
  446. +
  447. $(obj)/vmlinux.lzma.its: $(obj)/vmlinux.its.S $(VMLINUX) FORCE
  448. $(call if_changed_dep,cpp_its_S,lzma,vmlinux.bin.lzma)
  449. @@ -167,6 +180,9 @@
  450. $(obj)/vmlinux.bz2.itb: $(obj)/vmlinux.bz2.its $(obj)/vmlinux.bin.bz2 FORCE
  451. $(call if_changed,itb-image,$<)
  452. +$(obj)/vmlinux.lz.itb: $(obj)/vmlinux.lz.its $(obj)/vmlinux.bin.lz FORCE
  453. + $(call if_changed,itb-image,$<)
  454. +
  455. $(obj)/vmlinux.lzma.itb: $(obj)/vmlinux.lzma.its $(obj)/vmlinux.bin.lzma FORCE
  456. $(call if_changed,itb-image,$<)
  457. diff -urdN linux-4.14.21/arch/mips/boot/compressed/Makefile linux-4.14.21.new/arch/mips/boot/compressed/Makefile
  458. --- linux-4.14.21/arch/mips/boot/compressed/Makefile 2018-02-22 15:42:33.000000000 +0100
  459. +++ linux-4.14.21.new/arch/mips/boot/compressed/Makefile 2018-02-24 17:22:34.000000000 +0100
  460. @@ -61,6 +61,7 @@
  461. tool_$(CONFIG_KERNEL_GZIP) = gzip
  462. tool_$(CONFIG_KERNEL_BZIP2) = bzip2
  463. tool_$(CONFIG_KERNEL_LZ4) = lz4
  464. +tool_$(CONFIG_KERNEL_LZIP) = klzip
  465. tool_$(CONFIG_KERNEL_LZMA) = lzma
  466. tool_$(CONFIG_KERNEL_LZO) = lzo
  467. tool_$(CONFIG_KERNEL_XZ) = xzkern
  468. diff -urdN linux-4.14.21/arch/mips/boot/compressed/decompress.c linux-4.14.21.new/arch/mips/boot/compressed/decompress.c
  469. --- linux-4.14.21/arch/mips/boot/compressed/decompress.c 2018-02-22 15:42:33.000000000 +0100
  470. +++ linux-4.14.21.new/arch/mips/boot/compressed/decompress.c 2018-02-24 17:22:34.000000000 +0100
  471. @@ -64,6 +64,10 @@
  472. #include "../../../../lib/decompress_unlz4.c"
  473. #endif
  474. +#ifdef CONFIG_KERNEL_LZIP
  475. +#include "../../../../lib/decompress_lunzip.c"
  476. +#endif
  477. +
  478. #ifdef CONFIG_KERNEL_LZMA
  479. #include "../../../../lib/decompress_unlzma.c"
  480. #endif
  481. diff -urdN linux-4.14.21/arch/s390/Kconfig linux-4.14.21.new/arch/s390/Kconfig
  482. --- linux-4.14.21/arch/s390/Kconfig 2018-02-22 15:42:33.000000000 +0100
  483. +++ linux-4.14.21.new/arch/s390/Kconfig 2018-02-24 17:22:34.000000000 +0100
  484. @@ -151,6 +151,7 @@
  485. select HAVE_KERNEL_BZIP2
  486. select HAVE_KERNEL_GZIP
  487. select HAVE_KERNEL_LZ4
  488. + select HAVE_KERNEL_LZIP
  489. select HAVE_KERNEL_LZMA
  490. select HAVE_KERNEL_LZO
  491. select HAVE_KERNEL_XZ
  492. diff -urdN linux-4.14.21/arch/s390/boot/compressed/Makefile linux-4.14.21.new/arch/s390/boot/compressed/Makefile
  493. --- linux-4.14.21/arch/s390/boot/compressed/Makefile 2018-02-22 15:42:33.000000000 +0100
  494. +++ linux-4.14.21.new/arch/s390/boot/compressed/Makefile 2018-02-24 17:22:34.000000000 +0100
  495. @@ -7,9 +7,9 @@
  496. KCOV_INSTRUMENT := n
  497. -targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
  498. -targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
  499. -targets += misc.o piggy.o sizes.h head.o
  500. +targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
  501. +targets += vmlinux.bin.lz vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo
  502. +targets += vmlinux.bin.lz4 misc.o piggy.o sizes.h head.o
  503. KBUILD_CFLAGS := -m64 -D__KERNEL__ -O2
  504. KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
  505. @@ -51,6 +51,7 @@
  506. suffix-$(CONFIG_KERNEL_GZIP) := gz
  507. suffix-$(CONFIG_KERNEL_BZIP2) := bz2
  508. suffix-$(CONFIG_KERNEL_LZ4) := lz4
  509. +suffix-$(CONFIG_KERNEL_LZIP) := lz
  510. suffix-$(CONFIG_KERNEL_LZMA) := lzma
  511. suffix-$(CONFIG_KERNEL_LZO) := lzo
  512. suffix-$(CONFIG_KERNEL_XZ) := xz
  513. @@ -61,6 +62,8 @@
  514. $(call if_changed,bzip2)
  515. $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
  516. $(call if_changed,lz4)
  517. +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y)
  518. + $(call if_changed,klzip)
  519. $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
  520. $(call if_changed,lzma)
  521. $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
  522. diff -urdN linux-4.14.21/arch/s390/boot/compressed/misc.c linux-4.14.21.new/arch/s390/boot/compressed/misc.c
  523. --- linux-4.14.21/arch/s390/boot/compressed/misc.c 2018-02-22 15:42:33.000000000 +0100
  524. +++ linux-4.14.21.new/arch/s390/boot/compressed/misc.c 2018-02-24 17:22:34.000000000 +0100
  525. @@ -53,6 +53,10 @@
  526. #include "../../../../lib/decompress_unlz4.c"
  527. #endif
  528. +#ifdef CONFIG_KERNEL_LZIP
  529. +#include "../../../../lib/decompress_lunzip.c"
  530. +#endif
  531. +
  532. #ifdef CONFIG_KERNEL_LZMA
  533. #include "../../../../lib/decompress_unlzma.c"
  534. #endif
  535. diff -urdN linux-4.14.21/arch/sh/Kconfig linux-4.14.21.new/arch/sh/Kconfig
  536. --- linux-4.14.21/arch/sh/Kconfig 2018-02-22 15:42:33.000000000 +0100
  537. +++ linux-4.14.21.new/arch/sh/Kconfig 2018-02-24 17:22:34.000000000 +0100
  538. @@ -24,6 +24,7 @@
  539. select HAVE_KERNEL_GZIP
  540. select CPU_NO_EFFICIENT_FFS
  541. select HAVE_KERNEL_BZIP2
  542. + select HAVE_KERNEL_LZIP
  543. select HAVE_KERNEL_LZMA
  544. select HAVE_KERNEL_XZ
  545. select HAVE_KERNEL_LZO
  546. diff -urdN linux-4.14.21/arch/sh/Makefile linux-4.14.21.new/arch/sh/Makefile
  547. --- linux-4.14.21/arch/sh/Makefile 2018-02-22 15:42:33.000000000 +0100
  548. +++ linux-4.14.21.new/arch/sh/Makefile 2018-02-24 17:22:34.000000000 +0100
  549. @@ -205,9 +205,9 @@
  550. libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
  551. libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
  552. -BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
  553. - uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
  554. - romImage
  555. +BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lz uImage.lzma uImage.xz \
  556. + uImage.lzo uImage.srec uImage.bin zImage vmlinux.bin \
  557. + vmlinux.srec romImage
  558. PHONY += $(BOOT_TARGETS)
  559. all: $(notdir $(KBUILD_IMAGE))
  560. @@ -234,6 +234,7 @@
  561. @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
  562. @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)'
  563. @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
  564. + @echo ' uImage.lz - Kernel-only image for U-Boot (lzip)'
  565. @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)'
  566. @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
  567. @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
  568. diff -urdN linux-4.14.21/arch/sh/boot/Makefile linux-4.14.21.new/arch/sh/boot/Makefile
  569. --- linux-4.14.21/arch/sh/boot/Makefile 2018-02-22 15:42:33.000000000 +0100
  570. +++ linux-4.14.21.new/arch/sh/boot/Makefile 2018-02-24 17:22:34.000000000 +0100
  571. @@ -22,14 +22,15 @@
  572. suffix-y := bin
  573. suffix-$(CONFIG_KERNEL_GZIP) := gz
  574. suffix-$(CONFIG_KERNEL_BZIP2) := bz2
  575. +suffix-$(CONFIG_KERNEL_LZIP) := lz
  576. suffix-$(CONFIG_KERNEL_LZMA) := lzma
  577. suffix-$(CONFIG_KERNEL_XZ) := xz
  578. suffix-$(CONFIG_KERNEL_LZO) := lzo
  579. targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz \
  580. - uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin
  581. -extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
  582. - vmlinux.bin.xz vmlinux.bin.lzo
  583. + uImage.bz2 uImage.lz uImage.lzma uImage.xz uImage.lzo uImage.bin
  584. +extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
  585. + vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo
  586. subdir- := compressed romimage
  587. $(obj)/zImage: $(obj)/compressed/vmlinux FORCE
  588. @@ -71,6 +72,9 @@
  589. $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
  590. $(call if_changed,bzip2)
  591. +$(obj)/vmlinux.bin.lz: $(obj)/vmlinux.bin FORCE
  592. + $(call if_changed,klzip)
  593. +
  594. $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
  595. $(call if_changed,lzma)
  596. @@ -86,6 +90,9 @@
  597. $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz
  598. $(call if_changed,uimage,gzip)
  599. +$(obj)/uImage.lz: $(obj)/vmlinux.bin.lz
  600. + $(call if_changed,uimage,lzip)
  601. +
  602. $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma
  603. $(call if_changed,uimage,lzma)
  604. diff -urdN linux-4.14.21/arch/sh/boot/compressed/Makefile linux-4.14.21.new/arch/sh/boot/compressed/Makefile
  605. --- linux-4.14.21/arch/sh/boot/compressed/Makefile 2018-02-22 15:42:33.000000000 +0100
  606. +++ linux-4.14.21.new/arch/sh/boot/compressed/Makefile 2018-02-24 17:22:34.000000000 +0100
  607. @@ -5,10 +5,9 @@
  608. # create a compressed vmlinux image from the original vmlinux
  609. #
  610. -targets := vmlinux vmlinux.bin vmlinux.bin.gz \
  611. - vmlinux.bin.bz2 vmlinux.bin.lzma \
  612. - vmlinux.bin.xz vmlinux.bin.lzo \
  613. - head_$(BITS).o misc.o piggy.o
  614. +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
  615. + vmlinux.bin.lz vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo \
  616. + head_$(BITS).o misc.o piggy.o
  617. OBJECTS = $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/cache.o
  618. @@ -66,6 +65,8 @@
  619. $(call if_changed,gzip)
  620. $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
  621. $(call if_changed,bzip2)
  622. +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y) FORCE
  623. + $(call if_changed,klzip)
  624. $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
  625. $(call if_changed,lzma)
  626. $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
  627. diff -urdN linux-4.14.21/arch/sh/boot/compressed/misc.c linux-4.14.21.new/arch/sh/boot/compressed/misc.c
  628. --- linux-4.14.21/arch/sh/boot/compressed/misc.c 2018-02-22 15:42:33.000000000 +0100
  629. +++ linux-4.14.21.new/arch/sh/boot/compressed/misc.c 2018-02-24 17:22:34.000000000 +0100
  630. @@ -58,6 +58,10 @@
  631. #include "../../../../lib/decompress_bunzip2.c"
  632. #endif
  633. +#ifdef CONFIG_KERNEL_LZIP
  634. +#include "../../../../lib/decompress_lunzip.c"
  635. +#endif
  636. +
  637. #ifdef CONFIG_KERNEL_LZMA
  638. #include "../../../../lib/decompress_unlzma.c"
  639. #endif
  640. diff -urdN linux-4.14.21/arch/unicore32/.gitignore linux-4.14.21.new/arch/unicore32/.gitignore
  641. --- linux-4.14.21/arch/unicore32/.gitignore 2018-02-22 15:42:33.000000000 +0100
  642. +++ linux-4.14.21.new/arch/unicore32/.gitignore 2018-02-24 17:22:34.000000000 +0100
  643. @@ -17,5 +17,9 @@
  644. #
  645. boot/compressed/piggy.S
  646. boot/compressed/piggy.gzip
  647. +boot/compressed/piggy.bz2
  648. +boot/compressed/piggy.lzip
  649. +boot/compressed/piggy.lzma
  650. +boot/compressed/piggy.lzo
  651. boot/compressed/vmlinux
  652. boot/compressed/vmlinux.lds
  653. diff -urdN linux-4.14.21/arch/unicore32/Kconfig linux-4.14.21.new/arch/unicore32/Kconfig
  654. --- linux-4.14.21/arch/unicore32/Kconfig 2018-02-22 15:42:33.000000000 +0100
  655. +++ linux-4.14.21.new/arch/unicore32/Kconfig 2018-02-24 17:22:34.000000000 +0100
  656. @@ -8,6 +8,7 @@
  657. select HAVE_GENERIC_DMA_COHERENT
  658. select HAVE_KERNEL_GZIP
  659. select HAVE_KERNEL_BZIP2
  660. + select HAVE_KERNEL_LZIP
  661. select GENERIC_ATOMIC64
  662. select HAVE_KERNEL_LZO
  663. select HAVE_KERNEL_LZMA
  664. diff -urdN linux-4.14.21/arch/unicore32/boot/compressed/Makefile linux-4.14.21.new/arch/unicore32/boot/compressed/Makefile
  665. --- linux-4.14.21/arch/unicore32/boot/compressed/Makefile 2018-02-22 15:42:33.000000000 +0100
  666. +++ linux-4.14.21.new/arch/unicore32/boot/compressed/Makefile 2018-02-24 17:22:34.000000000 +0100
  667. @@ -23,6 +23,7 @@
  668. # piggy.S and piggy.o
  669. suffix_$(CONFIG_KERNEL_GZIP) := gzip
  670. suffix_$(CONFIG_KERNEL_BZIP2) := bz2
  671. +suffix_$(CONFIG_KERNEL_LZIP) := lzip
  672. suffix_$(CONFIG_KERNEL_LZO) := lzo
  673. suffix_$(CONFIG_KERNEL_LZMA) := lzma
  674. @@ -36,10 +37,10 @@
  675. $(obj)/piggy.o: $(obj)/piggy.$(suffix_y) $(obj)/piggy.S FORCE
  676. targets := vmlinux vmlinux.lds font.o font.c head.o misc.o \
  677. - piggy.$(suffix_y) piggy.o piggy.S \
  678. + piggy.$(suffix_y) piggy.o piggy.S
  679. # Make sure files are removed during clean
  680. -extra-y += piggy.gzip piggy.bz2 piggy.lzo piggy.lzma
  681. +extra-y += piggy.gzip piggy.bz2 piggy.lzip piggy.lzo piggy.lzma
  682. # ?
  683. LDFLAGS_vmlinux += -p
  684. diff -urdN linux-4.14.21/arch/unicore32/boot/compressed/misc.c linux-4.14.21.new/arch/unicore32/boot/compressed/misc.c
  685. --- linux-4.14.21/arch/unicore32/boot/compressed/misc.c 2018-02-22 15:42:33.000000000 +0100
  686. +++ linux-4.14.21.new/arch/unicore32/boot/compressed/misc.c 2018-02-24 17:22:34.000000000 +0100
  687. @@ -95,6 +95,10 @@
  688. #include "../../../../lib/decompress_bunzip2.c"
  689. #endif
  690. +#ifdef CONFIG_KERNEL_LZIP
  691. +#include "../../../../lib/decompress_lunzip.c"
  692. +#endif
  693. +
  694. #ifdef CONFIG_KERNEL_LZO
  695. #include "../../../../lib/decompress_unlzo.c"
  696. #endif
  697. diff -urdN linux-4.14.21/arch/x86/Kconfig linux-4.14.21.new/arch/x86/Kconfig
  698. --- linux-4.14.21/arch/x86/Kconfig 2018-02-22 15:42:33.000000000 +0100
  699. +++ linux-4.14.21.new/arch/x86/Kconfig 2018-02-24 17:22:34.000000000 +0100
  700. @@ -148,6 +148,7 @@
  701. select HAVE_KERNEL_BZIP2
  702. select HAVE_KERNEL_GZIP
  703. select HAVE_KERNEL_LZ4
  704. + select HAVE_KERNEL_LZIP
  705. select HAVE_KERNEL_LZMA
  706. select HAVE_KERNEL_LZO
  707. select HAVE_KERNEL_XZ
  708. diff -urdN linux-4.14.21/arch/x86/boot/compressed/Makefile linux-4.14.21.new/arch/x86/boot/compressed/Makefile
  709. --- linux-4.14.21/arch/x86/boot/compressed/Makefile 2018-02-22 15:42:33.000000000 +0100
  710. +++ linux-4.14.21.new/arch/x86/boot/compressed/Makefile 2018-02-24 17:22:34.000000000 +0100
  711. @@ -23,8 +23,8 @@
  712. # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
  713. KCOV_INSTRUMENT := n
  714. -targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
  715. - vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
  716. +targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lz \
  717. + vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
  718. KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ -O2
  719. KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
  720. @@ -127,6 +127,8 @@
  721. $(call if_changed,gzip)
  722. $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
  723. $(call if_changed,bzip2)
  724. +$(obj)/vmlinux.bin.lz: $(vmlinux.bin.all-y) FORCE
  725. + $(call if_changed,klzip)
  726. $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
  727. $(call if_changed,lzma)
  728. $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
  729. @@ -138,6 +140,7 @@
  730. suffix-$(CONFIG_KERNEL_GZIP) := gz
  731. suffix-$(CONFIG_KERNEL_BZIP2) := bz2
  732. +suffix-$(CONFIG_KERNEL_LZIP) := lz
  733. suffix-$(CONFIG_KERNEL_LZMA) := lzma
  734. suffix-$(CONFIG_KERNEL_XZ) := xz
  735. suffix-$(CONFIG_KERNEL_LZO) := lzo
  736. diff -urdN linux-4.14.21/arch/x86/boot/compressed/misc.c linux-4.14.21.new/arch/x86/boot/compressed/misc.c
  737. --- linux-4.14.21/arch/x86/boot/compressed/misc.c 2018-02-22 15:42:33.000000000 +0100
  738. +++ linux-4.14.21.new/arch/x86/boot/compressed/misc.c 2018-02-24 17:22:34.000000000 +0100
  739. @@ -60,6 +60,10 @@
  740. #include "../../../../lib/decompress_bunzip2.c"
  741. #endif
  742. +#ifdef CONFIG_KERNEL_LZIP
  743. +#include "../../../../lib/decompress_lunzip.c"
  744. +#endif
  745. +
  746. #ifdef CONFIG_KERNEL_LZMA
  747. #include "../../../../lib/decompress_unlzma.c"
  748. #endif
  749. diff -urdN linux-4.14.21/include/linux/decompress/lunzip.h linux-4.14.21.new/include/linux/decompress/lunzip.h
  750. --- linux-4.14.21/include/linux/decompress/lunzip.h 1970-01-01 01:00:00.000000000 +0100
  751. +++ linux-4.14.21.new/include/linux/decompress/lunzip.h 2018-02-24 17:22:34.000000000 +0100
  752. @@ -0,0 +1,10 @@
  753. +#ifndef LINUX_DECOMPRESS_LUNZIP_H
  754. +#define LINUX_DECOMPRESS_LUNZIP_H
  755. +
  756. +int lunzip(unsigned char *inbuf, long in_len,
  757. + long (*fill)(void*, unsigned long),
  758. + long (*flush)(void*, unsigned long),
  759. + unsigned char *outbuf,
  760. + long *in_posp,
  761. + void (*error)(char *x));
  762. +#endif
  763. diff -urdN linux-4.14.21/init/Kconfig linux-4.14.21.new/init/Kconfig
  764. --- linux-4.14.21/init/Kconfig 2018-02-22 15:42:33.000000000 +0100
  765. +++ linux-4.14.21.new/init/Kconfig 2018-02-24 17:22:34.000000000 +0100
  766. @@ -115,6 +115,9 @@
  767. config HAVE_KERNEL_BZIP2
  768. bool
  769. +config HAVE_KERNEL_LZIP
  770. + bool
  771. +
  772. config HAVE_KERNEL_LZMA
  773. bool
  774. @@ -130,7 +133,7 @@
  775. choice
  776. prompt "Kernel compression mode"
  777. default KERNEL_GZIP
  778. - depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
  779. + depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZIP || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
  780. help
  781. The linux kernel is a kind of self-extracting executable.
  782. Several compression algorithms are available, which differ
  783. @@ -166,6 +169,15 @@
  784. Bzip2 uses a large amount of memory. For modern kernels you
  785. will need at least 8MB RAM or more for booting.
  786. +config KERNEL_LZIP
  787. + bool "Lzip"
  788. + depends on HAVE_KERNEL_LZIP
  789. + help
  790. + Lzip's compression ratio is better than that of gzip and bzip2.
  791. + Decompression speed is between gzip and bzip2. Compression can
  792. + be as fast as gzip or slower than bzip2 depending on compression
  793. + level. Lzip can produce a kernel about a 16% smaller than gzip.
  794. +
  795. config KERNEL_LZMA
  796. bool "LZMA"
  797. depends on HAVE_KERNEL_LZMA
  798. @@ -1834,8 +1846,8 @@
  799. depends on MODULES
  800. help
  801. - Compresses kernel modules when 'make modules_install' is run; gzip or
  802. - xz depending on "Compression algorithm" below.
  803. + Compresses kernel modules when 'make modules_install' is run; gzip,
  804. + lzip or xz are used depending on "Compression algorithm" below.
  805. module-init-tools MAY support gzip, and kmod MAY support gzip and xz.
  806. @@ -1857,11 +1869,14 @@
  807. This determines which sort of compression will be used during
  808. 'make modules_install'.
  809. - GZIP (default) and XZ are supported.
  810. + GZIP (default), LZIP and XZ are supported.
  811. config MODULE_COMPRESS_GZIP
  812. bool "GZIP"
  813. +config MODULE_COMPRESS_LZIP
  814. + bool "LZIP"
  815. +
  816. config MODULE_COMPRESS_XZ
  817. bool "XZ"
  818. diff -urdN linux-4.14.21/init/do_mounts_rd.c linux-4.14.21.new/init/do_mounts_rd.c
  819. --- linux-4.14.21/init/do_mounts_rd.c 2018-02-22 15:42:33.000000000 +0100
  820. +++ linux-4.14.21.new/init/do_mounts_rd.c 2018-02-24 17:22:34.000000000 +0100
  821. @@ -59,6 +59,7 @@
  822. * squashfs
  823. * gzip
  824. * bzip2
  825. + * lzip
  826. * lzma
  827. * xz
  828. * lzo
  829. diff -urdN linux-4.14.21/lib/Kconfig linux-4.14.21.new/lib/Kconfig
  830. --- linux-4.14.21/lib/Kconfig 2018-02-22 15:42:33.000000000 +0100
  831. +++ linux-4.14.21.new/lib/Kconfig 2018-02-24 17:22:34.000000000 +0100
  832. @@ -270,6 +270,9 @@
  833. config DECOMPRESS_BZIP2
  834. tristate
  835. +config DECOMPRESS_LZIP
  836. + tristate
  837. +
  838. config DECOMPRESS_LZMA
  839. tristate
  840. diff -urdN linux-4.14.21/lib/Makefile linux-4.14.21.new/lib/Makefile
  841. --- linux-4.14.21/lib/Makefile 2018-02-22 15:42:33.000000000 +0100
  842. +++ linux-4.14.21.new/lib/Makefile 2018-02-24 17:22:34.000000000 +0100
  843. @@ -125,6 +125,7 @@
  844. lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
  845. lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
  846. +lib-$(CONFIG_DECOMPRESS_LZIP) += decompress_lunzip.o
  847. lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
  848. lib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
  849. lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
  850. diff -urdN linux-4.14.21/lib/decompress.c linux-4.14.21.new/lib/decompress.c
  851. --- linux-4.14.21/lib/decompress.c 2018-02-22 15:42:33.000000000 +0100
  852. +++ linux-4.14.21.new/lib/decompress.c 2018-02-24 17:22:34.000000000 +0100
  853. @@ -8,6 +8,7 @@
  854. #include <linux/decompress/generic.h>
  855. #include <linux/decompress/bunzip2.h>
  856. +#include <linux/decompress/lunzip.h>
  857. #include <linux/decompress/unlzma.h>
  858. #include <linux/decompress/unxz.h>
  859. #include <linux/decompress/inflate.h>
  860. @@ -25,6 +26,9 @@
  861. #ifndef CONFIG_DECOMPRESS_BZIP2
  862. # define bunzip2 NULL
  863. #endif
  864. +#ifndef CONFIG_DECOMPRESS_LZIP
  865. +# define lunzip NULL
  866. +#endif
  867. #ifndef CONFIG_DECOMPRESS_LZMA
  868. # define unlzma NULL
  869. #endif
  870. @@ -48,6 +52,7 @@
  871. { {0x1f, 0x8b}, "gzip", gunzip },
  872. { {0x1f, 0x9e}, "gzip", gunzip },
  873. { {0x42, 0x5a}, "bzip2", bunzip2 },
  874. + { {0x4c, 0x5a}, "lzip", lunzip },
  875. { {0x5d, 0x00}, "lzma", unlzma },
  876. { {0xfd, 0x37}, "xz", unxz },
  877. { {0x89, 0x4c}, "lzo", unlzo },
  878. diff -urdN linux-4.14.21/lib/decompress_lunzip.c linux-4.14.21.new/lib/decompress_lunzip.c
  879. --- linux-4.14.21/lib/decompress_lunzip.c 1970-01-01 01:00:00.000000000 +0100
  880. +++ linux-4.14.21.new/lib/decompress_lunzip.c 2018-02-24 17:22:34.000000000 +0100
  881. @@ -0,0 +1,795 @@
  882. +/*
  883. + * lunzip implementation for linux
  884. + *
  885. + * Copyright (C) 2016, 2017 Antonio Diaz Diaz.
  886. + *
  887. + * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  888. + */
  889. +
  890. +#ifdef STATIC
  891. +#define PREBOOT
  892. +#else
  893. +#include <linux/decompress/lunzip.h>
  894. +#endif
  895. +
  896. +#include <linux/decompress/mm.h>
  897. +
  898. +typedef int State;
  899. +
  900. +enum { states = 12 };
  901. +
  902. +static inline bool St_is_char(const State st) { return st < 7; }
  903. +
  904. +static inline State St_set_char(const State st)
  905. +{
  906. + static const State next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
  907. + return next[st];
  908. +}
  909. +
  910. +static inline State St_set_match(const State st)
  911. +{
  912. + return ((st < 7) ? 7 : 10);
  913. +}
  914. +
  915. +static inline State St_set_rep(const State st)
  916. +{
  917. + return ((st < 7) ? 8 : 11);
  918. +}
  919. +
  920. +static inline State St_set_short_rep(const State st)
  921. +{
  922. + return ((st < 7) ? 9 : 11);
  923. +}
  924. +
  925. +
  926. +enum {
  927. + min_dictionary_bits = 12,
  928. + min_dictionary_size = 1 << min_dictionary_bits,
  929. + max_dictionary_bits = 29,
  930. + max_dictionary_size = 1 << max_dictionary_bits,
  931. + literal_context_bits = 3,
  932. + pos_state_bits = 2,
  933. + pos_states = 1 << pos_state_bits,
  934. + pos_state_mask = pos_states - 1,
  935. +
  936. + len_states = 4,
  937. + dis_slot_bits = 6,
  938. + start_dis_model = 4,
  939. + end_dis_model = 14,
  940. + modeled_distances = 1 << (end_dis_model / 2), /* 128 */
  941. + dis_align_bits = 4,
  942. + dis_align_size = 1 << dis_align_bits,
  943. +
  944. + len_low_bits = 3,
  945. + len_mid_bits = 3,
  946. + len_high_bits = 8,
  947. + len_low_symbols = 1 << len_low_bits,
  948. + len_mid_symbols = 1 << len_mid_bits,
  949. + len_high_symbols = 1 << len_high_bits,
  950. + max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols,
  951. +
  952. + min_match_len = 2, /* must be 2 */
  953. + max_match_len = min_match_len + max_len_symbols - 1, /* 273 */
  954. + min_match_len_limit = 5
  955. +};
  956. +
  957. +static inline int get_len_state(const int len)
  958. +{
  959. + return min(len - min_match_len, len_states - 1);
  960. +}
  961. +
  962. +static inline int get_lit_state(const uint8_t prev_byte)
  963. +{
  964. + return (prev_byte >> (8 - literal_context_bits));
  965. +}
  966. +
  967. +
  968. +enum { bit_model_move_bits = 5,
  969. + bit_model_total_bits = 11,
  970. + bit_model_total = 1 << bit_model_total_bits
  971. +};
  972. +
  973. +typedef uint16_t Bit_model;
  974. +
  975. +static inline void Bm_init(Bit_model * const probability)
  976. +{
  977. + *probability = bit_model_total / 2;
  978. +}
  979. +
  980. +static inline void Bm_array_init(Bit_model * const p, const int size)
  981. +{
  982. + int i = 0;
  983. +
  984. + while (i < size)
  985. + p[i++] = bit_model_total / 2;
  986. +}
  987. +
  988. +struct Len_model {
  989. + Bit_model choice1;
  990. + Bit_model choice2;
  991. + Bit_model bm_low[pos_states][len_low_symbols];
  992. + Bit_model bm_mid[pos_states][len_mid_symbols];
  993. + Bit_model bm_high[len_high_symbols];
  994. +};
  995. +
  996. +static inline void Lm_init(struct Len_model * const lm)
  997. +{
  998. + Bm_init(&lm->choice1);
  999. + Bm_init(&lm->choice2);
  1000. + Bm_array_init(lm->bm_low[0], pos_states * len_low_symbols);
  1001. + Bm_array_init(lm->bm_mid[0], pos_states * len_mid_symbols);
  1002. + Bm_array_init(lm->bm_high, len_high_symbols);
  1003. +}
  1004. +
  1005. +
  1006. +typedef uint32_t CRC32[256]; /* Table of CRCs of all 8-bit messages. */
  1007. +
  1008. +static CRC32 crc32;
  1009. +
  1010. +static inline void CRC32_init(void)
  1011. +{
  1012. + unsigned n;
  1013. +
  1014. + for (n = 0; n < 256; ++n) {
  1015. + unsigned c = n;
  1016. + int k;
  1017. +
  1018. + for (k = 0; k < 8; ++k) {
  1019. + if (c & 1)
  1020. + c = 0xEDB88320U ^ (c >> 1);
  1021. + else
  1022. + c >>= 1;
  1023. + }
  1024. + crc32[n] = c;
  1025. + }
  1026. +}
  1027. +
  1028. +static inline void CRC32_update_buf(uint32_t * const crc,
  1029. + const uint8_t * const buffer,
  1030. + const long size)
  1031. +{
  1032. + long i;
  1033. + uint32_t c = *crc;
  1034. +
  1035. + for (i = 0; i < size; ++i)
  1036. + c = crc32[(c^buffer[i])&0xFF] ^ (c >> 8);
  1037. + *crc = c;
  1038. +}
  1039. +
  1040. +
  1041. +static const uint8_t magic_string[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
  1042. +
  1043. +typedef uint8_t File_header[6]; /* 0-3 magic bytes */
  1044. + /* 4 version */
  1045. + /* 5 coded_dict_size */
  1046. +enum { Fh_size = 6 };
  1047. +
  1048. +static inline bool Fh_verify_magic(const File_header data)
  1049. +{
  1050. + int i;
  1051. +
  1052. + for (i = 0; i < 4; ++i)
  1053. + if (data[i] != magic_string[i])
  1054. + return false;
  1055. + return (data[4] == 1);
  1056. +}
  1057. +
  1058. +static inline unsigned Fh_get_dictionary_size(const File_header data)
  1059. +{
  1060. + unsigned sz = (1 << (data[5] & 0x1F));
  1061. +
  1062. + if (sz > min_dictionary_size)
  1063. + sz -= (sz / 16) * ((data[5] >> 5) & 7);
  1064. + return sz;
  1065. +}
  1066. +
  1067. +
  1068. +typedef uint8_t File_trailer[20];
  1069. + /* 0-3 CRC32 of the uncompressed data */
  1070. + /* 4-11 size of the uncompressed data */
  1071. + /* 12-19 member size including header and trailer */
  1072. +
  1073. +enum { Ft_size = 20 };
  1074. +
  1075. +static inline unsigned Ft_get_data_crc(const File_trailer data)
  1076. +{
  1077. + unsigned tmp = 0;
  1078. + int i;
  1079. +
  1080. + for (i = 3; i >= 0; --i) {
  1081. + tmp <<= 8;
  1082. + tmp += data[i];
  1083. + }
  1084. + return tmp;
  1085. +}
  1086. +
  1087. +static inline unsigned long long Ft_get_data_size(const File_trailer data)
  1088. +{
  1089. + unsigned long long tmp = 0;
  1090. + int i;
  1091. +
  1092. + for (i = 11; i >= 4; --i) {
  1093. + tmp <<= 8;
  1094. + tmp += data[i];
  1095. + }
  1096. + return tmp;
  1097. +}
  1098. +
  1099. +static inline unsigned long long Ft_get_member_size(const File_trailer data)
  1100. +{
  1101. + unsigned long long tmp = 0;
  1102. + int i;
  1103. +
  1104. + for (i = 19; i >= 12; --i) {
  1105. + tmp <<= 8;
  1106. + tmp += data[i];
  1107. + }
  1108. + return tmp;
  1109. +}
  1110. +
  1111. +
  1112. +struct Range_decoder {
  1113. + unsigned long long partial_member_pos;
  1114. + uint8_t *buffer; /* input buffer */
  1115. + long buffer_size;
  1116. + long pos; /* current pos in buffer */
  1117. + long stream_pos; /* when reached, a new block must be read */
  1118. + uint32_t code;
  1119. + uint32_t range;
  1120. + long (*fill)(void*, unsigned long);
  1121. + bool at_stream_end;
  1122. + bool buffer_given;
  1123. +};
  1124. +
  1125. +
  1126. +static bool Rd_read_block(struct Range_decoder * const rdec)
  1127. +{
  1128. + if (!rdec->at_stream_end) {
  1129. + rdec->stream_pos = rdec->fill ?
  1130. + rdec->fill(rdec->buffer, rdec->buffer_size) : 0;
  1131. + rdec->at_stream_end = (rdec->stream_pos < rdec->buffer_size);
  1132. + rdec->partial_member_pos += rdec->pos;
  1133. + rdec->pos = 0;
  1134. + }
  1135. + return rdec->pos < rdec->stream_pos;
  1136. +}
  1137. +
  1138. +
  1139. +static bool Rd_init(struct Range_decoder * const rdec, uint8_t * const inbuf,
  1140. + const long in_len, long (*fill)(void*, unsigned long))
  1141. +{
  1142. + rdec->partial_member_pos = 0;
  1143. + rdec->buffer_size = (inbuf && in_len > 0) ? in_len : 16384;
  1144. + rdec->buffer = inbuf ? inbuf : malloc(rdec->buffer_size);
  1145. + if (!rdec->buffer)
  1146. + return false;
  1147. + rdec->pos = 0;
  1148. + rdec->stream_pos = (inbuf && in_len > 0) ? in_len : 0;
  1149. + rdec->code = 0;
  1150. + rdec->range = 0xFFFFFFFFU;
  1151. + rdec->fill = fill;
  1152. + rdec->at_stream_end = false;
  1153. + rdec->buffer_given = (inbuf != 0);
  1154. + return true;
  1155. +}
  1156. +
  1157. +static inline void Rd_free(struct Range_decoder * const rdec)
  1158. +{
  1159. + if (!rdec->buffer_given)
  1160. + free(rdec->buffer);
  1161. +}
  1162. +
  1163. +static inline bool Rd_finished(struct Range_decoder * const rdec)
  1164. +{
  1165. + return rdec->pos >= rdec->stream_pos && !Rd_read_block(rdec);
  1166. +}
  1167. +
  1168. +static inline unsigned long long
  1169. +Rd_member_position(const struct Range_decoder * const rdec)
  1170. +{
  1171. + return rdec->partial_member_pos + rdec->pos;
  1172. +}
  1173. +
  1174. +static inline void Rd_reset_member_position(struct Range_decoder * const rdec)
  1175. +{
  1176. + rdec->partial_member_pos = 0; rdec->partial_member_pos -= rdec->pos;
  1177. +}
  1178. +
  1179. +static inline uint8_t Rd_get_byte(struct Range_decoder * const rdec)
  1180. +{
  1181. + /* 0xFF avoids decoder error if member is truncated at EOS marker */
  1182. + if (Rd_finished(rdec))
  1183. + return 0xFF;
  1184. + return rdec->buffer[rdec->pos++];
  1185. +}
  1186. +
  1187. +static void Rd_load(struct Range_decoder * const rdec)
  1188. +{
  1189. + int i;
  1190. +
  1191. + rdec->code = 0;
  1192. + for (i = 0; i < 5; ++i)
  1193. + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
  1194. + rdec->range = 0xFFFFFFFFU;
  1195. +}
  1196. +
  1197. +static inline void Rd_normalize(struct Range_decoder * const rdec)
  1198. +{
  1199. + if (rdec->range <= 0x00FFFFFFU) {
  1200. + rdec->range <<= 8;
  1201. + rdec->code = (rdec->code << 8) | Rd_get_byte(rdec);
  1202. + }
  1203. +}
  1204. +
  1205. +static uint32_t Rd_decode(struct Range_decoder * const rdec,
  1206. + const uint32_t num_bits)
  1207. +{
  1208. + uint32_t symbol = 0;
  1209. + uint32_t i;
  1210. +
  1211. + for (i = num_bits; i > 0; --i) {
  1212. + bool bit;
  1213. +
  1214. + Rd_normalize(rdec);
  1215. + rdec->range >>= 1;
  1216. + /* symbol <<= 1; */
  1217. + /* if(rdec->code >= rdec->range) { rdec->code -= rdec->range; symbol |= 1; } */
  1218. + bit = (rdec->code >= rdec->range);
  1219. + symbol = (symbol << 1) + bit;
  1220. + rdec->code -= rdec->range & (0U - bit);
  1221. + }
  1222. + return symbol;
  1223. +}
  1224. +
  1225. +static inline uint32_t Rd_decode_bit(struct Range_decoder * const rdec,
  1226. + Bit_model * const probability)
  1227. +{
  1228. + uint32_t bound;
  1229. +
  1230. + Rd_normalize(rdec);
  1231. + bound = (rdec->range >> bit_model_total_bits) * *probability;
  1232. + if (rdec->code < bound) {
  1233. + rdec->range = bound;
  1234. + *probability += (bit_model_total - *probability) >> bit_model_move_bits;
  1235. + return 0;
  1236. + } else {
  1237. + rdec->range -= bound;
  1238. + rdec->code -= bound;
  1239. + *probability -= *probability >> bit_model_move_bits;
  1240. + return 1;
  1241. + }
  1242. +}
  1243. +
  1244. +static inline uint32_t Rd_decode_tree(struct Range_decoder * const rdec,
  1245. + Bit_model bm[], const uint32_t num_bits)
  1246. +{
  1247. + uint32_t symbol = 1;
  1248. + uint32_t i;
  1249. +
  1250. + for (i = num_bits; i > 0; --i)
  1251. + symbol = (symbol << 1) | Rd_decode_bit(rdec, &bm[symbol]);
  1252. + return symbol - (1 << num_bits);
  1253. +}
  1254. +
  1255. +static inline uint32_t Rd_decode_tree_reversed(struct Range_decoder * const rdec,
  1256. + Bit_model bm[], const uint32_t num_bits)
  1257. +{
  1258. + uint32_t model = 1;
  1259. + uint32_t symbol = 0;
  1260. + uint32_t i;
  1261. +
  1262. + for (i = 0; i < num_bits; ++i) {
  1263. + const uint32_t bit = Rd_decode_bit(rdec, &bm[model]);
  1264. +
  1265. + model = (model << 1) + bit;
  1266. + symbol |= (bit << i);
  1267. + }
  1268. + return symbol;
  1269. +}
  1270. +
  1271. +static uint32_t Rd_decode_matched(struct Range_decoder * const rdec,
  1272. + Bit_model bm[], uint32_t match_byte)
  1273. +{
  1274. + uint32_t symbol = 1;
  1275. + uint32_t mask = 0x100;
  1276. +
  1277. + while (true) {
  1278. + const uint32_t match_bit = (match_byte <<= 1) & mask;
  1279. + const uint32_t bit = Rd_decode_bit(rdec, &bm[symbol+match_bit+mask]);
  1280. +
  1281. + symbol = (symbol << 1) + bit;
  1282. + if (symbol > 0xFF)
  1283. + return symbol & 0xFF;
  1284. + mask &= ~(match_bit ^ (bit << 8)); /* if( match_bit != bit ) mask = 0; */
  1285. + }
  1286. +}
  1287. +
  1288. +static inline uint32_t Rd_decode_len(struct Range_decoder * const rdec,
  1289. + struct Len_model * const lm,
  1290. + const int pos_state)
  1291. +{
  1292. + if (Rd_decode_bit(rdec, &lm->choice1) == 0)
  1293. + return Rd_decode_tree(rdec, lm->bm_low[pos_state], len_low_bits);
  1294. + if (Rd_decode_bit(rdec, &lm->choice2) == 0)
  1295. + return len_low_symbols +
  1296. + Rd_decode_tree(rdec, lm->bm_mid[pos_state], len_mid_bits);
  1297. + return len_low_symbols + len_mid_symbols +
  1298. + Rd_decode_tree(rdec, lm->bm_high, len_high_bits);
  1299. +}
  1300. +
  1301. +
  1302. +struct LZ_decoder {
  1303. + unsigned long long partial_data_pos;
  1304. + struct Range_decoder *rdec;
  1305. + /* Don't move bm_* to LZd_decode_member; makes frame too large. */
  1306. + Bit_model bm_literal[1 << literal_context_bits][0x300];
  1307. + Bit_model bm_match[states][pos_states];
  1308. + Bit_model bm_rep[states];
  1309. + Bit_model bm_rep0[states];
  1310. + Bit_model bm_rep1[states];
  1311. + Bit_model bm_rep2[states];
  1312. + Bit_model bm_len[states][pos_states];
  1313. + Bit_model bm_dis_slot[len_states][1 << dis_slot_bits];
  1314. + Bit_model bm_dis[modeled_distances-end_dis_model+1];
  1315. + Bit_model bm_align[dis_align_size];
  1316. + struct Len_model match_len_model;
  1317. + struct Len_model rep_len_model;
  1318. +
  1319. + unsigned long buffer_size;
  1320. + uint32_t dictionary_size;
  1321. + uint8_t *buffer; /* output buffer */
  1322. + unsigned long pos; /* current pos in buffer */
  1323. + unsigned long stream_pos; /* first byte not yet written to file */
  1324. + uint32_t crc;
  1325. + long (*flush)(void*, unsigned long);
  1326. + bool pos_wrapped;
  1327. + bool buffer_given;
  1328. + bool write_error;
  1329. +};
  1330. +
  1331. +static void LZd_flush_data(struct LZ_decoder * const d)
  1332. +{
  1333. + if (d->pos > d->stream_pos) {
  1334. + const long size = d->pos - d->stream_pos;
  1335. +
  1336. + CRC32_update_buf(&d->crc, d->buffer + d->stream_pos, size);
  1337. + if ((d->flush &&
  1338. + d->flush(d->buffer + d->stream_pos, size) != size) ||
  1339. + (!d->flush && d->pos_wrapped))
  1340. + d->write_error = true;
  1341. + if (d->pos >= d->buffer_size) {
  1342. + d->partial_data_pos += d->pos;
  1343. + d->pos = 0;
  1344. + d->pos_wrapped = true;
  1345. + }
  1346. + d->stream_pos = d->pos;
  1347. + }
  1348. +}
  1349. +
  1350. +static inline uint8_t LZd_peek_prev(const struct LZ_decoder * const d)
  1351. +{
  1352. + if (d->pos > 0)
  1353. + return d->buffer[d->pos-1];
  1354. + if (d->pos_wrapped)
  1355. + return d->buffer[d->buffer_size-1];
  1356. + return 0; /* prev_byte of first byte */
  1357. +}
  1358. +
  1359. +static inline uint8_t LZd_peek(const struct LZ_decoder * const d,
  1360. + const uint32_t distance)
  1361. +{
  1362. + const unsigned long i = ((d->pos > distance) ? 0 : d->buffer_size) +
  1363. + d->pos - distance - 1;
  1364. + return d->buffer[i];
  1365. +}
  1366. +
  1367. +static inline void LZd_put_byte(struct LZ_decoder * const d, const uint8_t b)
  1368. +{
  1369. + d->buffer[d->pos] = b;
  1370. + if (++d->pos >= d->buffer_size)
  1371. + LZd_flush_data(d);
  1372. +}
  1373. +
  1374. +static void LZd_copy_block(struct LZ_decoder * const d,
  1375. + const uint32_t distance, uint32_t len)
  1376. +{
  1377. + unsigned long lpos = d->pos, i = lpos - distance - 1;
  1378. + bool fast, fast2;
  1379. +
  1380. + if (lpos > distance) {
  1381. + fast = (len < d->buffer_size - lpos);
  1382. + fast2 = (fast && len <= lpos - i);
  1383. + } else {
  1384. + i += d->buffer_size;
  1385. + fast = (len < d->buffer_size - i); /* (i == pos) may happen */
  1386. + fast2 = (fast && len <= i - lpos);
  1387. + }
  1388. + if (fast) { /* no wrap */
  1389. + d->pos += len;
  1390. + if (fast2) /* no wrap, no overlap */
  1391. + memcpy(d->buffer + lpos, d->buffer + i, len);
  1392. + else
  1393. + for (; len > 0; --len)
  1394. + d->buffer[lpos++] = d->buffer[i++];
  1395. + } else
  1396. + for (; len > 0; --len) {
  1397. + d->buffer[d->pos] = d->buffer[i];
  1398. + if (++d->pos >= d->buffer_size)
  1399. + LZd_flush_data(d);
  1400. + if (++i >= d->buffer_size)
  1401. + i = 0;
  1402. + }
  1403. +}
  1404. +
  1405. +static bool LZd_init(struct LZ_decoder * const d,
  1406. + struct Range_decoder * const rde,
  1407. + const uint32_t dict_size, uint8_t * const outbuf,
  1408. + long out_size, long (*flush)(void*, unsigned long))
  1409. +{
  1410. + d->partial_data_pos = 0;
  1411. + d->rdec = rde;
  1412. + Bm_array_init(d->bm_literal[0], (1 << literal_context_bits) * 0x300);
  1413. + Bm_array_init(d->bm_match[0], states * pos_states);
  1414. + Bm_array_init(d->bm_rep, states);
  1415. + Bm_array_init(d->bm_rep0, states);
  1416. + Bm_array_init(d->bm_rep1, states);
  1417. + Bm_array_init(d->bm_rep2, states);
  1418. + Bm_array_init(d->bm_len[0], states * pos_states);
  1419. + Bm_array_init(d->bm_dis_slot[0], len_states * (1 << dis_slot_bits));
  1420. + Bm_array_init(d->bm_dis, modeled_distances - end_dis_model + 1);
  1421. + Bm_array_init(d->bm_align, dis_align_size);
  1422. + Lm_init(&d->match_len_model);
  1423. + Lm_init(&d->rep_len_model);
  1424. +
  1425. + d->buffer_size = (outbuf && out_size > 0) ? out_size : dict_size;
  1426. + d->dictionary_size = min_t(unsigned long, d->buffer_size, dict_size);
  1427. + d->buffer = outbuf ? outbuf : large_malloc(d->buffer_size);
  1428. + if (!d->buffer)
  1429. + return false;
  1430. + d->pos = 0;
  1431. + d->stream_pos = 0;
  1432. + d->crc = 0xFFFFFFFFU;
  1433. + d->flush = flush;
  1434. + d->pos_wrapped = false;
  1435. + d->buffer_given = (outbuf != 0);
  1436. + d->write_error = false;
  1437. + return true;
  1438. +}
  1439. +
  1440. +static inline void LZd_free(struct LZ_decoder * const d)
  1441. +{
  1442. + if (!d->buffer_given)
  1443. + large_free(d->buffer);
  1444. +}
  1445. +
  1446. +static inline uint32_t LZd_crc(const struct LZ_decoder * const d)
  1447. +{
  1448. + return d->crc ^ 0xFFFFFFFFU;
  1449. +}
  1450. +
  1451. +static inline unsigned long long
  1452. +LZd_data_position(const struct LZ_decoder * const d)
  1453. +{
  1454. + return d->partial_data_pos + d->pos;
  1455. +}
  1456. +
  1457. +
  1458. +static bool LZd_verify_trailer(struct LZ_decoder * const d)
  1459. +{
  1460. + File_trailer trailer;
  1461. + int i = 0;
  1462. +
  1463. + while (i < Ft_size)
  1464. + trailer[i++] = Rd_get_byte(d->rdec);
  1465. +
  1466. + return (Ft_get_data_crc(trailer) == LZd_crc(d) &&
  1467. + Ft_get_data_size(trailer) == LZd_data_position(d) &&
  1468. + Ft_get_member_size(trailer) == Rd_member_position(d->rdec));
  1469. +}
  1470. +
  1471. +
  1472. +/* Return value: -1 = write error, 0 = OK, 1 = data error. */
  1473. +static int LZd_decode_member(struct LZ_decoder * const d)
  1474. +{
  1475. + struct Range_decoder * const rdec = d->rdec;
  1476. + uint32_t rep0 = 0; /* rep[0-3] latest four distances */
  1477. + uint32_t rep1 = 0; /* used for efficient coding of */
  1478. + uint32_t rep2 = 0; /* repeated distances */
  1479. + uint32_t rep3 = 0;
  1480. + State state = 0;
  1481. +
  1482. + Rd_load(rdec);
  1483. + while (!Rd_finished(rdec)) {
  1484. + const int pos_state = LZd_data_position(d) & pos_state_mask;
  1485. +
  1486. + if (Rd_decode_bit(rdec, &d->bm_match[state][pos_state]) == 0) {
  1487. + Bit_model * const bm = d->bm_literal[get_lit_state(LZd_peek_prev(d))];
  1488. +
  1489. + if (St_is_char(state)) {
  1490. + state -= (state < 4) ? state : 3;
  1491. + LZd_put_byte(d, Rd_decode_tree(rdec, bm, 8));
  1492. + } else {
  1493. + state -= (state < 10) ? 3 : 6;
  1494. + LZd_put_byte(d, Rd_decode_matched(rdec, bm, LZd_peek(d, rep0)));
  1495. + }
  1496. + } else { /* match or repeated match */
  1497. + uint32_t len;
  1498. +
  1499. + if (Rd_decode_bit(rdec, &d->bm_rep[state]) != 0) {
  1500. + if (Rd_decode_bit(rdec, &d->bm_rep0[state]) == 0) {
  1501. + if (Rd_decode_bit(rdec, &d->bm_len[state][pos_state]) == 0) {
  1502. + state = St_set_short_rep(state);
  1503. + LZd_put_byte(d, LZd_peek(d, rep0));
  1504. + continue;
  1505. + }
  1506. + } else {
  1507. + uint32_t distance;
  1508. +
  1509. + if (Rd_decode_bit(rdec, &d->bm_rep1[state]) == 0)
  1510. + distance = rep1;
  1511. + else {
  1512. + if (Rd_decode_bit(rdec, &d->bm_rep2[state]) == 0)
  1513. + distance = rep2;
  1514. + else {
  1515. + distance = rep3;
  1516. + rep3 = rep2;
  1517. + }
  1518. + rep2 = rep1;
  1519. + }
  1520. + rep1 = rep0;
  1521. + rep0 = distance;
  1522. + }
  1523. + state = St_set_rep(state);
  1524. + len = min_match_len + Rd_decode_len(rdec, &d->rep_len_model, pos_state);
  1525. + } else { /* match */
  1526. + uint32_t distance;
  1527. +
  1528. + len = min_match_len + Rd_decode_len(rdec, &d->match_len_model, pos_state);
  1529. + distance = Rd_decode_tree(rdec, d->bm_dis_slot[get_len_state(len)], 6);
  1530. + if (distance >= start_dis_model) {
  1531. + const uint32_t dis_slot = distance;
  1532. + const uint32_t direct_bits = (dis_slot >> 1) - 1;
  1533. +
  1534. + distance = (2 | (dis_slot & 1)) << direct_bits;
  1535. + if (dis_slot < end_dis_model)
  1536. + distance += Rd_decode_tree_reversed(rdec,
  1537. + d->bm_dis + (distance - dis_slot), direct_bits);
  1538. + else {
  1539. + distance += Rd_decode(rdec, direct_bits - dis_align_bits) << dis_align_bits;
  1540. + distance += Rd_decode_tree_reversed(rdec, d->bm_align, dis_align_bits);
  1541. + if (distance == 0xFFFFFFFFU) { /* marker found */
  1542. + Rd_normalize(rdec);
  1543. + LZd_flush_data(d);
  1544. + if (d->write_error)
  1545. + return -1;
  1546. + if (len == min_match_len && /* End Of Stream marker */
  1547. + LZd_verify_trailer(d))
  1548. + return 0;
  1549. + if (len == min_match_len + 1) { /* Sync Flush marker */
  1550. + Rd_load(rdec);
  1551. + continue;
  1552. + }
  1553. + return 1;
  1554. + }
  1555. + }
  1556. + }
  1557. + rep3 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance;
  1558. + state = St_set_match(state);
  1559. + if (rep0 >= d->dictionary_size ||
  1560. + (rep0 >= d->pos && !d->pos_wrapped)) {
  1561. + LZd_flush_data(d);
  1562. + return 1;
  1563. + }
  1564. + }
  1565. + LZd_copy_block(d, rep0, len);
  1566. + }
  1567. + }
  1568. + LZd_flush_data(d);
  1569. + return 1;
  1570. +}
  1571. +
  1572. +
  1573. +STATIC int INIT __lunzip(unsigned char *inbuf, long in_len,
  1574. + long (*fill)(void*, unsigned long),
  1575. + long (*flush)(void*, unsigned long),
  1576. + unsigned char *outbuf, long out_len,
  1577. + long *in_posp,
  1578. + void (*error)(char *x))
  1579. +{
  1580. + unsigned char *outptr = outbuf;
  1581. + long out_size = out_len;
  1582. + int retval = 0;
  1583. + struct Range_decoder rdec;
  1584. + struct LZ_decoder *decoder = 0;
  1585. + bool first_member;
  1586. +
  1587. + if (in_posp)
  1588. + *in_posp = 0;
  1589. + CRC32_init();
  1590. +
  1591. + if (!Rd_init(&rdec, inbuf, in_len, fill)) {
  1592. + error("Out of memory while allocating input buffer");
  1593. + return -1;
  1594. + }
  1595. +
  1596. + for (first_member = true;; first_member = false) {
  1597. + int result, size;
  1598. + unsigned dictionary_size;
  1599. + File_header header;
  1600. +
  1601. + Rd_reset_member_position(&rdec);
  1602. + for (size = 0; size < Fh_size; ++size)
  1603. + header[size] = Rd_get_byte(&rdec);
  1604. + if (Rd_finished(&rdec)) { /* End Of File */
  1605. + if (first_member) {
  1606. + error("File ends unexpectedly at member header");
  1607. + retval = -1;
  1608. + }
  1609. + break;
  1610. + }
  1611. + if (!Fh_verify_magic(header)) {
  1612. + if (first_member) {
  1613. + error("Bad magic number (file not in lzip format)");
  1614. + retval = -1;
  1615. + }
  1616. + break;
  1617. + }
  1618. + dictionary_size = Fh_get_dictionary_size(header);
  1619. + if (dictionary_size < min_dictionary_size ||
  1620. + dictionary_size > max_dictionary_size) {
  1621. + error("Invalid dictionary size in member header");
  1622. + retval = -1;
  1623. + break;
  1624. + }
  1625. +
  1626. + if (!decoder)
  1627. + decoder = malloc(sizeof *decoder);
  1628. + if (!decoder || !LZd_init(decoder, &rdec, dictionary_size, outptr, out_size, flush)) {
  1629. + error("Out of memory while allocating output buffer");
  1630. + retval = -1;
  1631. + break;
  1632. + }
  1633. + result = LZd_decode_member(decoder);
  1634. + if (in_posp)
  1635. + *in_posp += Rd_member_position(&rdec);
  1636. + if (outptr)
  1637. + outptr += LZd_data_position(decoder);
  1638. + if (out_size > 0)
  1639. + out_size -= LZd_data_position(decoder);
  1640. + LZd_free(decoder);
  1641. + if (result != 0) {
  1642. + if (result < 0)
  1643. + error("write error");
  1644. + else
  1645. + error("LZIP-compressed data is corrupt");
  1646. + retval = -1;
  1647. + break;
  1648. + }
  1649. + }
  1650. + if (decoder)
  1651. + free(decoder);
  1652. + Rd_free(&rdec);
  1653. + return retval;
  1654. +}
  1655. +
  1656. +#ifndef PREBOOT
  1657. +STATIC int INIT lunzip(unsigned char *inbuf, long in_len,
  1658. + long (*fill)(void*, unsigned long),
  1659. + long (*flush)(void*, unsigned long),
  1660. + unsigned char *outbuf,
  1661. + long *in_posp,
  1662. + void (*error)(char *x))
  1663. +{
  1664. + return __lunzip(inbuf, in_len, fill, flush, outbuf, 0, in_posp, error);
  1665. +}
  1666. +#else
  1667. +STATIC int INIT __decompress(unsigned char *inbuf, long in_len,
  1668. + long (*fill)(void*, unsigned long),
  1669. + long (*flush)(void*, unsigned long),
  1670. + unsigned char *outbuf, long out_len,
  1671. + long *in_posp,
  1672. + void (*error)(char *x))
  1673. +{
  1674. + return __lunzip(inbuf, in_len - 4, fill, flush, outbuf, out_len, in_posp, error);
  1675. +}
  1676. +#endif
  1677. diff -urdN linux-4.14.21/scripts/Makefile.lib linux-4.14.21.new/scripts/Makefile.lib
  1678. --- linux-4.14.21/scripts/Makefile.lib 2018-02-22 15:42:33.000000000 +0100
  1679. +++ linux-4.14.21.new/scripts/Makefile.lib 2018-02-24 17:22:34.000000000 +0100
  1680. @@ -343,6 +343,21 @@
  1681. bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
  1682. (rm -f $@ ; false)
  1683. +# Lzip
  1684. +# ---------------------------------------------------------------------------
  1685. +# The .lz format has the uncompressed size available at the end of the
  1686. +# file, but at offset (member_size - 16). So we append a gzip-style size.
  1687. +# Use klzip to compress the kernel image and lzip to compress other things.
  1688. +
  1689. +quiet_cmd_klzip = LZIP $@
  1690. +cmd_klzip = (cat $(filter-out FORCE,$^) | \
  1691. + lzip -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
  1692. + (rm -f $@ ; false)
  1693. +
  1694. +quiet_cmd_lzip = LZIP $@
  1695. +cmd_lzip = (cat $(filter-out FORCE,$^) | lzip -9) > $@ || \
  1696. + (rm -f $@ ; false)
  1697. +
  1698. # Lzma
  1699. # ---------------------------------------------------------------------------
  1700. diff -urdN linux-4.14.21/scripts/extract-ikconfig linux-4.14.21.new/scripts/extract-ikconfig
  1701. --- linux-4.14.21/scripts/extract-ikconfig 2018-02-22 15:42:33.000000000 +0100
  1702. +++ linux-4.14.21.new/scripts/extract-ikconfig 2018-02-24 17:22:34.000000000 +0100
  1703. @@ -59,6 +59,7 @@
  1704. try_decompress '\037\213\010' xy gunzip
  1705. try_decompress '\3757zXZ\000' abcde unxz
  1706. try_decompress 'BZh' xy bunzip2
  1707. +try_decompress 'LZIP' xyz 'lzip -d'
  1708. try_decompress '\135\0\0\0' xxx unlzma
  1709. try_decompress '\211\114\132' xy 'lzop -d'
  1710. try_decompress '\002\041\114\030' xyy 'lz4 -d -l'
  1711. diff -urdN linux-4.14.21/scripts/extract-vmlinux linux-4.14.21.new/scripts/extract-vmlinux
  1712. --- linux-4.14.21/scripts/extract-vmlinux 2018-02-22 15:42:33.000000000 +0100
  1713. +++ linux-4.14.21.new/scripts/extract-vmlinux 2018-02-24 17:22:34.000000000 +0100
  1714. @@ -55,6 +55,7 @@
  1715. try_decompress '\037\213\010' xy gunzip
  1716. try_decompress '\3757zXZ\000' abcde unxz
  1717. try_decompress 'BZh' xy bunzip2
  1718. +try_decompress 'LZIP' xyz 'lzip -d'
  1719. try_decompress '\135\0\0\0' xxx unlzma
  1720. try_decompress '\211\114\132' xy 'lzop -d'
  1721. diff -urdN linux-4.14.21/scripts/gen_initramfs_list.sh linux-4.14.21.new/scripts/gen_initramfs_list.sh
  1722. --- linux-4.14.21/scripts/gen_initramfs_list.sh 2018-02-22 15:42:33.000000000 +0100
  1723. +++ linux-4.14.21.new/scripts/gen_initramfs_list.sh 2018-02-24 17:22:34.000000000 +0100
  1724. @@ -249,6 +249,9 @@
  1725. echo "$output_file" | grep -q "\.bz2$" \
  1726. && [ -x "`which bzip2 2> /dev/null`" ] \
  1727. && compr="bzip2 -9 -f"
  1728. + echo "$output_file" | grep -q "\.lz$" \
  1729. + && [ -x "`which lzip 2> /dev/null`" ] \
  1730. + && compr="lzip -9 -f"
  1731. echo "$output_file" | grep -q "\.lzma$" \
  1732. && [ -x "`which lzma 2> /dev/null`" ] \
  1733. && compr="lzma -9 -f"
  1734. diff -urdN linux-4.14.21/scripts/package/Makefile linux-4.14.21.new/scripts/package/Makefile
  1735. --- linux-4.14.21/scripts/package/Makefile 2018-02-22 15:42:33.000000000 +0100
  1736. +++ linux-4.14.21.new/scripts/package/Makefile 2018-02-24 17:22:34.000000000 +0100
  1737. @@ -123,8 +123,9 @@
  1738. $(if $(findstring tar-src,$@),, \
  1739. $(if $(findstring bz2,$@),bzip2, \
  1740. $(if $(findstring gz,$@),gzip, \
  1741. +$(if $(findstring lz,$@),lzip, \
  1742. $(if $(findstring xz,$@),xz, \
  1743. -$(error unknown target $@)))) \
  1744. +$(error unknown target $@))))) \
  1745. -f -9 $(perf-tar).tar)
  1746. perf-%pkg: FORCE
  1747. @@ -140,8 +141,10 @@
  1748. @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
  1749. @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
  1750. @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
  1751. + @echo ' tarlz-pkg - Build the kernel as a lzip compressed tarball'
  1752. @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
  1753. @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
  1754. @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
  1755. @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
  1756. + @echo ' perf-tarlz-src-pkg - Build $(perf-tar).tar.lz source tarball'
  1757. @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
  1758. diff -urdN linux-4.14.21/scripts/package/buildtar linux-4.14.21.new/scripts/package/buildtar
  1759. --- linux-4.14.21/scripts/package/buildtar 2018-02-22 15:42:33.000000000 +0100
  1760. +++ linux-4.14.21.new/scripts/package/buildtar 2018-02-24 17:22:34.000000000 +0100
  1761. @@ -35,6 +35,10 @@
  1762. opts=--bzip2
  1763. tarball=${tarball}.bz2
  1764. ;;
  1765. + tarlz-pkg)
  1766. + opts=--lzip
  1767. + tarball=${tarball}.lz
  1768. + ;;
  1769. tarxz-pkg)
  1770. opts=--xz
  1771. tarball=${tarball}.xz
  1772. diff -urdN linux-4.14.21/scripts/patch-kernel linux-4.14.21.new/scripts/patch-kernel
  1773. --- linux-4.14.21/scripts/patch-kernel 2018-02-22 15:42:33.000000000 +0100
  1774. +++ linux-4.14.21.new/scripts/patch-kernel 2018-02-24 17:22:34.000000000 +0100
  1775. @@ -117,6 +117,10 @@
  1776. ext=".bz2"
  1777. name="bzip2"
  1778. uncomp="bunzip2 -dc"
  1779. + elif [ -r ${filebase}.lz ]; then
  1780. + ext=".lz"
  1781. + name="lzip"
  1782. + uncomp="lzip -dc"
  1783. elif [ -r ${filebase}.xz ]; then
  1784. ext=".xz"
  1785. name="xz"
  1786. diff -urdN linux-4.14.21/tools/testing/selftests/gen_kselftest_tar.sh linux-4.14.21.new/tools/testing/selftests/gen_kselftest_tar.sh
  1787. --- linux-4.14.21/tools/testing/selftests/gen_kselftest_tar.sh 2018-02-22 15:42:33.000000000 +0100
  1788. +++ linux-4.14.21.new/tools/testing/selftests/gen_kselftest_tar.sh 2018-02-24 17:22:34.000000000 +0100
  1789. @@ -29,6 +29,10 @@
  1790. copts="cvjf"
  1791. ext=".tar.bz2"
  1792. ;;
  1793. + tarlz)
  1794. + copts="cv --lzip -f"
  1795. + ext=".tar.lz"
  1796. + ;;
  1797. tarxz)
  1798. copts="cvJf"
  1799. ext=".tar.xz"
  1800. diff -urdN linux-4.14.21/usr/.gitignore linux-4.14.21.new/usr/.gitignore
  1801. --- linux-4.14.21/usr/.gitignore 2018-02-22 15:42:33.000000000 +0100
  1802. +++ linux-4.14.21.new/usr/.gitignore 2018-02-24 17:22:34.000000000 +0100
  1803. @@ -5,6 +5,7 @@
  1804. initramfs_data.cpio
  1805. initramfs_data.cpio.gz
  1806. initramfs_data.cpio.bz2
  1807. +initramfs_data.cpio.lz
  1808. initramfs_data.cpio.lzma
  1809. initramfs_list
  1810. include
  1811. diff -urdN linux-4.14.21/usr/Kconfig linux-4.14.21.new/usr/Kconfig
  1812. --- linux-4.14.21/usr/Kconfig 2018-02-22 15:42:33.000000000 +0100
  1813. +++ linux-4.14.21.new/usr/Kconfig 2018-02-24 17:22:34.000000000 +0100
  1814. @@ -70,6 +70,15 @@
  1815. Support loading of a bzip2 encoded initial ramdisk or cpio buffer
  1816. If unsure, say N.
  1817. +config RD_LZIP
  1818. + bool "Support initial ramdisk/ramfs compressed using lzip"
  1819. + default y
  1820. + depends on BLK_DEV_INITRD
  1821. + select DECOMPRESS_LZIP
  1822. + help
  1823. + Support loading of a lzip encoded initial ramdisk or cpio buffer.
  1824. + If unsure, say N.
  1825. +
  1826. config RD_LZMA
  1827. bool "Support initial ramdisk/ramfs compressed using LZMA"
  1828. default y
  1829. @@ -165,6 +174,18 @@
  1830. If you choose this, keep in mind that you need to have the bzip2 tool
  1831. available to be able to compress the initram.
  1832. +config INITRAMFS_COMPRESSION_LZIP
  1833. + bool "Lzip"
  1834. + depends on RD_LZIP
  1835. + help
  1836. + Lzip's compression ratio is better than that of gzip and bzip2.
  1837. + Decompression speed is between gzip and bzip2. Compression can
  1838. + be as fast as gzip or slower than bzip2 depending on compression
  1839. + level. Lzip can produce a initramfs about a 16% smaller than gzip.
  1840. +
  1841. + If you choose this, keep in mind that you need to have the lzip tool
  1842. + available to be able to compress the initram.
  1843. +
  1844. config INITRAMFS_COMPRESSION_LZMA
  1845. bool "LZMA"
  1846. depends on RD_LZMA
  1847. @@ -222,12 +243,14 @@
  1848. default "" if INITRAMFS_COMPRESSION_NONE
  1849. default ".gz" if INITRAMFS_COMPRESSION_GZIP
  1850. default ".bz2" if INITRAMFS_COMPRESSION_BZIP2
  1851. + default ".lz" if INITRAMFS_COMPRESSION_LZIP
  1852. default ".lzma" if INITRAMFS_COMPRESSION_LZMA
  1853. default ".xz" if INITRAMFS_COMPRESSION_XZ
  1854. default ".lzo" if INITRAMFS_COMPRESSION_LZO
  1855. default ".lz4" if INITRAMFS_COMPRESSION_LZ4
  1856. default ".gz" if RD_GZIP
  1857. default ".lz4" if RD_LZ4
  1858. + default ".lz" if RD_LZIP
  1859. default ".lzo" if RD_LZO
  1860. default ".xz" if RD_XZ
  1861. default ".lzma" if RD_LZMA