[PATCH 1/2] ARM: optee-early: drop superfluous sync_caches_for_execution

Rouven Czerwinski rouven.czerwinski at linaro.org
Wed Jun 4 03:00:15 PDT 2025


Hi,

On Tue, 3 Jun 2025 at 11:20, Fabian Pflug <f.pflug at pengutronix.de> wrote:
>
> We expect start_optee_early() to be called with caches disabled, so there
> is no point in calling sync_caches_for_execution inside.
>
> Therefore let's verify the assumption that caches are indeed disabled
> and drop the useless call.
>
> Co-authored-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> Signed-off-by: Fabian Pflug <f.pflug at pengutronix.de>
> ---
>  arch/arm/lib32/optee-early.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/lib32/optee-early.c b/arch/arm/lib32/optee-early.c
> index 735d829c99..0cda0ab163 100644
> --- a/arch/arm/lib32/optee-early.c
> +++ b/arch/arm/lib32/optee-early.c
> @@ -7,6 +7,7 @@
>   */
>  #include <asm/cache.h>
>  #include <asm/setjmp.h>
> +#include <asm/system.h>
>  #include <tee/optee.h>
>  #include <debug_ll.h>
>  #include <string.h>
> @@ -24,13 +25,16 @@ int start_optee_early(void *fdt, void *tee)
>         if (ret < 0)
>                 return ret;
>
> +       /* We expect this function to be called with data caches disabled */
> +       if (get_cr() & CR_C)
> +               return -ENXIO;
> +

I don't think returning an error here is correct, we should probably
just panic()
with a useful error message. None of the current callers of the function check
the return code, so at best the board starts without OP-TEE, at worst
it randomly
hangs because no PSCI provider can be found.

>         memcpy((void *)hdr->init_load_addr_lo, tee + sizeof(*hdr), hdr->init_size);
>         tee_start = (void *) hdr->init_load_addr_lo;
>
>         /* We use setjmp/longjmp here because OP-TEE clobbers most registers */
>         ret = setjmp(tee_buf);
>         if (ret == 0) {
> -               sync_caches_for_execution();
>                 tee_start(0, 0, fdt);
>                 longjmp(tee_buf, 1);
>         }
> --
> 2.39.5
>

- Rouven



More information about the barebox mailing list