Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp696815ybt; Mon, 6 Jul 2020 20:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2jHAzvz3tRMiqQoQRhgVxQgaRIzcrP626VmXlVaC83mG4sfbi8ERKj5nZn4PjPmd7RfP2 X-Received: by 2002:a17:907:4420:: with SMTP id om24mr36109330ejb.10.1594093914326; Mon, 06 Jul 2020 20:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594093914; cv=none; d=google.com; s=arc-20160816; b=f0ES+hww6s3igmku9oDHrNxK2WNSKEODyBgitXQBFJJTylay6OzvIG7/9gCKPY1XQV uJtLnXXUIXXq7lgWm9JbYukzfe3kRoyyHjmhEHM8iD/3m+JiqgB4Iq5cxlwRieGd8A8M ezLsk/qHpnBMDzeV4jHCO23PKu9AY7rD/wT4GXBwrvehdITDr/q9iZ/j+NeipLuNnCN7 jRQwufL6xGO4I27dGM17Cc+xVXfSy21h/605/O/IbVisHOB+8h1kUOjSPAGy+W7iadgw l4vqwBr9/DavNTqJaU5PRhKcEVmfMoLrKxagmCfxag+GNj13iJBtXSWLOvRDMygQUOtg XteA== 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=LV2ySR9N0pCUXnyCR3IIrgn2+ek6tONedEqvPBsJXXKhKP2mnUXFx0poIp11Dy9yb5 cEQuC6rSxNSeHsz4GMLL5wRPPJkuJwQ/q3qFyIN9ZXJmJC4++rQNepJKgoLX1tamaUaJ 3H5G0qdHRgla8Ay5fnPFS4tI1TaJaCHtXkjwkdKbm+aAwkUH2FgOX1lvMGzBiY6joOyB gUVN8PAxZEtBw/lrZBkL3ZshLZhjH5NWY8GUY0kSJ7tHJolIj6XMD3HgOUvA3t2+Iffg UWZ0v0wkcPvRR3p5R1/6ObQO3VANuD7jZO24pSCo7JyLh6LN5y+ALCN/tdksmzuA0Udw TEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rE7i9cEW; 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 t24si14748416ejr.733.2020.07.06.20.51.30; Mon, 06 Jul 2020 20:51:54 -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=rE7i9cEW; 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 S1728152AbgGGDvH (ORCPT + 99 others); Mon, 6 Jul 2020 23:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgGGDvH (ORCPT ); Mon, 6 Jul 2020 23:51:07 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B07C061755; Mon, 6 Jul 2020 20:51:07 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id 1so146716pfn.9; Mon, 06 Jul 2020 20:51:07 -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=rE7i9cEWIBvwtYgkNdz4ua+7Y4X3+xt/vy88ZS5IAfsJhE8lZipXrCL8mXvXaDq3cD RwxEEI03JTY/ty2lfmlQb85X1KSM2kqKIE0Vb0yClKmmzyPjmJk/2PhFp4xbD8Lmmd+2 dXG8iFEP1uhK7K4WoP9ibnypOyLMMe5Gp68bctgD+JvHdJ5PQhSw+QbAPSudRMOXlcMx NVKURp2hqHPXCnFWoKU96I1Nb3SvRgHdhyRyd3KgCuRHaKtEDUHokzuYAuYYSZIggamn r9WkqP/Lge/fMniWJrSTgduZBLuJz/+PLLhxZckPqeFhBz3dXRp0jD2ApihM58c97brW 9NTA== 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=m14i8BVWUCS2QOBQOv+SUsk7Ze9EpeZbiMLMRlgUUFWNR08Dc9HB8SmLpKXAgxy5rV wPBAUSnWss4J/Ji4s1Al0hAEgRj8MRBsmjIQtdTNUJbSjDS2ag3tBUyyAFavlHCxH1wP ixTJuqZmRUIm5KSBItc8ZmNlLDhv6pZGVet6vp0UKKFYiqZ/YVFybHrblDW5BsBc24Ml NQ9F0ltNi/Xdaxg1qUEIlN3y+QwRdQal9/AUZf/NJ6jw7/8yXixeZgvimRi9VcbQYlrA tv9EcJTNBrikaGWuFFERmdoTbbLs3CuT3++XVR2l4RofOlewwdAXeJgs+ZBxJpczY//u Gurg== X-Gm-Message-State: AOAM530NpPtI43pTVK5ZRA7Oggf6EJ5v1vOA5Tib1TdFNtTj7GZXWSit +tI8TK2yRiM31jmlkQXLPHY= X-Received: by 2002:a63:7d16:: with SMTP id y22mr40888624pgc.136.1594093866557; Mon, 06 Jul 2020 20:51:06 -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 d22sm20466320pfd.105.2020.07.06.20.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 20:51:06 -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 , Nick Terrell Subject: [PATCH v6 5/8] usr: add support for zstd compressed initramfs Date: Mon, 6 Jul 2020 20:46:01 -0700 Message-Id: <20200707034604.1539157-6-nickrterrell@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707034604.1539157-1-nickrterrell@gmail.com> References: <20200707034604.1539157-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