From patchwork Wed Apr 12 21:21:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 13209535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10359C77B6C for ; Wed, 12 Apr 2023 21:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Es/55uAaliSmcewPCQnnxnt2I4z/T8hBfchFQ+uGC20=; b=I9PXK3IiZWIM8P /awuEFKe7ZhGFkDdNcBDjVeeyEOXybx4kfxFnOEXxr4omkZnajZvzgnAkQxPoY54HfLrGOAH8A6vP AB5wHuSLatcb8fsnHzWED6gjHFi9/dVPSNDhCPdv2RQ/dQBiUlE06B5a0mzmoaltpei3C9NCNGFsm +/YuzYA+kIFNBBPjwW9fTR1aUq8RkWtK6QU2Gf8wCea6GjNhq6oYWE6oYcM8CzJksQit7OAwSzLoN JdbOql3nOQILLaY4Qp5PyJom2xkVL+5YQ/kWemuRd8FrfWq9df4c8Ydcr59uEnuWyB8zl/LaT41tx 5ZXFs6xBUxI/Gvruko8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmhvN-004NcO-2z; Wed, 12 Apr 2023 21:22:41 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmhvF-004NZS-1Y for linux-arm-kernel@lists.infradead.org; Wed, 12 Apr 2023 21:22:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1681334514; i=j.neuschaefer@gmx.net; bh=w4sCM12T3GwE9Idp4Z+5KQM9o6BWvMigt3zMC505xKw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=EIthzBk7V9dTwGCevl2ID2eaBvJ99830DWe/E4B+7cEm17DwtfvhtH6sal9eMXI4P pbTzg+2Ukbp+YMO9gNMkrbrpkUx40LvdQ/C1rJsDUMPothsoLVLrJEE/4YCZRqw5Nw vc0jF19Y1J/resZculEGxxkm3tynBsAQGbqW85MVQtQie0FXETsYLUgLUhR6LpiOEI CPaTksxxq5e8MyO8jb1wb/81I1wj8ChMRpPH7o16uScDohkBuP17RaioouhQWNnR2B hG1Y76JCgA0fdU+pvE711NPZZahOJgV5S6OGywqviolcfVoA+j7sSTHBbJ60QPdb8E YSYTUnGOmeyYA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from probook ([185.66.193.41]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N4QsO-1qTERQ26K6-011Ohg; Wed, 12 Apr 2023 23:21:54 +0200 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Nick Terrell , Arnd Bergmann , Tony Lindgren , Geert Uytterhoeven , Linus Walleij , Sebastian Reichel , Nick Hawkins , Christophe Leroy , =?utf-8?q?Jonathan_Neusch?= =?utf-8?q?=C3=A4fer?= , Florian Fainelli , Nick Desaulniers , Xin Li , Seung-Woo Kim , Paul Bolle , Bart Van Assche , linux-kernel@vger.kernel.org, "Russell King (Oracle)" Subject: [PATCH 1/3] ARM: compressed: Pass the actual output length to the decompressor Date: Wed, 12 Apr 2023 23:21:24 +0200 Message-Id: <20230412212126.3966502-2-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230412212126.3966502-1-j.neuschaefer@gmx.net> References: <20230412212126.3966502-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:asTkI05mit0v6ML4tVuKmImFEuUsK0Fu2edpCC39+pLZg2GbPEp uz6X4ZfRT20DLhLPUl8stqEq3qsocNzWidlj25tSp8ODUYV8E61NLSs9J2c01K8hlt2sdnU 4eLQbQQmZxMqVRPCi2Ngsw55OhjDQbP4MkfpuGDNQgKVJ4vIs98dvmU1022PSQkJ8VjBKJl cm/3GJ/kQSIr4KYl47XQQ== UI-OutboundReport: notjunk:1;M01:P0:wYI1qy9oxMg=;ZVVUPgqmOo4gpzWIhJbrqdHAqdl N/GLP6C6/VhJGvwN/crPZrSQBl8auweY4IQwlsQeyi5qyOCoWzQrSaDquJfz55LP19Gppap3t wQObz41pOU4bLa6Y8cM9EBOrXquszDEKVaVgRj9GKRnftxUuIZh8ZQtpVd5bwHPZrTMC+KwmC wLmUVxzfg29ft2ErEWZACAYnztBqaYr5OkLudtrTyBRfc/ZqhBJkeucHwKA8GehJmrrmIikNq IJG2bv5jvss8+W8HYYjUlEAG/g1nSKi9lsQhGXXgECDzgwAU9Hv4KCbEIWG71L252b2BG64nf h0y9IxXFHTLJYRN6AFpDxP9DqPtaMAdmF0i5LnsUw21I/arDhvspGVpVpLr7XHSUc7KMqO3BK 4EbzfaFLHvm09ep3TfdNS1tV2WSj3VZ06UNkBI7EwOHzrWw86tBf0ebxyRI1BPXnfT7aYU+8Z Ce3wO+HJcOrMhhIpkz9eZdKOw8i3mDgTMe1cYVtlGyIA6vZ9W2Vo8178qismrg/v25MAejjxt oD+IEAeHOrGMp1/LhCad1/wybR/BG5fsHh5yhgNoSQeu5iuxoWYwXcGpoC5TZSMRYRsxLpdNT y96LkkEmGQ5H9DaX6Rp/f5ODudF614GI9aJH/vWYFcfVpnhdiY+Jo6BAY3Syeu2aSJo8kmv5f 2Ab6Z1bWpZYl33Ons8+F7v3B2ZT+4l8HxyDTnC2NhiYJVpDYqQCSlvy9V44cCkUfsfZUBlHIS TXeR/p5qQbkv2OwasfFVrbbswyhpDtgXH6camhneX7UAKkHx6A0o6gJtcLmhOBGxnH1i3dBvv MEGuUBs8b7AOfR/iMogtMFY5I47xjUIMoJCib7Y2S/hTtwAal7syElPOb58tuoVns9Hu3+QJx UuEVsGJUYFA2G3SXzk3WaHq057WuDBTvfAdFoxQZjG9XttxcWVKDLwH60H9VLbJEPYU53H02i ijJvIQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230412_142233_822101_C6F018CB X-CRM114-Status: GOOD ( 14.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ZSTD writes outside of the space that is necessary for the uncompressed data, when it is told it has unlimited output length. To fix this, pass the actual output length (the length of the uncompressed kernel) to the decompressor. The uncompressed length is already stored as a little endian 32-bit constant before the input_data_end symbol. Signed-off-by: Jonathan Neuschäfer Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Reviewed-by: Tony Lindgren --- arch/arm/boot/compressed/decompress.c | 4 ++-- arch/arm/boot/compressed/misc.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.39.2 diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c index 74255e8198314..3d098b84ee391 100644 --- a/arch/arm/boot/compressed/decompress.c +++ b/arch/arm/boot/compressed/decompress.c @@ -59,7 +59,7 @@ extern char * strchrnul(const char *, int); #include "../../../../lib/decompress_unlz4.c" #endif -int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)) +int do_decompress(u8 *input, int len, u8 *output, int outlen, void (*error)(char *x)) { - return __decompress(input, len, NULL, NULL, output, 0, NULL, error); + return __decompress(input, len, NULL, NULL, output, outlen, NULL, error); } diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c index abfed1aa2baa8..8402b29bccc82 100644 --- a/arch/arm/boot/compressed/misc.c +++ b/arch/arm/boot/compressed/misc.c @@ -22,6 +22,7 @@ unsigned int __machine_arch_type; #include /* for inline */ #include #include +#include #include "misc.h" #ifdef CONFIG_ARCH_EP93XX #include "misc-ep93xx.h" @@ -131,17 +132,24 @@ asmlinkage void __div0(void) error("Attempting division by 0!"); } -extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)); +extern int do_decompress(u8 *input, int len, u8 *output, int outlen, + void (*error)(char *x)); +static u32 get_inflated_image_size(void) +{ + return get_unaligned_le32(input_data_end - 4); +} void decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, unsigned long free_mem_ptr_end_p, int arch_id) { + unsigned long output_data_len; int ret; output_data = (unsigned char *)output_start; + output_data_len = get_inflated_image_size(); free_mem_ptr = free_mem_ptr_p; free_mem_end_ptr = free_mem_ptr_end_p; __machine_arch_type = arch_id; @@ -153,7 +161,7 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, putstr("Uncompressing Linux..."); ret = do_decompress(input_data, input_data_end - input_data, - output_data, error); + output_data, output_data_len, error); if (ret) error("decompressor returned an error"); else From patchwork Wed Apr 12 21:21:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 13209534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EDD0C77B6E for ; Wed, 12 Apr 2023 21:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5rT/m4mLenwcIWi6Wf7AVmBvpHGf0VegPXYXuSQsU1g=; b=NNH2JYOdz3b7Jp 94XzKQGnyl9IFR2irA/oFsNhNh+IAqQINIj5OEYjlVU2auDGMldLcy/sCRpzGdU6OW058lTt23WCk 9pW3kxVhLhQIPC9Ln6w/fast6h00alDWz8DEQHdyT7TRtUeI2LKyrdLVFnTo7zs6lAIz2TTch2+YD A1qUAWUf/Gbz5wYCnfc6N9HWEHbSiw0pMhKhnG2oS6PNtXwQfn3gvgNnk2LC5sFa/1DWxqrGVxJIv Ms883cg72gimwur4eOmMPAii3nXO7aBotRyMG/KP9XoWpx6rMphYU53WC8jVKxeS01zb7BNAT6pGS veDnZNzYMOXFeiOSlNdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmhvI-004Nbh-2a; Wed, 12 Apr 2023 21:22:36 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmhvE-004NZE-1B for linux-arm-kernel@lists.infradead.org; Wed, 12 Apr 2023 21:22:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1681334517; i=j.neuschaefer@gmx.net; bh=2NkEXNzdSvLHDezuc3e95Ppy4PB6xfiWobcIdlZ2Mq0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=heNVrkO8V0JA6m6qAVX76ayzgy0jtcDI1MX8C7Uaw1rjIM6LwY2sKB5xugYz/DCjs EHjy05Y8y7C0T6mTgOFZ/Y7sF6K8CSerenKbM+WlcoNtTWIhfYsvLXCxyoNdZB3YdW WvMqRZpixnHS6GkmzVSqSOpKeoUqHIyJysYaR/Y070FZQu7JbNZ2HFnYxjDEQ6jxR0 HuDvEOFIdLwHUwgS1a5mO5BZ207gY/+py1+idDeYXkonKeBgOdeVukjt3GcrQPLk96 +r8iSYHYYonhoaq+ru9UbK+tK6awcDk6+r2AajX8qxPD/NTEwDFV0shpMjszUzCK86 3doeYafMk3RFA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from probook ([185.66.193.41]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MqJqD-1q80IA0yBP-00nSaK; Wed, 12 Apr 2023 23:21:57 +0200 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Nick Terrell , Arnd Bergmann , Tony Lindgren , Geert Uytterhoeven , Linus Walleij , Sebastian Reichel , Nick Hawkins , Christophe Leroy , =?utf-8?q?Jonathan_Neusch?= =?utf-8?q?=C3=A4fer?= , Florian Fainelli , Nick Desaulniers , Xin Li , Seung-Woo Kim , Paul Bolle , Bart Van Assche , linux-kernel@vger.kernel.org, "Russell King (Oracle)" , Kees Cook Subject: [PATCH 2/3] ARM: compressed: Bump MALLOC_SIZE to 128 KiB Date: Wed, 12 Apr 2023 23:21:25 +0200 Message-Id: <20230412212126.3966502-3-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230412212126.3966502-1-j.neuschaefer@gmx.net> References: <20230412212126.3966502-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:wZAOHj/rfJsRhnvDlu5y2Pqf209q3GQxBJDNPOKh5N5aJE/28+u aiTYOIGQtqjo7mKUL2Ge+mmrO+v1wx2Ilp0Bdx3HscAKyzz1xnkU6JULKEApP5ucS3xblXQ M60hb/DFKUwIcjooNEcWjrBxnxOMlNYwgJ1WtCxlL7FpUo91a9QZIksmXVCkWneYb4k/kGV I8tTOyyrv5gc2q/o+z6Iw== UI-OutboundReport: notjunk:1;M01:P0:nNpt2s/KZB4=;FZwzPIEsOrYhKsQ2vHPC+bc7IdD xn2kjP1QkVU+suszm+o38bgUmA2AukMfClil/xRcfNU2btUGsh9K8lS7fELArAzWY9Ru3LntF bIjTwx1icmJ8KOHFE/aAJceVd9RMNrFfKuWMBaYBcR5S6HC2ZLPy0ee68z6tbPwh0QQAY8u7K VYY2ec2QzkbpGGmNov45aH9YBwFoHN3XAa+Po1Wx+V9Kz06d2SGzPhz0wmSVJiyG4682IzVmh bxpIKxiHbg3oA+Zlz3LteC832eimhRyrxNpz22Ld7dYzEfNae8ggZnMG9sIl9kjdUnZRQZHkO 1UW/PVZKY/C2+n0GfV0+/UkMuDXPmLL+4ywjD5ZLNnTbIpJQDolumKDG+1f2xH48hBf4H7BDl dM62mia8CRnL3feQtFWaL3JsMeA0X/KrlBJDTwryl7Ap66DmtP3jthw2GMJYJIg17Bn8/LA8Z Va8xp0GzI1PirUYfEfD9L3qO5ueXcr6nQz3fDSAkeyifNMwKAqhmAiFgZwylwtKJCWmGTdac1 HZMDqVTTYq3C6XFCvDqowArHekDGllKf0heEgbuhhefNBKV14NTcbX03JldFgqeofXWYN+X2H O35OHbalTd7UGKXmgQDb93UHqw6tmj+PQZsIMEnX+bvU79Zvfxf9KCEZ0WcBCGlzVvNOvyoiF K3ZTVQnkBGbtlx5GqChTVFkymcQ6GyDsySGlNix2iKFgdPw05YmrWiN4Raq/0t1RP0p63HkMh 8+z3/mjSPKIpLT4AXMC0dICmOzEoJBYQSOkrLSJqyKiS8gYshf7L0xJQzFDAhzvs773YgZhEG x/IqPFS3C8HFJShjcy8iI4WUNuR9ggypmZNKxF8eq0U2bOQ2SMJB6x3D3WumR4vFcqukoTZk2 GcEeVJEeJI63J9Prl7eLOGdcXbZk5qdE982Qs4lv9B3k7ORIN26wLOdFnkvVCiz4nX3qbJ73u RXX5ok5RznmjNVLEJADdazInIMY= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230412_142232_695212_BA6C5286 X-CRM114-Status: GOOD ( 12.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ZSTD compressor needs about 100 KiB. Signed-off-by: Jonathan Neuschäfer Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli --- arch/arm/boot/compressed/Makefile | 2 +- arch/arm/boot/compressed/head.S | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) -- 2.39.2 diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 2ef651a78fa2a..dec565a5b1f21 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -69,7 +69,7 @@ ZTEXTADDR := 0 ZBSSADDR := ALIGN(8) endif -MALLOC_SIZE := 65536 +MALLOC_SIZE := 131072 AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET) -DMALLOC_SIZE=$(MALLOC_SIZE) CPPFLAGS_vmlinux.lds := -DTEXT_START="$(ZTEXTADDR)" -DBSS_START="$(ZBSSADDR)" diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 9f406e9c0ea6f..23fbbe94da6e8 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -337,7 +337,7 @@ restart: adr r0, LC1 get_inflated_image_size r9, r10, lr #ifndef CONFIG_ZBOOT_ROM - /* malloc space is above the relocated stack (64k max) */ + /* malloc space is above the relocated stack (128k max) */ add r10, sp, #MALLOC_SIZE #else /* @@ -629,7 +629,7 @@ not_relocated: mov r0, #0 */ mov r0, r4 mov r1, sp @ malloc space above stack - add r2, sp, #MALLOC_SIZE @ 64k max + add r2, sp, #MALLOC_SIZE @ 128k max mov r3, r7 bl decompress_kernel From patchwork Wed Apr 12 21:21:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 13209533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6AC2C77B6C for ; Wed, 12 Apr 2023 21:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=isPhNqjQolo/NjWLgJC6OA1oZ3PrFhuKhZYEPvakzQo=; b=d4FQJxCyIayT+a D6e0peBAHwYM//O1bu+fRYu6fOeOseBnrnn2crkzyGMkYouVVfxagWYbjU1lnkMkXleOK58pxTMRK 9//I+Mj/EI64Q8Vm5u/3CGy7nGDJlsqtOgRJY5Yp06PlE1s66Hw4AEhlqN3PjK+qQXLnaB+VZ1Q6F Y1JDymBqfz8WnEzUAqKEKlwhUnVpSP07ITZCpZEUd4ttBoORGsrN6waIyO+XYudjZ1MBdNeZrYXOa sr3yIZ5ROZXqCr/eQnps77oTmnsWUfYOpwBDHIMxZoQyA8EBI4RfHFb88FyBdviehh+Dz4TgIxUFT /UkAVL50WXYBrasN9Vqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pmhvP-004Ndd-0i; Wed, 12 Apr 2023 21:22:43 +0000 Received: from mout.gmx.net ([212.227.17.21]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pmhvF-004NZs-2I for linux-arm-kernel@lists.infradead.org; Wed, 12 Apr 2023 21:22:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1681334525; i=j.neuschaefer@gmx.net; bh=O8EbCtqxtHYhZl3Wus9zpBDqTyNgSWv3QZ/g5KBbeZI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=OEA1FhescqUfkOmuDqtkrGYkKZCy/DMEnk/LaDmgvBNs6cqpozk4B5wSbdVg4eX+0 jA55Hn+8mgTDiLiJxRBXYzrhFkxTydPaae1mBbv9EbLrqTZdeeWYTRdDeA2ysIHdWe T2au7ZXelcTcVcaqof0jmgi2RFJ3ed08v4XSOUmqSy2YPWT6FEYzFJDBE66qLlX55A G8gUPrynRofubUWeiO5vh20659JGdvj+8KHG/VPf2VS6bJ027Hv9i5RSjdo/5QZ4fC Jl1N5WtMV8ONYplNfVOxh77gD05BSzzrBsqyp4ZJf/e7cO1qJFFJOGGgoDoehmWX6a EffFTMVy6YMBQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from probook ([185.66.193.41]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N63RQ-1qShXR3GeW-016N3I; Wed, 12 Apr 2023 23:22:05 +0200 From: =?utf-8?q?Jonathan_Neusch=C3=A4fer?= To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Nick Terrell , Arnd Bergmann , Tony Lindgren , Geert Uytterhoeven , Linus Walleij , Sebastian Reichel , Nick Hawkins , Christophe Leroy , =?utf-8?q?Jonathan_Neusch?= =?utf-8?q?=C3=A4fer?= , Florian Fainelli , Nick Desaulniers , Xin Li , Seung-Woo Kim , Paul Bolle , Bart Van Assche , linux-kernel@vger.kernel.org, "Russell King (Oracle)" , Kees Cook Subject: [PATCH 3/3] ARM: compressed: Enable ZSTD compression Date: Wed, 12 Apr 2023 23:21:26 +0200 Message-Id: <20230412212126.3966502-4-j.neuschaefer@gmx.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230412212126.3966502-1-j.neuschaefer@gmx.net> References: <20230412212126.3966502-1-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:NLKJGLSHU/mKfwCFI6t1irU5z5u/MoO8jr3NJmsYweqgxdI5Qej 8HKkQD920FU6M/3UgPqB3iyyeKTUracoZXdCvl6zR9JR8iCBQopsrIkYbHNi829tR8F85qN gfcXNwiXoc7xB1PZcoSLxNCks6kZ4E9WWqCJxk/io62ncpopqYU+SGyVLaLVgRb6vXLg/q0 nlxUZapXHoRUQp5KeUkCg== UI-OutboundReport: notjunk:1;M01:P0:7C88/EJwyYk=;EeZbn8oZQQ/XlBkmsNhLXC3DX7O R87+ukUz9LEx9YhSUTia1vUhBfnlR+q/60srJ9GvSFs3KRBjshvC2NEXiM+VR6mKcx5zKDJGv p08RzsUUX0moiNRGbI4unwoyVbI+tI93CkBjnl8PAGA7QRRK0y6SJWoDU9Z6+BXglJ/sLlvKY EaHPhCyVSyMPTxMDDdfcpd8SSksT5Q91jf2+YQBm/c1XYi/M5Lk4HFxw/bARvBqEYaqe8ZOgy Pt309QyAELbHcVzb/45JWFFsKWO5Jr8LkhAMDaULrGq+E+PBZskNxU3h4O3fxbC4xcjHHhAGu ihSPkV7N88zZL+B6EeNYQYn3s8ayZU8PV9AuCvIWH0pNJEVa9b7CkH66XbkJJDHmhF1Rb0aYP zXzk+Q6pSnSiV4mb7x0IAZcNIw6PtbLnkGQ11w0yJEW4PtthEZmL+opLCg2ddmRmZwQ8GYVch K1ED8gy3/+lWlpp31ahWDrq/7jZdlcdDYH0pX+IGtAVBVtY3xEqK91270ofa6CJGr9KylJ4zv YYTCFR+6ffFOkvpqnw9rEtN0tk65MjseXOK1Cy9CVFA+CLzm9jW1S1rVvSMvuny/W69DYM2gW qp/uM7ccNaBPcdpmdrYGo1EOFi+J8OVw+/qf1dJf14uliHL3T2hWP0MWIEvUl4WseV0Nui1/t EZ98duNQ5kZCmiLiWc5MnmLIDvIYB7RDHzV9gJHZRXww/BGdI18S0EkE3774F4BTjifZodfgy hGN73q3Tku/qeJsvWustKlGnEch6/OkzV54elWHrrYxj8ugoX9nZP+Iy5pE2A8/aMNr8myvCo 1Tofwfxw2qg5xMBP24MahPlPk/HgM7JPwsjqNTQyVfCclALIHvIdgmk2TJGxGM6EyZFS6ddXx nbe4+8TGXLF4Rax/CoyhO1MswNk+4dp9n2+FcBxMsZ9A/xBlSYdVKYfqy6ITGFrIlc2l2lCJp eyu5pQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230412_142234_039142_1D4B5A52 X-CRM114-Status: GOOD ( 13.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With the previous two commits, it is possible to enable ZSTD in the decompressor stub for 32-bit ARM. Unfortunately, ZSTD decompression has been quite slow in my tests (on ARM926EJ-S, ARMv5T): - LZO: 7.2 MiB, 6 seconds - ZSTD: 5.6 MiB, 60 seconds Signed-off-by: Jonathan Neuschäfer Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli --- arch/arm/Kconfig | 1 + arch/arm/boot/compressed/Makefile | 3 ++- arch/arm/boot/compressed/decompress.c | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) -- 2.39.2 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e24a9820e12fa..065a1746a257a 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -108,6 +108,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 dec565a5b1f21..55bfca154b12a 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -81,6 +81,7 @@ compress-$(CONFIG_KERNEL_LZO) = lzo_with_size compress-$(CONFIG_KERNEL_LZMA) = lzma_with_size compress-$(CONFIG_KERNEL_XZ) = xzkern_with_size compress-$(CONFIG_KERNEL_LZ4) = lz4_with_size +compress-$(CONFIG_KERNEL_ZSTD) = zstd22_with_size libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o @@ -98,7 +99,7 @@ OBJS += lib1funcs.o ashldi3.o bswapsdi2.o targets := vmlinux vmlinux.lds piggy_data piggy.o \ head.o $(OBJS) -KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING +KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \ diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c index 3d098b84ee391..2c4fd33444829 100644 --- a/arch/arm/boot/compressed/decompress.c +++ b/arch/arm/boot/compressed/decompress.c @@ -59,6 +59,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, int outlen, void (*error)(char *x)) { return __decompress(input, len, NULL, NULL, output, outlen, NULL, error);