[PATCH 13/14] ARM: optee-early: drop start_optee_early()

Sascha Hauer s.hauer at pengutronix.de
Fri Jun 27 07:07:59 PDT 2025


Now that all users of start_optee_early() use the SoC variants
make start_optee_early() a static function. While at it move the zeroing
of the data_location which was duplicated in the SoC specific functions
to start_optee_early().

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/lib32/optee-early.c | 34 +++++++++++++++-------------------
 include/tee/optee.h          |  1 -
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/arch/arm/lib32/optee-early.c b/arch/arm/lib32/optee-early.c
index 6f842bdd2010582c61a8e88c9f644e6ae93bcbf4..7ef3f3e9c6f3b934aba9d4d3db2df3fd7a0aa642 100644
--- a/arch/arm/lib32/optee-early.c
+++ b/arch/arm/lib32/optee-early.c
@@ -15,12 +15,24 @@
 
 static jmp_buf tee_buf;
 
-int start_optee_early(void *fdt, void *tee)
+static int start_optee_early(void *fdt, void *tee, void *data_location,
+			     unsigned int data_location_size)
 {
 	void (*tee_start)(void *r0, void *r1, void *r2);
 	struct optee_header *hdr;
 	int ret;
 
+	/* We expect this function to be called with data caches disabled */
+	BUG_ON(get_cr() & CR_C);
+
+	/*
+	 * Set the OP-TEE <-> barebox exchange data location to zero.
+	 * This is optional since recent OP-TEE versions perform the
+	 * memset too.
+	 */
+	if (data_location)
+		memset(data_location, 0, data_location_size);
+
 	hdr = tee;
 	ret = optee_verify_header(hdr);
 	if (ret < 0)
@@ -49,15 +61,7 @@ int imx6q_start_optee_early(void *fdt, void *tee, void *data_location,
 	/* Add early non-secure TZASC region1 to pass DTO */
 	imx6q_tzc380_early_ns_region1();
 
-	/*
-	 * Set the OP-TEE <-> barebox exchange data location to zero.
-	 * This is optional since recent OP-TEE versions perform the
-	 * memset too.
-	 */
-	if (data_location)
-		memset(data_location, 0, data_location_size);
-
-	return start_optee_early(fdt, tee);
+	return start_optee_early(fdt, tee, data_location, data_location_size);
 }
 
 int imx6ul_start_optee_early(void *fdt, void *tee, void *data_location,
@@ -69,13 +73,5 @@ int imx6ul_start_optee_early(void *fdt, void *tee, void *data_location,
 	/* Add early non-secure TZASC region1 to pass DTO */
 	imx6ul_tzc380_early_ns_region1();
 
-	/*
-	 * Set the OP-TEE <-> barebox exchange data location to zero.
-	 * This is optional since recent OP-TEE versions perform the
-	 * memset too.
-	 */
-	if (data_location)
-		memset(data_location, 0, data_location_size);
-
-	return start_optee_early(fdt, tee);
+	return start_optee_early(fdt, tee, data_location, data_location_size);
 }
diff --git a/include/tee/optee.h b/include/tee/optee.h
index 943dbb8fdab6a11e25fb27e3487fe6fdec59a182..77f7924aa4793c001aa6fb15440729e6c77bd483 100644
--- a/include/tee/optee.h
+++ b/include/tee/optee.h
@@ -53,7 +53,6 @@ static inline int optee_get_membase(u64 *membase)
 
 #ifdef __PBL__
 
-int start_optee_early(void* fdt, void* tee);
 int imx6q_start_optee_early(void *fdt, void *tee, void *data_location,
 			    unsigned int data_location_size);
 int imx6ul_start_optee_early(void *fdt, void *tee, void *data_location,

-- 
2.39.5




More information about the barebox mailing list