From patchwork Thu Jan 19 16:42:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 46132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp9688wrn; Thu, 19 Jan 2023 20:38:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtJzaolg3hOhXKJw9fy+0E4GetTSfwqm5xDMCj1Mz6u3QFB94Cjma1g43+Cjz2E9VYatvO7 X-Received: by 2002:a17:90a:f483:b0:229:74a2:a692 with SMTP id bx3-20020a17090af48300b0022974a2a692mr13935703pjb.28.1674189523290; Thu, 19 Jan 2023 20:38:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674189523; cv=none; d=google.com; s=arc-20160816; b=b8ZBlhAkG5Pl8+lOB0qgB+2TLjT21fFrSMWgsyda8pbZPVDwR3XEUEnVx09ep64xp3 d5SLQl5+4rS4OH+YLPceUt8O59sD8qMaa2yiKkWy6svr0kAxNC7UfGsPwPhvxbrv902D JC0qngxQyWdDQNJcjZ9haG/bjRqKRnBq2t8dfo1GP7qfSqc8caL1rapm1wqzV90hGJUk 8B9MGUvf152pP/cl+MO6SOxHglCJyolRsie6BhHiheukbLfCJEXCfUtplPmggwcita1N n8OyTawhlt+hFyNXF3Aih0R+WiUFumC6UW1V5/LoUXIz15ocykNzW42soO5HXmW089Hc DZNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OXWJJ7GOw3Gc2widxDFABb28GCpT8U8QR+faRa7owjA=; b=ieYXqitYezVErFbU8YuzhTEW45Lnnfp33GfaAkEtqyFz9udXLwvFPYvzlT7OQAifF0 4SPmRyjR0UpPSjQvdyyONP1AhZL9au19ejjmYvbqc0WaJem/FmX/jjw3n3fo6jBa8/vD ++JeXa1N0VBAkPCRJ7sdbjWXZbyGWWDRXWZCVxbftrHd9XBUOPpTG01Cfn9fYXRT2J2b TrXbL+VHIfGbZd2NvOh0uXUuzx1s5BzONPU3EIIoAWYZjYKqdyWVDWNha6vtNfnCg3n1 M5z1rg5XUKeVEmYtrHiypooJJsIhqvcv/UGdrqjNun3IGGCCjq2XValp/xu9hOk+rKRW u9uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c4ZmBDSe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a17090a400c00b0022ad16e158esi1201644pjc.135.2023.01.19.20.38.30; Thu, 19 Jan 2023 20:38:43 -0800 (PST) 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=pass header.i=@kernel.org header.s=k20201202 header.b=c4ZmBDSe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbjATEhf (ORCPT + 99 others); Thu, 19 Jan 2023 23:37:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjATEhJ (ORCPT ); Thu, 19 Jan 2023 23:37:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D24C3829; Thu, 19 Jan 2023 20:34:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 697FFB82629; Thu, 19 Jan 2023 16:45:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0129FC433D2; Thu, 19 Jan 2023 16:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674146748; bh=Ik8KGBx4efM6Qvmj0I2GTqwFRPzmKf5LmQQLhwoAEQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c4ZmBDSeAohseCGX28vHo4/i9s+S5U76T11M0gprfwIW+/x608C2+8ZozXffHJuz/ o5OmXKd5qFW+7FwSWAdteoeUd++W6qWB9LTf9s0AP6mp4Eu//+neoK4HaiEymf94Qz SX57/vt+rn+QH0OE/3sGKVRBVX8bG4za7YwcDDrP4vAj9JIGVrbpIurXqb3NZypOeC Az9QTIfTIhz2en5hXFtfhgAmnuC9BpcJbNzcl+qettrPojl78TE1/jYZOXPOzDvEgF rFnGGNaiT1VbCO7+k/J0Lw8wiemoJBc9isH8yIyeI/d0aqOUczW1Cn3XcukUiJSFk8 SD7OxzxPKTkig== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pIY3M-0007Mr-2B; Thu, 19 Jan 2023 17:46:16 +0100 From: Johan Hovold To: Ard Biesheuvel Cc: Matthew Garrett , Jeremy Kerr , Maximilian Luz , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/4] efi: efivars: add efivars printk prefix Date: Thu, 19 Jan 2023 17:42:52 +0100 Message-Id: <20230119164255.28091-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230119164255.28091-1-johan+linaro@kernel.org> References: <20230119164255.28091-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755514953373053342?= X-GMAIL-MSGID: =?utf-8?q?1755514953373053342?= Add an 'efivars: ' printk prefix to make the log entries stand out more, for example: efivars: Registered efivars operations While at it, change the sole remaining direct printk() call to pr_err(). Signed-off-by: Johan Hovold --- drivers/firmware/efi/vars.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index aa5ba38f81ff..f34e7741e0c3 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -6,6 +6,8 @@ * Copyright (C) 2004 Intel Corporation */ +#define pr_fmt(fmt) "efivars: " fmt + #include #include #include @@ -90,7 +92,7 @@ int efivars_unregister(struct efivars *efivars) return -EINTR; if (!__efivars) { - printk(KERN_ERR "efivars not registered\n"); + pr_err("efivars not registered\n"); rv = -EINVAL; goto out; } From patchwork Thu Jan 19 16:42:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 46133 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp9689wrn; Thu, 19 Jan 2023 20:38:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvHN9lMYAp7A0daEu6oIkJAxUiPENpAXnLAyhMIST1WdK0ZxdxC1gWNUyEMXk41iaI6j/WK X-Received: by 2002:a17:902:7c15:b0:189:77c1:b5a7 with SMTP id x21-20020a1709027c1500b0018977c1b5a7mr13570374pll.41.1674189523757; Thu, 19 Jan 2023 20:38:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674189523; cv=none; d=google.com; s=arc-20160816; b=nU0VJyzWnGnh72S+o/mjMQLrdwSR48NQX/Rce5eMVDjRKOV4eewCdY19tIclXKtveF qOExiHK/PCDhzlfhwpjC1fh8nQk5jWSdBc2EWA08tteSnXi8b9OL7DnEEzmhc74iQsIn 2qz08aSsD1+mMVVqSiFGr5qpfW2Ht/PDBHaPQAsTWm+kueCotbNKOO3fjj+4SJCpLXXP dlyXCn9h003inBpb1IADsLv2Xih7UpZv3Or02VVDX2BAuOWqPOjZai5/IuZnk3SKqggF i0NmkAL1vrjYTyRkXLhD+XGDIbfzfpJHudq35DlYPO85eDWl8dXKuNwmFV0r7Tazxsvp IgDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uEqlKxoDXNPsQXEoBqb77iH3houuhG/HYk+QTVYwnps=; b=kiZh4wZY8GCdCRAfABqi3kdYr70EVqzxPU1wok6EsQkS5+LpvLyOj1qNdh9oU3l8CS gVSbtJbt+Iz847WI86SO8jN0Tk0Hqzjt3Wgne3Vm6KjEvi9LLg6XXCaXdz6VdN7eN2F7 tCJ3vgFryERTYc12ZVIBT0G2JewYizDWAQL10jOPIzEkWCHrwMGPu2+6JLFUO19ms9TX wkoPhmVij/TdQdzU3lZZF+7ap/Q6SGp/VY2TMeJpjs1oYiIuuMSBme5C+SXDL7sAHEI3 jNCHqpdA/XF+qaGMF8chZAQPc/IciUUEo3/Xwu1QpGTzl1Kl5crh1ZFWPFg0+w1VXz1J 6wcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tfk0eksC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a170902ebd200b0019339bf8b0csi29680950plg.190.2023.01.19.20.38.32; Thu, 19 Jan 2023 20:38:43 -0800 (PST) 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=pass header.i=@kernel.org header.s=k20201202 header.b=tfk0eksC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbjATEhu (ORCPT + 99 others); Thu, 19 Jan 2023 23:37:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbjATEhX (ORCPT ); Thu, 19 Jan 2023 23:37:23 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E91BBD16F; Thu, 19 Jan 2023 20:34:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 69278B82628; Thu, 19 Jan 2023 16:45:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03CD1C433F2; Thu, 19 Jan 2023 16:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674146748; bh=asXttCr/Y7FiSRak2/8wvKzUociZdAqvkoeYDxDt7sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tfk0eksC4hNa55RHiLox2lxfYRCDeDn2mcSCFdjcQ/iAfHWGd+Zwv5YjBhENhZRw3 qez8I7DT0YGuK5DrXInDinkDxWgcJAkBhXc9gVBoRAgFT1QnJmoJvcpcWQqtTvvckj I1JbMNzCXihEJ64+/jh0iVfDV2k74zlOm4b7w12aeR5+LGFyhYeSYaiRIDqEhvlvsw SxyoDaV4seVGBENtVe+6rUEjpsF5iREA8AkGE1z6N7vsRharHF//xHZaPhDmqa4nxx zpdEjyttLq4yo3BunaxrIVPPDZ3wxqCoEmBbPqwmTmITwlvOrSDOAEeccKoFAminUB irrP5SBTNbTxQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pIY3M-0007Mt-5P; Thu, 19 Jan 2023 17:46:16 +0100 From: Johan Hovold To: Ard Biesheuvel Cc: Matthew Garrett , Jeremy Kerr , Maximilian Luz , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/4] efivarfs: always register filesystem Date: Thu, 19 Jan 2023 17:42:53 +0100 Message-Id: <20230119164255.28091-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230119164255.28091-1-johan+linaro@kernel.org> References: <20230119164255.28091-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755514953792120577?= X-GMAIL-MSGID: =?utf-8?q?1755514953792120577?= The efivar ops are typically registered at subsys init time so that they are available when efivarfs is registered at module init time. Other efivars implementations, such as Google SMI, exists and can currently be build as modules which means that efivar may not be available when efivarfs is initialised. Move the efivar availability check from module init to when the filesystem is mounted to allow late registration of efivars. Signed-off-by: Johan Hovold --- fs/efivarfs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index f72c529c8ec3..b67d431c861a 100644 --- a/fs/efivarfs/super.c +++ b/fs/efivarfs/super.c @@ -194,6 +194,9 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc) struct dentry *root; int err; + if (!efivar_is_available()) + return -EOPNOTSUPP; + sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; @@ -256,9 +259,6 @@ static struct file_system_type efivarfs_type = { static __init int efivarfs_init(void) { - if (!efivar_is_available()) - return -ENODEV; - return register_filesystem(&efivarfs_type); } From patchwork Thu Jan 19 16:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 45862 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp436413wrn; Thu, 19 Jan 2023 08:57:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXvuof1bCz6q5Akj0zBWe/WBAXveONGmsLFYcMhdXr6pl1AjMWHTrOrJnhnvbyz6lEUCCPij X-Received: by 2002:a17:906:90c3:b0:870:b5bb:625d with SMTP id v3-20020a17090690c300b00870b5bb625dmr11914061ejw.16.1674147478241; Thu, 19 Jan 2023 08:57:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674147478; cv=none; d=google.com; s=arc-20160816; b=Vi/azrljUYz6wt+39knHbEpaMJMWCOYO1ZDDk4FHZ6PYQ/tTTyd1NCmYEHpVQpjwsw 3vg9HDeMebykigHnAqp3Qzk+xGnpdU287aerAaw2C0n6D9d3ZwpCXpv6QnSdTpB6zrOM kYxUIYSywNLsLxUctCPh1+Lx1JN0g5GeGrHvZd9amTM6pY00LN19eQd/zp2cv2f4/7RZ JtJgJ6dPjoyk+aXLMTNsagBz4XJ3gtBThgu1Hjxi6sGqmHP9Tqlh73o79BngU4H0i3kA l+2fM5i2xuinz7UcNbBo9DHWRE1DwwlhJ69iefcSUFhLrKmugiOLtMsZ+jpzfSahVRR8 TPsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qybvzKiStNiUNGATO663RjHw6VximamN/ZpXa1IOz+M=; b=0mhVCELE7zxKyJ3MJWPjGuNOeys9iAi5GJ5Hk1fCudHnj5lrDYlSV1MQH4WZMLJ3tc utfslB2MAlcxvaRVbI9/ILFT1DlvvuEK5i9/whwLZdqWG6G1d+8PDArfez/WUdge5M/+ 8stt7bAGQ+m8VuwjFMhkfAqsZ/MDfvTdPMkPSDER6rEQQ9x92GLwQsgPrdsr5K9AYW6b PS2ufJ89d11AQ6+71sZlRzZ198xZE8OhJibuj2hlrSqEYOIiyYdUGzH73xCU6tcsBo3o 65rKvN12wJBFx7s21ON0afSTQ3wAvc5W8j/hkdOZczvIqVtBlcR0QZctqeCW/ynHYUoZ AL0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FcC3eOC0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a1709062a0400b007adc8d6b77esi33886524eje.308.2023.01.19.08.57.34; Thu, 19 Jan 2023 08:57:58 -0800 (PST) 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=pass header.i=@kernel.org header.s=k20201202 header.b=FcC3eOC0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230451AbjASQqO (ORCPT + 99 others); Thu, 19 Jan 2023 11:46:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230403AbjASQqE (ORCPT ); Thu, 19 Jan 2023 11:46:04 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 756998BAA2; Thu, 19 Jan 2023 08:45:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C7B7ACE24F8; Thu, 19 Jan 2023 16:45:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E105C43392; Thu, 19 Jan 2023 16:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674146748; bh=QeWwkHCkmPI6InIWABry3ht60PE2twa3Wx83EnocKUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FcC3eOC0tK1JDm2vU5t6lG8N6tu2TTkZsEkQFINKv3WNnID1xUrnhqQa7j+fE2+eO LcdFhQp59mnpkqoWEGnz6PhnIH/Pg6NwhEDX7x3kj4AHY50PIe4zwX0LpS+WD+V/5J cwDq20s978Dr0himuRr1MO4WFz+zoObpD4Kinu4ZdJ1rDUhcwohVF99J00aZlaUHWT lAdsUpO2pS7hFAQTko8jDkFb2joMJ07UK8+jEeVo1m1033azICpEOXvSQaiwXi2shX DLK+9UsVAtYuOCeg4TWtEhoZF0yyCbbeDcOgI8Sya7pkc4vj0Daq03uym8g9IvcfYK UhqdEVTUPEutw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pIY3M-0007Mv-7w; Thu, 19 Jan 2023 17:46:16 +0100 From: Johan Hovold To: Ard Biesheuvel Cc: Matthew Garrett , Jeremy Kerr , Maximilian Luz , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 3/4] efi: verify that variable services are supported Date: Thu, 19 Jan 2023 17:42:54 +0100 Message-Id: <20230119164255.28091-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230119164255.28091-1-johan+linaro@kernel.org> References: <20230119164255.28091-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755470799327381840?= X-GMAIL-MSGID: =?utf-8?q?1755470866047343809?= Current Qualcomm UEFI firmware does not implement the variable services but not all revisions clear the corresponding bits in the RT_PROP table services mask and instead the corresponding calls return EFI_UNSUPPORTED. This leads to efi core registering the generic efivar ops even when the variable services are not supported or when they are accessed through some other interface (e.g. Google SMI or the upcoming Qualcomm SCM implementation). Instead of playing games with init call levels to make sure that the custom implementations are registered after the generic one, make sure that get_next_variable() is actually supported before registering the generic ops. Signed-off-by: Johan Hovold --- drivers/firmware/efi/efi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index a7f1a32537f1..03ccc4e8d1fc 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -187,8 +187,27 @@ static const struct attribute_group efi_subsys_attr_group = { static struct efivars generic_efivars; static struct efivar_operations generic_ops; +static bool generic_ops_supported(void) +{ + unsigned long name_size; + efi_status_t status; + efi_char16_t name; + efi_guid_t guid; + + name_size = sizeof(name); + + status = efi.get_next_variable(&name_size, &name, &guid); + if (status == EFI_UNSUPPORTED) + return false; + + return true; +} + static int generic_ops_register(void) { + if (!generic_ops_supported()) + return 0; + generic_ops.get_variable = efi.get_variable; generic_ops.get_next_variable = efi.get_next_variable; generic_ops.query_variable_store = efi_query_variable_store; @@ -202,6 +221,9 @@ static int generic_ops_register(void) static void generic_ops_unregister(void) { + if (!generic_ops.get_variable) + return; + efivars_unregister(&generic_efivars); } From patchwork Thu Jan 19 16:42:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 45861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp435955wrn; Thu, 19 Jan 2023 08:56:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXuyJMmMPNKBmmPTQB8buIm0rSJFhpQ7ciUaf3M9Z8d1ByIgjAM26FTJ36i06zPA98h2zTAJ X-Received: by 2002:a17:907:7f14:b0:84d:3e5b:7c02 with SMTP id qf20-20020a1709077f1400b0084d3e5b7c02mr10767669ejc.22.1674147415583; Thu, 19 Jan 2023 08:56:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674147415; cv=none; d=google.com; s=arc-20160816; b=qdRLBW8O+z5Ja6gwoqF1XgSnSkv40Q28g6XDtMDLgBFBtD6XB6tK7oR+fjgDs8Ww9e t3YHR2a7MqJszHppIlO4k/C2vlGYuyUSWrObs64VqATJKJshl238VpnNmOg23YtmaKRP aZO4m4NmTHltbRkcHBEV+vrYmWtIaNyKo4yy8ZskyMIPJZnwBNwY+qDJinWmEXaSaUbP DEx2pxz48ywZ/szGXm6FhHNwjFVWLHfvN4fP3qJoHsHDqHW7F5MKqhlFaIcVXYCVACUr MIIfI8OZL/dfTUvpTvhiAB77WnRRGtpFtfZY1QWxvT9EEIFGqqSjKWHDeDZnQfV9XgEO 1n7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rq0KuYbJtVEpo5YGCcj7QfqZwlDW9fGVxu1e1R6BqdM=; b=W703SaSGo6AtqFYbZrm2MBHsv8LD2Opf5fCdordtJ2gekq7PEyethO9opE986kplyK 1G2FazSnBlWdZBLekFXm6bDRlhPMIxdM+88nEQtkU4fwuY/M4jI3NmwWvo/73pEda2/l q6MNwvYPbUMPndl6pV3RomNMbZayPnRPalWR0Nescypf85xLUCwaHoPv1sI1+lSCL6HN evPgdqEHgVAqYRzbAnnKcvnhqm5KSzaX1W7uO7nuDeJYeRz4UcfrQphJ/Ym42LngR3RA h62cjsIdPOyMGRfHuGYHWWqxnyRQNP8/SsF8f1TAYucf59V9CQIZKUSeX0HN16dseJEM xjrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QvBnUIlJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw9-20020a170907a0c900b008774ec3fe91si6963070ejc.647.2023.01.19.08.56.32; Thu, 19 Jan 2023 08:56:55 -0800 (PST) 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=pass header.i=@kernel.org header.s=k20201202 header.b=QvBnUIlJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbjASQqA (ORCPT + 99 others); Thu, 19 Jan 2023 11:46:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjASQpv (ORCPT ); Thu, 19 Jan 2023 11:45:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E72458975; Thu, 19 Jan 2023 08:45:49 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A64761CDC; Thu, 19 Jan 2023 16:45:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2EB5C433F1; Thu, 19 Jan 2023 16:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674146748; bh=XeXJuV70b8QQ89031T2UsnyGwGhNXA27WLTobdUHe78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QvBnUIlJA0r4hT8+uu0mSag3a39SFxvH1ekgdar6RSpWa9Cqdh0t9UVAMzwVdJ66t Tnujp0eswYce5xvH99u9CXa+OocodvEkvGLDQ5+w9e8R7kx3mTkMHg+BBlJTZ8Onwj wEhodzItoVhF/usjpg7axTNYqWXBx8EtcycfZnSUH8I208NKyRBTRU24o4T+6gcw5M Ny8dQ5LS0NpHnCF9yvh3DzP9ay09XeF+4AtiiQFK1lIiNOYzOd1hj1K5i+0hKUEnS8 f/wMFhIk0q7m5ualI0qSNQA93/egjP+FTwooyePpgHQIZNFpKtKct0UkvaksxSimyr 1vWwdU2DyIofg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pIY3M-0007Mx-AT; Thu, 19 Jan 2023 17:46:16 +0100 From: Johan Hovold To: Ard Biesheuvel Cc: Matthew Garrett , Jeremy Kerr , Maximilian Luz , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 4/4] efi: efivars: prevent double registration Date: Thu, 19 Jan 2023 17:42:55 +0100 Message-Id: <20230119164255.28091-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230119164255.28091-1-johan+linaro@kernel.org> References: <20230119164255.28091-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755470800782257466?= X-GMAIL-MSGID: =?utf-8?q?1755470800782257466?= Add the missing sanity check to efivars_register() so that it is no longer possible to override an already registered set of efivar ops (without first deregistering them). This can help debug initialisation ordering issues where drivers have so far unknowingly been relying on overriding the generic ops. Signed-off-by: Johan Hovold --- drivers/firmware/efi/vars.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index f34e7741e0c3..bd75b87f5fc1 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -62,18 +62,27 @@ EXPORT_SYMBOL_GPL(efivar_is_available); int efivars_register(struct efivars *efivars, const struct efivar_operations *ops) { + int rv; + if (down_interruptible(&efivars_lock)) return -EINTR; + if (__efivars) { + pr_warn("efivars already registered\n"); + rv = -EBUSY; + goto out; + } + efivars->ops = ops; __efivars = efivars; pr_info("Registered efivars operations\n"); - + rv = 0; +out: up(&efivars_lock); - return 0; + return rv; } EXPORT_SYMBOL_GPL(efivars_register);