Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp2560105imi; Mon, 25 Jul 2022 01:48:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vXnzZZCnvaLEmWYIgQA3vnYnOZ5V1ndUczcxLtsB7tnSHn2KUVBDPeYhCQOPMCSZwfDQtO X-Received: by 2002:a05:6402:b37:b0:43b:c447:17cf with SMTP id bo23-20020a0564020b3700b0043bc44717cfmr11849857edb.280.1658738887583; Mon, 25 Jul 2022 01:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658738887; cv=none; d=google.com; s=arc-20160816; b=b6EjN8X1nrEFWdZMxNpcajF9GYkwfD7EIkGEKi6OYhtsksfB9GMDUfKIPnw9uQ2kuU EEf0RE3rTVq2ZlGtqRUcBnF8/pQhSHDoXr/VTAM6bTfI7KbQQG0i1C79zA50PxpQ4yza ZqEMjfo3KSaQhDF8OrYajxar6sm10n3vVsb7Ie0MNrg1Og/7Pz178h1DHTyLUNVzIfNy +ZdoUl89r5w3oaKOYVQAnuZiLgZlfBsYawHvqcfzuH8QnVMKCBUuO44+LHCZ9/IUMm+Q 2RCF/WRkHiJ38InOsQ4VxgH5y4xOHiRah4tWgW/yt0yfqSONyNuvZUwUmaLeBDSJo08k DYSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=kHG5WLJXoefEp1rBIYi3cGiQrYB7FX8IJTWGZ213f6w=; b=oJa6fmhH3rTYuMS/wC6Yuypeh8Q6jsYABbNfaah94avgmonDYn2zCWVMKN4TLCdEmF cL2t07ApmZv6T6wcvg7/gfSjSGAwE5KryEDzb+iTlYUhFq+SXj/cDS+7A3eU2sw4yUsQ TvUwMMluwsuPoYQfmoepzJfdx2Xgn0QGRsAqUL+U2HMsZZcddbuwXAg+OY6gYa0nW6QM tDYhN28HhO8EamQM1EzhK9/Cwz67TrrdyO2IwMp+c0xJhBqqB4krNfYpvJESnJk8gua2 YMvo8AedrGGHV8tT26cUwMNwARGygu/af3ydjDOvTt/aYcbCHvLBN2HbDT+9dY2LhCz5 lsuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=oKvYNiy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf8-20020a1709077f0800b0072ab4b5ffdcsi8269999ejc.96.2022.07.25.01.47.41; Mon, 25 Jul 2022 01:48:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=oKvYNiy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234114AbiGYIkQ (ORCPT + 99 others); Mon, 25 Jul 2022 04:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234095AbiGYIkF (ORCPT ); Mon, 25 Jul 2022 04:40:05 -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 3A97814095 for ; Mon, 25 Jul 2022 01:40:04 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id ku18so9756942pjb.2 for ; Mon, 25 Jul 2022 01:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kHG5WLJXoefEp1rBIYi3cGiQrYB7FX8IJTWGZ213f6w=; b=oKvYNiy1a+B/y9HqhMS1eeDAuKnP/B7jW4Edzu3YQyc2TAbENzdFRYsH/9lNY8kWnv mDlx1UTjYca33UMNa2+p/+myi0hxsLQCasyKkMq1x8zl+YEaPYMhwxaMj58FfiJQkuem oY7MdUKQxELSYp92yDUBkKgkRKS8izlCQYk+7v76P0U8k8YBea+7YQXsWcTyurNEw6+h g7Hjv+yxgV99jZT+HZxNmp1iEIFgYtKfT6SxHsrN3SkrcdYdnshla+dW249GJ/IUi3U+ WuJc6bRxEjWXYuxp5MZLGXyU+w+1HAYCMZ0gYpDElGaSKspUa6sKF1m4l4DG677dRYU2 G8NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kHG5WLJXoefEp1rBIYi3cGiQrYB7FX8IJTWGZ213f6w=; b=EJVV0UzpgyifHQuJ0X8NR0Sxq54jtjSE9GnMv9oQjNPFhhDwW+Lz5R80EmHDsRSGPK pG6eG8x6D6/1bnIU9Pvh5KOA1ncpiba6HK1W1fcOH2F3kVNEtr/nQF0/a9wTuceme3AJ WLychrYobB9Z12Z7/Jqw7airc4sN22UO9nG+BLCUZnT3hyE08ZxsSOFhADCGet4CDIKR OjeNv3+hvvEqIoN0AG9jGv/+qQI8yTPwRpo0yHHWU5pXWE0P02TmZVo8b9LXSOK0s58N wNsBGTLV1wKBRqrXCY1Gh9kD0o9pAnI2YWsfiCGYwdtRkfiwPSJ8yfQJ5T0oMGQR6X5q 0Gjg== X-Gm-Message-State: AJIora+NtOkE/uw2YqYEX2tGBGL4pctWiQlcSEJhd5jaeEgZBpSS7y5X 3ge0Vt2Vc1B+AiD6GzDYVNVVWw== X-Received: by 2002:a17:90a:c4f:b0:1df:a178:897f with SMTP id u15-20020a17090a0c4f00b001dfa178897fmr13156990pje.19.1658738403592; Mon, 25 Jul 2022 01:40:03 -0700 (PDT) Received: from C02FG34NMD6R.bytedance.net ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id 128-20020a621886000000b0052abc2438f1sm8893479pfy.55.2022.07.25.01.39.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jul 2022 01:40:03 -0700 (PDT) From: Albert Huang Cc: "huangjie.albert" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Eric Biederman , Masahiro Yamada , Michal Marek , Nick Desaulniers , "Kirill A. Shutemov" , Brijesh Singh , Michael Roth , Nathan Chancellor , Kuppuswamy Sathyanarayanan , Ard Biesheuvel , Peter Zijlstra , Sean Christopherson , Joerg Roedel , Mark Rutland , Kees Cook , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-kbuild@vger.kernel.org Subject: [PATCH 2/4] kexec: add CONFING_KEXEC_PURGATORY_SKIP_SIG Date: Mon, 25 Jul 2022 16:38:54 +0800 Message-Id: <20220725083904.56552-3-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20220725083904.56552-1-huangjie.albert@bytedance.com> References: <20220725083904.56552-1-huangjie.albert@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "huangjie.albert" the verify_sha256_digest may cost 300+ ms in my test environment: bzImage: 53M initramfs:28M We can add a macro to control whether to enable this check. If we can confirm that the data in this will not change, we can turn off the check and get a faster startup. Signed-off-by: huangjie.albert --- arch/x86/Kconfig | 9 +++++++++ arch/x86/purgatory/purgatory.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 52a7f91527fe..adbd3a2bd60f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2052,6 +2052,15 @@ config KEXEC_BZIMAGE_VERIFY_SIG help Enable bzImage signature verification support. +config KEXEC_PURGATORY_SKIP_SIG + bool "skip kexec purgatory signature verification" + depends on ARCH_HAS_KEXEC_PURGATORY + help + this options makes the kexec purgatory do not signature verification + which would get hundreds of milliseconds saved during kexec boot. If we can + confirm that the data of each segment loaded by kexec will not change we may + enable this option + config CRASH_DUMP bool "kernel crash dumps" depends on X86_64 || (X86_32 && HIGHMEM) diff --git a/arch/x86/purgatory/purgatory.c b/arch/x86/purgatory/purgatory.c index 7558139920f8..b3f15774d86d 100644 --- a/arch/x86/purgatory/purgatory.c +++ b/arch/x86/purgatory/purgatory.c @@ -20,6 +20,12 @@ u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(".kexec-purgatory"); struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX] __section(".kexec-purgatory"); +#ifdef CONFIG_KEXEC_PURGATORY_SKIP_SIG +static int verify_sha256_digest(void) +{ + return 0; +} +#else static int verify_sha256_digest(void) { struct kexec_sha_region *ptr, *end; @@ -39,6 +45,7 @@ static int verify_sha256_digest(void) return 0; } +#endif void purgatory(void) { -- 2.31.1