[PATCH 1/3] ARM: make arm_mem_scratch respect the OP-TEE stack

Sascha Hauer s.hauer at pengutronix.de
Tue Dec 9 23:18:16 PST 2025


Hi Fabian,

On Mon, Dec 08, 2025 at 10:28:38AM +0100, Fabian Pflug wrote:
> According to the ASCII-ART above, before the end of memory comes the
> optee memory, then the scratch stack.
> 
> Signed-off-by: Fabian Pflug <f.pflug 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 11be8b8583..e630969796 100644
> --- a/arch/arm/include/asm/barebox-arm.h
> +++ b/arch/arm/include/asm/barebox-arm.h
> @@ -159,7 +159,7 @@ static inline unsigned long arm_mem_stack_top(unsigned long endmem)
>  
>  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_optee(arm_mem_endmem_get()));

arm_mem_scratch() is:

static inline unsigned long arm_mem_scratch(unsigned long endmem)
{
	return arm_mem_optee(endmem) - SCRATCH_SIZE;
}

So this already has the OPTEE space substracted. With your patch it's
substracted twice.

Sascha

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