Skip to contentSkip to conversation

Conformance Profiles Table support in U-boot

PATCH In review Jose Marinho 3 participants 6 messages Dec 23, 2021

lore
Share & tools
lore
#0 lore raw

v2 cover Conformance Profiles Table support in U-boot

patch v2:
- address v1 comments
- define EFI_EBBR_2_0_CONFORMANCE unconditionally.
- introduce ECPT EFI selftet
- drop the efidebug ECPT print

The Conformance Profiles Table (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

This patch set implements the ECPT table in U-boot.

Jose Marinho (3):
efi: Create ECPT table
efi: ECPT add EBBRv2.0 conformance profile
efi: ECPT EFI selftest

 cmd/efidebug.c                       |   4 +
 include/efi_api.h                    |  14 ++++
 include/efi_loader.h                 |   7 ++
 lib/efi_loader/Kconfig               |  11 +++
 lib/efi_loader/Makefile              |   1 +
 lib/efi_loader/efi_conformance.c     |  75 +++++++++++++++++++
 lib/efi_loader/efi_setup.c           |   6 ++
 lib/efi_selftest/Makefile            |   2 +
 lib/efi_selftest/efi_selftest_ecpt.c | 105 +++++++++++++++++++++++++++
 9 files changed, 225 insertions(+)
 create mode 100644 lib/efi_loader/efi_conformance.c
 create mode 100644 lib/efi_selftest/efi_selftest_ecpt.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 efi: Create ECPT table

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.

---
 cmd/efidebug.c                   |  4 ++
 include/efi_api.h                | 10 +++++
 include/efi_loader.h             |  7 ++++
 lib/efi_loader/Kconfig           |  6 +++
 lib/efi_loader/Makefile          |  1 +
 lib/efi_loader/efi_conformance.c | 66 ++++++++++++++++++++++++++++++++
 lib/efi_loader/efi_setup.c       |  6 +++
 7 files changed, 100 insertions(+)
 create mode 100644 lib/efi_loader/efi_conformance.c
cmd/efidebug.c +4 -0
index a977ca9c72..a53a5029fa 100644
@@ -619,6 +619,10 @@ static const struct {
 		"TCG2 Final Events Table",
 		EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
 	},
+	{
+		"EFI Conformance Profiles Table",
+		EFI_CONFORMANCE_PROFILES_TABLE_GUID,
+	},
 };
 
 /**
include/efi_api.h +10 -0
index 80109f012b..6fd4f04de3 100644
@@ -226,6 +226,16 @@ 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)
+
+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;
include/efi_loader.h +7 -0
index d52e399841..d20ff396d0 100644
@@ -976,6 +976,13 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
  */
 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.
lib/efi_loader/Kconfig +6 -0
index 700dc838dd..b2398976f4 100644
@@ -367,4 +367,10 @@ 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.
+
 endif
lib/efi_loader/Makefile +1 -0
index fd344cea29..9f5a0cebd1 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
 obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.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)
lib/efi_loader/efi_conformance.c new file +66 -0

66 lines not on this page · raw message

lib/efi_loader/efi_setup.c +6 -0
index 1aba71cd96..fa5ad13500 100644
@@ -231,6 +231,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)
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/3 efi: ECPT add EBBRv2.0 conformance profile

In reply to Jose Marinho

Display the EBBRv2.0 conformance in the ECPT table.

The EBBRv2.0 conformance profile is set in the ECPT if CONFIG_EFI_EBBR_2_0_CONFORMANCE=y.
The config defaults to 'n'.

---
 include/efi_api.h                | 4 ++++
 lib/efi_loader/Kconfig           | 5 +++++
 lib/efi_loader/efi_conformance.c | 9 +++++++++
 3 files changed, 18 insertions(+)
include/efi_api.h +4 -0
index 6fd4f04de3..49919caa35 100644
@@ -230,6 +230,10 @@ enum efi_reset_type {
 	EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
 		 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)
 
+#define EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID \
+	EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \
+		 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27)
+
 struct efi_conformance_profiles_table {
 	u16 version;
 	u16 number_of_profiles;
lib/efi_loader/Kconfig +5 -0
index b2398976f4..9688d48366 100644
@@ -373,4 +373,9 @@ config EFI_ECPT
 	help
 	  Enabling this option created the ECPT UEFI table.
 
+config EFI_EBBR_2_0_CONFORMANCE
+	bool "Add the EBBRv2.0 conformance entry to the ECPT table"
+	default n
+	help
+	  Enabling this option adds the EBBRv2.0 conformance entry to the ECPT UEFI table.
 endif
lib/efi_loader/efi_conformance.c +9 -0
index 1bb06c3b7e..325afe2d56 100644
@@ -12,6 +12,7 @@
 #include <malloc.h>
 
 const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+const efi_guid_t efi_ebbr_2_0_guid = EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID;
 
 #define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
 
@@ -29,6 +30,9 @@ efi_status_t efi_ecpt_register(void)
 
 	efi_debug("ECPT table creation start\n");
 
+	if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE))
+		num_entries++;
+
 	ecpt_size = num_entries * sizeof(efi_guid_t)
 		+ sizeof(struct efi_conformance_profiles_table);
 	ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
