Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp807002ybt; Tue, 7 Jul 2020 00:20:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjPeeAN9g97ZDOqKIgHvmRiOGZu/HIxoA6PVofr1u32nzs36SIpK2N3t6QqFvdkAnYvk+T X-Received: by 2002:a17:906:ef2:: with SMTP id x18mr45042731eji.547.1594106440517; Tue, 07 Jul 2020 00:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594106440; cv=none; d=google.com; s=arc-20160816; b=hyeJLiM0U+9VB3eX1mUn79yaJZGoiTbQhXgXQzWuI6iBJoF+KxNeD+Zax50Ni9KC8J NxJpqKAEomFHPv0dZr/gSujdzYPX1CTpXIAdXIWlcBX70+rK6JWPCZBDyoEc2MUlB4dN YGukWGAGbnBMGDC6d9gvzcJyDVod24XW9nKq4o2CPJ1jHI54pEGgdELYoOrGkSYtbInx UOoU+NUEuuzgDnJdo0JHvngD8jxrS25bU4lJ1EjTRdqxPc71BLgCXOWw1S79ViRAy4Ki R6aVhbDEtMyzbnJdt9Tqg/kW9VrFtKKHjyUTxWTkR4jrJQ2AzdK0eLhEcwaNC/iQpxSL SA4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pUcELUyx1ePV8JGPwNHC9kj6M/wJ4Z99BXP40MiJsuQ=; b=XqKidOhnQq4jxuA8r1Rp020dWen6+4uKMEbFAxR3N9G72HwrMuScYoq9oFzBRMagEB qSjTHB2Y3kq7cNUXNuntibcUdHJ6Jo+mxt3OMF7S6rs8pHMsFTXpdonGNOrE8RwF3BUL 3Ejk3KmRkxu+Xw33HwbI8AMQtervUK7Tm3UZiUeZIi6UG/1cGJPvolUxrYHKq71cDYka X23WAMinZcE9+13RPkTAwLKJ7LFCkm3FmgNWzh2PIEo2o+DvCDtTNeEPd56TdpFFJdQ8 LBps4ekwnY6wrGZ8lf0qgfTL5LnXkK8OAqtDRgjTfspR4Ju9PLMtELzkVELOcxUf0bhO ue5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Iiqc7L/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s27si14035701edw.322.2020.07.07.00.20.16; Tue, 07 Jul 2020 00:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Iiqc7L/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726946AbgGGHTz (ORCPT + 99 others); Tue, 7 Jul 2020 03:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGGHTz (ORCPT ); Tue, 7 Jul 2020 03:19:55 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ECFBC061755; Tue, 7 Jul 2020 00:19:55 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id i4so42025506iov.11; Tue, 07 Jul 2020 00:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pUcELUyx1ePV8JGPwNHC9kj6M/wJ4Z99BXP40MiJsuQ=; b=Iiqc7L/1eoO3HhnVjs00e1l5cW8R/SVcbdQRqn9fHQ2wzm3mS3qjOOkM2wiKChUUii dv5Dp2fNaU1yiHXsaGHvbuVhfn6Zdg+MtM8pHRR4bJuKT8D8uohOM7TgUfOFNmN5G+bs 16gHzTvDXQNM8qRNyXiQ8LEKV2yokA6LVkxcKrfTis/koaT0fiOWh+5QbhWeZ4AF0At+ Fqnak8r/4JFUl3wPTF1bPRqcMbvk6WpGpMJ9CVmxOaz47w3j80XNkwIAqYWoqlsBckZJ 5EKvPqb2hxKsrZRtshmIUWoFzujX8T7ahYgAqC2z84dRT+NDfxJJ/m5OQ+hTkrVxQWpc ZTWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pUcELUyx1ePV8JGPwNHC9kj6M/wJ4Z99BXP40MiJsuQ=; b=S+rSxA8CFaf7cAX/5j6vPJxZoVALJI+e63Xu6PFYguiC6/HIu6OjlGAMCa2JkP1JUp d7oGTiYPRcukNy57s9xAXL77JuJDCrYfMvXaOiZDKMk+Q8ODSDrkxm5Ew7pq8MWKHZc7 AF4kFfvWqdeR/ifQuGffAkUdA1S4sigKLtDxmhVVvVzD8cLc/Wv5oW/c6bAbnZi+V400 1c5UtKdglXANHko7aJp5Ngd+6y+NXP4oVf/PktK4Tl0g77iGyIsRsJsfl076QK+39z30 ErNlW0C8X2pNBIwp+0q+lgLA2Z1Ry6SCidRtfT0YzTevfrzblTSUzVYLtmPFzhJrzEqt Pc6Q== X-Gm-Message-State: AOAM530lfGBLahmdw31uFzSHapbAxl6EB6peM/axUMXSqW2naKr7Rzyw CUmz1RYXzvOI8D8n2pXjopobo6MS+XJwJs/yn8g= X-Received: by 2002:a6b:ee02:: with SMTP id i2mr29458822ioh.110.1594106394647; Tue, 07 Jul 2020 00:19:54 -0700 (PDT) MIME-Version: 1.0 References: <20200707034604.1539157-1-nickrterrell@gmail.com> <20200707034604.1539157-5-nickrterrell@gmail.com> In-Reply-To: <20200707034604.1539157-5-nickrterrell@gmail.com> From: Norbert Lange Date: Tue, 7 Jul 2020 09:19:43 +0200 Message-ID: Subject: Re: [PATCH v6 4/8] init: add support for zstd compressed kernel To: Nick Terrell Cc: Borislav Petkov , Thomas Gleixner , linux-kernel , Chris Mason , linux-kbuild@vger.kernel.org, x86@kernel.org, gregkh@linuxfoundation.org, Petr Malat , Kees Cook , Kernel Team , Adam Borowski , Patrick Williams , rmikey@fb.com, mingo@kernel.org, Patrick Williams , Sedat Dilek , Andrew Morton , Nick Terrell Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the respin. Am Di., 7. Juli 2020 um 05:51 Uhr schrieb Nick Terrell : > > From: Nick Terrell > > * Adds the zstd cmd to scripts/Makefile.lib > * Adds the HAVE_KERNEL_ZSTD and KERNEL_ZSTD options > > Architecture specific support is still needed for decompression. > > Reviewed-by: Kees Cook > Tested-by: Sedat Dilek > Signed-off-by: Nick Terrell > --- > init/Kconfig | 15 ++++++++++++++- > scripts/Makefile.lib | 15 +++++++++++++++ > 2 files changed, 29 insertions(+), 1 deletion(-) > > diff --git a/init/Kconfig b/init/Kconfig > index 0498af567f70..8d99f0c5e240 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -191,13 +191,16 @@ config HAVE_KERNEL_LZO > config HAVE_KERNEL_LZ4 > bool > > +config HAVE_KERNEL_ZSTD > + bool > + > config HAVE_KERNEL_UNCOMPRESSED > 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 || HAVE_KERNEL_LZ4 || HAVE_KERNEL_UNCOMPRESSED > + depends on HAVE_KERNEL_GZIP || HAVE_KERNEL_BZIP2 || HAVE_KERNEL_LZMA || HAVE_KERNEL_XZ || HAVE_KERNEL_LZO || HAVE_KERNEL_LZ4 || HAVE_KERNEL_ZSTD || HAVE_KERNEL_UNCOMPRESSED > help > The linux kernel is a kind of self-extracting executable. > Several compression algorithms are available, which differ > @@ -276,6 +279,16 @@ config KERNEL_LZ4 > is about 8% bigger than LZO. But the decompression speed is > faster than LZO. > > +config KERNEL_ZSTD > + bool "ZSTD" > + depends on HAVE_KERNEL_ZSTD > + help > + ZSTD is a compression algorithm targeting intermediate compression > + with fast decompression speed. It will compress better than GZIP and > + decompress around the same speed as LZO, but slower than LZ4. You > + will need at least 192 KB RAM or more for booting. The zstd command > + line tools is required for compression. > + > config KERNEL_UNCOMPRESSED > bool "None" > depends on HAVE_KERNEL_UNCOMPRESSED > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index 916b2f7f7098..d960f8815f87 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -413,6 +413,21 @@ quiet_cmd_xzkern = XZKERN $@ > quiet_cmd_xzmisc = XZMISC $@ > cmd_xzmisc = cat $(real-prereqs) | $(XZ) --check=crc32 --lzma2=dict=1MiB > $@ > > +# ZSTD > +# --------------------------------------------------------------------------- > +# Appends the uncompressed size of the data using size_append. The .zst > +# format has the size information available at the beginning of the file too, > +# but it's in a more complex format and it's good to avoid changing the part > +# of the boot code that reads the uncompressed size. > +# Note that the bytes added by size_append will make the zstd tool think that > +# the file is corrupt. This is expected. > + > +quiet_cmd_zstd = ZSTD $@ > +cmd_zstd = (cat $(filter-out FORCE,$^) | \ > + zstd -19 && \ > + $(call size_append, $(filter-out FORCE,$^))) > $@ || \ > + (rm -f $@ ; false) Is there any reason not to use '--ultra -22' ? As far as I understand the other patches, the decompression should be able to handle it, and in terms of time required for a kernel build the difference is insignificant. And would it be better to run zstd on a prepared file instead of stream enconding? windowsize would be adjusted to min(windowsize, filesize) for one. Regards, Norbert