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