Re: [PATCH v2 04/34] ARM: put scratch mem area below OP-TEE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 17, 2023 at 02:48:43PM +0200, Ahmad Fatoum wrote:
> On 17.05.23 11:03, Sascha Hauer wrote:
> > We want to reserve memory for OP-TEE at the end of available SDRAM,
> > so move the scratch area below OP-TEE and not above.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> > ---
> >  arch/arm/include/asm/barebox-arm.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
> > index f446044be6..6e6606d005 100644
> > --- a/arch/arm/include/asm/barebox-arm.h
> > +++ b/arch/arm/include/asm/barebox-arm.h
> > @@ -71,14 +71,14 @@ static inline void arm_fixup_vectors(void)
> >  
> >  void *barebox_arm_boot_dtb(void);
> >  
> > -#define arm_mem_scratch(endmem) ((endmem) - SZ_32K)
> > +#define arm_mem_scratch(endmem) ((endmem) - OPTEE_SIZE - SZ_32K)
> >  
> >  static inline const void *arm_mem_scratch_get(void)
> >  {
> >  	return (const void *)arm_mem_scratch(arm_mem_endmem_get());
> >  }
> >  
> > -#define arm_mem_stack_top(endmem) ((endmem) - SZ_64K - OPTEE_SIZE)
> > +#define arm_mem_stack_top(endmem) ((endmem) - SZ_64K)
> 
> I don't understand why you drop OPTEE_SIZE here. Wouldn't the stack
> now eat into the OP-TEE region?

I accidently thought that arm_mem_stack_top() is calculated based on the
region above it, namely arm_mem_scratch(), but really it's calculated
based on endmem directly.

Indeed it's wrong like this, it should be:

#define arm_mem_stack_top(endmem) (arm_mem_scratch(endmem) - SZ_64K)

I just stumbled upon the SZ_64K here. I followed the value back to 2016
and found 75c96bd2459e ("ARM: Do not use last 64KiB of address space for
barebox"). I had a board that time that has SDRAM at the very end of the
32bit address space. On that board it happened that we overwrite parts
of the lowlevel memory with the vector table. It seems that has been
lost over time as now we put the scratch space and possibly parts of
OP-TEE into the last 64k.

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 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux