]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi: Create ECPT table
authorJose Marinho <jose.marinho@arm.com>
Thu, 23 Dec 2021 14:51:07 +0000 (14:51 +0000)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 3 Sep 2022 07:35:48 +0000 (09:35 +0200)
The ECPT table will be included in the UEFI specification 2.9+.
The ECPT table was introduced in UEFI following the code-first path. The
acceptance ticket can be viewed at:
https://bugzilla.tianocore.org/show_bug.cgi?id=3591

The Conformance Profiles table is a UEFI configuration table that contains
GUID of the UEFI profiles that the UEFI implementation conforms with.

The ECPT table is created when CONFIG_EFI_ECPT=y.
The config is set by default.

Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
include/efi_api.h
include/efi_loader.h
lib/efi_loader/Kconfig
lib/efi_loader/Makefile
lib/efi_loader/efi_conformance.c [new file with mode: 0644]
lib/efi_loader/efi_setup.c
lib/uuid.c

index 83c01085fded94a4a8a658c2759dc2bce4ff9152..58934bd0d588190190da7157252d25866a3ee9e9 100644 (file)
@@ -226,6 +226,18 @@ enum efi_reset_type {
        EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
                 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
 
+#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \
+       EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
+                0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)
+
+#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
+
+struct efi_conformance_profiles_table {
+       u16 version;
+       u16 number_of_profiles;
+       efi_guid_t      conformance_profiles[];
+} __packed;
+
 struct efi_capsule_header {
        efi_guid_t capsule_guid;
        u32 header_size;
index 9611aec2debddda96608971218c16a29e9266017..545ba06d9466dbe48d7c16860b906d84a634209a 100644 (file)
@@ -1052,6 +1052,13 @@ extern u8 num_image_type_guids;
  */
 efi_status_t efi_esrt_register(void);
 
+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void);
+
 /**
  * efi_esrt_populate() - Populates the ESRT entries from the FMP instances
  * present in the system.
index 5cfff8c56bc33ffc846f77590d71ea6b9102e175..2b2e9ae03ba269aff55a32330791c5f0974946ec 100644 (file)
@@ -385,6 +385,12 @@ config EFI_ESRT
        help
          Enabling this option creates the ESRT UEFI system table.
 
+config EFI_ECPT
+       bool "Enable the UEFI ECPT generation"
+       default y
+       help
+         Enabling this option created the ECPT UEFI table.
+
 config EFI_RISCV_BOOT_PROTOCOL
        bool "RISCV_EFI_BOOT_PROTOCOL support"
        default y
index f54c244c326895c77eb8a34f1db98368ceb0c9e8..e187d2a914f9526305189caefc17c48951a9e760 100644 (file)
@@ -76,6 +76,7 @@ obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
 obj-$(CONFIG_EFI_RISCV_BOOT_PROTOCOL) += efi_riscv.o
 obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
 obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
+obj-$(CONFIG_EFI_ECPT) += efi_conformance.o
 
 EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
 $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
new file mode 100644 (file)
index 0000000..385d76c
--- /dev/null
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  EFI conformance profile table
+ *
+ *  Copyright (C) 2022 Arm Ltd.
+ */
+
+#include <common.h>
+#include <efi_loader.h>
+#include <log.h>
+#include <efi_api.h>
+#include <malloc.h>
+
+static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+
+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void)
+{
+       int 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)
+               + sizeof(struct efi_conformance_profiles_table);
+       ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
+                               (void **)&ecpt);
+
+       if (ret != EFI_SUCCESS) {
+               log_err("Out of memory\n");
+
+               return ret;
+       }
+
+       ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
+       ecpt->number_of_profiles = num_entries;
+
+       /* Install the ECPT in the system configuration table. */
+       ret = efi_install_configuration_table(&efi_ecpt_guid, (void *)ecpt);
+       if (ret != EFI_SUCCESS) {
+               log_err("Failed to install ECPT\n");
+               efi_free_pool(ecpt);
+
+               return ret;
+       }
+
+       log_debug("ECPT created\n");
+
+       return EFI_SUCCESS;
+}
index 45a9a1d5004db327950a5a6cf2a70d8dfd314c13..c633fcd91e35e8d7bca79ecf1c5d4ed45f4a4d9d 100644 (file)
@@ -274,6 +274,12 @@ efi_status_t efi_init_obj_list(void)
        if (ret != EFI_SUCCESS)
                goto out;
 
+       if (IS_ENABLED(CONFIG_EFI_ECPT)) {
+               ret = efi_ecpt_register();
+               if (ret != EFI_SUCCESS)
+                       goto out;
+       }
+
        if (IS_ENABLED(CONFIG_EFI_ESRT)) {
                ret = efi_esrt_register();
                if (ret != EFI_SUCCESS)
index 284f8113ff8adf842a427a59923a67124138be36..465e1ac38f57df7295db61f8ed7e9d00a10a878b 100644 (file)
@@ -220,6 +220,10 @@ static const struct {
                "TCG2 Final Events Table",
                EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
        },
+       {
+               "EFI Conformance Profiles Table",
+               EFI_CONFORMANCE_PROFILES_TABLE_GUID,
+       },
 #ifdef CONFIG_EFI_RISCV_BOOT_PROTOCOL
        {
                "RISC-V Boot",