The KEXE PE format parser needs the kernel built-in decompressor to decompress the kernel image. So moving the decompressor out of __init sections.
Signed-off-by: Pingfan Liu <[email protected]> Cc: Andrew Morton <[email protected]> To: [email protected] --- include/linux/decompress/mm.h | 8 ++++++++ lib/Kconfig | 6 ++++++ lib/decompress.c | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h index ac862422df158..39df02bcbc661 100644 --- a/include/linux/decompress/mm.h +++ b/include/linux/decompress/mm.h @@ -81,6 +81,7 @@ MALLOC_VISIBLE void free(void *where) #include <linux/string.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <generated/autoconf.h> /* Use defines rather than static inline in order to avoid spurious * warnings when not needed (indeed large_malloc / large_free are not @@ -92,7 +93,14 @@ MALLOC_VISIBLE void free(void *where) #define large_malloc(a) vmalloc(a) #define large_free(a) vfree(a) +#ifdef CONFIG_KEEP_DECOMPRESSOR +#define INIT +#define INITCONST +#else #define INIT __init +#define INITCONST __initconst +#endif + #define STATIC #include <linux/init.h> diff --git a/lib/Kconfig b/lib/Kconfig index 2923924bea78c..4424ae14dcf12 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -165,6 +165,12 @@ config RANDOM32_SELFTEST # # compression support is select'ed if needed # +config KEEP_DECOMPRESSOR + bool "keeps the decompress routines after kernel initialization" + default n + help + This option keeps the decompress routines after kernel initialization + config 842_COMPRESS select CRC32 tristate diff --git a/lib/decompress.c b/lib/decompress.c index 7785471586c62..29d4c749f1fc4 100644 --- a/lib/decompress.c +++ b/lib/decompress.c @@ -6,7 +6,7 @@ */ #include <linux/decompress/generic.h> - +#include <linux/decompress/mm.h> #include <linux/decompress/bunzip2.h> #include <linux/decompress/unlzma.h> #include <linux/decompress/unxz.h> @@ -48,7 +48,7 @@ struct compress_format { decompress_fn decompressor; }; -static const struct compress_format compressed_formats[] __initconst = { +static const struct compress_format compressed_formats[] INITCONST = { { .magic = {0x1f, 0x8b}, .name = "gzip", .decompressor = gunzip }, { .magic = {0x1f, 0x9e}, .name = "gzip", .decompressor = gunzip }, { .magic = {0x42, 0x5a}, .name = "bzip2", .decompressor = bunzip2 }, @@ -60,7 +60,7 @@ static const struct compress_format compressed_formats[] __initconst = { { /* sentinel */ } }; -decompress_fn __init decompress_method(const unsigned char *inbuf, long len, +decompress_fn INIT decompress_method(const unsigned char *inbuf, long len, const char **name) { const struct compress_format *cf; -- 2.49.0
