efi: clean up config table description arrays
Ard Biesheuvel
maintainerPATCH 1/2 efi: clean up config table description arrays
Increase legibility by adding whitespace to the efi_config_table_type_t arrays that describe which EFI config tables we look for when going over the firmware provided list. While at it, replace the 'name' char pointer with a char array, which is more space efficient on relocatable 64-bit kernels, as it avoids a 8 byte pointer and the associated relocation data (24 bytes when using RELA format)
Signed-off-by Ard Biesheuvel <[email protected]>
--- arch/ia64/kernel/efi.c | 12 ++++++------ arch/x86/platform/efi/efi.c | 8 ++++---- drivers/firmware/efi/arm-init.c | 4 ++-- drivers/firmware/efi/efi.c | 28 ++++++++++++++-------------- include/linux/efi.h | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-)
arch/ia64/kernel/efi.c +6 -6
@@ -57,12 +57,12 @@ unsigned long hcdp_phys = EFI_INVALID_TABLE_ADDR;unsigned long sal_systab_phys =EFI_INVALID_TABLE_ADDR ;static const efi_config_table_type_t arch_tables[]__initconst = { - {ESI_TABLE_GUID ,"ESI" , &esi_phys}, - {HCDP_TABLE_GUID ,"HCDP" , &hcdp_phys}, - {MPS_TABLE_GUID ,"MPS" , &mps_phys}, - {PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID ,"PALO" , &palo_phys}, - {SAL_SYSTEM_TABLE_GUID ,"SALsystab" , &sal_systab_phys}, - {NULL_GUID ,NULL ,0 }, + {ESI_TABLE_GUID , &esi_phys,"ESI" }, + {HCDP_TABLE_GUID , &hcdp_phys,"HCDP" }, + {MPS_TABLE_GUID , &mps_phys,"MPS" }, + {PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID , &palo_phys,"PALO" }, + {SAL_SYSTEM_TABLE_GUID , &sal_systab_phys,"SALsystab" }, + {}, };extern efi_status_t efi_call_phys (void *, ...);
arch/x86/platform/efi/efi.c +4 -4
@@ -62,12 +62,12 @@ static unsigned long efi_runtime, efi_nr_tables;unsigned long efi_fw_vendor, efi_config_table;static const efi_config_table_type_t arch_tables[]__initconst = { - {EFI_PROPERTIES_TABLE_GUID ,"PROP" , &prop_phys}, - {UGA_IO_PROTOCOL_GUID ,"UGA" , &uga_phys}, + {EFI_PROPERTIES_TABLE_GUID , &prop_phys,"PROP" }, + {UGA_IO_PROTOCOL_GUID , &uga_phys,"UGA" }, #ifdef CONFIG_X86_UV - {UV_SYSTEM_TABLE_GUID ,"UVsystab" , &uv_systab_phys}, + {UV_SYSTEM_TABLE_GUID , &uv_systab_phys,"UVsystab" }, #endif - {NULL_GUID ,NULL ,NULL }, + {}, };static const unsigned long *const efi_tables[] = {
drivers/firmware/efi/arm-init.c +2 -2
@@ -54,8 +54,8 @@ static phys_addr_t __init efi_to_phys(unsigned long addr)static __initdata unsigned long screen_info_table =EFI_INVALID_TABLE_ADDR ;static const efi_config_table_type_t arch_tables[]__initconst = { - {LINUX_EFI_ARM_SCREEN_INFO_TABLE_GUID ,NULL , &screen_info_table}, - {NULL_GUID ,NULL ,NULL } + {LINUX_EFI_ARM_SCREEN_INFO_TABLE_GUID , &screen_info_table}, + {} };static void __init init_screen_info (void )
drivers/firmware/efi/efi.c +14 -14
@@ -502,21 +502,21 @@ void __init efi_mem_reserve(phys_addr_t addr, u64 size) }static const efi_config_table_type_t common_tables[]__initconst = { - {ACPI_20_TABLE_GUID ,"ACPI 2.0" , &efi.acpi20}, - {ACPI_TABLE_GUID ,"ACPI" , &efi.acpi}, - {SMBIOS_TABLE_GUID ,"SMBIOS" , &efi.smbios}, - {SMBIOS3_TABLE_GUID ,"SMBIOS 3.0" , &efi.smbios3}, - {EFI_SYSTEM_RESOURCE_TABLE_GUID ,"ESRT" , &efi.esrt}, - {EFI_MEMORY_ATTRIBUTES_TABLE_GUID ,"MEMATTR" , &efi_mem_attr_table}, - {LINUX_EFI_RANDOM_SEED_TABLE_GUID ,"RNG" , &efi_rng_seed}, - {LINUX_EFI_TPM_EVENT_LOG_GUID ,"TPMEventLog" , &efi.tpm_log}, - {LINUX_EFI_TPM_FINAL_LOG_GUID ,"TPMFinalLog" , &efi.tpm_final_log}, - {LINUX_EFI_MEMRESERVE_TABLE_GUID ,"MEMRESERVE" , &mem_reserve}, - {EFI_RT_PROPERTIES_TABLE_GUID ,"RTPROP" , &rt_prop}, + {ACPI_20_TABLE_GUID , &efi.acpi20,"ACPI 2.0" }, + {ACPI_TABLE_GUID , &efi.acpi,"ACPI" }, + {SMBIOS_TABLE_GUID , &efi.smbios,"SMBIOS" }, + {SMBIOS3_TABLE_GUID , &efi.smbios3,"SMBIOS 3.0" }, + {EFI_SYSTEM_RESOURCE_TABLE_GUID , &efi.esrt,"ESRT" }, + {EFI_MEMORY_ATTRIBUTES_TABLE_GUID , &efi_mem_attr_table,"MEMATTR" }, + {LINUX_EFI_RANDOM_SEED_TABLE_GUID , &efi_rng_seed,"RNG" }, + {LINUX_EFI_TPM_EVENT_LOG_GUID , &efi.tpm_log,"TPMEventLog" }, + {LINUX_EFI_TPM_FINAL_LOG_GUID , &efi.tpm_final_log,"TPMFinalLog" }, + {LINUX_EFI_MEMRESERVE_TABLE_GUID , &mem_reserve,"MEMRESERVE" }, + {EFI_RT_PROPERTIES_TABLE_GUID , &rt_prop,"RTPROP" }, #ifdef CONFIG_EFI_RCI2_TABLE - {DELLEMC_EFI_RCI2_TABLE_GUID ,NULL , &rci2_table_phys}, + {DELLEMC_EFI_RCI2_TABLE_GUID , &rci2_table_phys }, #endif - {NULL_GUID ,NULL ,NULL }, + {}, }; static __init int match_config_table(const efi_guid_t *guid,
@@ -529,7 +529,7 @@ static __init int match_config_table(const efi_guid_t *guid,for (i =0 ;efi_guidcmp (table_types[i].guid,NULL_GUID ); i++) {if (!efi_guidcmp (*guid, table_types[i].guid)) { *(table_types[i].ptr) = table; -if (table_types[i].name) +if (table_types[i].name[0 ])pr_cont (" %s=0x%lx " , table_types[i].name, table);return 1 ;
include/linux/efi.h +1 -1
@@ -379,8 +379,8 @@ typedef union {typedef struct {efi_guid_t guid; -const char *name;unsigned long *ptr; +const char name[16 ]; }efi_config_table_type_t ;#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
Signature · 1 line
2.17.1
Ard Biesheuvel
maintainerPATCH 2/2 efi: move arch_tables check to caller
Instead of making match_config_table() test its table_types pointer for NULL-ness, omit the call entirely if there is no arch_tables pointer was provided to efi_config_parse_tables().
Signed-off-by Ard Biesheuvel <[email protected]>
--- drivers/firmware/efi/efi.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/firmware/efi/efi.c +8 -10
@@ -525,15 +525,13 @@ static __init int match_config_table(const efi_guid_t *guid, {int i; -if (table_types) { -for (i =0 ;efi_guidcmp (table_types[i].guid,NULL_GUID ); i++) { -if (!efi_guidcmp (*guid, table_types[i].guid)) { - *(table_types[i].ptr) = table; -if (table_types[i].name[0 ]) -pr_cont (" %s=0x%lx " , - table_types[i].name, table); -return 1 ; - } +for (i =0 ;efi_guidcmp (table_types[i].guid,NULL_GUID ); i++) { +if (!efi_guidcmp (*guid, table_types[i].guid)) { + *(table_types[i].ptr) = table; +if (table_types[i].name[0 ]) +pr_cont (" %s=0x%lx " , + table_types[i].name, table); +return 1 ; } }
@@ -570,7 +568,7 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables, table = tbl32[i].table; } -if (!match_config_table (guid, table, common_tables)) +if (!match_config_table (guid, table, common_tables) && arch_tables)match_config_table (guid, table, arch_tables); }pr_cont ("\n" );
Signature · 1 line
2.17.1