diff options
author | Matthew Garrett <matthewgarrett@google.com> | 2019-06-07 16:51:46 -0400 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2019-06-24 16:57:49 -0400 |
commit | 82d736ac56d7cd78696c5234853684bad05efadf (patch) | |
tree | 2e5b20a4133bb208c43519874482facebe36b29f /drivers/firmware | |
parent | db4d8cb9c9f2af71c4d087817160d866ed572cc9 (diff) |
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>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/efi/libstub/efi-stub-helper.c | 15 | ||||
-rw-r--r-- | drivers/firmware/efi/libstub/efistub.h | 2 | ||||
-rw-r--r-- | drivers/firmware/efi/libstub/fdt.c | 27 |
3 files changed, 26 insertions, 18 deletions
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index e4610e72b78f..1db780c0f07b 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c | |||
@@ -926,3 +926,18 @@ free_map: | |||
926 | fail: | 926 | fail: |
927 | return status; | 927 | return status; |
928 | } | 928 | } |
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 | } | ||
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 1b1dfcaa6fb9..7f1556fd867d 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h | |||
@@ -65,6 +65,8 @@ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg); | |||
65 | 65 | ||
66 | efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg); | 66 | efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg); |
67 | 67 | ||
68 | void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid); | ||
69 | |||
68 | /* Helper macros for the usual case of using simple C variables: */ | 70 | /* Helper macros for the usual case of using simple C variables: */ |
69 | #ifndef fdt_setprop_inplace_var | 71 | #ifndef fdt_setprop_inplace_var |
70 | #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \ | 72 | #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \ |
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c index 5440ba17a1c5..0bf0190917e0 100644 --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c | |||
@@ -363,26 +363,17 @@ fail: | |||
363 | 363 | ||
364 | void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size) | 364 | void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size) |
365 | { | 365 | { |
366 | efi_guid_t fdt_guid = DEVICE_TREE_GUID; | 366 | void *fdt; |
367 | efi_config_table_t *tables; | ||
368 | int i; | ||
369 | 367 | ||
370 | tables = (efi_config_table_t *)sys_table->tables; | 368 | fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID); |
371 | 369 | ||
372 | for (i = 0; i < sys_table->nr_tables; i++) { | 370 | if (!fdt) |
373 | void *fdt; | 371 | return NULL; |
374 | 372 | ||
375 | if (efi_guidcmp(tables[i].guid, fdt_guid) != 0) | 373 | if (fdt_check_header(fdt) != 0) { |
376 | continue; | 374 | pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n"); |
377 | 375 | return NULL; | |
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; | ||
385 | } | 376 | } |
386 | 377 | *fdt_size = fdt_totalsize(fdt); | |
387 | return NULL; | 378 | return fdt; |
388 | } | 379 | } |