* [PATCH] efi: Avoid weak references to arch-specific objects
@ 2026-11-23 12:24 Ard Biesheuvel
0 siblings, 0 replies; only message in thread
From: Ard Biesheuvel @ 2026-11-23 12:24 UTC (permalink / raw)
To: linux-efi; +Cc: Ard Biesheuvel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 12:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 12:24 [PATCH] efi: Avoid weak references to arch-specific objects Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox