Skip to content

Commit 82d736a

Browse files
Matthew GarrettJarkko Sakkinen
authored andcommitted
Abstract out support for locating an EFI config table
We want to grab a pointer to the TPM final events table, so abstract out the existing code for finding an FDT table and make it generic. Signed-off-by: Matthew Garrett <mjg59@google.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent db4d8cb commit 82d736a

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,3 +926,18 @@ efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg,
926926
fail:
927927
return status;
928928
}
929+
930+
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid)
931+
{
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;
943+
}

drivers/firmware/efi/libstub/efistub.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
6565

6666
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
6767

68+
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid);
69+
6870
/* Helper macros for the usual case of using simple C variables: */
6971
#ifndef fdt_setprop_inplace_var
7072
#define fdt_setprop_inplace_var(fdt, node_offset, name, var) \

drivers/firmware/efi/libstub/fdt.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -363,26 +363,17 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
363363

364364
void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
365365
{
366-
efi_guid_t fdt_guid = DEVICE_TREE_GUID;
367-
efi_config_table_t *tables;
368-
int i;
366+
void *fdt;
369367

370-
tables = (efi_config_table_t *)sys_table->tables;
368+
fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID);
371369

372-
for (i = 0; i < sys_table->nr_tables; i++) {
373-
void *fdt;
370+
if (!fdt)
371+
return NULL;
374372

375-
if (efi_guidcmp(tables[i].guid, fdt_guid) != 0)
376-
continue;
377-
378-
fdt = (void *)tables[i].table;
379-
if (fdt_check_header(fdt) != 0) {
380-
pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
381-
return NULL;
382-
}
383-
*fdt_size = fdt_totalsize(fdt);
384-
return fdt;
373+
if (fdt_check_header(fdt) != 0) {
374+
pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
375+
return NULL;
385376
}
386-
387-
return NULL;
377+
*fdt_size = fdt_totalsize(fdt);
378+
return fdt;
388379
}

0 commit comments

Comments
 (0)