From: Val Packett <val@packett.cool>
To: Kees Cook <kees@kernel.org>, Tony Luck <tony.luck@intel.com>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
Ard Biesheuvel <ardb@kernel.org>
Cc: Val Packett <val@packett.cool>,
linux-hardening@vger.kernel.org, linux-efi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] efi: pstore: Support late setup with TEE-backed efivars ops
Date: Wed, 3 Dec 2025 01:28:29 -0300 [thread overview]
Message-ID: <20251203042850.14210-1-val@packett.cool> (raw)
On some platforms, EFI variable services only become available when an
appropriate TEE driver is initialized such as qseecom, gsmi or stmm.
This would work fine when efi_pstore was built as a module and loaded
late by userspace, but with CONFIG_EFI_VARS_PSTORE=y this driver would
quit due to non-writable efivars before the necessary driver had any
chance to load.
Listen to efivar_ops_nh notifications and retry the initialization when
writable EFI variable ops become available.
Signed-off-by: Val Packett <val@packett.cool>
---
drivers/firmware/efi/efi-pstore.c | 32 +++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index a253b6144945..ad5192d5892e 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -253,14 +253,11 @@ static struct pstore_info efi_pstore_info = {
.erase = efi_pstore_erase,
};
-static int efivars_pstore_init(void)
+static int efivars_pstore_setup(void)
{
if (!efivar_supports_writes())
return 0;
- if (pstore_disable)
- return 0;
-
/*
* Notice that 1024 is the minimum here to prevent issues with
* decompression algorithms that were spotted during tests;
@@ -285,8 +282,35 @@ static int efivars_pstore_init(void)
return 0;
}
+static int efivars_pstore_ops_notifier(struct notifier_block *nb,
+ unsigned long event, void *data)
+{
+ if (event == EFIVAR_OPS_RDWR && !efi_pstore_info.bufsize)
+ efivars_pstore_setup();
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block efivars_pstore_ops_notifier_block = {
+ .notifier_call = efivars_pstore_ops_notifier,
+};
+
+static int efivars_pstore_init(void)
+{
+ if (pstore_disable)
+ return 0;
+
+ blocking_notifier_chain_register(&efivar_ops_nh,
+ &efivars_pstore_ops_notifier_block);
+
+ return efivars_pstore_setup();
+}
+
static void efivars_pstore_exit(void)
{
+ blocking_notifier_chain_unregister(&efivar_ops_nh,
+ &efivars_pstore_ops_notifier_block);
+
if (!efi_pstore_info.bufsize)
return;
--
2.51.0
next reply other threads:[~2025-12-03 4:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 4:28 Val Packett [this message]
2025-12-04 9:49 ` [PATCH] efi: pstore: Support late setup with TEE-backed efivars ops Ilias Apalodimas
2025-12-04 20:57 ` Val Packett
2025-12-05 10:27 ` Ard Biesheuvel
2025-12-05 10:56 ` Ilias Apalodimas
2025-12-04 23:36 ` Kees Cook
2025-12-10 8:40 ` kernel test robot
2025-12-10 9:13 ` Ard Biesheuvel
2025-12-10 14:28 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251203042850.14210-1-val@packett.cool \
--to=val@packett.cool \
--cc=ardb@kernel.org \
--cc=gpiccoli@igalia.com \
--cc=kees@kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox