[PATCH v2 05/34] ARM: add arm_mem_optee()

Ahmad Fatoum a.fatoum at pengutronix.de
Wed May 17 05:53:05 PDT 2023


On 17.05.23 11:03, Sascha Hauer wrote:
> We have several functions/macros named arm_mem_* returning the different
> addresses for early memory locations. Add one for OP-Tee as well.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  arch/arm/include/asm/barebox-arm.h | 5 +++++
>  arch/arm/mach-imx/atf.c            | 6 +++---
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
> index 6e6606d005..8ab1e90e94 100644
> --- a/arch/arm/include/asm/barebox-arm.h
> +++ b/arch/arm/include/asm/barebox-arm.h
> @@ -71,6 +71,11 @@ static inline void arm_fixup_vectors(void)
>  
>  void *barebox_arm_boot_dtb(void);
>  
> +static inline unsigned long arm_mem_optee(unsigned long endmem)
> +{
> +	return endmem - OPTEE_SIZE;
> +}

I'd prefer to return OPTEE_SIZE ? endmem - OPTEE_SIZE : 0;
That way we are a bit more robust against future broken code.

With that adressed:

Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>

> +
>  #define arm_mem_scratch(endmem) ((endmem) - OPTEE_SIZE - SZ_32K)
>  
>  static inline const void *arm_mem_scratch_get(void)
> diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
> index c5e6817aad..659798b95f 100644
> --- a/arch/arm/mach-imx/atf.c
> +++ b/arch/arm/mach-imx/atf.c
> @@ -141,7 +141,7 @@ __noreturn void imx8mm_load_and_start_image_via_tfa(void)
>  	imx8mm_load_bl33(bl33);
>  
>  	if (IS_ENABLED(CONFIG_FIRMWARE_IMX8MM_OPTEE))
> -		imx8m_load_and_start_optee_via_tfa(imx8mm, endmem - OPTEE_SIZE, bl33);
> +		imx8m_load_and_start_optee_via_tfa(imx8mm, arm_mem_optee(endmem), bl33);
>  	else
>  		imx8mm_load_and_start_tfa(imx8mm_bl31_bin);
>  }
> @@ -189,7 +189,7 @@ __noreturn void imx8mp_load_and_start_image_via_tfa(void)
>  	imx8mp_load_bl33(bl33);
>  
>  	if (IS_ENABLED(CONFIG_FIRMWARE_IMX8MP_OPTEE))
> -		imx8m_load_and_start_optee_via_tfa(imx8mp, endmem - OPTEE_SIZE, bl33);
> +		imx8m_load_and_start_optee_via_tfa(imx8mp, arm_mem_optee(endmem), bl33);
>  	else
>  		imx8mp_load_and_start_tfa(imx8mp_bl31_bin);
>  }
> @@ -238,7 +238,7 @@ __noreturn void imx8mn_load_and_start_image_via_tfa(void)
>  	imx8mn_load_bl33(bl33);
>  
>  	if (IS_ENABLED(CONFIG_FIRMWARE_IMX8MN_OPTEE))
> -		imx8m_load_and_start_optee_via_tfa(imx8mn, endmem - OPTEE_SIZE, bl33);
> +		imx8m_load_and_start_optee_via_tfa(imx8mn, arm_mem_optee(endmem), bl33);
>  	else
>  		imx8mn_load_and_start_tfa(imx8mn_bl31_bin);
>  }

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




More information about the barebox mailing list