diff options
| author | Vincent Stehlé <[email protected]> | 2026-02-12 15:40:15 +0100 |
|---|---|---|
| committer | Heinrich Schuchardt <[email protected]> | 2026-02-15 08:30:57 +0100 |
| commit | ca4eda24c64401eec477c4073e56d136d86f88b0 (patch) | |
| tree | 9e7de98eaed85e421b0ca5dd384047c5eeef71ed /lib/efi_loader | |
| parent | 05b13c05896f43a25f07e01385f156b2142f69aa (diff) | |
efi_loader: fix ecpt size computation
The size of the memory allocated for the EFI Conformance Profiles Table is
computed with `num_entries' always equal to zero, which is incorrect when
CONFIG_EFI_EBBR_2_1_CONFORMANCE is enabled.
This can be verified by allocating the ECPT memory with malloc() instead of
efi_allocate_pool(), building u-boot with sandbox_defconfig and
CONFIG_VALGRIND=y, and by finally running the following command:
valgrind --suppressions=scripts/u-boot.supp \
./u-boot -T -c 'efidebug tables'
Fix this by using an array of the supported profiles GUIDs instead, which
should also be easier to extend in the future as U-Boot should publish the
GUIDs for all supported EBBR revisions.
Fixes: 6b92c1735205 ("efi: Create ECPT table")
Suggested-by: Heinrich Schuchardt <[email protected]>
Signed-off-by: Vincent Stehlé <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Jose Marinho <[email protected]>
Reviewed-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'lib/efi_loader')
| -rw-r--r-- | lib/efi_loader/efi_conformance.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c index 2bae93a94bd..2d31800ccb8 100644 --- a/lib/efi_loader/efi_conformance.c +++ b/lib/efi_loader/efi_conformance.c @@ -13,8 +13,6 @@ #include <malloc.h> static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID; -static const efi_guid_t efi_ebbr_2_1_guid = - EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID; /** * efi_ecpt_register() - Install the ECPT system table. @@ -23,12 +21,17 @@ static const efi_guid_t efi_ebbr_2_1_guid = */ efi_status_t efi_ecpt_register(void) { - u16 num_entries = 0; struct efi_conformance_profiles_table *ecpt; efi_status_t ret; size_t ecpt_size; - ecpt_size = num_entries * sizeof(efi_guid_t) + static const efi_guid_t profiles[] = { + #if CONFIG_IS_ENABLED(EFI_EBBR_2_1_CONFORMANCE) + EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID, + #endif + }; + + ecpt_size = sizeof(profiles) + sizeof(struct efi_conformance_profiles_table); ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size, (void **)&ecpt); @@ -39,12 +42,9 @@ efi_status_t efi_ecpt_register(void) return ret; } - if (CONFIG_IS_ENABLED(EFI_EBBR_2_1_CONFORMANCE)) - guidcpy(&ecpt->conformance_profiles[num_entries++], - &efi_ebbr_2_1_guid); - + memcpy(ecpt->conformance_profiles, profiles, sizeof(profiles)); ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION; - ecpt->number_of_profiles = num_entries; + ecpt->number_of_profiles = ARRAY_SIZE(profiles); /* Install the ECPT in the system configuration table. */ ret = efi_install_configuration_table(&efi_ecpt_guid, (void *)ecpt); |
