blob: 2caeb58b82c7ec0c05381a83788d435b15793dda [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 370422921b2a3f4f7b73ce5b08820c24e82bba19 Mon Sep 17 00:00:00 2001
Brad Bishopbec4ebc2022-08-03 09:55:16 -04002From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
3Date: Thu, 18 Nov 2021 16:42:59 +0000
Patrick Williams92b42cb2022-09-03 06:53:57 -05004Subject: [PATCH 13/24] corstone1000: Make sure shared buffer contents are not
Brad Bishopbec4ebc2022-08-03 09:55:16 -04005 cached
6
7After updating the shared buffer, it is required to flush the cache
8to ensure that the secure world sees expected the shared buffer
9contents.
10
11The MM communication shared buffer is configured in device region of optee
12which has cache disabled. So we need to invalidate the cache every time we
13update the buffer on uboot otherwise the secure world does not see the
14accurate values.
15
16Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
17%% original patch: 0027-Make-sure-shared-buffer-contents-are-not-cached.patch
18
19%% original patch: 0027-Make-sure-shared-buffer-contents-are-not-cached.patch
20
21Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
22---
23 lib/efi_loader/efi_variable_tee.c | 6 ++++++
24 1 file changed, 6 insertions(+)
25
26diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
27index 9cb8cfb9c779..b6be2b54a030 100644
28--- a/lib/efi_loader/efi_variable_tee.c
29+++ b/lib/efi_loader/efi_variable_tee.c
30@@ -22,6 +22,7 @@
31 #if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
32
33 #include <arm_ffa_helper.h>
34+#include <cpu_func.h>
35 #include <mapmem.h>
36
37 /* MM return codes */
38@@ -335,6 +336,11 @@ static efi_status_t __efi_runtime ffa_mm_communicate(void *comm_buf, ulong comm_
39 virt_shared_buf = (void *)map_sysmem((phys_addr_t)FFA_SHARED_MM_BUFFER_ADDR, 0);
40 efi_memcpy_runtime(virt_shared_buf, comm_buf, tx_data_size);
41
42+ /* The secure world has cache disabled for device region which we use for shared buffer
43+ So, the secure world reads the data from DDR. Let's flush the cache so the DDR is
44+ updated with the latest data */
45+ invalidate_dcache_all();
46+
47 /* Announce there is data in the shared buffer */
48
49 ffa_ret = ffa_notify_mm_sp();
50--
Patrick Williams92b42cb2022-09-03 06:53:57 -0500512.37.1
Brad Bishopbec4ebc2022-08-03 09:55:16 -040052