u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Jose Marinho <jose.marinho@arm.com>
To: u-boot@lists.denx.de
Cc: Jose Marinho <jose.marinho@arm.com>,
	ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org,
	xypron.glpk@gmx.de, takahiro.akashi@linaro.org, agraf@csgraf.de,
	nd@arm.com
Subject: [PATCH 1/3] efi: Create ECPT table
Date: Fri, 17 Dec 2021 12:55:04 +0000	[thread overview]
Message-ID: <20211217125506.138902-2-jose.marinho@arm.com> (raw)
In-Reply-To: <20211217125506.138902-1-jose.marinho@arm.com>

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>
---
 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

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a977ca9c72..a53a5029fa 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -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,
+	},
 };
 
 /**
diff --git a/include/efi_api.h b/include/efi_api.h
index 80109f012b..6fd4f04de3 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -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;
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d52e399841..d20ff396d0 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -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.
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 700dc838dd..b2398976f4 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -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
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index fd344cea29..9f5a0cebd1 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -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)
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
new file mode 100644
index 0000000000..86c26d6b79
--- /dev/null
+++ b/lib/efi_loader/efi_conformance.c
@@ -0,0 +1,66 @@
+// 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>
+
+const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+
+#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
+
+/**
+ * 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 = 0;
+
+	EFI_PRINT("ECPT table creation start\n");
+
+	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) {
+		EFI_PRINT("ECPT cannot allocate memory for %u entries (%zu bytes)\n",
+			  num_entries, ecpt_size);
+
+		return ret;
+	}
+
+	ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
+	ecpt->number_of_profiles = num_entries;
+
+	if (num_entries)
+		EFI_PRINT("ECPT check conformance profiles, not all entries populated in table\n");
+
+	/* Install the ECPT in the system configuration table. */
+	ret = efi_install_configuration_table(&efi_ecpt_guid, (void *)ecpt);
+	if (ret != EFI_SUCCESS) {
+		EFI_PRINT("ECPT failed to install the ECPT in the system table\n");
+		goto error;
+	}
+
+	EFI_PRINT("ECPT table successfully created\n");
+
+	return ret;
+
+error:
+
+	ret = efi_free_pool(ecpt);
+
+	return ret;
+}
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 1aba71cd96..fa5ad13500 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -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)
-- 
2.25.1


  reply	other threads:[~2021-12-17 12:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 12:55 [PATCH 0/3] Conformance Profiles Table support in U-boot Jose Marinho
2021-12-17 12:55 ` Jose Marinho [this message]
2021-12-17 17:19   ` [PATCH 1/3] efi: Create ECPT table Heinrich Schuchardt
2021-12-23 15:01     ` Jose Marinho
2021-12-17 12:55 ` [PATCH 2/3] efi: ECPT add EBBRv2.0 conformance profile Jose Marinho
2021-12-17 17:26   ` Heinrich Schuchardt
2021-12-23 14:57     ` Jose Marinho
2021-12-23 18:31       ` Heinrich Schuchardt
2021-12-31 14:36         ` Jose Marinho
2022-01-01 23:56           ` Heinrich Schuchardt
2022-08-29 23:58             ` Heinrich Schuchardt
2021-12-17 12:55 ` [PATCH 3/3] cmd: efi: efidebug print ECPT table Jose Marinho
2021-12-17 13:29   ` Heinrich Schuchardt
2021-12-17 18:07   ` Heinrich Schuchardt
2021-12-23 14:59     ` Jose Marinho
2021-12-17 18:05 ` [PATCH 0/3] Conformance Profiles Table support in U-boot Heinrich Schuchardt
2021-12-23 15:20   ` Jose Marinho
2021-12-23 18:27     ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211217125506.138902-2-jose.marinho@arm.com \
    --to=jose.marinho@arm.com \
    --cc=agraf@csgraf.de \
    --cc=ilias.apalodimas@linaro.org \
    --cc=nd@arm.com \
    --cc=sughosh.ganu@linaro.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).