Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1028912ybb; Wed, 8 Apr 2020 15:01:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLfE5CxVi9DYtaV/ij+k1X2B+NPM4N18chFmz1m2jnED4ChCyhr76KHv2c/X+LbJR5AfQ2I X-Received: by 2002:a05:6830:1cd:: with SMTP id r13mr1650178ota.231.1586383266652; Wed, 08 Apr 2020 15:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586383266; cv=none; d=google.com; s=arc-20160816; b=Kfa0qyriUmxUCU6+M8IDwYf1BGKjPfOUvpi/WqJmPXrelVrywZRdOOkV1un/Q5eMUZ 6rI2AN6UlDAkzLIIXd1ValKFUkrs+W4aGH3dnOtiV2CpUqFOk0OHoRURr2fOQlwQ6+bU QLWC3CIBrXKaD8gN7ySnokbNoADVE4a0h9R6ka9svA5Crhz4hMvr5Fx2oUmx7OqaMzJc SzoLSCJNHUEt1680h/U5m3O0g+v66MOGfUSA3PYydFoDSEdiMF7oTW69bSONdzTOwGK/ gK77KXrIDh6TWG7GxE32mi2dIS+WY5niIMLjiGQEMmxcV99EopHAdnF72rZyPArBks7q Odvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x/7kW0cmEuUJVUvzc/KSfN5Zbm5nXQUqMb4FSyTtXWw=; b=U/PPW+K4YYIH3caq52FLDFhHsDti2sCzpObkpiLyVks3oBTMogZjI4tnUXhRMixebR T5qcvrLPvYyEdOe4Y0eqd8uV194ZKH1O8tPru02+EqkksHzbyonKtPgyey7GQfvE3jJc zmFcRK4dZSBTr5iVmKJp5ym/Ab632PXK9kdEFGezdmkdS18G3cipEQrDlZYxy8lgdUJf nfLll1t11j2aZv6Qg1DcTv8Cn2pQtPIjrxvwB8V4jSA3a45CCy1HmfpdiMB/kunex9ke CUQB+N1kJBfs4PZh0sBmcarpIOBu3ft+hqgPMUl2SB1vfrfY0PSeEWCFlrhPNhqORUtI qFSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PpeIq0Jf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d16si3230021oti.42.2020.04.08.15.00.54; Wed, 08 Apr 2020 15:01:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PpeIq0Jf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726877AbgDHV4M (ORCPT + 99 others); Wed, 8 Apr 2020 17:56:12 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33636 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgDHV4K (ORCPT ); Wed, 8 Apr 2020 17:56:10 -0400 Received: by mail-pl1-f194.google.com with SMTP id ay1so3052856plb.0; Wed, 08 Apr 2020 14:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x/7kW0cmEuUJVUvzc/KSfN5Zbm5nXQUqMb4FSyTtXWw=; b=PpeIq0JfDPS2kP9J/CGwtDCFqo9DEuuffcu0RP+XEoAjBtkqJCLffSD8nc5AJANqLK drY33xPk1gLtyRlCzv/o6Z50moAMU4m/em0J4VA3kX7CHHSiSvYFkxRU+v8nGXhKVmJL AROoUNAm7rrakoLy8Lmz5wR+lRWrsjWX5I+GBWNCYsHVVPiuFckMFpbk9Wgn30BpuWp1 B5mgcH1kBXcpLtL8DdZlR2ZpV7d+j+tNvfmF+j0jGjeHu1aMGwhz6iaul7eg3MxOJrwm uCFPPiip02oJPrTgCAjzbjXD19PwqP1FNtwo0bBaj/JkCsAJKO38B8EIAoJlm+zaQMoU f/YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x/7kW0cmEuUJVUvzc/KSfN5Zbm5nXQUqMb4FSyTtXWw=; b=j2A0Ggh5tIKgiFRncZTxcpwks3erz2YRNjpCP2OqKbGzhp47Ku9ffLceSRkKyUrlXa I3ZrkVPDIz93oRTGAU+UhaddjR30KnTgw1RVJRRNc+XqBa7jiE6FqPFYgfODshTdo998 KW2APl5f82XqLSP/FqKZelQbr6owBRqhvx04EAmydFWrQUij+G4Rbv+WEzR9rDUh41ZW 0+4wj3SUDyF4bsV0MSMQSW8ylyVzvH1tzzWwr06YRBk8MVxa61DqhxMhzTGInXQKEpk9 bv2aglWTvENsV/o1gE4GRi2bPV/ZDk6qIjxppA1LisQIGdKypoNYc6zdOqeGpyKqxmL2 8sYg== X-Gm-Message-State: AGi0PuZ2TogJ9dZ3/c4C1VhYxUzqcuDaz2M0LIP0+jvb7gk7hAdkXpXA FoyOn2JSie+F3ytwUddQgxc= X-Received: by 2002:a17:902:7b82:: with SMTP id w2mr9349367pll.132.1586382968479; Wed, 08 Apr 2020 14:56:08 -0700 (PDT) Received: from nickserv.localdomain (c-73-222-55-223.hsd1.ca.comcast.net. [73.222.55.223]) by smtp.gmail.com with ESMTPSA id ci13sm459604pjb.16.2020.04.08.14.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 14:56:07 -0700 (PDT) From: Nick Terrell To: Nick Terrell Cc: linux-kernel@vger.kernel.org, Chris Mason , linux-kbuild@vger.kernel.org, x86@kernel.org, gregkh@linuxfoundation.org, Petr Malat , Kees Cook , Kernel Team , Nick Terrell , Adam Borowski , Patrick Williams , rmikey@fb.com, mingo@kernel.org, Patrick Williams , Sedat Dilek Subject: [PATCH v5 4/8] init: add support for zstd compressed kernel Date: Wed, 8 Apr 2020 14:57:07 -0700 Message-Id: <20200408215711.137639-5-nickrterrell@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200408215711.137639-1-nickrterrell@gmail.com> References: <20200408215711.137639-1-nickrterrell@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 492bb7000aa4..806874fdd663 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -176,13 +176,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 @@ -261,6 +264,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 b12dd5ba4896..efe69b78d455 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -405,6 +405,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) + # ASM offsets # --------------------------------------------------------------------------- -- 2.26.0