Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 1 | From 709e5d8ff07474f840f1d34d3077135f77795452 Mon Sep 17 00:00:00 2001 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | From: Vishnu Banavath <vishnu.banavath@arm.com> |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 3 | Date: Mon, 15 Aug 2022 15:46:18 +0100 |
| 4 | Subject: [PATCH 24/26] efi_loader: send bootcomplete message to secure enclave |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 5 | |
| 6 | On corstone1000 platform, Secure Enclave will be expecting |
| 7 | an event from uboot when it performs capsule update. Previously, |
| 8 | an event is sent at exitbootservice level. This will create a problem |
| 9 | when user wants to interrupt at UEFI shell, hence, it is required |
| 10 | to send an uboot efi initialized event at efi sub-system initialization |
| 11 | stage. |
| 12 | |
| 13 | Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 14 | Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> |
| 15 | Upstream-Status: Pending [Not submitted to upstream yet] |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 16 | --- |
| 17 | include/configs/corstone1000.h | 2 +- |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 18 | lib/efi_loader/efi_boottime.c | 43 ---------------------------------- |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 19 | lib/efi_loader/efi_firmware.c | 2 +- |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 20 | lib/efi_loader/efi_setup.c | 39 ++++++++++++++++++++++++++++++ |
| 21 | 4 files changed, 41 insertions(+), 45 deletions(-) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 22 | |
| 23 | diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 24 | index 4637dd5d5d..333b1d93b6 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 25 | --- a/include/configs/corstone1000.h |
| 26 | +++ b/include/configs/corstone1000.h |
| 27 | @@ -22,7 +22,7 @@ |
| 28 | |
| 29 | /* Notification events used with SE Proxy update service */ |
| 30 | #define CORSTONE1000_BUFFER_READY_EVT (0x1) |
| 31 | -#define CORSTONE1000_KERNEL_STARTED_EVT (0x2) |
| 32 | +#define CORSTONE1000_UBOOT_EFI_STARTED_EVT (0x2) |
| 33 | |
| 34 | #define PREP_SEPROXY_SVC_ID_MASK GENMASK(31, 16) |
| 35 | #define PREP_SEPROXY_SVC_ID(x) (FIELD_PREP(PREP_SEPROXY_SVC_ID_MASK, (x))) |
| 36 | diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 37 | index de815484d2..cede7826bd 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 38 | --- a/lib/efi_loader/efi_boottime.c |
| 39 | +++ b/lib/efi_loader/efi_boottime.c |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 40 | @@ -27,11 +27,6 @@ |
| 41 | #include <arm_ffa.h> |
| 42 | #endif |
| 43 | |
| 44 | -#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) |
| 45 | -#include <linux/bitfield.h> |
| 46 | -#include <linux/bitops.h> |
| 47 | -#endif |
| 48 | - |
| 49 | DECLARE_GLOBAL_DATA_PTR; |
| 50 | |
| 51 | /* Task priority level */ |
| 52 | @@ -2100,35 +2095,6 @@ static void efi_exit_caches(void) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 53 | #endif |
| 54 | } |
| 55 | |
| 56 | -#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) |
| 57 | -/** |
| 58 | - * efi_corstone1000_kernel_started_event - notifies SE Proxy FW update service |
| 59 | - * |
| 60 | - * This function notifies the SE Proxy update service that the kernel has already started |
| 61 | - * |
| 62 | - * Return: |
| 63 | - * |
| 64 | - * 0: on success, otherwise failure |
| 65 | - */ |
| 66 | -static int efi_corstone1000_kernel_started_event(void) |
| 67 | -{ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 68 | - struct ffa_send_direct_data msg = {0}; |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 69 | - |
| 70 | - log_debug("[%s]\n", __func__); |
| 71 | - |
| 72 | - /* |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 73 | - * setting the kernel started event arguments: |
| 74 | - * setting capsule update interface ID(31:16) |
| 75 | - * the kernel started event ID(15:0) |
| 76 | - */ |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 77 | - msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | |
| 78 | - PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 79 | - |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 80 | - return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg); |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 81 | -} |
| 82 | - |
| 83 | -#endif |
| 84 | - |
| 85 | /** |
| 86 | * efi_exit_boot_services() - stop all boot services |
| 87 | * @image_handle: handle of the loaded image |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 88 | @@ -2244,15 +2210,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 89 | /* Recalculate CRC32 */ |
| 90 | efi_update_table_header_crc32(&systab.hdr); |
| 91 | |
| 92 | -#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) |
| 93 | - /* Notifying SE Proxy FW update service */ |
| 94 | - ffa_ret = efi_corstone1000_kernel_started_event(); |
| 95 | - if (ffa_ret) |
| 96 | - debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n"); |
| 97 | - else |
| 98 | - debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n"); |
| 99 | -#endif |
| 100 | - |
| 101 | /* Give the payload some time to boot */ |
| 102 | efi_set_watchdog(0); |
| 103 | WATCHDOG_RESET(); |
| 104 | diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 105 | index af43d4502f..25f427b936 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 106 | --- a/lib/efi_loader/efi_firmware.c |
| 107 | +++ b/lib/efi_loader/efi_firmware.c |
| 108 | @@ -47,7 +47,7 @@ static efi_status_t efi_corstone1000_img_info_get ( |
| 109 | *package_version_name = NULL; /* not supported */ |
| 110 | |
| 111 | if(image_info == NULL) { |
| 112 | - log_warning("image_info is null\n"); |
| 113 | + log_info("image_info is null\n"); |
| 114 | return EFI_BUFFER_TOO_SMALL; |
| 115 | } |
| 116 | |
| 117 | diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 118 | index bfd4687e10..6c9e14c37e 100644 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 119 | --- a/lib/efi_loader/efi_setup.c |
| 120 | +++ b/lib/efi_loader/efi_setup.c |
| 121 | @@ -17,6 +17,9 @@ |
| 122 | efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED; |
| 123 | |
| 124 | #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) |
| 125 | +#include <linux/bitfield.h> |
| 126 | +#include <linux/bitops.h> |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 127 | +#include <arm_ffa.h> |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 128 | /** |
| 129 | * efi_corstone1000_alloc_capsule_shared_buf - allocate capsule shared buffer |
| 130 | */ |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 131 | @@ -126,6 +129,34 @@ static efi_status_t efi_init_secure_boot(void) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 132 | } |
| 133 | #endif /* CONFIG_EFI_SECURE_BOOT */ |
| 134 | |
| 135 | +#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) |
| 136 | +/** |
| 137 | + * efi_corstone1000_uboot-efi_started_event - notifies SE Proxy FW update service |
| 138 | + * |
| 139 | + * This function notifies the SE Proxy update service that uboot efi has already started |
| 140 | + * |
| 141 | + * Return: |
| 142 | + * |
| 143 | + * 0: on success, otherwise failure |
| 144 | + * */ |
| 145 | +static int efi_corstone1000_uboot_efi_started_event(void) |
| 146 | +{ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 147 | + struct ffa_send_direct_data msg = {0}; |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 148 | + |
| 149 | + log_debug("[%s]\n", __func__); |
| 150 | + |
| 151 | + /* |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 152 | + * setting the kernel started event arguments: |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 153 | + * setting capsule update interface ID(31:16) |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 154 | + * the kernel started event ID(15:0) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 155 | + */ |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 156 | + msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) | |
| 157 | + PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 158 | + |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 159 | + return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg); |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 160 | +} |
| 161 | +#endif |
| 162 | + |
| 163 | /** |
| 164 | * efi_init_capsule - initialize capsule update state |
| 165 | * |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 166 | @@ -136,6 +167,14 @@ static efi_status_t efi_init_capsule(void) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 167 | efi_status_t ret = EFI_SUCCESS; |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 168 | |
| 169 | #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000) |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 170 | + int ffa_ret; |
| 171 | + |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 172 | + ffa_ret = efi_corstone1000_uboot_efi_started_event(); |
| 173 | + if (ffa_ret) |
| 174 | + debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n"); |
| 175 | + else |
| 176 | + debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n"); |
| 177 | + |
| 178 | ret = efi_corstone1000_alloc_capsule_shared_buf(); |
| 179 | if (ret != EFI_SUCCESS) { |
| 180 | printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n"); |
| 181 | -- |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame^] | 182 | 2.17.1 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 183 | |