Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e76e1fdf authored by Kyungsik Lee's avatar Kyungsik Lee Committed by Linus Torvalds
Browse files

lib: add support for LZ4-compressed kernel



Add support for extracting LZ4-compressed kernel images, as well as
LZ4-compressed ramdisk images in the kernel boot process.

Signed-off-by: default avatarKyungsik Lee <kyungsik.lee@lge.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Florian Fainelli <florian@openwrt.org>
Cc: Yann Collet <yann.collet.73@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cffb78b0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
#ifndef DECOMPRESS_UNLZ4_H
#define DECOMPRESS_UNLZ4_H

int unlz4(unsigned char *inbuf, int len,
	int(*fill)(void*, unsigned int),
	int(*flush)(void*, unsigned int),
	unsigned char *output,
	int *pos,
	void(*error)(char *x));
#endif
+16 −1
Original line number Diff line number Diff line
@@ -112,10 +112,13 @@ config HAVE_KERNEL_XZ
config HAVE_KERNEL_LZO
	bool

config HAVE_KERNEL_LZ4
	bool

choice
	prompt "Kernel compression mode"
	default KERNEL_GZIP
	depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO
	depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4
	help
	  The linux kernel is a kind of self-extracting executable.
	  Several compression algorithms are available, which differ
@@ -182,6 +185,18 @@ config KERNEL_LZO
	  size is about 10% bigger than gzip; however its speed
	  (both compression and decompression) is the fastest.

config KERNEL_LZ4
	bool "LZ4"
	depends on HAVE_KERNEL_LZ4
	help
	  LZ4 is an LZ77-type compressor with a fixed, byte-oriented encoding.
	  A preliminary version of LZ4 de/compression tool is available at
	  <https://code.google.com/p/lz4/>.

	  Its compression ratio is worse than LZO. The size of the kernel
	  is about 8% bigger than LZO. But the decompression speed is
	  faster than LZO.

endchoice

config DEFAULT_HOSTNAME
+7 −0
Original line number Diff line number Diff line
@@ -194,6 +194,9 @@ config LZO_COMPRESS
config LZO_DECOMPRESS
	tristate

config LZ4_DECOMPRESS
	tristate

source "lib/xz/Kconfig"

#
@@ -218,6 +221,10 @@ config DECOMPRESS_LZO
	select LZO_DECOMPRESS
	tristate

config DECOMPRESS_LZ4
	select LZ4_DECOMPRESS
	tristate

#
# Generic allocator support is selected if needed
#
+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ obj-$(CONFIG_REED_SOLOMON) += reed_solomon/
obj-$(CONFIG_BCH) += bch.o
obj-$(CONFIG_LZO_COMPRESS) += lzo/
obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
obj-$(CONFIG_LZ4_DECOMPRESS) += lz4/
obj-$(CONFIG_XZ_DEC) += xz/
obj-$(CONFIG_RAID6_PQ) += raid6/

@@ -83,6 +84,7 @@ lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
lib-$(CONFIG_DECOMPRESS_XZ) += decompress_unxz.o
lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
lib-$(CONFIG_DECOMPRESS_LZ4) += decompress_unlz4.o

obj-$(CONFIG_TEXTSEARCH) += textsearch.o
obj-$(CONFIG_TEXTSEARCH_KMP) += ts_kmp.o
+5 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/decompress/unxz.h>
#include <linux/decompress/inflate.h>
#include <linux/decompress/unlzo.h>
#include <linux/decompress/unlz4.h>

#include <linux/types.h>
#include <linux/string.h>
@@ -31,6 +32,9 @@
#ifndef CONFIG_DECOMPRESS_LZO
# define unlzo NULL
#endif
#ifndef CONFIG_DECOMPRESS_LZ4
# define unlz4 NULL
#endif

struct compress_format {
	unsigned char magic[2];
@@ -45,6 +49,7 @@ static const struct compress_format compressed_formats[] __initconst = {
	{ {0x5d, 0x00}, "lzma", unlzma },
	{ {0xfd, 0x37}, "xz", unxz },
	{ {0x89, 0x4c}, "lzo", unlzo },
	{ {0x02, 0x21}, "lz4", unlz4 },
	{ {0, 0}, NULL, NULL }
};

Loading