1
0
mirror of https://git.yoctoproject.org/meta-arm synced 2026-07-25 18:57:07 +00:00

Compare commits

..

13 Commits

Author SHA1 Message Date
Vishnu Banavath eb48eea801 arm-bsp/uboot: send bootcomplete event to secure enclave
On corstone1000 platform, Secure Enclave will be expecting
an event from uboot when it performs capsule update. Previously,
an event is sent at exitbootservice level. This will create a problem
when user wants to interrupt at UEFI shell, hence, it is required
to send an uboot efi initialized event at efi sub-system initialization
stage.

Change-Id: I7d16e184675d537d790365e1b03a414ac802694a
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-06 08:58:41 -05:00
Vishnu Banavath 15815c7d49 arm-bsp/secure-partitions: add check for null attribute field
UEFI spec says that if 0 is passed in the attributes filed in
setVariable() API, it means that it's a delete variable call.
Currently smm gateway doesn't handle this case. This change
is to add above mentioned check.

Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
Change-Id: Id3a54601d403102da5c5617d7b4da8ec51029200
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-04 14:43:27 -05:00
Gowtham Suresh Kumar 3d1183ab54 arm-bsp/u-boot: corstone1000: Disable mm_communicate failure log
When a getVariable() call is made with data size set to 0,
mm_communicate should return EFI_BUFFER_TOO_SMALL. This is
an expected behavior. There should not be any failure logs
in this case. So the error log is commented here.

Change-Id: Id5b36928b1450ef9f83d34a3ab7feb4839ff9734
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2022-01-04 14:43:13 -05:00
Vishnu Banavath 6124334645 arm-bsp/u-boot: fix EFI image load alignment
This patch is cherry-picked from upstream to fix misalignment
of efi load image

Change-Id: If64e635a80cd0b6ecb8f09c62aa2b248d0e36f4e
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2021-12-23 19:03:16 +00:00
Vishnu Banavath 6e16e76bf3 arm-bsp/u-boot: add ethernet device and enable configs for SCT
These changes are to add
* ethernet device SMC911x device and this is required to support
  bootfromnetwork SCT
* also enabled other config options to fix SCT issues

Change-Id: Ic6112c019cb08f77e29508ad47980f851f79088c
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2021-12-22 09:00:08 -05:00
Gowtham Suresh Kumar b7b634a788 arm-bsp/secure-partitions: Add error cases to setVariable() and getNextVariableName()
This patch fixes the SCT errors seen for setVariable() and
getNextVariableName() functions. The existing implementation of these
functions does not cover certain error conditions which are listed in
the uefi specification. This patch adds these changes.

Change-Id: Idcddc799588339de6729b73c0ceada5c2018dd4b
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-21 14:00:09 -05:00
Gowtham Suresh Kumar 2c084144c7 arm-bsp/secure-partitions: corstone1000: Change UID of variable index in SMM
This patch fixes the os_indications setVariable() failure. The variable
index UID in SMM gateway which was 1 is changed in this patch. TFM has a
special usage for variable with UID 1, which makes it write once only.
This is not required for SMM variable index.

Change-Id: I50d60b87d3ef44ffd50e71ec4f20d31fdacf7acd
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-21 14:00:09 -05:00
Vishnu Banavath 7afe7d50f1 arm-bsp/u-boot: populate ESRT table with image_info
These changes are to support populating corstone1000 image_info
to ESRT table

Change-Id: I6e5cdd8a3477fbf3c480bf7a725198841ed79796
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
2021-12-20 10:00:09 -05:00
Gowtham Suresh Kumar 5661a1d614 arm-bsp/security: Revert set append write TS patch
Change-Id: I6e8aea102ea24271097efe92f4eb820c68ff70d5
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-20 10:00:09 -05:00
Gowtham Suresh Kumar 9ac90c6b25 arm-bsp/u-boot: corstone1000: Fix SCT failures
This patch removes the CONFIG_CMD_DHCP and CONFIG_CMD_PING
config parameters from the defconfig. It also reverts the workaround
patch which disabled NV get and set on u-boot.

Change-Id: I80f41235dbca2e76003c28164b42f4403dadc499
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-20 10:00:09 -05:00
Gowtham Suresh Kumar 5f69e4a51b arm-bsp/secure-partitions: corstone1000: Configure storage in SMM gateway
This patch will add a macro to configure the volatile and
non volatile storage in SMM gateway. Few useful logs are
also added to the secure world.

Change-Id: Ifdb405a09a9a72718df8b335b9f42509dd8c850c
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2021-12-20 10:00:09 -05:00
Ross Burton 8613971bf0 arm/edk2-firmware: correctly set the target prefix in Clang builds
We set GCC5_AARCH64_PREFIX so the tools are prefixed correctly in GCC
builds, but didn't set CLANG38_AARCH64_PREFIX. This meant the clang build
used the host objcopy, which may not know about the target architecture.

Also these can just be the prefix and not a full path, as the binaries
are on $PATH.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-16 14:39:57 +00:00
Huifeng Zhang 33f5505b58 arm/fvpboot: change the execution order of do_write_fvpboot_conf
add the do_write_fvpboot_conf function into IMAGE_POSTPROCESS_COMMAND
so that this function can be called after the build system created the
final image output files.

It's possible that bitbake doesn't run start from the do_rootfs task but
run start from do_image_<type> at the stage of image generation.

For example, there are multiple partitions in the wic file and the
grub.cfg file is placed to the first partition and the rootfs is placed
to the second partition. At this time, if we change the content of
the grub.cfg file resided in the related recipe's directory and build,
the do_rootfs task won't be run by bitbake but a new wic file will be
generated. In this situation, the fvpconf file also won't be updated and
the 'bp.virtioblockdevice.image_path' is still pointing to a old image
file.

