[PATCH 01/27] ARM: fix scratch mem position with OP-TEE

Ahmad Fatoum a.fatoum at pengutronix.de
Fri May 12 10:17:05 PDT 2023


Hi,

On 12.05.23 13:09, Sascha Hauer wrote:
> OP-TEE is placed right below the end of memory, so the scratch space
> has to go below it.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  arch/arm/include/asm/barebox-arm.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
> index 0cf4549cd7..711ccd2510 100644
> --- a/arch/arm/include/asm/barebox-arm.h
> +++ b/arch/arm/include/asm/barebox-arm.h
> @@ -75,7 +75,7 @@ void *barebox_arm_boot_dtb(void);
>  
>  static inline const void *arm_mem_scratch_get(void)
>  {
> -	return (const void *)__arm_mem_scratch(arm_mem_endmem_get());
> +	return (const void *)__arm_mem_scratch(arm_mem_endmem_get() - OPTEE_SIZE);

PBL uses __arm_mem_scratch, so you would've to add OPTEE_SIZE there.

I hadn't done it, because I wrote arm_mem_scratch_get() with the expectation
that OPTEE_SIZE would be omitted from the RAM bank size, so it gets mapped
uncacheable by simply being considered non-RAM, see for example the usage
sites of CONFIG_FIRMWARE_IMX8M*_OPTEE. You'll have to fix these sites
too to avoid reserving the memory twice.

>  }
>  
>  #define arm_mem_stack_top(membase, endmem) ((endmem) - SZ_64K - OPTEE_SIZE)

-- 
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