Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2172283ybg; Thu, 30 Jul 2020 12:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl6kav5zn6+i9FMsXkkfCRS3HkfSYI9z3Ih4YVlJbnGFjnd5SAQ17xRJEKCr8Zz6sLENGL X-Received: by 2002:a50:d697:: with SMTP id r23mr447123edi.223.1596136330290; Thu, 30 Jul 2020 12:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596136330; cv=none; d=google.com; s=arc-20160816; b=Q90zygX1BIdzMueJ44akLLQDOmU19spHS0JrnODJT1Vt+ewC2seR8dXEuzH8r+B+tS jttFTH3jOdpi8/S4b8538ZFf2tuwMFN6uaT3UI/L8kle28JAhbZFrCuVjIVau29wewgz E6vhjLg1pKTPJzfRYRlWXYSHVZgycEtq9Vq5TqLKBKINnQGuFA9VtnifpHSs1x126kTA kPWGcbdGxjxY46gMv4ZQBaXlNBF4iA2K6j6/l1UBGf6eBHM6/XHCdpdHuS+0qJP8xWdG UiJKdIAzDfOLS0LC/vcGiWbc9Q3ApaVRGdo+0k0tMnpd0nN883Tx7JNi+WIRx6vNChIf Ud1Q== 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=fmIcvsol2hVEYD4hslBcgfIPlSJK4NAnFqyLqCM1gdk=; b=NOx8Aah1HtT7hFh0gwcrRrMpt4ugLVnvdFuMUV2A9NtyEppqyqAuArax/nKjLswbjk cpgF02gYW0MKOsdfqMEoI1NCgTe4VilrpaRFY/KzompY+ShmO4QEI58iD/UoDHQJZJkh Ei3m2eudyNu/9Q4s5QIC0Cj/riueRGc1rfVSaKyDGPoiBUy5Fv7EFBlPLJRiAmrKIn46 LiCiDWcB9Jfn89NOdUcxJaoaksXjbjVvXLJsFEu8Qm7x1pK1xieSaEmT+YDh2/H7gjIv B+xzZr5tMMWAf7VnchqGz05lyo/YfxQMEJijy2LsTYU4ZDfTasauHxEXj8JJwEcVCQ1T iNlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OYeysaA5; 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 e26si4263032edv.66.2020.07.30.12.11.47; Thu, 30 Jul 2020 12:12:10 -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=OYeysaA5; 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 S1730479AbgG3TLb (ORCPT + 99 others); Thu, 30 Jul 2020 15:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730444AbgG3TLa (ORCPT ); Thu, 30 Jul 2020 15:11:30 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABE63C061574; Thu, 30 Jul 2020 12:11:30 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id ha11so5437714pjb.1; Thu, 30 Jul 2020 12:11:30 -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=fmIcvsol2hVEYD4hslBcgfIPlSJK4NAnFqyLqCM1gdk=; b=OYeysaA5vFkzYebKJCg+7lQgoWOFfnVI8qfBmxjzSgbrPdZlPs+z2ksxmwX26xsYnc zSWS1H+spEaGmRGX2HNqeZF3iornchIkd+7WkCoP9XL7Q6F+ji+Qq7LFIhhaiuwp/MoG 2nXLpEHp8m69FULHvHS2JOEN8shBNYIaMHm+6A/4oAv89gdaeI3Y6HVtNvr1fwxHfKiR upEP9svLS3lV4uDlHBXrY8vQH6LWrp0m4v3XXvNT4Kg0viM8+zeDb7cgvKIwfJC1GvmM lQuRpxMnnQKj73J1S4cUmEbjZDmRcxwDPMqo9YzdY/iDZH2jjV7eg5SGAX17bnx9M45s CGXA== 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=fmIcvsol2hVEYD4hslBcgfIPlSJK4NAnFqyLqCM1gdk=; b=F++8V7NVT39sPq+QctanlAsmQXlJyACnQijGdJSZSEOg0hsD9nl1QyGnStds+Os8LB rSK9aRCoWf0IB4LwCWpTylQodaIo0LV0KkcFeGvAnr7TWpozDqayiB/jmSlKXW93No5q QBXWSzwxUMOTaObfgtcJ3wh8X5k0m0iH95qw17ODKTE4p2a2edSFnBBbElhAWxev4Y8n kjG31723ynttVrgM14hWG1yrMgvm76kQ6tClQNonn/hP9JIZGPE3tfYQ/fbBs8rs/l/Y Tryomtm900CE09fFGodXzx7pqc8wprXXY9nsM0h7CAhySeTSVRTv/3/hbT7f6Msa/HCl OgDQ== X-Gm-Message-State: AOAM532rwaRm4OWb7cT1LuaJIPeBGut5Po/sYH9U0gEHz6JisHVzTzV1 /9ERpeSP0cnYUujtB/ozW+o= X-Received: by 2002:a17:90a:8543:: with SMTP id a3mr569088pjw.31.1596136289012; Thu, 30 Jul 2020 12:11:29 -0700 (PDT) Received: from nickserv.localdomain (c-98-33-101-203.hsd1.ca.comcast.net. [98.33.101.203]) by smtp.gmail.com with ESMTPSA id o22sm8644976pfu.206.2020.07.30.12.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 12:11:28 -0700 (PDT) From: Nick Terrell To: Borislav Petkov , Thomas Gleixner 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 , Norbert Lange , Andrew Morton , Alex Xu , Masahiro Yamada , Nick Terrell Subject: [PATCH v10 4/8] usr: add support for zstd compressed initramfs Date: Thu, 30 Jul 2020 12:08:37 -0700 Message-Id: <20200730190841.2071656-5-nickrterrell@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200730190841.2071656-1-nickrterrell@gmail.com> References: <20200730190841.2071656-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 * Add support for a zstd compressed initramfs. * Add compression for compressing built-in initramfs with zstd. I have tested this patch by boot testing with buildroot and QEMU. Specifically, I booted the kernel with both a zstd and gzip compressed initramfs, both built into the kernel and separate. I ensured that the correct compression algorithm was used. I tested on arm, aarch64, i386, and x86_64. This patch has been tested in production on aarch64 and x86_64 devices. Additionally, I have performance measurements from internal use in production. On an aarch64 device we saw 19 second boot time improvement from switching from lzma to zstd (27 seconds to 8 seconds). On an x86_64 device we saw a 9 second boot time reduction from switching from xz to zstd. Reviewed-by: Kees Cook Tested-by: Sedat Dilek Signed-off-by: Nick Terrell --- usr/Kconfig | 20 ++++++++++++++++++++ usr/Makefile | 1 + 2 files changed, 21 insertions(+) diff --git a/usr/Kconfig b/usr/Kconfig index 96afb03b65f9..2599bc21c1b2 100644 --- a/usr/Kconfig +++ b/usr/Kconfig @@ -100,6 +100,15 @@ config RD_LZ4 Support loading of a LZ4 encoded initial ramdisk or cpio buffer If unsure, say N. +config RD_ZSTD + bool "Support initial ramdisk/ramfs compressed using ZSTD" + default y + depends on BLK_DEV_INITRD + select DECOMPRESS_ZSTD + help + Support loading of a ZSTD encoded initial ramdisk or cpio buffer. + If unsure, say N. + choice prompt "Built-in initramfs compression mode" depends on INITRAMFS_SOURCE != "" @@ -196,6 +205,17 @@ config INITRAMFS_COMPRESSION_LZ4 If you choose this, keep in mind that most distros don't provide lz4 by default which could cause a build failure. +config INITRAMFS_COMPRESSION_ZSTD + bool "ZSTD" + depends on RD_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. + + If you choose this, keep in mind that you may need to install the zstd + tool to be able to compress the initram. + config INITRAMFS_COMPRESSION_NONE bool "None" help diff --git a/usr/Makefile b/usr/Makefile index c12e6b15ce72..b1a81a40eab1 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -15,6 +15,7 @@ compress-$(CONFIG_INITRAMFS_COMPRESSION_LZMA) := lzma compress-$(CONFIG_INITRAMFS_COMPRESSION_XZ) := xzmisc compress-$(CONFIG_INITRAMFS_COMPRESSION_LZO) := lzo compress-$(CONFIG_INITRAMFS_COMPRESSION_LZ4) := lz4 +compress-$(CONFIG_INITRAMFS_COMPRESSION_ZSTD) := zstd obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o -- 2.27.0