Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1880193rda; Tue, 24 Oct 2023 06:18:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjvWk7eoZGuCLyKq70gfTwrqBwlvaspL3QaMqahy2W6EJ0q7djMOYQ91qBrfTGc4Tobl7c X-Received: by 2002:a05:6e02:1cac:b0:357:4c22:e032 with SMTP id x12-20020a056e021cac00b003574c22e032mr15167304ill.18.1698153482469; Tue, 24 Oct 2023 06:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698153482; cv=none; d=google.com; s=arc-20160816; b=ZHmQ2HU8E36AOutSTUPfslEwMJu2MaYvi+xhs6x14T/lgUT4qz3pVfdsNa24Ux4vX2 YTHv3pCZzBqUTbQqhAjjbgNMG1GLDDBuD5XfF8/ZkWGx6JV+GLtPiXmGxo6ytouno6JZ bvmNAmRPySbFve/G65dYGx+rP4bEcJ0vpKHxsLKrCTsfmnIhoi3npod+iPFMEurVW93i BjG53uGV2oI/gKKgkgn4lzEkPe/MXURZMB3BagLM92oRcXP66ACQQ1N6elad8d4vIT0U 6RhQXE0bQtsAeEE/dDDUG8/jq9wMdjFSZCGk+nGqilttTeqBj4jRRdlEJfowDU5cMBa7 4VkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=juLUN5EOf1oun38yO5yy2NS/PjvfZz4177Yn5+hz4yQ=; fh=qkKIeZJ8D4LXlOxdSjord5+lBDkFZ4y2pYTdOFYzgOg=; b=cmOk9aJO5sDWtxuXgzNzpHe1xEwT8M5aMgAZ1HcI6bJ78bLQl/jWc9lqCj/uhC0AwH pkQSG0Z4+3iB9zNa2dM9ZHBrPv153uUV9KtR01DNrdwwDsKdTn4KODkDmnvG1/S+QgwU EeOxv1w2lDZ7P5OwmEzAVQOZMX1lJepbh4lueI0bxBkmfHjmxCKGMOEhwHlJNtq17Y81 6atppixlGnNF5d7knngkqKAZKQASBNfDvzB51u+88sO7+iQ0DvEwe9nS1IprdXXLSq8g +ivIX6GY6CNGYXEFnhBuKGKPuuRqIOuvfMRKpzoLK2W5AfN7Mr+E+p3RRnFruN+Nq5Ay KTMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=n5Juawav; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ho066+fp; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o1-20020a634e41000000b0056a670ebd6fsi8132808pgl.669.2023.10.24.06.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 06:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=n5Juawav; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ho066+fp; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2286C8056C57; Tue, 24 Oct 2023 06:17:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234176AbjJXNRz (ORCPT + 99 others); Tue, 24 Oct 2023 09:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232084AbjJXNRy (ORCPT ); Tue, 24 Oct 2023 09:17:54 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91364C1; Tue, 24 Oct 2023 06:17:52 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id CEEBB5C017D; Tue, 24 Oct 2023 09:17:51 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Tue, 24 Oct 2023 09:17:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1698153471; x=1698239871; bh=ju LUN5EOf1oun38yO5yy2NS/PjvfZz4177Yn5+hz4yQ=; b=n5JuawavBckG+td4zd 9bgRwuRpqQu0e1li/e77umwTpwdBwy0DLjFX3CyNt7mh81Xb8VYW0gXvlCFWRw6B hj+fijwsz4eR49wI1VEhiMuAzHMpeRbELUPOmwyMHvqXjYp/QUR+9/Se6UYL+T4L WDLTJHnW+8emUnHY2/S3SYHChMwDWnqqUAr12P0GwcRPCfjHc/Vx6zet1zUiY9Ab QW3noxYanY1quUXitS/QIyprE60azjurUOVXm3jRf8IdUBLJOPQUfQwF1h0Y5NGi 6gLzeDZxr2RnAK37E9QNOt1pBZVPzuFw/z/XlaaIMV9UrlXcEYm5x7VM6gugIv8o UBfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1698153471; x=1698239871; bh=juLUN5EOf1oun 38yO5yy2NS/PjvfZz4177Yn5+hz4yQ=; b=ho066+fpz4vqxQspl7eYkBvf670M0 QafoG/BnV/LA3QmmYpX25gHOuy6e1KX2q/EJoviBgTiQ8bEtGXhlgixr0PdEtdHP UdgVO0ss1ZYKXyYAaPFpHpAb7uNyOApEx16iBFvqNHtzguv2pCDNgoXgDvDBXbx2 Eum49PB45Qv1wQwNAXunVGDvSL4OeJfcTdyC4QaVURCUcVN4eVgopaLx8oMT2E7V cq9G95XNfiV1VTUkmn6go/PuJpp4x55ovVtU75KGke9BYIzfPM9PljR5ZiBtKHN/ HPitZ1g+BQNBBD4GmNtyUC4pTpD3oY2cjimFc6ZnqS4klc1L3cWmqG2ZQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrkeekgdeiudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedtkeet ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrh hnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5ADF0B60089; Tue, 24 Oct 2023 09:17:51 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1048-g9229b632c5-fm-20231019.001-g9229b632 MIME-Version: 1.0 Message-Id: In-Reply-To: References: <20231023110308.1202042-1-arnd@kernel.org> Date: Tue, 24 Oct 2023 15:17:30 +0200 From: "Arnd Bergmann" To: "Baoquan He" Cc: "Vivek Goyal" , "Andrew Morton" , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-crypto@vger.kernel.org, eric_devolder@yahoo.com Subject: Re: [PATCH 1/2] kexec: fix KEXEC_FILE dependencies Content-Type: text/plain X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 24 Oct 2023 06:17:56 -0700 (PDT) On Tue, Oct 24, 2023, at 14:44, Baoquan He wrote: > Just add people and mailing list to CC since I didn't find this mail in > my box, just drag it via 'b4 am'. > > On 10/23/23 at 01:01pm, Arnd Bergmann wrote: > ...... >> diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec >> index 7aff28ded2f48..bfc636d64ff2b 100644 >> --- a/kernel/Kconfig.kexec >> +++ b/kernel/Kconfig.kexec >> @@ -36,6 +36,7 @@ config KEXEC >> config KEXEC_FILE >> bool "Enable kexec file based system call" >> depends on ARCH_SUPPORTS_KEXEC_FILE >> + depends on CRYPTO_SHA256=y || !ARCH_SUPPORTS_KEXEC_PURGATORY > > I am not sure if the logic is correct. In theory, kexec_file code > utilizes purgatory to verify the checksum digested during kernel loading > when try to jump to the kernel. That means kexec_file depends on > purgatory, but not contrary? The expression I wrote is a bit confusing, but I think this just keeps the existing behavior: - on architectures that select ARCH_SUPPORTS_KEXEC_PURGATORY (powerpc, riscv, s390 and x86), we also require CRYPTO_SHA256 to be built-in. - on architectures that do not have ARCH_SUPPORTS_KEXEC_PURGATORY (arm64 and parisc), CRYPTO_SHA256 is not used and can be disabled or =m. Since ARCH_SUPPORTS_KEXEC_PURGATORY is a 'bool' symbol, it could be written as depends on (ARCH_SUPPORTS_KEXEC_PURGATORY && CRYPTO_SHA256=y) \ || !ARCH_SUPPORTS_KEXEC_PURGATORY if you find that clearer. I see that the second patch actually gets this wrong, it should actually do select CRYPTO if ARCH_SUPPORTS_KEXEC_PURGATORY select CRYPTO_SHA256 if ARCH_SUPPORTS_KEXEC_PURGATORY > With these changes, we can achieve the goal to avoid building issue, > whereas the code logic becomes confusing. E.g people could disable > CONFIG_KEXEC_FILE, but still get purgatory code built in which is > totally useless. > > Not sure if I think too much over this. I see your point here, and I would suggest changing the CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY symbol to just indicate the availability of the purgatory code for the arch, rather than actually controlling the code itself. I already mentioned this for s390, but riscv would need the same thing on top. I think the change below should address your concern. Arnd diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index e60fbd8660c4..3ac341d296db 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -266,7 +266,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, cmdline = modified_cmdline; } -#ifdef CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY +#ifdef CONFIG_KEXEC_FILE /* Add purgatory to the image */ kbuf.top_down = true; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; @@ -280,7 +280,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, sizeof(kernel_start), 0); if (ret) pr_err("Error update purgatory ret=%d\n", ret); -#endif /* CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY */ +#endif /* CONFIG_KEXEC_FILE */ /* Add the initrd to the image */ if (initrd != NULL) { diff --git a/arch/riscv/Kbuild b/arch/riscv/Kbuild index d25ad1c19f88..ab181d187c23 100644 --- a/arch/riscv/Kbuild +++ b/arch/riscv/Kbuild @@ -5,7 +5,7 @@ obj-$(CONFIG_BUILTIN_DTB) += boot/dts/ obj-y += errata/ obj-$(CONFIG_KVM) += kvm/ -obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/ +obj-$(CONFIG_KEXEC_FILE) += purgatory/ # for cleaning subdir- += boot diff --git a/arch/s390/Kbuild b/arch/s390/Kbuild index a5d3503b353c..361aa01dbd49 100644 --- a/arch/s390/Kbuild +++ b/arch/s390/Kbuild @@ -7,7 +7,7 @@ obj-$(CONFIG_S390_HYPFS) += hypfs/ obj-$(CONFIG_APPLDATA_BASE) += appldata/ obj-y += net/ obj-$(CONFIG_PCI) += pci/ -obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/ +obj-$(CONFIG_KEXEC_FILE) += purgatory/ # for cleaning subdir- += boot tools