Issue-Id: SCM-3724
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
Change-Id: I7a41afa1d7471d09b60d118c4a6c99c57a6b548c
Signed-off-by: Jon Mason <jon.mason@arm.com>
2021-12-16 13:21:47 +00:00
20 changed files with 2486 additions and 2 deletions
@@ -0,0 +1,31 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From e6b420ce5d56fcc08aac2812ee5402686fa56fae Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Thu, 16 Dec 2021 17:25:29 +0000
Subject: [PATCH] Disable DHCP, PING config parameters
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
---
configs/corstone1000_defconfig | 2 --
1 file changed, 2 deletions(-)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index 3c00e13ceb..e11ffbfc89 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -31,10 +31,8 @@ CONFIG_CMD_NVEDIT_EFI=y
CONFIG_CMD_USB=y
CONFIG_CMD_ITEST=y
# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
# CONFIG_CMD_NFS is not set
CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
CONFIG_CMD_CACHE=y
CONFIG_CMD_EFIDEBUG=y
CONFIG_CMD_FAT=y
--
2.17.1
@@ -0,0 +1,48 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 2a8d1b3fb89ae68d126e16f8346405df8fcc3ed6 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Thu, 16 Dec 2021 19:36:18 +0000
Subject: [PATCH] Revert "corstone1000: Disable set/get of NV variables"
This reverts commit 5c77e9883ea29472c353d63c66a7f8ffd6ea367f.
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
---
lib/efi_loader/efi_setup.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index fcf2eae9cd..9e3399a28c 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -83,11 +83,7 @@ static efi_status_t efi_init_platform_lang(void)
ret = efi_set_variable_int(L"PlatformLang",
&efi_global_variable_guid,
- /*
- * This is a temporary change until NV memory is accessible
- * through OpenAmp.
- */
- //EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
1 + strlen(lang), lang, false);
@@ -214,11 +210,7 @@ static efi_status_t efi_clear_os_indications(void)
os_indications &=
~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED;
ret = efi_set_variable_int(L"OsIndications", &efi_global_variable_guid,
- /*
- * This is a temporary change until NV memory is accessible
- * through OpenAmp.
- */
- //EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(os_indications), &os_indications,
--
2.17.1
@@ -0,0 +1,31 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From 4820222f24901fbed8e0a87487603c0e06dfff5a Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 17 Dec 2021 19:46:52 +0000
Subject: [PATCH 1/3] corstone1000/defconfig: enable CAPSULE_FIRMWARE_RAW
config option
This change is to enable CAPSULE_FIRMWARE_RAW config option as
we use RAW image on corstone1000 target. Also, disable
CONFIG_EFI_CAPSULE_FIRMWARE_FIT
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
---
configs/corstone1000_defconfig | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index e11ffbfc89..d576ee1b67 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -65,3 +65,5 @@ CONFIG_EFI_SET_TIME=y
CONFIG_RTC_EMULATION=y
CONFIG_PSCI_RESET=y
CONFIG_DISTRO_DEFAULTS=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
+# CONFIG_EFI_CAPSULE_FIRMWARE_FIT is not set
--
2.25.1
@@ -0,0 +1,38 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From b9126620d74aed1a0ddd286e4c70344626dd72c3 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 17 Dec 2021 19:49:02 +0000
Subject: [PATCH 2/3] efi_loader: populate ESRT table if EFI_ESRT config option
is set
This change is to call efi_esrt_populate function if CONFIG_EFI_ESRT
is set. This will populte esrt table with firmware image info
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
---
lib/efi_loader/efi_capsule.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index ec89865c98..00b3b21105 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -591,6 +591,13 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
ret = EFI_SUCCESS;
}
+ if (IS_ENABLED(CONFIG_EFI_ESRT)) {
+ /* Rebuild the ESRT to reflect any updated FW images. */
+ ret = efi_esrt_populate();
+ if (ret != EFI_SUCCESS)
+ log_warning("EFI Capsule: failed to update ESRT\n");
+ }
+
goto out;
#endif
--
2.25.1
@@ -0,0 +1,119 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From 6a3f1d425321545869f00295d9173e3a3519a6c6 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 17 Dec 2021 19:50:25 +0000
Subject: [PATCH] efi_firmware: add get_image_info for corstone1000
This change is to populate get_image_info which eventually
will be populated in ESRT table
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
%% original patch: 0047-efi_firmware-add-get_image_info-for-corstone1000.patch
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index a1b88dbfc2..85fb5254eb 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -238,6 +238,7 @@ const efi_guid_t efi_firmware_image_type_uboot_fit =
*
* Return status code
*/
+
static
efi_status_t EFIAPI efi_firmware_fit_get_image_info(
struct efi_firmware_management_protocol *this,
@@ -329,6 +330,56 @@ const struct efi_firmware_management_protocol efi_fmp_fit = {
const efi_guid_t efi_firmware_image_type_uboot_raw =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
+#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
+static efi_status_t efi_corstone1000_img_info_get (
+ 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,
+ const efi_guid_t *image_type)
+{
+ int i = 0;
+
+ *image_info_size = sizeof(*image_info);
+ *descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
+ *descriptor_count = 1;//dfu_num;
+ *descriptor_size = sizeof(*image_info);
+ if (package_version)
+ *package_version = 0xffffffff; /* not supported */
+ if(package_version_name)
+ *package_version_name = NULL; /* not supported */
+
+ if(image_info == NULL) {
+ log_warning("image_info is null\n");
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ image_info[i].image_index = i;
+ image_info[i].image_type_id = *image_type;
+ image_info[i].image_id = 0;
+ image_info[i].image_id_name = "wic";
+ image_info[i].version = 1;
+ image_info[i].version_name = NULL;
+ image_info[i].size = 0x1000;
+ image_info[i].attributes_supported = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE |
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED;
+ image_info[i].attributes_setting = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE;
+ /* Check if the capsule authentication is enabled */
+ if (IS_ENABLED(CONFIG_EFI_CAPSULE_AUTHENTICATE))
+ image_info[0].attributes_setting |=
+ IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED;
+ image_info[i].lowest_supported_image_version = 0;
+ image_info[i].last_attempt_version = 0;
+ image_info[i].last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS;
+ image_info[i].hardware_instance = 1;
+ image_info[i].dependencies = NULL;
+
+ return EFI_SUCCESS;
+}
+#endif
/**
* efi_firmware_raw_get_image_info - return information about the current
firmware image
@@ -373,12 +424,20 @@ efi_status_t EFIAPI efi_firmware_raw_get_image_info(
!descriptor_size || !package_version || !package_version_name))
return EFI_EXIT(EFI_INVALID_PARAMETER);
- ret = efi_get_dfu_info(image_info_size, image_info,
+#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
+ ret = efi_corstone1000_img_info_get(image_info_size, image_info,
descriptor_version, descriptor_count,
descriptor_size,
package_version, package_version_name,
&efi_firmware_image_type_uboot_raw);
+#else
+ ret = efi_get_dfu_info(image_info_size, image_info,
+ descriptor_version, descriptor_count,
+ descriptor_size,
+ package_version, package_version_name,
+ &efi_firmware_image_type_uboot_raw);
+#endif
return EFI_EXIT(ret);
}
@@ -459,6 +518,9 @@ efi_status_t EFIAPI efi_firmware_raw_set_image(
}
+#if CONFIG_IS_ENABLED(TARGET_CORSTONE1000)
+ return EFI_EXIT(EFI_SUCCESS);
+#endif
if (dfu_write_by_alt(image_index - 1, (void *)image, image_size,
NULL, NULL))
return EFI_EXIT(EFI_DEVICE_ERROR);
--
2.17.1
@@ -0,0 +1,83 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From 0f90466c2d435534ea19669515c6e0af389d430b Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Wed, 22 Dec 2021 11:31:28 +0000
Subject: [PATCH] corstone1000: enable ethernet device
This change is to enable ethernet device (SMC911x) and few
other config options which are required by EDK-2 conformance test
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
index a51f5ddfa0..113a8238c7 100644
--- a/board/armltd/corstone1000/corstone1000.c
+++ b/board/armltd/corstone1000/corstone1000.c
@@ -54,6 +54,14 @@ static struct mm_region corstone1000_mem_map[] = {
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
PTE_BLOCK_NON_SHARE |
PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ /* ethernet */
+ .virt = 0x40100000UL,
+ .phys = 0x40100000UL,
+ .size = 0x00100000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
}, {
/* OCVM */
.virt = 0x80000000UL,
@@ -95,6 +103,23 @@ int dram_init_banksize(void)
return 0;
}
+/*
+ * Board specific ethernet initialization routine.
+ * */
+int board_eth_init(struct bd_info *bis)
+{
+ int rc = 0;
+#ifndef CONFIG_DM_ETH
+#ifdef CONFIG_SMC91111
+ rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
+#endif
+#ifdef CONFIG_SMC911X
+ rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
+#endif
+#endif
+ return rc;
+}
+
void reset_cpu(ulong addr)
{
}
diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
index d576ee1b67..45904ec98d 100644
--- a/configs/corstone1000_defconfig
+++ b/configs/corstone1000_defconfig
@@ -67,3 +67,19 @@ CONFIG_PSCI_RESET=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
# CONFIG_EFI_CAPSULE_FIRMWARE_FIT is not set
+CONFIG_CMD_DHCP=y
+CONFIG_SMC911X=y
+CONFIG_SMC911X_BASE=0x40100000
+CONFIG_DM_ETH=y
+CONFIG_PHY_SMSC=y
+CONFIG_CMD_BOOTEFI_SELFTEST=y
+CONFIG_CMD_TIME=y
+CONFIG_CMD_GETTIME=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_VERSION_VARIABLE=y
+CONFIG_PHYLIB=y
+CONFIG_PHY=y
+CONFIG_RAM=y
+CONFIG_ERRNO_STR=y
+CONFIG_CMD_EDITENV=y
+CONFIG_MISC=y
--
2.25.1
@@ -0,0 +1,134 @@
Upstream-Status: Backport [ebdea88d57d5e67b8f6e6cf615300eedbc7200a9]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From b4f1dd98dce5779e7d43807479c0c8b1a56e8761 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Thu, 23 Dec 2021 15:20:59 +0000
Subject: [PATCH] efi_loader: Fix loaded image alignment
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We are ignoring the alignment communicated via the PE/COFF header.
Starting 5.10 the Linux kernel will loudly complain about it. For more
details look at [1] (in linux kernel).
So add a function that can allocate aligned EFI memory and use it for
our relocated loaded image.
[1] c32ac11da3f83 ("efi/libstub: arm64: Double check image alignment at
entry")
Signed-off-by: Ilias Apalodimas's avatarIlias Apalodimas
<ilias.apalodimas@linaro.org>
Tested-by: default avatarVincent Stehlé <vincent.stehle@arm.com>
Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
Reviewed-by: Heinrich Schuchardt's avatarHeinrich Schuchardt
<xypron.glpk@gmx.de>
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 676b03aa07..c3e6a36def 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -588,6 +588,8 @@ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t guid);
#define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT)
/* Generic EFI memory allocator, call this to get memory */
void *efi_alloc(uint64_t len, int memory_type);
+/* Allocate pages on the specified alignment */
+void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align);
/* More specific EFI memory allocator, called by EFI payloads */
efi_status_t efi_allocate_pages(int type, int memory_type, efi_uintn_t pages,
uint64_t *memory);
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index a0eb63fceb..ab4fbd0dfd 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -880,8 +880,9 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
image_base = opt->ImageBase;
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
handle->image_type = opt->Subsystem;
- efi_reloc = efi_alloc(virt_size,
- loaded_image_info->image_code_type);
+ efi_reloc = efi_alloc_aligned_pages(virt_size,
+ loaded_image_info->image_code_type,
+ opt->SectionAlignment);
if (!efi_reloc) {
log_err("Out of memory\n");
ret = EFI_OUT_OF_RESOURCES;
@@ -896,8 +897,9 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
image_base = opt->ImageBase;
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
handle->image_type = opt->Subsystem;
- efi_reloc = efi_alloc(virt_size,
- loaded_image_info->image_code_type);
+ efi_reloc = efi_alloc_aligned_pages(virt_size,
+ loaded_image_info->image_code_type,
+ opt->SectionAlignment);
if (!efi_reloc) {
log_err("Out of memory\n");
ret = EFI_OUT_OF_RESOURCES;
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index be2f655dff..e0640323bc 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -548,6 +548,58 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
return ret;
}
+/**
+ * efi_alloc_aligned_pages - allocate
+ *
+ * @len: len in bytes
+ * @memory_type: usage type of the allocated memory
+ * @align: alignment in bytes
+ * Return: aligned memory or NULL
+ */
+void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align)
+{
+ u64 req_pages = efi_size_in_pages(len);
+ u64 true_pages = req_pages + efi_size_in_pages(align) - 1;
+ u64 free_pages;
+ u64 aligned_mem;
+ efi_status_t r;
+ u64 mem;
+
+ /* align must be zero or a power of two */
+ if (align & (align - 1))
+ return NULL;
+
+ /* Check for overflow */
+ if (true_pages < req_pages)
+ return NULL;
+
+ if (align < EFI_PAGE_SIZE) {
+ r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, memory_type,
+ req_pages, &mem);
+ return (r == EFI_SUCCESS) ? (void *)(uintptr_t)mem : NULL;
+ }
+
+ r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, memory_type,
+ true_pages, &mem);
+ if (r != EFI_SUCCESS)
+ return NULL;
+
+ aligned_mem = ALIGN(mem, align);
+ /* Free pages before alignment */
+ free_pages = efi_size_in_pages(aligned_mem - mem);
+ if (free_pages)
+ efi_free_pages(mem, free_pages);
+
+ /* Free trailing pages */
+ free_pages = true_pages - (req_pages + free_pages);
+ if (free_pages) {
+ mem = aligned_mem + req_pages * EFI_PAGE_SIZE;
+ efi_free_pages(mem, free_pages);
+ }
+
+ return (void *)(uintptr_t)aligned_mem;
+}
+
/**
* efi_allocate_pool - allocate memory from pool
*
--
2.17.1
@@ -0,0 +1,35 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 152ff06c983b7b1a685d82bc229efdd6260d9a12 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Fri, 24 Dec 2021 14:22:52 +0000
Subject: [PATCH] Comment mm_communicate failure log
When a getVariable() call is made with data size set to 0,
mm_communicate should return EFI_BUFFER_TOO_SMALL. This is
an expected behavior. There should not be any failure logs
in this case. So the error log is commented here.
---
lib/efi_loader/efi_variable_tee.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index b466702983..fc4d684669 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -407,7 +407,10 @@ static efi_status_t __efi_runtime mm_communicate(u8 *comm_buf, efi_uintn_t dsize
ret = ffa_mm_communicate(comm_buf, dsize);
#endif
if (ret != EFI_SUCCESS) {
- log_err("%s failed!\n", __func__);
+ /* mm_communicate failure is logged even when getVariable() is called
+ * with data size set to 0. This is not expected so logging is commented.
+ */
+ //log_err("%s failed!\n", __func__);
return ret;
}
--
2.17.1
@@ -0,0 +1,186 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From b315c9e23e38341cd105802e85f606b64e0f0449 Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Wed, 5 Jan 2022 17:56:09 +0000
Subject: [PATCH] efi_loader: send bootcomplete message to secure enclave
On corstone1000 platform, Secure Enclave will be expecting
an event from uboot when it performs capsule update. Previously,
an event is sent at exitbootservice level. This will create a problem
when user wants to interrupt at UEFI shell, hence, it is required
to send an uboot efi initialized event at efi sub-system initialization
stage.
diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
index 4a78e1a3c5..c4a1146b52 100644
--- a/include/configs/corstone1000.h
+++ b/include/configs/corstone1000.h
@@ -22,7 +22,7 @@
/* Notification events used with SE Proxy update service */
#define CORSTONE1000_BUFFER_READY_EVT (0x1)
-#define CORSTONE1000_KERNEL_STARTED_EVT (0x2)
+#define CORSTONE1000_UBOOT_EFI_STARTED_EVT (0x2)
#define PREP_SEPROXY_SVC_ID_MASK GENMASK(31, 16)
#define PREP_SEPROXY_SVC_ID(x) \
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 17cc692064..154b69e514 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2094,46 +2094,6 @@ static void efi_exit_caches(void)
#endif
}
-#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
-/**
- * efi_corstone1000_kernel_started_event - notifies SE Proxy FW update service
- *
- * This function notifies the SE Proxy update service that the kernel has already started
- *
- * Return:
- *
- * 0: on success, otherwise failure
- */
-static int efi_corstone1000_kernel_started_event(void)
-{
- struct ffa_interface_data func_data = {0};
- struct ffa_send_direct_data msg = {0};
- u16 part_id = CORSTONE1000_SEPROXY_PART_ID;
-
- log_debug("[%s]\n", __func__);
-
- /*
- * telling the driver which partition to use
- */
- func_data.data0_size = sizeof(part_id);
- func_data.data0 = &part_id;
-
- /*
- * setting the kernel started event arguments:
- * setting capsule update interface ID(31:16)
- * the kernel started event ID(15:0)
- */
- msg.a4 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
- PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT);
-
- func_data.data1_size = sizeof(msg);
- func_data.data1 = &msg;
-
- return ffa_helper_msg_send_direct_req(&func_data);
-}
-
-#endif
-
/**
* efi_exit_boot_services() - stop all boot services
* @image_handle: handle of the loaded image
@@ -2239,15 +2199,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
/* Recalculate CRC32 */
efi_update_table_header_crc32(&systab.hdr);
-#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
- /* Notifying SE Proxy FW update service */
- ffa_ret = efi_corstone1000_kernel_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
-
/* Give the payload some time to boot */
efi_set_watchdog(0);
WATCHDOG_RESET();
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index 85fb5254eb..a7f7598eab 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -353,7 +353,7 @@ static efi_status_t efi_corstone1000_img_info_get (
*package_version_name = NULL; /* not supported */
if(image_info == NULL) {
- log_warning("image_info is null\n");
+ log_info("image_info is null\n");
return EFI_BUFFER_TOO_SMALL;
}
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 9e3399a28c..25524fafe4 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -17,6 +17,9 @@
efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <arm_ffa_helper.h>
/**
* efi_corstone1000_alloc_capsule_shared_buf - allocate capsule shared buffer
*/
@@ -126,6 +129,44 @@ static efi_status_t efi_init_secure_boot(void)
}
#endif /* CONFIG_EFI_SECURE_BOOT */
+#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+/**
+ * efi_corstone1000_uboot-efi_started_event - notifies SE Proxy FW update service
+ *
+ * This function notifies the SE Proxy update service that uboot efi has already started
+ *
+ * Return:
+ *
+ * 0: on success, otherwise failure
+ * */
+static int efi_corstone1000_uboot_efi_started_event(void)
+{
+ struct ffa_interface_data func_data = {0};
+ struct ffa_send_direct_data msg = {0};
+ u16 part_id = CORSTONE1000_SEPROXY_PART_ID;
+
+ log_debug("[%s]\n", __func__);
+
+ /*
+ * telling the driver which partition to use
+ */
+ func_data.data0_size = sizeof(part_id);
+ func_data.data0 = &part_id;
+ /*
+ * setting the uboot efi subsystem started event arguments:
+ * setting capsule update interface ID(31:16)
+ * the uboot efi subsystem started event ID(15:0)
+ */
+ msg.a4 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
+ PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT);
+
+ func_data.data1_size = sizeof(msg);
+ func_data.data1 = &msg;
+
+ return ffa_helper_msg_send_direct_req(&func_data);
+}
+#endif
+
/**
* efi_init_capsule - initialize capsule update state
*
@@ -134,8 +175,15 @@ static efi_status_t efi_init_secure_boot(void)
static efi_status_t efi_init_capsule(void)
{
efi_status_t ret = EFI_SUCCESS;
+ int ffa_ret;
#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
+ 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");
--
2.17.1
@@ -54,6 +54,15 @@ SRC_URI:append:corstone1000 = " \
file://0040-Return-proper-error-code-when-rx-buffer-is-larger.patch \
file://0041-Use-correct-buffer-size.patch \
file://0042-Update-comm_buf-when-EFI_BUFFER_TOO_SMALL.patch \
file://0043-Disable-DHCP-PING-config-parameters.patch \
file://0044-Revert-corstone1000-Disable-set-get-of-NV-variables.patch \
file://0045-corstone1000-defconfig-enable-CAPSULE_FIRMWARE_RAW-c.patch \
file://0046-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch \
file://0047-efi_firmware-add-get_image_info-for-corstone1000.patch \
file://0048-corstone1000-enable-ethernet-device.patch \
file://0049-efi_loader-Fix-loaded-image-alignment.patch \
file://0050-Comment-mm_communicate-failure-log.patch \
file://0051-efi_loader-send-bootcomplete-message-to-secure-encla.patch \
"
#
@@ -0,0 +1,251 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 9dc09450180d2d35b61359399c1313a97016ad07 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Thu, 16 Dec 2021 13:29:58 +0000
Subject: [PATCH] Add logs to functions in SMM gateway SP
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
%% original patch: 0026-Logging.patch
---
.../backend/uefi_variable_store.c | 29 +++++++++++++++++--
.../provider/smm_variable_provider.c | 7 +++--
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c
index ed50eaf..0c371e9 100644
--- a/components/service/smm_variable/backend/uefi_variable_store.c
+++ b/components/service/smm_variable/backend/uefi_variable_store.c
@@ -11,6 +11,7 @@
#include "uefi_variable_store.h"
#include "variable_index_iterator.h"
#include "variable_checker.h"
+#include <trace.h>
/* Private functions */
static void load_variable_index(
@@ -151,12 +152,15 @@ void uefi_variable_store_set_storage_limits(
size_t total_capacity,
size_t max_variable_size)
{
+ EMSG("In func %s\n", __func__);
struct delegate_variable_store *delegate_store = select_delegate_store(
context,
attributes);
delegate_store->total_capacity = total_capacity;
delegate_store->max_variable_size = max_variable_size;
+ EMSG("In func %s total_capacity is %d\n", __func__, total_capacity);
+ EMSG("In func %s max_variable_size is %d\n", __func__, max_variable_size);
}
efi_status_t uefi_variable_store_set_variable(
@@ -265,6 +269,7 @@ efi_status_t uefi_variable_store_get_variable(
size_t max_data_len,
size_t *total_length)
{
+ EMSG("In func %s\n", __func__);
efi_status_t status = check_name_terminator(var->Name, var->NameSize);
if (status != EFI_SUCCESS) return status;
@@ -299,6 +304,7 @@ efi_status_t uefi_variable_store_get_next_variable_name(
size_t max_name_len,
size_t *total_length)
{
+ EMSG("In func %s\n", __func__);
efi_status_t status = check_name_terminator(cur->Name, cur->NameSize);
if (status != EFI_SUCCESS) return status;
@@ -329,6 +335,8 @@ efi_status_t uefi_variable_store_query_variable_info(
struct uefi_variable_store *context,
SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO *var_info)
{
+
+ EMSG("In func %s\n", __func__);
struct delegate_variable_store *delegate_store = select_delegate_store(
context,
var_info->Attributes);
@@ -337,13 +345,15 @@ efi_status_t uefi_variable_store_query_variable_info(
context,
var_info->Attributes,
delegate_store->storage_backend);
-
+ EMSG("In func %s total_used is %d\n", __func__, total_used);
var_info->MaximumVariableSize = delegate_store->max_variable_size;
var_info->MaximumVariableStorageSize = delegate_store->total_capacity;
var_info->RemainingVariableStorageSize = (total_used < delegate_store->total_capacity) ?
delegate_store->total_capacity - total_used :
0;
-
+ EMSG("In func %s var_info->MaximumVariableSize is %d\n", __func__, var_info->MaximumVariableSize);
+ EMSG("In func %s var_info->MaximumVariableStorageSize is %d\n", __func__, var_info->MaximumVariableStorageSize);
+ EMSG("In func %s var_info->RemainingVariableStorageSize is %d\n", __func__, var_info->RemainingVariableStorageSize);
return EFI_SUCCESS;
}
@@ -358,6 +368,7 @@ efi_status_t uefi_variable_store_set_var_check_property(
struct uefi_variable_store *context,
const SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY *property)
{
+ EMSG("In func %s\n", __func__);
efi_status_t status = check_name_terminator(property->Name, property->NameSize);
if (status != EFI_SUCCESS) return status;
@@ -404,6 +415,7 @@ efi_status_t uefi_variable_store_get_var_check_property(
struct uefi_variable_store *context,
SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY *property)
{
+ EMSG("In func %s\n", __func__);
efi_status_t status = check_name_terminator(property->Name, property->NameSize);
if (status != EFI_SUCCESS) return status;
@@ -430,6 +442,7 @@ efi_status_t uefi_variable_store_get_var_check_property(
static void load_variable_index(
struct uefi_variable_store *context)
{
+ EMSG("In func %s\n", __func__);
struct storage_backend *persistent_store = context->persistent_store.storage_backend;
if (persistent_store) {
@@ -444,6 +457,7 @@ static void load_variable_index(
context->index_sync_buffer_size,
context->index_sync_buffer,
&data_len);
+ EMSG("In func %s get status is %d\n", __func__, psa_status);
if (psa_status == PSA_SUCCESS) {
@@ -455,6 +469,7 @@ static void load_variable_index(
static efi_status_t sync_variable_index(
struct uefi_variable_store *context)
{
+ EMSG("In func %s\n", __func__);
efi_status_t status = EFI_SUCCESS;
/* Sync the varibale index to storage if anything is dirty */
@@ -479,6 +494,7 @@ static efi_status_t sync_variable_index(
data_len,
context->index_sync_buffer,
PSA_STORAGE_FLAG_NONE);
+ EMSG("In func %s set status is %d\n", __func__, psa_status);
status = psa_to_efi_storage_status(psa_status);
}
@@ -490,6 +506,7 @@ static efi_status_t sync_variable_index(
static efi_status_t check_capabilities(
const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *var)
{
+ EMSG("In func %s\n", __func__);
efi_status_t status = EFI_SUCCESS;
/* Check if any unsupported variable attributes have been requested */
@@ -551,6 +568,7 @@ static efi_status_t store_variable_data(
const struct variable_info *info,
const SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *var)
{
+ EMSG("In func %s\n", __func__);
psa_status_t psa_status = PSA_SUCCESS;
size_t data_len = var->DataSize;
const uint8_t *data = (const uint8_t*)var +
@@ -599,6 +617,7 @@ static efi_status_t remove_variable_data(
struct uefi_variable_store *context,
const struct variable_info *info)
{
+ EMSG("In func %s\n", __func__);
psa_status_t psa_status = PSA_SUCCESS;
if (info->is_variable_set) {
@@ -613,6 +632,7 @@ static efi_status_t remove_variable_data(
delegate_store->storage_backend->context,
context->owner_id,
info->metadata.uid);
+ EMSG("In func %s status is %d\n", __func__, psa_status);
}
}
@@ -625,6 +645,7 @@ static efi_status_t load_variable_data(
SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE *var,
size_t max_data_len)
{
+ EMSG("In func %s\n", __func__);
psa_status_t psa_status = PSA_SUCCESS;
size_t data_len = 0;
uint8_t *data = (uint8_t*)var +
@@ -644,6 +665,7 @@ static efi_status_t load_variable_data(
max_data_len,
data,
&data_len);
+ EMSG("In func %s get status is %d\n", __func__, psa_status);
var->DataSize = data_len;
}
@@ -771,6 +793,7 @@ static void purge_orphan_index_entries(
context->owner_id,
info->metadata.uid,
&storage_info);
+ EMSG("In func %s get status is %d\n", __func__, psa_status);
if (psa_status != PSA_SUCCESS) {
@@ -802,6 +825,7 @@ static size_t space_used(
uint32_t attributes,
struct storage_backend *storage_backend)
{
+ EMSG("In func %s\n", __func__);
if (!storage_backend) return 0;
size_t total_used = 0;
@@ -823,6 +847,7 @@ static size_t space_used(
context->owner_id,
info->metadata.uid,
&storage_info);
+ EMSG("In func %s get status is %d\n", __func__, psa_status);
if (psa_status == PSA_SUCCESS) total_used += storage_info.size;
}
diff --git a/components/service/smm_variable/provider/smm_variable_provider.c b/components/service/smm_variable/provider/smm_variable_provider.c
index 52e68d0..1f362c1 100644
--- a/components/service/smm_variable/provider/smm_variable_provider.c
+++ b/components/service/smm_variable/provider/smm_variable_provider.c
@@ -9,6 +9,7 @@
#include <protocols/service/smm_variable/smm_variable_proto.h>
#include <protocols/rpc/common/packed-c/status.h>
#include "smm_variable_provider.h"
+#include <trace.h>
/* Service request handlers */
static rpc_status_t get_variable_handler(void *context, struct call_req *req);
@@ -252,17 +253,18 @@ static rpc_status_t set_variable_handler(void *context, struct call_req* req)
static rpc_status_t query_variable_info_handler(void *context, struct call_req* req)
{
+ EMSG("In func %s \n", __func__);
efi_status_t efi_status = EFI_INVALID_PARAMETER;
struct smm_variable_provider *this_instance = (struct smm_variable_provider*)context;
const struct call_param_buf *req_buf = call_req_get_req_buf(req);
-
+ EMSG("In func %s sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO) is %d\n", __func__, sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO));
if (req_buf->data_len >= sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO)) {
struct call_param_buf *resp_buf = call_req_get_resp_buf(req);
if (resp_buf->size >= req_buf->data_len) {
-
+
memmove(resp_buf->data, req_buf->data, req_buf->data_len);
efi_status = uefi_variable_store_query_variable_info(
@@ -272,6 +274,7 @@ static rpc_status_t query_variable_info_handler(void *context, struct call_req*
if (efi_status == EFI_SUCCESS) {
resp_buf->data_len = sizeof(SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO);
+ EMSG("In func %s resp_buf->data_len is %d\n", __func__, resp_buf->data_len);
}
}
else {
--
2.17.1
@@ -0,0 +1,43 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 02746a26472f6aa7d57cfd5388823b0ec3c8a945 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Thu, 16 Dec 2021 21:31:40 +0000
Subject: [PATCH] Configure storage size
---
.../service/smm_variable/backend/uefi_variable_store.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c
index 0c371e9..b7cfff4 100644
--- a/components/service/smm_variable/backend/uefi_variable_store.c
+++ b/components/service/smm_variable/backend/uefi_variable_store.c
@@ -87,6 +87,7 @@ static efi_status_t check_name_terminator(
* may be overridden using uefi_variable_store_set_storage_limits()
*/
#define DEFAULT_MAX_VARIABLE_SIZE (2048)
+#define CONFIGURE_STORAGE_SIZE (50)
efi_status_t uefi_variable_store_init(
struct uefi_variable_store *context,
@@ -100,13 +101,13 @@ efi_status_t uefi_variable_store_init(
/* Initialise persistent store defaults */
context->persistent_store.is_nv = true;
context->persistent_store.max_variable_size = DEFAULT_MAX_VARIABLE_SIZE;
- context->persistent_store.total_capacity = DEFAULT_MAX_VARIABLE_SIZE * max_variables;
+ context->persistent_store.total_capacity = CONFIGURE_STORAGE_SIZE * max_variables;
context->persistent_store.storage_backend = persistent_store;
/* Initialise volatile store defaults */
context->volatile_store.is_nv = false;
context->volatile_store.max_variable_size = DEFAULT_MAX_VARIABLE_SIZE;
- context->volatile_store.total_capacity = DEFAULT_MAX_VARIABLE_SIZE * max_variables;
+ context->volatile_store.total_capacity = CONFIGURE_STORAGE_SIZE * max_variables;
context->volatile_store.storage_backend = volatile_store;
context->owner_id = owner_id;
--
2.17.1
@@ -0,0 +1,34 @@
From 451eac3ed36231380b8e3dd0ad76c1a3c010a375 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Mon, 20 Dec 2021 19:54:39 +0000
Subject: [PATCH 1/3] Change UID of variable index in SMM
This patch fixes the os_indications setVariable() failure. The variable
index UID in SMM gateway which was 1 is changed in this patch. TFM has a
special usage for variable with UID 1, which makes it write once only.
This is not required for SMM variable index.
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
%% original patch: 0029-Change-UID-of-variable-index-in-SMM.patch
---
components/service/smm_variable/backend/uefi_variable_store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c
index 6a90f46..1bb869a 100644
--- a/components/service/smm_variable/backend/uefi_variable_store.c
+++ b/components/service/smm_variable/backend/uefi_variable_store.c
@@ -67,7 +67,7 @@ static efi_status_t check_name_terminator(
size_t name_size);
/* Private UID for storing the variable index */
-#define VARIABLE_INDEX_STORAGE_UID (1)
+#define VARIABLE_INDEX_STORAGE_UID (0x787)
/* Default maximum variable size -
* may be overridden using uefi_variable_store_set_storage_limits()
--
2.17.1
@@ -0,0 +1,76 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 2ba5fa76a886e0ef59656fe96666f2582e8ffc72 Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Mon, 20 Dec 2021 19:56:30 +0000
Subject: [PATCH 2/3] Add missing features to setVariable()
This patch resolves the failing tests in SCT related to
setVariable() function. The existing implementation is
missing few cases where error codes are returned when called
with certain paramters. These conditions are implemented in
this patch based on the explanation provided in uefi spec.
%% original patch: 0030-Add-missing-features-to-setVariable.patch
---
.../backend/uefi_variable_store.c | 29 ++++++++++++++++---
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c
index 1bb869a..a167107 100644
--- a/components/service/smm_variable/backend/uefi_variable_store.c
+++ b/components/service/smm_variable/backend/uefi_variable_store.c
@@ -161,6 +161,17 @@ efi_status_t uefi_variable_store_set_variable(
bool should_sync_index = false;
if (status != EFI_SUCCESS) return status;
+
+ /*
+ * Runtime access to a data variable implies boot service access. Attributes that have
+ * EFI_VARIABLE_RUNTIME_ACCESS set must also have EFI_VARIABLE_BOOTSERVICE_ACCESS set.
+ * The caller is responsible for following this rule.
+ */
+ if((var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS))
+ {
+ if((var->Attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS) != EFI_VARIABLE_BOOTSERVICE_ACCESS )
+ return EFI_INVALID_PARAMETER;
+ }
/* Find in index */
const struct variable_info *info = variable_index_find(
@@ -221,6 +232,13 @@ efi_status_t uefi_variable_store_set_variable(
if (!info) status = EFI_OUT_OF_RESOURCES;
should_sync_index = info && (info->metadata.attributes & EFI_VARIABLE_NON_VOLATILE);
}
+ else
+ {
+ /* Return EFI_NOT_FOUND when a remove operation is performed
+ * on variable that is not existing.
+ */
+ status = EFI_NOT_FOUND;
+ }
/* The order of these operations is important. For an update
* or create operation, The variable index is always synchronized
@@ -555,10 +573,13 @@ static efi_status_t check_access_permitted_on_set(
if ((status == EFI_SUCCESS) && var->DataSize) {
/* Restrict which attributes can be modified for an existing variable */
- if ((var->Attributes & EFI_VARIABLE_NON_VOLATILE) !=
- (info->metadata.attributes & EFI_VARIABLE_NON_VOLATILE)) {
-
- /* Don't permit change of storage class */
+ if (((var->Attributes & EFI_VARIABLE_NON_VOLATILE) !=
+ (info->metadata.attributes & EFI_VARIABLE_NON_VOLATILE)) ||
+ ((var->Attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS) !=
+ (info->metadata.attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) ||
+ ((var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) !=
+ (info->metadata.attributes & EFI_VARIABLE_RUNTIME_ACCESS))) {
+ /* Don't permit change of attributes */
status = EFI_INVALID_PARAMETER;
}
}
--
2.17.1
@@ -0,0 +1,58 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
From 8a2a47d360e43004d277c00ed06cbc59ccfb721e Mon Sep 17 00:00:00 2001
From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
Date: Mon, 20 Dec 2021 20:01:10 +0000
Subject: [PATCH 3/3] Add invalid parameter check in getNextVariableName()
This patch resolves the failing tests in SCT related to
getNextVariableName() function. The existing implementation is
missing few cases where error codes are returned when called
with certain paramters. These conditions are implemented in
this patch based on the explanation provided in uefi spec.
%% original patch: 0031-Add-invalid-parameter-check-in-getNextVariableName.patch
---
.../smm_variable/backend/uefi_variable_store.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c
index a167107..a57b334 100644
--- a/components/service/smm_variable/backend/uefi_variable_store.c
+++ b/components/service/smm_variable/backend/uefi_variable_store.c
@@ -161,7 +161,7 @@ efi_status_t uefi_variable_store_set_variable(
bool should_sync_index = false;
if (status != EFI_SUCCESS) return status;
-
+
/*
* Runtime access to a data variable implies boot service access. Attributes that have
* EFI_VARIABLE_RUNTIME_ACCESS set must also have EFI_VARIABLE_BOOTSERVICE_ACCESS set.
@@ -310,6 +310,22 @@ efi_status_t uefi_variable_store_get_next_variable_name(
status = EFI_NOT_FOUND;
*total_length = 0;
+ /*
+ * If input values of VariableName and VendorGuid are not a name and GUID of an
+ * existing variable, EFI_INVALID_PARAMETER is returned.
+ */
+ if (cur->NameSize >= sizeof(int16_t)) {
+ /*
+ * Name must be at least one character long to accommodate
+ * the mandatory null terminator.
+ */
+ if (cur->Name[0] != 0) {
+ const struct variable_info *var_info = variable_index_find(&context->variable_index,&cur->Guid,cur->NameSize,cur->Name);
+ if(var_info == NULL)
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
const struct variable_info *info = variable_index_find_next(
&context->variable_index,
&cur->Guid,
--
2.17.1
@@ -0,0 +1,79 @@
Upstream-Status: Pending [Not submitted to upstream yet]
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
From c88937f3fb2d1259b1abb1a6926e869bf2f5d69e Mon Sep 17 00:00:00 2001
From: Vishnu Banavath <vishnu.banavath@arm.com>
Date: Fri, 24 Dec 2021 19:17:17 +0000
Subject: [PATCH] smm_gateway: add checks for null attributes
As par EDK-2 and EDK-2 test code, when a user issue's
setVariable() with 0 in attributes field, it means a variable
delete request. Currently, smm gatway doesn't handle this scenario.
This change is to add that support
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
diff --git a/components/service/smm_variable/backend/uefi_variable_store.c b/components/service/smm_variable/backend/uefi_variable_store.c
index a57b334..e8771c2 100644
--- a/components/service/smm_variable/backend/uefi_variable_store.c
+++ b/components/service/smm_variable/backend/uefi_variable_store.c
@@ -167,7 +167,9 @@ efi_status_t uefi_variable_store_set_variable(
* EFI_VARIABLE_RUNTIME_ACCESS set must also have EFI_VARIABLE_BOOTSERVICE_ACCESS set.
* The caller is responsible for following this rule.
*/
- if((var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS))
+ if (!var->Attributes)
+ EMSG("It might be a delete variable request\n");
+ else if((var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS))
{
if((var->Attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS) != EFI_VARIABLE_BOOTSERVICE_ACCESS )
return EFI_INVALID_PARAMETER;
@@ -191,7 +193,7 @@ efi_status_t uefi_variable_store_set_variable(
(var->Attributes & EFI_VARIABLE_NON_VOLATILE) ||
(info->is_variable_set && (info->metadata.attributes & EFI_VARIABLE_NON_VOLATILE));
- if (var->DataSize) {
+ if (var->DataSize && var->Attributes) {
/* It's a set rather than a remove operation */
variable_index_update_variable(
@@ -206,7 +208,9 @@ efi_status_t uefi_variable_store_set_variable(
* that it's never possible for an object to exist within
* the storage backend without a corresponding index entry.
*/
- remove_variable_data(context, info);
+ EMSG(" deleting variable %s \n",var->Name);
+ if (remove_variable_data(context, info) != PSA_SUCCESS)
+ EMSG(" deleting variable %s FAILED\n",var->Name);
variable_index_remove_variable(&context->variable_index, info);
/* Variable info no longer valid */
@@ -587,14 +591,18 @@ static efi_status_t check_access_permitted_on_set(
}
if ((status == EFI_SUCCESS) && var->DataSize) {
-
+ /* Delete the variable with Attributes is 0 */
+ if (!var->Attributes) {
+ EMSG("Null attributes, may be a delete variable request\n");
+ status = EFI_SUCCESS;
+ }
/* Restrict which attributes can be modified for an existing variable */
- if (((var->Attributes & EFI_VARIABLE_NON_VOLATILE) !=
- (info->metadata.attributes & EFI_VARIABLE_NON_VOLATILE)) ||
- ((var->Attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS) !=
- (info->metadata.attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) ||
- ((var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) !=
- (info->metadata.attributes & EFI_VARIABLE_RUNTIME_ACCESS))) {
+ else if (((var->Attributes & EFI_VARIABLE_NON_VOLATILE) !=
+ (info->metadata.attributes & EFI_VARIABLE_NON_VOLATILE)) ||
+ ((var->Attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS) !=
+ (info->metadata.attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) ||
+ ((var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) !=
+ (info->metadata.attributes & EFI_VARIABLE_RUNTIME_ACCESS))) {
/* Don't permit change of attributes */
status = EFI_INVALID_PARAMETER;
}
--
2.17.1
@@ -36,6 +36,13 @@ SRC_URI:append = " \
file://0023-add-psa-ipc-crypto-backend.patch \
file://0024-Increase-SMM-gateway-UEFI-variable-macro-value.patch \
file://0025-Add-stub-capsule-update-service-components.patch \
file://0026-Add-logs-to-functions-in-SMM-gateway-SP.patch \
file://0027-Configure-storage-size.patch \
file://0028-Revert-Add-uefi-variable-append-write-support.patch \
file://0029-Change-UID-of-variable-index-in-SMM.patch \
file://0030-Add-missing-features-to-setVariable.patch \
file://0031-Add-invalid-parameter-check-in-getNextVariableName.patch \
file://0032-smm_gateway-add-checks-for-null-attributes.patch \
"
SRC_URI_MBED = "git://github.com/ARMmbed/mbed-crypto.git;protocol=https;branch=development;name=mbed;destsuffix=git/mbedcrypto"
+1 -1
View File
@@ -25,7 +25,7 @@ EXTRA_IMAGEDEPENDS += "${FVP_PROVIDER}"
inherit image-artifact-names
addtask do_write_fvpboot_conf after do_rootfs before do_image
IMAGE_POSTPROCESS_COMMAND += "do_write_fvpboot_conf;"
python do_write_fvpboot_conf() {
# Note that currently this JSON file is in development and the format may
# change at any point, so it should always be used with a matching runfvp.
+3 -1
View File
@@ -53,7 +53,6 @@ LDFLAGS[unexport] = "1"
do_configure[cleandirs] += "${B}"
# Set variables as per envsetup
export GCC5_AARCH64_PREFIX = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}"
export PACKAGES_PATH = "${S}:${S}/edk2-platforms"
export WORKSPACE = "${B}"
export EDK_TOOLS_PATH = "${S}/BaseTools"
@@ -63,7 +62,10 @@ export CONF_PATH = "${S}/Conf"
export BTOOLS_PATH = "${EDK_TOOLS_PATH}/BinWrappers/PosixLike"
EDK_COMPILER ?= "GCC5"
export GCC5_AARCH64_PREFIX = "${TARGET_PREFIX}"
EDK_COMPILER:toolchain-clang = "CLANG38"
export CLANG38_AARCH64_PREFIX = "${TARGET_PREFIX}"
do_configure:prepend() {
sed -i -e "s#-target ${HOST_ARCH}-linux-gnu*#-target ${HOST_SYS}#" ${S}/BaseTools/Conf/tools_def.template