* [PATCH] arm: spl: flush and disable cache before jumping to OPTEE
@ 2021-09-25 14:05 Oleksandr Suvorov
2021-09-26 9:59 ` Peng Fan (OSS)
2021-10-14 23:44 ` Tom Rini
0 siblings, 2 replies; 4+ messages in thread
From: Oleksandr Suvorov @ 2021-09-25 14:05 UTC (permalink / raw)
To: u-boot
Cc: Ricardo Salveti, Oleksandr Suvorov, Alexandru Gagniuc, Bin Meng,
Marek Behún, Marek Vasut, Michael Walle, Pali Rohár,
Patrick Delaunay, Simon Glass, Stefan Roese, Tom Rini
From: Ricardo Salveti <ricardo@foundries.io>
Make sure to flush, disable caches and interrupts before jumpint 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>
---
arch/arm/lib/spl.c | 11 +++++++++++
common/spl/spl.c | 11 +++++++++--
include/spl.h | 9 +++++++++
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
index 8e2bdf3536..16e3cd557a 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)
+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 d55d3c2848..f3fab3c4d9 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -171,6 +171,14 @@ __weak void spl_board_prepare_for_optee(void *fdt)
{
}
+#if CONFIG_IS_ENABLED(OPTEE)
+__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! */
@@ -777,8 +785,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..8e7173d294 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
*
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm: spl: flush and disable cache before jumping to OPTEE
2021-09-25 14:05 [PATCH] arm: spl: flush and disable cache before jumping to OPTEE Oleksandr Suvorov
@ 2021-09-26 9:59 ` Peng Fan (OSS)
2021-10-14 23:44 ` Tom Rini
1 sibling, 0 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2021-09-26 9:59 UTC (permalink / raw)
To: Oleksandr Suvorov, u-boot
Cc: Ricardo Salveti, Alexandru Gagniuc, Bin Meng, Marek Behún,
Marek Vasut, Michael Walle, Pali Rohár, Patrick Delaunay,
Simon Glass, Stefan Roese, Tom Rini
On 2021/9/25 22:05, Oleksandr Suvorov wrote:
> From: Ricardo Salveti <ricardo@foundries.io>
>
> Make sure to flush, disable caches and interrupts before jumpint to
> OPTEE. This fixes the SDP->SPL->OPTEE boot flow on iMX6Q and most
> likely on some other ARM SoCs.
You have I/DCache and interrupt enabled in SPL?
Regards,
Peng.
>
> 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>
> ---
>
> arch/arm/lib/spl.c | 11 +++++++++++
> common/spl/spl.c | 11 +++++++++--
> include/spl.h | 9 +++++++++
> 3 files changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
> index 8e2bdf3536..16e3cd557a 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)
> +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 d55d3c2848..f3fab3c4d9 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -171,6 +171,14 @@ __weak void spl_board_prepare_for_optee(void *fdt)
> {
> }
>
> +#if CONFIG_IS_ENABLED(OPTEE)
> +__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! */
> @@ -777,8 +785,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..8e7173d294 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
> *
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm: spl: flush and disable cache before jumping to OPTEE
2021-09-25 14:05 [PATCH] arm: spl: flush and disable cache before jumping to OPTEE Oleksandr Suvorov
2021-09-26 9:59 ` Peng Fan (OSS)
@ 2021-10-14 23:44 ` Tom Rini
2021-10-17 11:00 ` Oleksandr Suvorov
1 sibling, 1 reply; 4+ messages in thread
From: Tom Rini @ 2021-10-14 23:44 UTC (permalink / raw)
To: Oleksandr Suvorov
Cc: u-boot, Ricardo Salveti, Alexandru Gagniuc, Bin Meng,
Marek Behún, Marek Vasut, Michael Walle, Pali Rohár,
Patrick Delaunay, Simon Glass, Stefan Roese
[-- Attachment #1: Type: text/plain, Size: 3146 bytes --]
On Sat, Sep 25, 2021 at 05:05:43PM +0300, Oleksandr Suvorov wrote:
> From: Ricardo Salveti <ricardo@foundries.io>
>
> Make sure to flush, disable caches and interrupts before jumpint 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>
> ---
>
> arch/arm/lib/spl.c | 11 +++++++++++
> common/spl/spl.c | 11 +++++++++--
> include/spl.h | 9 +++++++++
> 3 files changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
> index 8e2bdf3536..16e3cd557a 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)
> +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 d55d3c2848..f3fab3c4d9 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -171,6 +171,14 @@ __weak void spl_board_prepare_for_optee(void *fdt)
> {
> }
>
> +#if CONFIG_IS_ENABLED(OPTEE)
> +__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! */
> @@ -777,8 +785,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..8e7173d294 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
> *
At current, this causes evb-rk3229 and evb-rk3288 to fail to build. A
trivial "test on OPTEE_IMAGE" instead leads to warnings about a
noreturnn function returning. Please rebase on current master and
retest your use cases, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm: spl: flush and disable cache before jumping to OPTEE
2021-10-14 23:44 ` Tom Rini
@ 2021-10-17 11:00 ` Oleksandr Suvorov
0 siblings, 0 replies; 4+ messages in thread
From: Oleksandr Suvorov @ 2021-10-17 11:00 UTC (permalink / raw)
To: Tom Rini
Cc: U-Boot-Denx, Ricardo Salveti, Alexandru Gagniuc, Bin Meng,
Marek Behún, Marek Vasut, Michael Walle, Pali Rohár,
Patrick Delaunay, Simon Glass, Stefan Roese
Hello Tom,
On Fri, Oct 15, 2021 at 2:44 AM Tom Rini <trini@konsulko.com> wrote:
>
> On Sat, Sep 25, 2021 at 05:05:43PM +0300, Oleksandr Suvorov wrote:
>
> > From: Ricardo Salveti <ricardo@foundries.io>
> >
> > Make sure to flush, disable caches and interrupts before jumpint 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>
> > ---
> >
> > arch/arm/lib/spl.c | 11 +++++++++++
> > common/spl/spl.c | 11 +++++++++--
> > include/spl.h | 9 +++++++++
> > 3 files changed, 29 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
> > index 8e2bdf3536..16e3cd557a 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)
> > +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 d55d3c2848..f3fab3c4d9 100644
> > --- a/common/spl/spl.c
> > +++ b/common/spl/spl.c
> > @@ -171,6 +171,14 @@ __weak void spl_board_prepare_for_optee(void *fdt)
> > {
> > }
> >
> > +#if CONFIG_IS_ENABLED(OPTEE)
> > +__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! */
> > @@ -777,8 +785,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..8e7173d294 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
> > *
>
> At current, this causes evb-rk3229 and evb-rk3288 to fail to build. A
> trivial "test on OPTEE_IMAGE" instead leads to warnings about a
> noreturnn function returning. Please rebase on current master and
> retest your use cases, thanks!
Thank you for the notes! I've fixed both issues in the 2nd version of
the patchset.
>
> --
> Tom
--
Best regards,
Oleksandr Suvorov
Software Engineer
T: +380 63 8489656
E: oleksandr.suvorov@foundries.io
W: www.foundries.io
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-17 11:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-25 14:05 [PATCH] arm: spl: flush and disable cache before jumping to OPTEE Oleksandr Suvorov
2021-09-26 9:59 ` Peng Fan (OSS)
2021-10-14 23:44 ` Tom Rini
2021-10-17 11:00 ` Oleksandr Suvorov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.