U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/1] arm: spl: prepare for jumping to OPTEE
@ 2021-10-20 12:12 Oleksandr Suvorov
  2021-10-20 12:12 ` [PATCH v3 1/1] " Oleksandr Suvorov
  0 siblings, 1 reply; 3+ messages in thread
From: Oleksandr Suvorov @ 2021-10-20 12:12 UTC (permalink / raw)
  To: u-boot
  Cc: Tom Rini, Oleksandr Suvorov, Alexandru Gagniuc, Bin Meng,
	Jaehoon Chung, Marek Behún, Marek Vasut, Michael Walle,
	Pali Rohár, Patrick Delaunay, Ricardo Salveti, Simon Glass


This series introduces a weak and ARM-specific function to jump into
OP-TEE from SPL. The ARM-specific function fixes a system halting
when jumping to OP-TEE on some SoCs (the issue was found and fixed
for iMX6Q).

Changes in v3:
- squashed the fix commit :)

Changes in v2:
- fix: building on evb-rk3229 and evb-rk3288;
- fix: warning about return from noreturn-function.

Ricardo Salveti (1):
  arm: spl: prepare for jumping to OPTEE

 arch/arm/lib/spl.c | 11 +++++++++++
 common/spl/spl.c   | 11 +++++++++--
 include/spl.h      | 11 ++++++++++-
 3 files changed, 30 insertions(+), 3 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v3 1/1] arm: spl: prepare for jumping to OPTEE
  2021-10-20 12:12 [PATCH v3 0/1] arm: spl: prepare for jumping to OPTEE Oleksandr Suvorov
@ 2021-10-20 12:12 ` Oleksandr Suvorov
  2021-10-26 13:34   ` Tom Rini
  0 siblings, 1 reply; 3+ messages in thread
From: Oleksandr Suvorov @ 2021-10-20 12:12 UTC (permalink / raw)
  To: u-boot
  Cc: Tom Rini, Ricardo Salveti, Oleksandr Suvorov, Alexandru Gagniuc,
	Bin Meng, Jaehoon Chung, Marek Behún, Marek Vasut,
	Michael Walle, Pali Rohár, Patrick Delaunay, Simon Glass

From: Ricardo Salveti <ricardo@foundries.io>

Make sure to (if applicable) flush the D-cache, invalidate I-cache,
and disable MMU and caches before jumping to OPTEE.
This fixes the SDP->SPL->OPTEE boot flow on iMX6Q and most likely on
some other ARM SoCs.

Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
Co-developed-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
---

Changes in v3:
- squashed the fix commit :)

Changes in v2:
- fix: building on evb-rk3229 and evb-rk3288;
- fix: warning about return from noreturn-function.

 arch/arm/lib/spl.c | 11 +++++++++++
 common/spl/spl.c   | 11 +++++++++--
 include/spl.h      | 11 ++++++++++-
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
index 8e2bdf3536..4f9b84ba34 100644
--- a/arch/arm/lib/spl.c
+++ b/arch/arm/lib/spl.c
@@ -77,3 +77,14 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
 }
 #endif	/* CONFIG_ARM64 */
 #endif
+
+#if CONFIG_IS_ENABLED(OPTEE_IMAGE)
+void __noreturn jump_to_image_optee(struct spl_image_info *spl_image)
+{
+	/* flush and turn off caches before jumping to OPTEE */
+	cleanup_before_linux();
+
+	spl_optee_entry(NULL, NULL, spl_image->fdt_addr,
+			(void *)spl_image->entry_point);
+}
+#endif
diff --git a/common/spl/spl.c b/common/spl/spl.c
index a9304d4148..0c08da06e8 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -174,6 +174,14 @@ __weak void spl_board_prepare_for_optee(void *fdt)
 {
 }
 
+#if CONFIG_IS_ENABLED(OPTEE_IMAGE)
+__weak void __noreturn jump_to_image_optee(struct spl_image_info *spl_image)
+{
+	spl_optee_entry(NULL, NULL, spl_image->fdt_addr,
+			(void *)spl_image->entry_point);
+}
+#endif
+
 __weak void spl_board_prepare_for_boot(void)
 {
 	/* Nothing to do! */
@@ -780,8 +788,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	case IH_OS_TEE:
 		debug("Jumping to U-Boot via OP-TEE\n");
 		spl_board_prepare_for_optee(spl_image.fdt_addr);
-		spl_optee_entry(NULL, NULL, spl_image.fdt_addr,
-				(void *)spl_image.entry_point);
+		jump_to_image_optee(&spl_image);
 		break;
 #endif
 #if CONFIG_IS_ENABLED(OPENSBI)
diff --git a/include/spl.h b/include/spl.h
index afbf39bef4..f7d1ef5c88 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -460,6 +460,15 @@ int spl_board_boot_device(u32 boot_device);
  */
 void __noreturn jump_to_image_linux(struct spl_image_info *spl_image);
 
+/**
+ * jump_to_image_linux() - Jump to OP-TEE OS from SPL
+ *
+ * This jumps into OP-TEE OS using the information in @spl_image.
+ *
+ * @spl_image: Image description to set up
+ */
+void __noreturn jump_to_image_optee(struct spl_image_info *spl_image);
+
 /**
  * spl_start_uboot() - Check if SPL should start the kernel or U-Boot
  *
@@ -751,7 +760,7 @@ struct bl_params *bl2_plat_get_bl31_params_v2_default(uintptr_t bl32_entry,
  * @arg2: device tree address, (ARMv7 standard bootarg #2)
  * @arg3: non-secure entry address (ARMv7 bootarg #0)
  */
-void spl_optee_entry(void *arg0, void *arg1, void *arg2, void *arg3);
+void __noreturn spl_optee_entry(void *arg0, void *arg1, void *arg2, void *arg3);
 
 /**
  * spl_invoke_opensbi - boot using a RISC-V OpenSBI image
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 1/1] arm: spl: prepare for jumping to OPTEE
  2021-10-20 12:12 ` [PATCH v3 1/1] " Oleksandr Suvorov
@ 2021-10-26 13:34   ` Tom Rini
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Rini @ 2021-10-26 13:34 UTC (permalink / raw)
  To: Oleksandr Suvorov
  Cc: u-boot, Ricardo Salveti, Alexandru Gagniuc, Bin Meng,
	Jaehoon Chung, Marek Behún, Marek Vasut, Michael Walle,
	Pali Rohár, Patrick Delaunay, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

On Wed, Oct 20, 2021 at 03:12:06PM +0300, Oleksandr Suvorov wrote:

> From: Ricardo Salveti <ricardo@foundries.io>
> 
> Make sure to (if applicable) flush the D-cache, invalidate I-cache,
> and disable MMU and caches before jumping to OPTEE.
> This fixes the SDP->SPL->OPTEE boot flow on iMX6Q and most likely on
> some other ARM SoCs.
> 
> Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
> Co-developed-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-26 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-20 12:12 [PATCH v3 0/1] arm: spl: prepare for jumping to OPTEE Oleksandr Suvorov
2021-10-20 12:12 ` [PATCH v3 1/1] " Oleksandr Suvorov
2021-10-26 13:34   ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox