Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp80693ybg; Mon, 27 Jul 2020 16:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwILA+E5hSz3RMDFf0M9I+yoV/ki24snMfVbTOq2I9yEC9rKr9ASZ3eUL95JRNSqr9oXmRn X-Received: by 2002:aa7:db10:: with SMTP id t16mr9809164eds.196.1595891662451; Mon, 27 Jul 2020 16:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595891662; cv=none; d=google.com; s=arc-20160816; b=H2uNoWf2yFd/gQHpOhfXa4AAsgX7QzsEqbdjAFOd/FHZfz+ALnm+HVPhIW6LzzGbpF 4rRoP06bLDxdNUS5qndErDKLBUt5d3prY9e1kZ3qxtWwBlusv3gOzVgO8k+W221yjpJ9 UuAdCVmDiKuh530XQGjUYBXwnkl//Kmxp8NVOZ5ZRHgsJMyCQes8TaW2HIjfSC8l7yU7 lpWqsNaqGNpeFRFqkAiQHlJLTcSqQHAAkZ3r2RPyYjEmiJmrnvt9pJ5A2GvfOQQhQq5+ 9QpmEpkzMVtuGdRSozD6nwk81rwP112g0v+D88M8wfCQTQWtdpv+AhnAya52t3nnYdsQ A0zw== 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=xQzmWSlBLsVubSNZYXfygRjGUHlcvSruyeQ4YPSC52S9V0/qkG9gYVFHF1iHXxU71S zkT+gdMvhYd+hvapdRLg5vy59UbzjLnNQ4bb4t2kw5P6L8rkzFk9bsZzzqvykNCq/ExF r+KNyehUDEdENFSZV+q37VudCZORqzP+rOUselgN3GK9tbOQkuDxyCGDUnhrokFRJbMx XWAFrW4Solu8QCv4+62Q7SBgdPSfybiVUi3TrjSwUX8WoBXchFcjVY++zr1A+iaW6j9u jLuCAbAagIOLhtMSxjTUDCrPEZTS1ROLjdp7nb2yuc4Exf/iyIrDe9CDg6LJF5jo+rjx LY3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qV7ro9Zj; 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 f9si3816796ejt.242.2020.07.27.16.13.59; Mon, 27 Jul 2020 16:14:22 -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=qV7ro9Zj; 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 S1727962AbgG0XLH (ORCPT + 99 others); Mon, 27 Jul 2020 19:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgG0XLG (ORCPT ); Mon, 27 Jul 2020 19:11:06 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AF90C0619D2; Mon, 27 Jul 2020 16:11:06 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id n5so10820665pgf.7; Mon, 27 Jul 2020 16:11:06 -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=qV7ro9ZjovZkkZyMXKYWC0Oe5Q9Fdx3g7cJvZY2XwbQLOywlWt+vBRZRaU9wFuNfW0 Br4q/uxbqlOpllX3Q9XVON65Cn9UPJtbgZoteNE4XQUWPKaBue9xhwbxzk815CYiUUnk pvIPd0ctOuqZemWBvbiw8OEB+jXmwgMB4cFDdyCeLCGHyegzjOn+moR7OB+LmTVsMlj+ HeL3fIgnLs0zIFkUimXjMbida5nz4Ht+JjV9pYLm4w85l4hEdFZs4Rl6PfLxSrKaTUKu I+NH8FrIeA/BD5ZnVrlQnKtJan7/dvegiLnJktrDZKyeTsj0Au9hpVlD3PNO985jNi3i xq7Q== 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=ZlMnzpmnlZ3BKaXsvChOdKqlTSQz8gMyvshlZLvt6gBkzd5XoeSnpYderUhnQZRNYc nZGyXOvxv9jeAAwSOLla2iixE4U+7kBxesIxQJYwX8vxMDu9WMQNm91XH88yMpyyMvcU HMAxtJv3k7cy3zVxaRmEc8MAqg4/1OkjFSIYMfCRRYDG10vwyZ7Njq6T4aZDGxCbHl8L GLQBH7yKQ8GlSs1GTSrPJi5T6nPpJw6GzxzrV5+mmjzOnmtQ8xWSuTUKVs8RD4+q9Gwl iBuQclwkUnwscXeOrSRLXKAMuxYZ+9DCWdPeA5yhPLt+w/mc+aEbC+fbvqGTi7tg4bG2 W9fw== X-Gm-Message-State: AOAM5305002CSOAzbrhmNmwYCPlOpdPeskW+jzdgVMJ6BN0NNYzdzMSP G3dM8bEqdyFK4iGmRcRv2TI= X-Received: by 2002:aa7:971d:: with SMTP id a29mr12555508pfg.308.1595891465730; Mon, 27 Jul 2020 16:11:05 -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 y68sm3515931pfy.185.2020.07.27.16.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 16:11:05 -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 , Arvind Sankar , Nick Terrell Subject: [PATCH v9 4/7] usr: add support for zstd compressed initramfs Date: Mon, 27 Jul 2020 16:06:03 -0700 Message-Id: <20200727230606.906598-5-nickrterrell@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727230606.906598-1-nickrterrell@gmail.com> References: <20200727230606.906598-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