| From af2defbfaffa4264052e30f269b91794068e4773 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 25/27] 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. |
| |
| Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> |
| --- |
| include/configs/corstone1000.h | 2 +- |
| lib/efi_loader/efi_boottime.c | 49 ---------------------------------- |
| lib/efi_loader/efi_firmware.c | 2 +- |
| lib/efi_loader/efi_setup.c | 48 +++++++++++++++++++++++++++++++++ |
| 4 files changed, 50 insertions(+), 51 deletions(-) |
| |
| diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h |
| index a7445e61348b..06b605e43bdf 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) (FIELD_PREP(PREP_SEPROXY_SVC_ID_MASK, (x))) |
| diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c |
| index b58a8c98fd05..d0703060491b 100644 |
| --- a/lib/efi_loader/efi_boottime.c |
| +++ b/lib/efi_loader/efi_boottime.c |
| @@ -2101,46 +2101,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 |
| @@ -2254,15 +2214,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 9eb89849b28d..477ad072070e 100644 |
| --- a/lib/efi_loader/efi_firmware.c |
| +++ b/lib/efi_loader/efi_firmware.c |
| @@ -356,7 +356,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 989380d4f8cd..515a0bdf74ef 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.30.2 |
| |