Skip to contentSkip to conversation

arm-bsp/corstone1000: add partial esrt support

PATCH Applied [email protected] 2 participants 6 messages Oct 14, 2022

lore
Share & tools
lore
#0 lore raw

cover arm-bsp/corstone1000: add partial esrt support

From: Mohamed Omar Asaker <[email protected]>

Add esrt support in u-boot and TFM

Satish Kumar (4):
arm-bsp/u-boot: corstone1000: esrt support arm-bsp/trusted-firmware-m: corstone1000: bump tfm SHA arm-bsp/trusted-firmware-m: corstone1000: fix sournce dir of libmetal
and openamp
arm-bsp/trusted-firmware-m: corstone1000: secure debug code checkout
from yocto

 .../trusted-firmware-m-corstone1000.inc       |  31 ++-
 .../0030-arm-corstone1000-esrt-support.patch  | 223 ++++++++++++++++++
 .../recipes-bsp/u-boot/u-boot_%.bbappend      |   3 +-
 3 files changed, 254 insertions(+), 3 deletions(-)
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-arm-corstone1000-esrt-support.patch
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/4 arm-bsp/u-boot: corstone1000: esrt support

From: Satish Kumar <[email protected]>

---
 .../0030-arm-corstone1000-esrt-support.patch  | 223 ++++++++++++++++++
 .../recipes-bsp/u-boot/u-boot_%.bbappend      |   3 +-
 2 files changed, 225 insertions(+), 1 deletion(-)
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-arm-corstone1000-esrt-support.patch
meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-arm-corstone1000-esrt-support.patch new file +223 -0
new file mode 100644
index 00000000..2db5c2a1
@@ -0,0 +1,223 @@
+From d8fca6ebd5917df9a12dbf1da6a97f99af06eee9 Mon Sep 17 00:00:00 2001
+From: Satish Kumar <[email protected]>
+Date: Fri, 19 Aug 2022 09:18:33 +0100
+Subject: [PATCH] arm/corstone1000: esrt support
+
+The implementation is platform specific and would require
+change in future.
+
+The patch should not be upstreamed as it is to the u-boot.
+Redesign of FMP protocol for ESRT and Capsule Update interface
+is to be considered in the future.
+
+Signed-off-by: Satish Kumar <[email protected]>
+Upstream-Status: Inappropriate [Redesign of FMP protocol for ESRT and Capsule update interface is required]
+---
+ include/efi_api.h             |   2 +-
+ lib/efi_loader/efi_firmware.c | 133 ++++++++++++++++++++++++++++++++++
+ lib/efi_loader/efi_setup.c    |  16 ++--
+ 3 files changed, 142 insertions(+), 9 deletions(-)
+
+diff --git a/include/efi_api.h b/include/efi_api.h
+index 83c01085fd..26899afd01 100644
+--- a/include/efi_api.h
++++ b/include/efi_api.h
+@@ -2014,7 +2014,7 @@ struct efi_firmware_image_descriptor {
+ 	u32 last_attempt_status;
+ 	u64 hardware_instance;
+ 	efi_firmware_image_dep_t *dependencies;
+-};
++} __packed;
+ 
+ struct efi_firmware_management_protocol {
+ 	efi_status_t (EFIAPI *get_image_info)(
+diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
+index 28d9a19edb..aa4af8036b 100644
+--- a/lib/efi_loader/efi_firmware.c
++++ b/lib/efi_loader/efi_firmware.c
+@@ -14,6 +14,7 @@
+ #include <signatures.h>
+ 
+ #include <linux/list.h>
++#include <efi_variable.h>
+ 
+ #define FMP_PAYLOAD_HDR_SIGNATURE	SIGNATURE_32('M', 'S', 'S', '1')
+ 
+@@ -416,8 +417,140 @@ efi_status_t EFIAPI efi_firmware_fit_set_image(
+ 	return EFI_EXIT(EFI_SUCCESS);
+ }
+ 
++#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
++
++/**
++ * efi_firmware_corstone1000_get_image_info - return information about the current
++                                    firmware image
++ * @this:                      Protocol instance
++ * @image_info_size:           Size of @image_info
++ * @image_info:                        Image information
++ * @descriptor_version:                Pointer to version number
++ * @descriptor_count:          Pointer to number of descriptors
++ * @descriptor_size:           Pointer to descriptor size
++ * package_version:            Package version
++ * package_version_name:       Package version's name
++ *
++ * Return information bout the current firmware image in @image_info.
++ * @image_info will consist of a number of descriptors.
++ * Each descriptor will be created based on efi fetched variable.
++ *
++ * Return              status code
++ */
++static
++efi_status_t EFIAPI efi_firmware_corstone1000_get_image_info(
++       struct efi_firmware_management_protocol *this,
++       efi_uintn_t *image_info_size,
++       struct efi_firmware_image_descriptor *image_info,
++       u32 *descriptor_version,
++       u8 *descriptor_count,
++       efi_uintn_t *descriptor_size,
++       u32 *package_version,
++       u16 **package_version_name)
++{
++	efi_uintn_t var_size;
++	efi_status_t ret = EFI_SUCCESS;
++	efi_uintn_t image_info_size_var = 0;
++	efi_uintn_t image_info_name_size_var;
++	efi_uintn_t image_info_version_size_var;
++	u8 *runner = (u8 *)image_info;
++	u16 fmp_image_name[14] = {'F', 'm', 'p', 'I', 'm', 'a', 'g', 'e', 'N', 'a', 'm', 'e', '1', '\0'};
++	u16 fmp_version_name[16] = {'F', 'm', 'p', 'V', 'e', 'r', 's', 'i', 'o', 'n', 'N', 'a', 'm', 'e', '1', '\0'};
++
++	EFI_ENTRY("%p %p %p %p %p %p %p %p\n", this,
++	          image_info_size, image_info,
++	          descriptor_version, descriptor_count, descriptor_size,
++	          package_version, package_version_name);
++
++	if (!image_info_size)
++	        return EFI_EXIT(EFI_INVALID_PARAMETER);
++
++	if (*image_info_size &&
++	    (!image_info || !descriptor_version || !descriptor_count ||
++	     !descriptor_size || !package_version || !package_version_name))
++	        return EFI_EXIT(EFI_INVALID_PARAMETER);
++
++	var_size = sizeof(*descriptor_version);
++	ret = efi_get_variable(u"FmpDescriptorVersion",
++	                           &efi_guid_firmware_management_protocol, NULL,
++	                           &var_size, descriptor_version);
++	if (ret != EFI_SUCCESS)
++	        return EFI_EXIT(ret);
++
++	if (*descriptor_version != EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION)
++	        return EFI_EXIT(EFI_UNSUPPORTED);
++
++	var_size = sizeof(image_info_size_var);
++	ret = efi_get_variable(u"FmpImageInfoSize",
++	                           &efi_guid_firmware_management_protocol, NULL,
++	                           &var_size, &image_info_size_var);
++	if (ret != EFI_SUCCESS)
++	        return EFI_EXIT(ret);
++
++	if (*image_info_size < image_info_size_var) {
++	        *image_info_size = image_info_size_var;
++	        return EFI_EXIT(EFI_BUFFER_TOO_SMALL);
++	}
++
++	image_info_name_size_var = image_info_size_var;
++
++	var_size = sizeof(*descriptor_count);
++	ret = efi_get_variable(u"FmpDescriptorCount",
++	                           &efi_guid_firmware_management_protocol, NULL,
++	                           &var_size, descriptor_count);
++	if (ret != EFI_SUCCESS) {
++	        return EFI_EXIT(ret);
++	}
++
++	ret = efi_get_variable(u"FmpImageInfo",
++	                           &efi_guid_firmware_management_protocol, NULL,
++	                           &image_info_size_var, image_info);
++	if (ret != EFI_SUCCESS)
++	        return EFI_EXIT(ret);
++
++	runner += image_info_size_var;
++
++	image_info_name_size_var -= image_info_size_var;
++	image_info_version_size_var = image_info_name_size_var;
++
++        /* Consider changing the string modfication logic */
++	fmp_image_name[12] = '0' + (u16)image_info->image_id;
++	ret = efi_get_variable(fmp_image_name,
++	                      &efi_guid_firmware_management_protocol, NULL,
++	                      &image_info_name_size_var, runner);
++	if (ret != EFI_SUCCESS)
++	       return EFI_EXIT(ret);
++
++	image_info_version_size_var -= image_info_name_size_var;
++	image_info->image_id_name = runner;
++	runner += image_info_name_size_var;
++
++        /* Consider changing the string modfication logic */
++	fmp_version_name[14] = '0' + (u16)image_info->image_id;
++	ret = efi_get_variable(fmp_version_name,
++	                       &efi_guid_firmware_management_protocol, NULL,
++	                       &image_info_version_size_var, runner);
++	if (ret != EFI_SUCCESS)
++	        return EFI_EXIT(ret);
++
++	image_info->version_name = runner;
++
++	*image_info_size = image_info_size_var;
++
++	*package_version = 0xffffffff; /* not supported */
++	*package_version_name = NULL; /* not supported */
++
++	return EFI_EXIT(ret);
++}
++
++#endif
++
+ const struct efi_firmware_management_protocol efi_fmp_fit = {
++#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
++	.get_image_info = efi_firmware_corstone1000_get_image_info,
++#else
+ 	.get_image_info = efi_firmware_get_image_info,
++#endif
+ 	.get_image = efi_firmware_get_image_unsupported,
+ 	.set_image = efi_firmware_fit_set_image,
+ 	.check_image = efi_firmware_check_image_unsupported,
+diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
+index 6c9e14c37e..6ccda175ff 100644
+--- a/lib/efi_loader/efi_setup.c
++++ b/lib/efi_loader/efi_setup.c
+@@ -168,13 +168,6 @@ static efi_status_t efi_init_capsule(void)
+ 
+ #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+ 	int ffa_ret;
+-
+-	ffa_ret = efi_corstone1000_uboot_efi_started_event();
+-	if (ffa_ret)
+-		debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n");
+-	else
+-		debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n");
+-
+ 	ret = efi_corstone1000_alloc_capsule_shared_buf();
+ 	if (ret != EFI_SUCCESS) {
+ 		printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n");
+@@ -306,7 +299,14 @@ efi_status_t efi_init_obj_list(void)
+ 		if (ret != EFI_SUCCESS)
+ 			goto out;
+ 	}
+-
++#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
++		int ffa_ret;
++		ffa_ret = efi_corstone1000_uboot_efi_started_event();
++		if (ffa_ret)
++			debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n");
++		else
++			debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n");
++#endif
+ 	/* Initialize variable services */
+ 	ret = efi_init_variables();
+ 	if (ret != EFI_SUCCESS)
+-- 
+2.25.1
+
meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend +2 -1
index 420cee65..465f0349 100644
@@ -47,7 +47,8 @@ SRC_URI:append:corstone1000 = " \
         file://0027-corstone1000-use-a-compressed-kernel.patch \
         file://0028-Introduce-external-sys-driver-to-device-tree.patch \
         file://0029-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch \
-        "
+        file://0030-arm-corstone1000-esrt-support.patch \
+      "
 
 #
 # FVP BASE
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/4 arm-bsp/trusted-firmware-m: corstone1000: bump tfm SHA

In reply to [email protected]

From: Satish Kumar <[email protected]>

The patch bumps the tfm SHA to
b065a6b28cc6c692b99e4f7e9387d96f51bf4d07

---
 .../trusted-firmware-m-corstone1000.inc          | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-corstone1000.inc +16 -0
index 95c49d06..e57b1a97 100644
@@ -11,6 +11,22 @@ TFM_PLATFORM_IS_FVP ?= "FALSE"
 EXTRA_OECMAKE += "-DPLATFORM_IS_FVP=${TFM_PLATFORM_IS_FVP}"
 EXTRA_OECMAKE += "-DCC312_LEGACY_DRIVER_API_ENABLED=OFF"
 
+SRCBRANCH_tfm = "master"
+SRC_URI  = "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=https;branch=${SRCBRANCH_tfm};name=tfm;destsuffix=git/tfm \
+            git://git.trustedfirmware.org/TF-M/tf-m-tests.git;protocol=https;branch=master;name=tfm-tests;destsuffix=git/tf-m-tests \
+            git://github.com/ARMmbed/mbedtls.git;protocol=https;branch=master;name=mbedtls;destsuffix=git/mbedtls \
+            git://github.com/mcu-tools/mcuboot.git;protocol=https;branch=main;name=mcuboot;destsuffix=git/mcuboot \
+            "
+
+# Bumping the SHA of TFM is required as multiple changes are needed in the TFM to support the ESRT 
+# The most crucial change needed is TFM support for UEFI FMP Image Information 
+SRCREV_tfm = "b065a6b28cc6c692b99e4f7e9387d96f51bf4d07"
+SRCREV_mbedtls = "869298bffeea13b205343361b7a7daf2b210e33d"
+SRCREV_mcuboot = "c657cbea75f2bb1faf1fceacf972a0537a8d26dd"
+SRCREV_tfm-tests = "3e6c52b4b255e4b1343ba6a257a77fa7a976e8fb"
+PV .= "+git${SRCPV}"
+SRCREV_FORMAT ?= "tfm"
+
 # libmetal
 LICENSE += "& BSD-3-Clause"
 LIC_FILES_CHKSUM += "file://../libmetal/LICENSE.md;md5=fe0b8a4beea8f0813b606d15a3df3d3c"
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/4 arm-bsp/trusted-firmware-m: corstone1000: fix sournce dir of libmetal and openamp

In reply to [email protected]

From: Satish Kumar <[email protected]>

The patch corrects the source dir for libmetal and openamp.

Devtool modify on tf-m will work after this fix.

---
 .../trusted-firmware-m/trusted-firmware-m-corstone1000.inc    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-corstone1000.inc +2 -2
index e57b1a97..3cd1a4bb 100644
@@ -32,14 +32,14 @@ LICENSE += "& BSD-3-Clause"
 LIC_FILES_CHKSUM += "file://../libmetal/LICENSE.md;md5=fe0b8a4beea8f0813b606d15a3df3d3c"
 SRC_URI += "git://github.com/OpenAMP/libmetal.git;protocol=https;branch=main;name=libmetal;destsuffix=git/libmetal"
 SRCREV_libmetal = "f252f0e007fbfb8b3a52b1d5901250ddac96baad"
-EXTRA_OECMAKE += "-DLIBMETAL_SRC_PATH=${WORKDIR}/git/libmetal -DLIBMETAL_BIN_PATH=${B}/libmetal-build"
+EXTRA_OECMAKE += "-DLIBMETAL_SRC_PATH=${S}/../libmetal -DLIBMETAL_BIN_PATH=${B}/libmetal-build"
 
 # OpenAMP
 LICENSE += "& BSD-2-Clause & BSD-3-Clause"
 LIC_FILES_CHKSUM += "file://../openamp/LICENSE.md;md5=a8d8cf662ef6bf9936a1e1413585ecbf"
 SRC_URI += "git://github.com/OpenAMP/open-amp.git;protocol=https;branch=main;name=openamp;destsuffix=git/openamp"
 SRCREV_openamp = "347397decaa43372fc4d00f965640ebde042966d"
-EXTRA_OECMAKE += "-DLIBOPENAMP_SRC_PATH=${WORKDIR}/git/openamp -DLIBOPENAMP_BIN_PATH=${B}/libopenamp-build"
+EXTRA_OECMAKE += "-DLIBOPENAMP_SRC_PATH=${S}/../openamp -DLIBOPENAMP_BIN_PATH=${B}/libopenamp-build"
 
 do_install() {
   install -D -p -m 0644 ${B}/install/outputs/tfm_s_signed.bin ${D}/firmware/tfm_s_signed.bin
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/4 arm-bsp/trusted-firmware-m: corstone1000: secure debug code checkout from yocto

In reply to [email protected]

From: Satish Kumar <[email protected]>

Instead of checking out code through internal cmake, the patch explicitly checkout the psa-adac code.

---
 .../trusted-firmware-m-corstone1000.inc               | 11 +++++++++++
 1 file changed, 11 insertions(+)
meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-corstone1000.inc +11 -0
index 3cd1a4bb..dc57eacb 100644
@@ -41,6 +41,17 @@ SRC_URI += "git://github.com/OpenAMP/open-amp.git;protocol=https;branch=main;nam
 SRCREV_openamp = "347397decaa43372fc4d00f965640ebde042966d"
 EXTRA_OECMAKE += "-DLIBOPENAMP_SRC_PATH=${S}/../openamp -DLIBOPENAMP_BIN_PATH=${B}/libopenamp-build"
 
+# Secure Debug ADAC
+LICENSE += "& BSD-3-Clause"
+LIC_FILES_CHKSUM += "file://../psa-adac/license.rst;md5=07f368487da347f3c7bd0fc3085f3afa"
+SRC_URI += "git://git.trustedfirmware.org/shared/psa-adac.git;protocol=https;branch=master;name=psa-adac;destsuffix=git/psa-adac"
+SRCREV_psa-adac = "427923cc0152578d536fb2065154d5d0dd874910"
+# Secure debug is disabled by default
+EXTRA_OECMAKE += "-DPLATFORM_PSA_ADAC_SECURE_DEBUG=OFF"
+EXTRA_OECMAKE += "-DPLATFORM_PSA_ADAC_SOURCE_PATH=${S}/../psa-adac -DPLATFORM_PSA_ADAC_BUILD_PATH=${B}/libpsa-adac-build"
+
+DEPENDS += "trusted-firmware-a"
+
 do_install() {
   install -D -p -m 0644 ${B}/install/outputs/tfm_s_signed.bin ${D}/firmware/tfm_s_signed.bin
   install -D -p -m 0644 ${B}/install/outputs/bl2_signed.bin ${D}/firmware/bl2_signed.bin
Signature · 1 line
2.25.1
Applied
#5 lore raw
In reply to [email protected]
Quoted 11 lines · On Fri, 14 Oct 2022 12:02:47 +0100, [email protected] wrote:

Add esrt support in u-boot and TFM

Satish Kumar (4):
arm-bsp/u-boot: corstone1000: esrt support arm-bsp/trusted-firmware-m: corstone1000: bump tfm SHA arm-bsp/trusted-firmware-m: corstone1000: fix sournce dir of libmetal
and openamp
arm-bsp/trusted-firmware-m: corstone1000: secure debug code checkout
from yocto

[...]

Applied, thanks!

[1/4] arm-bsp/u-boot: corstone1000: esrt support

      commit: 60af2fc05334e13f38cdd8ff906ff12a2277dbcb
[2/4] arm-bsp/trusted-firmware-m: corstone1000: bump tfm SHA
      commit: 81181ed89818474bc6887b0383b4311099d482ca
[3/4] arm-bsp/trusted-firmware-m: corstone1000: fix sournce dir of libmetal and openamp
      commit: 0f49cad85fe69431d7de1a881e7fcbab51b70aa1
[4/4] arm-bsp/trusted-firmware-m: corstone1000: secure debug code checkout from yocto
      commit: 37ba0b162a363ec2884511b4994f36b48873df48

Best regards,

Signature · 1 line
Jon Mason <[email protected]>