From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C63CEC433EF for ; Fri, 17 Dec 2021 17:19:52 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A8B183433; Fri, 17 Dec 2021 18:19:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="VpWRkCJB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 050108347C; Fri, 17 Dec 2021 18:19:48 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 985518304C for ; Fri, 17 Dec 2021 18:19:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1639761580; bh=O37olLaLLo+Ak1qAn5YoE0bn92xLcFilWShom41MGdw=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=VpWRkCJBmQTae53619pXJM8dNGBPPpGCM9ovWSglOuj0S8EdYVHfxr92jKyJf0Bfj lLEh+TzM1ZVlTp08d/Q5xy0H4nftDC4jsBvxCdX93RLP3N8JXbUETIeQpGrXzFzdQR /md9gWYOsA4sC4A52p/qTsBC36OBIjIAQ9F2eygs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([88.152.144.157]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N2mBQ-1mUPC41rXY-0135LN; Fri, 17 Dec 2021 18:19:40 +0100 Message-ID: Date: Fri, 17 Dec 2021 18:19:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 1/3] efi: Create ECPT table Content-Language: en-US To: Jose Marinho , u-boot@lists.denx.de Cc: ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, takahiro.akashi@linaro.org, agraf@csgraf.de, nd@arm.com References: <20211217125506.138902-1-jose.marinho@arm.com> <20211217125506.138902-2-jose.marinho@arm.com> From: Heinrich Schuchardt In-Reply-To: <20211217125506.138902-2-jose.marinho@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:12+Eeprgt/1WMzgMblQqJbvDMWChQaZQGj0G77XhoZ7UfA1TMfF L5CzQOJAxBkxTNHnLFDpOxVnLB9V+3JVFeKsanRPhR1StWrAr4iW2xF03PSdrrSSYbCx8T7 5QDb8BEH33rXtGaIVVcpRhEjdFwfYYQCBf97GbL6yxZ2XyleRx6NwgMXWlkJc3LtE8XITxq MscVomHSlScYrHI83u7gA== X-UI-Out-Filterresults: notjunk:1;V03:K0:ZJYUNM07wQc=:kI4A7E/RVfKHImFR7b5X20 pKmUeP/rL0jX8XiMZyD8OlQuhRA/6tj+dgtoytSnYbHRIfAv80a/BqUyCPHJZN4H6iIk3QZl2 MERlKIT/RJ+J+azz7QmbdlV6Ug3ze/Kl+JpJsypnaEYol0jaqYOgrnSgjcUuBkz/YDolPnM94 PXjXT1pZ2zZr6OII37YMGWjQ2hVunG6fK91YUc+8Dre2rIlFXA3NsDp6h0ityTgb3txQu0quj zrrdygYbnDm0Q0BV/qNWRxl9gcM5Sd4eW3jgEXl1/WP9bhol4jX1T8WIIUx6OR0eVRXCPOMTU MAKxQzzjWUc3G8k4c4ypY3wGjXfrgBvsH1ZDAyjua+wc5o5GEjYLcPPOBaxz/fkN8mlf2Z4yn LlfFhv9wGbi9Kov5nVQ+LTijXe95yEWHHl60Asc8k+l97+MJCBv5QXfnsaacMsGyQ20zMqVwz Vo7qsL5tBqAKT3glh47in7Guih3JXg9b6HlduwYBdNATjLi0hcvuk0wLOQveWZ/ukDxnxCbYI tdgh3uPO+GEYF8/IGcIgS91v5WxCLZP9CEz5y+5nKzod06U3e8uoOeB9k4K12zjx/JWFpBdXM n2pEfRDeqW9cHI+ooLLxOMdft+ZxAX2NHUkuhoyDnvwN4Id4tmLNwVHPp8CKXap1USYg6penP 9NXtK/K/G+TJkJ+kJZMJxNSiQdWQSc0N6CJWr1vKlXbzTUcve2TNYarq+I9ysjR11Lzhny8kC fj4NJVdVDuT7VMQg4mR85+0hwI/eUhJv264KHWfw7edAtfLxU3wPYE7an46g2BfVc6Zpa7owS udKRbpOfEPIZbehLE4XqLtucdctKJATePK0RdmcGPlftDIJxP0hAguRZ/Tunqly+fn53PfUl2 bIUcBaBzi0Wm5BAcNza8AYGay7Z/gUbJkZ6022E7SwQlpOUsJXdKUnegRNo7g6KuCsN3GpPzx JQ7SbNQ0kaind+HC8qP+oNGCasHovjGyPq7f0kmMYspu0dYavdNsHrsgpRvQZCEvGZIyyMvz+ PI+/xUgEVKCEEZD8Hap8JN7KS4/+0poOkKpKhTjI/CB8S0P+/VwLFn+xWjnz7mmIBOgNo3S5N ooswHscUl6RLYs= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 12/17/21 13:55, Jose Marinho wrote: > 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=3D3591 > > The Conformance Profiles table is a UEFI configuration table that contai= ns > GUID of the UEFI profiles that the UEFI implementation conforms with. > > The ECPT table is created when CONFIG_EFI_ECPT=3Dy. > The config is set by default. > > Signed-off-by: Jose Marinho > --- > 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, Just as side note. Consider sending a patch for GRUB to amend: grub-core/commands/efi/lsefisystab.c include/grub/efi/api.h > + }, > }; > > /** > 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 *c= apsule, > */ > 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 insta= nces > * 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) +=3D efi_rng.o > obj-$(CONFIG_EFI_TCG2_PROTOCOL) +=3D efi_tcg2.o > obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) +=3D efi_load_initrd.o > obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) +=3D efi_signature.o > +obj-$(CONFIG_EFI_ECPT) +=3D efi_conformance.o > > EFI_VAR_SEED_FILE :=3D $(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_confo= rmance.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 > +#include > +#include > +#include > +#include > + > +const efi_guid_t efi_ecpt_guid =3D 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 =3D 0; Shouldn't we add EFI_CONFORMANCE_PROFILES_EBBR_2_0_GUID as entry? What would be the point of adding an empty ECPT table? > + struct efi_conformance_profiles_table *ecpt; > + efi_status_t ret; > + size_t ecpt_size =3D 0; > + > + EFI_PRINT("ECPT table creation start\n"); This function is not called via the EFI API. Please, use log_debug(). Best regards Heinrich > + > + ecpt_size =3D num_entries * sizeof(efi_guid_t) > + + sizeof(struct efi_conformance_profiles_table); > + ret =3D efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size, > + (void **)&ecpt); > + > + if (ret !=3D EFI_SUCCESS) { > + EFI_PRINT("ECPT cannot allocate memory for %u entries (%zu bytes)\n", > + num_entries, ecpt_size); > + > + return ret; > + } > + > + ecpt->version =3D EFI_CONFORMANCE_PROFILES_TABLE_VERSION; > + ecpt->number_of_profiles =3D 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 =3D efi_install_configuration_table(&efi_ecpt_guid, (void *)ecpt); > + if (ret !=3D 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 =3D 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 !=3D EFI_SUCCESS) > goto out; > > + if (IS_ENABLED(CONFIG_EFI_ECPT)) { > + ret =3D efi_ecpt_register(); > + if (ret !=3D EFI_SUCCESS) > + goto out; > + } > + > if (IS_ENABLED(CONFIG_EFI_ESRT)) { > ret =3D efi_esrt_register(); > if (ret !=3D EFI_SUCCESS)