From: Ard Biesheuvel <ardb+git@google.com>
To: linux-efi@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH] efi: Avoid weak references to arch-specific objects
Date: Mon, 23 Nov 2026 13:24:10 +0100 [thread overview]
Message-ID: <20261123122409.1096621-2-ardb+git@google.com> (raw)
From: Ard Biesheuvel <ardb@kernel.org>
There are two cases where generic EFI code in the kernel proper uses
weak references to refer to data objects that an architecture might not
define at all.
Unlike weak definitions, which guarantee that a definition will
ultimately exist, and where the weak attribute only decides which one
takes precedence, weak references are permitted to remain unsatisfied.
Given that PC relative symbol references in relocatable code cannot
reliably produce NULL, this forces the compiler to use a GOT slot when
the access is from code.
For data references (i.e., statically initialized global pointer
variables), it forces the use of a 24 byte RELA entry rather than a
single RELR bit for similar reasons.
Given that in both cases, only a single architecture does define the
symbols, and this is unlikely to change going forward, just replace the
weak references with Kconfig #ifdefs.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/efi-init.c | 5 +++--
drivers/firmware/efi/efi.c | 8 +++++---
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c
index 9f09b0d2daa0..58acb5d25adf 100644
--- a/drivers/firmware/efi/efi-init.c
+++ b/drivers/firmware/efi/efi-init.c
@@ -54,7 +54,7 @@ static phys_addr_t __init efi_to_phys(unsigned long addr)
return addr;
}
-extern __weak const efi_config_table_type_t efi_arch_tables[];
+extern const efi_config_table_type_t efi_arch_tables[];
/*
* x86 defines its own instance of sysfb_primary_display and uses
@@ -123,7 +123,8 @@ static int __init uefi_init(u64 efi_system_table)
goto out;
}
retval = efi_config_parse_tables(config_tables, systab->nr_tables,
- efi_arch_tables);
+ IS_ENABLED(CONFIG_ARM) ? efi_arch_tables
+ : NULL);
early_memunmap(config_tables, table_size);
out:
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 9bc22de0d67e..9d73aa5ebf92 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -157,18 +157,20 @@ static ssize_t fw_platform_size_show(struct kobject *kobj,
return sysfs_emit(buf, "%d\n", efi_enabled(EFI_64BIT) ? 64 : 32);
}
-extern __weak const struct kobj_attribute efi_attr_fw_vendor;
-extern __weak const struct kobj_attribute efi_attr_runtime;
-extern __weak const struct kobj_attribute efi_attr_config_table;
+extern const struct kobj_attribute efi_attr_fw_vendor;
+extern const struct kobj_attribute efi_attr_runtime;
+extern const struct kobj_attribute efi_attr_config_table;
static const struct kobj_attribute efi_attr_fw_platform_size =
__KOBJ_ATTR_RO(fw_platform_size);
static const struct attribute *const efi_subsys_attrs[] = {
&efi_attr_systab.attr,
&efi_attr_fw_platform_size.attr,
+#ifdef CONFIG_X86
&efi_attr_fw_vendor.attr,
&efi_attr_runtime.attr,
&efi_attr_config_table.attr,
+#endif
NULL,
};
--
2.56.1.750.gf70dc682cf-goog
reply other threads:[~2026-11-23 12:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261123122409.1096621-2-ardb+git@google.com \
--to=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=linux-efi@vger.kernel.org \
/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