efi: Avoid weak references to arch-specific objects
PATCH 1/1 efi: Avoid weak references to arch-specific objects
From: Ard Biesheuvel <[email protected]>
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.
--- drivers/firmware/efi/efi-init.c | 5 +++-- drivers/firmware/efi/efi.c | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/firmware/efi/efi-init.c +3 -2
@@ -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:
drivers/firmware/efi/efi.c +5 -3
@@ -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, +#endifNULL , };
Signature · 1 line
2.56.1.750.gf70dc682cf-goog