Skip to content

Commit b61fbc8

Browse files
jwrdegoedeArd Biesheuvel
authored andcommitted
efi-stub: Fix get_efi_config_table on mixed-mode setups
Fix get_efi_config_table using the wrong structs when booting a 64 bit kernel on 32 bit firmware. Fixes: 82d736a ("Abstract out support for locating an EFI config table") Signed-off-by: Hans de Goede <[email protected]> Acked-By: Matthew Garrett <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Acked-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 5f9e832 commit b61fbc8

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

drivers/firmware/efi/libstub/efi-stub-helper.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -927,17 +927,33 @@ efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg,
927927
return status;
928928
}
929929

930+
#define GET_EFI_CONFIG_TABLE(bits) \
931+
static void *get_efi_config_table##bits(efi_system_table_t *_sys_table, \
932+
efi_guid_t guid) \
933+
{ \
934+
efi_system_table_##bits##_t *sys_table; \
935+
efi_config_table_##bits##_t *tables; \
936+
int i; \
937+
\
938+
sys_table = (typeof(sys_table))_sys_table; \
939+
tables = (typeof(tables))(unsigned long)sys_table->tables; \
940+
\
941+
for (i = 0; i < sys_table->nr_tables; i++) { \
942+
if (efi_guidcmp(tables[i].guid, guid) != 0) \
943+
continue; \
944+
\
945+
return (void *)(unsigned long)tables[i].table; \
946+
} \
947+
\
948+
return NULL; \
949+
}
950+
GET_EFI_CONFIG_TABLE(32)
951+
GET_EFI_CONFIG_TABLE(64)
952+
930953
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid)
931954
{
932-
efi_config_table_t *tables = (efi_config_table_t *)sys_table->tables;
933-
int i;
934-
935-
for (i = 0; i < sys_table->nr_tables; i++) {
936-
if (efi_guidcmp(tables[i].guid, guid) != 0)
937-
continue;
938-
939-
return (void *)tables[i].table;
940-
}
941-
942-
return NULL;
955+
if (efi_is_64bit())
956+
return get_efi_config_table64(sys_table, guid);
957+
else
958+
return get_efi_config_table32(sys_table, guid);
943959
}

0 commit comments

Comments
 (0)