@@ -44,6 +48,11 @@ efi_status_t efi_ecpt_register(void)
 	ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
 	ecpt->number_of_profiles = num_entries;
 
+	if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE)) {
+		num_entries--;
+		guidcpy(&ecpt->conformance_profiles[num_entries], &efi_ecpt_guid);
+	}
+
 	if (num_entries)
 		efi_debug("ECPT check conformance profiles, not all entries populated in table\n");
 
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH v2 2/3] efi: ECPT add EBBRv2.0 conformance profile

Hi Jose,

Quoted 1 line · Jose Marinho

The config defaults to 'n'.

No need to mention this as it is the standard.

lib/efi_loader/Kconfig config EFI_ECPT · line 378

Quoted 3 lines
lib/efi_loader/Kconfig +3 -0
+config EFI_EBBR_2_0_CONFORMANCE
+       bool "Add the EBBRv2.0 conformance entry to the ECPT table"
+       default n

You should remove "default n"

#4 lore raw

PATCH v2 3/3 efi: ECPT EFI selftest

In reply to Jose Marinho

This test ensures the ECPT table is present and is consistent.

Invocation from the sandbox platform:
add to sandbox_defconfig:
+CONFIG_CMD_BOOTEFI_SELFTEST=y

make sandbox_capsule_defconfig all
./u-boot -d arch/sandbox/dts/test.dtb
bootefi selftest

---
 lib/efi_selftest/Makefile            |   2 +
 lib/efi_selftest/efi_selftest_ecpt.c | 105 +++++++++++++++++++++++++++
 2 files changed, 107 insertions(+)
 create mode 100644 lib/efi_selftest/efi_selftest_ecpt.c
lib/efi_selftest/Makefile +2 -0
index 9ff6e1760c..6cf548653f 100644
@@ -112,3 +112,5 @@ $(obj)/efi_selftest_loadimage.o: $(obj)/efi_miniapp_file_image_exit.h
 $(obj)/efi_selftest_startimage_exit.o: $(obj)/efi_miniapp_file_image_exit.h
 
 $(obj)/efi_selftest_startimage_return.o: $(obj)/efi_miniapp_file_image_return.h
+
+obj-$(CONFIG_EFI_ECPT) += efi_selftest_ecpt.o
lib/efi_selftest/efi_selftest_ecpt.c new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw
In reply to Jose Marinho
Quoted 8 lines · Jose Marinho

patch v2:
- address v1 comments
- define EFI_EBBR_2_0_CONFORMANCE unconditionally.
- introduce ECPT EFI selftet
- drop the efidebug ECPT print

The Conformance Profiles Table (ECPT) table will be included in the UEFI specification 2.9+.

@Samer:

The current spec draft assuming compliance if the table is not present makes no sense and needs to be fixed. U-Boot should not create a precedent of an implementation of this broken design.

@Jose:

As you cannot define under which circumstances the EBBR 2.0 GUID should be set we should not implement this table at all.

Best regards

Heinrich

Quoted 24 lines

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

This patch set implements the ECPT table in U-boot.

Jose Marinho (3):
efi: Create ECPT table
efi: ECPT add EBBRv2.0 conformance profile
efi: ECPT EFI selftest

  cmd/efidebug.c                       |   4 +
  include/efi_api.h                    |  14 ++++
  include/efi_loader.h                 |   7 ++
  lib/efi_loader/Kconfig               |  11 +++
  lib/efi_loader/Makefile              |   1 +
  lib/efi_loader/efi_conformance.c     |  75 +++++++++++++++++++
  lib/efi_loader/efi_setup.c           |   6 ++
  lib/efi_selftest/Makefile            |   2 +
  lib/efi_selftest/efi_selftest_ecpt.c | 105 +++++++++++++++++++++++++++
  9 files changed, 225 insertions(+)

create mode 100644 lib/efi_loader/efi_conformance.c create mode 100644 lib/efi_selftest/efi_selftest_ecpt.c