public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Norbert Lange <nolange79@gmail.com>
To: Russell King <linux@armlinux.org.uk>, Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, Petr Malat <oss@malat.biz>,
	Kees Cook <keescook@chromium.org>,
	Adam Borowski <kilobyte@angband.pl>,
	Sedat Dilek <sedat.dilek@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nick Terrell <terrelln@fb.com>,
	Norbert Lange <nolange79@gmail.com>
Subject: [PATCH] arm: Add support for ZSTD compressed kernel
Date: Thu,  6 Aug 2020 01:05:55 +0200	[thread overview]
Message-ID: <20200805230555.84214-1-nolange79@gmail.com> (raw)

* Add support for zstd compressed kernel
* Define __DISABLE_EXPORTS in Makefile
* Bump the heap size for zstd.

This replicates the steps taken for x86 support.

Only if ZSTD is selected, heap size for kernel decompression is
increased, this should guarantee no changes in code / sideeffects for
other compressors.

The patch is so far only tested with Qemu, and some 64MB size limit
exists (might be Qemu specific), but this seems not caused by
this patch (upstream 5.8 and GZIP exhibits similar problems).

Signed-off-by: Norbert Lange <nolange79@gmail.com>
---
 arch/arm/Kconfig                      | 1 +
 arch/arm/boot/compressed/Makefile     | 2 ++
 arch/arm/boot/compressed/decompress.c | 4 ++++
 arch/arm/boot/compressed/head.S       | 4 ++++
 4 files changed, 11 insertions(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 2ac74904a3ce..3e853cdc688d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -93,6 +93,7 @@ config ARM
 	select HAVE_KERNEL_LZMA
 	select HAVE_KERNEL_LZO
 	select HAVE_KERNEL_XZ
+	select HAVE_KERNEL_ZSTD
 	select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
 	select HAVE_KRETPROBES if HAVE_KPROBES
 	select HAVE_MOD_ARCH_SPECIFIC
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 00602a6fba04..61229e93ea4a 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -75,6 +75,7 @@ compress-$(CONFIG_KERNEL_LZO)  = lzo
 compress-$(CONFIG_KERNEL_LZMA) = lzma
 compress-$(CONFIG_KERNEL_XZ)   = xzkern
 compress-$(CONFIG_KERNEL_LZ4)  = lz4
+compress-$(CONFIG_KERNEL_ZSTD) = zstd22
 
 libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o
 
@@ -102,6 +103,7 @@ targets       := vmlinux vmlinux.lds piggy_data piggy.o \
 clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S
 
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
+KBUILD_CFLAGS += -D__DISABLE_EXPORTS
 
 ifeq ($(CONFIG_FUNCTION_TRACER),y)
 ORIG_CFLAGS := $(KBUILD_CFLAGS)
diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c
index aa075d8372ea..04f77491975a 100644
--- a/arch/arm/boot/compressed/decompress.c
+++ b/arch/arm/boot/compressed/decompress.c
@@ -56,6 +56,10 @@ extern char * strchrnul(const char *, int);
 #include "../../../../lib/decompress_unlz4.c"
 #endif
 
+#ifdef CONFIG_KERNEL_ZSTD
+#include "../../../../lib/decompress_unzstd.c"
+#endif
+
 int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x))
 {
 	return __decompress(input, len, NULL, NULL, output, 0, NULL, error);
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 434a16982e34..1af01bfe6638 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -614,7 +614,11 @@ not_relocated:	mov	r0, #0
  */
 		mov	r0, r4
 		mov	r1, sp			@ malloc space above stack
+#if defined(CONFIG_KERNEL_ZSTD)
+		add	r2, sp, #0x30000	@ Context needs ~160K
+#else
 		add	r2, sp, #0x10000	@ 64k max
+#endif
 		mov	r3, r7
 		bl	decompress_kernel
 
-- 
2.27.0


             reply	other threads:[~2020-08-05 23:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 23:05 Norbert Lange [this message]
2020-08-06  0:30 ` [PATCH] arm: Add support for ZSTD compressed kernel Russell King - ARM Linux admin
2020-08-06  8:45   ` Norbert Lange
2020-08-06 10:11     ` Russell King - ARM Linux admin
2020-08-06 10:12       ` [PATCH 1/2] ARM: add TEXT_OFFSET to decompressor kexec image structure Russell King
2020-08-06 10:12       ` [PATCH 2/2] ARM: add malloc size to decompressor kexec size structure Russell King
  -- strict thread matches above, loose matches on Subject: below --
2020-08-06 21:46 [PATCH] arm: Add support for ZSTD compressed kernel Peter Geis
2020-08-06 22:22 ` Russell King - ARM Linux admin
2020-08-06 22:58   ` Peter Geis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200805230555.84214-1-nolange79@gmail.com \
    --to=nolange79@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=keescook@chromium.org \
    --cc=kilobyte@angband.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=oss@malat.biz \
    --cc=sedat.dilek@gmail.com \
    --cc=terrelln@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox