[PATCH master 35/39] efi: loader: fix co-existence with EFI payload support

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 16 00:44:35 PST 2026


We can enable both EFI loader and payload support at the same time,
so we should take care at runtime to skip initialization that's not
applicable. On the payload side, this is taken care of by EFI payload
specific initcalls, but on the EFI loader side, we are missing some
explicit handling for defaultvars and deferred protocol inits.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 efi/loader/defaultvars.c | 4 ++++
 efi/loader/setup.c       | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/efi/loader/defaultvars.c b/efi/loader/defaultvars.c
index 4d8ec72d9166..906a68a47cf7 100644
--- a/efi/loader/defaultvars.c
+++ b/efi/loader/defaultvars.c
@@ -8,6 +8,7 @@
 #include <efi/error.h>
 #include <efi/guid.h>
 #include <efi/loader.h>
+#include <efi/mode.h>
 #include <efi/variable.h>
 #include <linux/printk.h>
 #include <linux/string.h>
@@ -109,6 +110,9 @@ static char *efi_lang_codes;
 
 static int efi_defaultvars_init(void)
 {
+	if (efi_is_payload())
+		return 0;
+
 	efi_lang_codes = xstrdup("en-US");
 	dev_add_param_string(&efidev, "lang.codes", NULL, NULL,
 			     &efi_lang_codes, NULL);
diff --git a/efi/loader/setup.c b/efi/loader/setup.c
index e27929aaeae9..8309c0338b8f 100644
--- a/efi/loader/setup.c
+++ b/efi/loader/setup.c
@@ -97,8 +97,12 @@ static LIST_HEAD(efi_deferred_cbs);
 
 void efi_register_deferred_init(efi_status_t (*init)(void *), void *data)
 {
-	struct efi_deferred_cb *deferred = xzalloc(sizeof(*deferred));
+	struct efi_deferred_cb *deferred;
 
+	if (efi_is_payload())
+		return;
+
+	deferred = xzalloc(sizeof(*deferred));
 	deferred->cb = init;
 	deferred->data = data;
 	list_add_tail(&deferred->list, &efi_deferred_cbs);
-- 
2.47.3




More information about the barebox mailing list