summaryrefslogtreecommitdiff
path: root/drivers/tee/tee-uclass.c
diff options
context:
space:
mode:
authorEtienne Carriere <etienne.carriere@linaro.org>2021-05-19 17:27:41 +0300
committerTom Rini <trini@konsulko.com>2021-07-23 14:13:25 +0300
commit9e6da34c72274578be6f86ba7b7aa7849a624315 (patch)
treeb620295bc54e40f7a00a60e313caa5fe3073f072 /drivers/tee/tee-uclass.c
parent674afa6b3588dafe02b99406278ed81216fbefcb (diff)
downloadu-boot-9e6da34c72274578be6f86ba7b7aa7849a624315.tar.xz
tee: optee: sync cache on pre-reloc OP-TEE invocation
This change ensures both U-Boot and OP-TEE see the same content from shared memory when OP-TEE is invoked prior U-Boot relocation. This change is required since U-Boot may execute with data cache off while OP-TEE always enables cache on memory shared with U-Boot. Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'drivers/tee/tee-uclass.c')
-rw-r--r--drivers/tee/tee-uclass.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c
index cb1b28e2f8..52412a4098 100644
--- a/drivers/tee/tee-uclass.c
+++ b/drivers/tee/tee-uclass.c
@@ -1,15 +1,17 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright (c) 2018 Linaro Limited
+ * Copyright (c) 2018-2020 Linaro Limited
*/
#define LOG_CATEGORY UCLASS_TEE
#include <common.h>
+#include <cpu_func.h>
#include <dm.h>
#include <log.h>
#include <malloc.h>
#include <tee.h>
+#include <asm/cache.h>
#include <dm/device-internal.h>
#include <dm/uclass-internal.h>
@@ -235,3 +237,18 @@ void tee_optee_ta_uuid_to_octets(u8 d[TEE_UUID_LEN],
d[7] = s->time_hi_and_version;
memcpy(d + 8, s->clock_seq_and_node, sizeof(s->clock_seq_and_node));
}
+
+void tee_flush_all_shm_dcache(struct udevice *dev)
+{
+ struct tee_uclass_priv *priv = dev_get_uclass_priv(dev);
+ struct tee_shm *s;
+
+ list_for_each_entry(s, &priv->list_shm, link) {
+ ulong start = rounddown((ulong)s->addr,
+ CONFIG_SYS_CACHELINE_SIZE);
+ ulong end = roundup((ulong)s->addr + s->size,
+ CONFIG_SYS_CACHELINE_SIZE);
+
+ flush_dcache_range(start, end);
+ }
+}