blob: e95609a38dde60ed7191f9f5f002e909e88eab1b [file] [log] [blame]
Andrew Geisslerea144b032023-01-27 16:03:57 -06001From 7bf9c380c63726b7de8316e9c743cb06c9bc7842 Mon Sep 17 00:00:00 2001
Patrick Williams92b42cb2022-09-03 06:53:57 -05002From: Vishnu Banavath <vishnu.banavath@arm.com>
Patrick Williams8dd68482022-10-04 07:57:18 -05003Date: Mon, 15 Aug 2022 15:46:18 +0100
Andrew Geisslerea144b032023-01-27 16:03:57 -06004Subject: [PATCH 18/25] efi_loader: send bootcomplete message to secure enclave
Patrick Williams92b42cb2022-09-03 06:53:57 -05005
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>
Patrick Williams8dd68482022-10-04 07:57:18 -050014Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
15Upstream-Status: Pending [Not submitted to upstream yet]
Patrick Williams92b42cb2022-09-03 06:53:57 -050016---
17 include/configs/corstone1000.h | 2 +-
Patrick Williams8dd68482022-10-04 07:57:18 -050018 lib/efi_loader/efi_boottime.c | 43 ----------------------------------
Patrick Williams92b42cb2022-09-03 06:53:57 -050019 lib/efi_loader/efi_firmware.c | 2 +-
Patrick Williams8dd68482022-10-04 07:57:18 -050020 lib/efi_loader/efi_setup.c | 39 ++++++++++++++++++++++++++++++
21 4 files changed, 41 insertions(+), 45 deletions(-)
Patrick Williams92b42cb2022-09-03 06:53:57 -050022
23diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
Andrew Geisslerea144b032023-01-27 16:03:57 -060024index 77f96e87a1..4cf1170ffb 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050025--- 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)))
36diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
Andrew Geisslerea144b032023-01-27 16:03:57 -060037index 88f2d050be..1099ccc800 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -050038--- a/lib/efi_loader/efi_boottime.c
39+++ b/lib/efi_loader/efi_boottime.c
Andrew Geisslerea144b032023-01-27 16:03:57 -060040@@ -30,11 +30,6 @@
Patrick Williams8dd68482022-10-04 07:57:18 -050041 #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 */
Andrew Geisslerea144b032023-01-27 16:03:57 -060052@@ -2108,35 +2103,6 @@ static void efi_exit_caches(void)
Patrick Williams92b42cb2022-09-03 06:53:57 -050053 #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 Williams92b42cb2022-09-03 06:53:57 -050068- struct ffa_send_direct_data msg = {0};
Patrick Williams92b42cb2022-09-03 06:53:57 -050069-
70- log_debug("[%s]\n", __func__);
71-
72- /*
Patrick Williams92b42cb2022-09-03 06:53:57 -050073- * setting the kernel started event arguments:
74- * setting capsule update interface ID(31:16)
75- * the kernel started event ID(15:0)
76- */
Patrick Williams8dd68482022-10-04 07:57:18 -050077- msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
78- PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */
Patrick Williams92b42cb2022-09-03 06:53:57 -050079-
Andrew Geisslerea144b032023-01-27 16:03:57 -060080- return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
Patrick Williams92b42cb2022-09-03 06:53:57 -050081-}
82-
83-#endif
84-
85 /**
86 * efi_exit_boot_services() - stop all boot services
87 * @image_handle: handle of the loaded image
Andrew Geisslerea144b032023-01-27 16:03:57 -060088@@ -2243,15 +2209,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
Patrick Williams92b42cb2022-09-03 06:53:57 -050089 /* 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();
104diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
Patrick Williams8dd68482022-10-04 07:57:18 -0500105index af43d4502f..25f427b936 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -0500106--- 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
117diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
Andrew Geisslerea144b032023-01-27 16:03:57 -0600118index 443f409906..c154eb0e9d 100644
Patrick Williams92b42cb2022-09-03 06:53:57 -0500119--- 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 Williams8dd68482022-10-04 07:57:18 -0500127+#include <arm_ffa.h>
Patrick Williams92b42cb2022-09-03 06:53:57 -0500128 /**
129 * efi_corstone1000_alloc_capsule_shared_buf - allocate capsule shared buffer
130 */
Patrick Williams8dd68482022-10-04 07:57:18 -0500131@@ -126,6 +129,34 @@ static efi_status_t efi_init_secure_boot(void)
Patrick Williams92b42cb2022-09-03 06:53:57 -0500132 }
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 Williams92b42cb2022-09-03 06:53:57 -0500147+ struct ffa_send_direct_data msg = {0};
Patrick Williams92b42cb2022-09-03 06:53:57 -0500148+
149+ log_debug("[%s]\n", __func__);
150+
151+ /*
Patrick Williams8dd68482022-10-04 07:57:18 -0500152+ * setting the kernel started event arguments:
Patrick Williams92b42cb2022-09-03 06:53:57 -0500153+ * setting capsule update interface ID(31:16)
Patrick Williams8dd68482022-10-04 07:57:18 -0500154+ * the kernel started event ID(15:0)
Patrick Williams92b42cb2022-09-03 06:53:57 -0500155+ */
Patrick Williams8dd68482022-10-04 07:57:18 -0500156+ msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
157+ PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */
Patrick Williams92b42cb2022-09-03 06:53:57 -0500158+
Andrew Geisslerea144b032023-01-27 16:03:57 -0600159+ return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
Patrick Williams92b42cb2022-09-03 06:53:57 -0500160+}
161+#endif
162+
163 /**
164 * efi_init_capsule - initialize capsule update state
165 *
Patrick Williams8dd68482022-10-04 07:57:18 -0500166@@ -136,6 +167,14 @@ static efi_status_t efi_init_capsule(void)
Patrick Williams92b42cb2022-09-03 06:53:57 -0500167 efi_status_t ret = EFI_SUCCESS;
Patrick Williams92b42cb2022-09-03 06:53:57 -0500168
169 #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
Patrick Williams8dd68482022-10-04 07:57:18 -0500170+ int ffa_ret;
171+
Patrick Williams92b42cb2022-09-03 06:53:57 -0500172+ 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 Williams8dd68482022-10-04 07:57:18 -05001822.17.1
Patrick Williams92b42cb2022-09-03 06:53:57 -0500183