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

Fabian Pflug f.pflug at pengutronix.de
Wed Dec 10 01:32:13 PST 2025


Hello Sascha :)

On Wed, 2025-12-10 at 08:18 +0100, Sascha Hauer wrote:
> 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.

Yes, you are right! Don't know why I did not see that...

This also makes the third patch in the series wrong, because it will remove the offset twice in another way.

I will send a new series after resolving the comment on the other patch. :)

Fabian

> 
> Sascha



More information about the barebox mailing list