[U-Boot] [PATCH] ARM: armv7: Add early stack for erratum workarounds

Nishanth Menon nm at ti.com
Tue Nov 20 23:14:52 UTC 2018


On 17:02-20181120, Nishanth Menon wrote:
> On 14:47-20181119, Andrew F. Davis wrote:
> > Some erratum workarounds call into C code before the stack
> > is setup, this can lead to values pushed onto the stack
> > being lost, firewall exceptions, and other undefined behavior.
> > 
> > Setup a temporary stack to allow these functions to work
> > correctly.
> > 
> > Signed-off-by: Andrew F. Davis <afd at ti.com>
> > ---
> >  arch/arm/cpu/armv7/start.S | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
> > index 81edec01bf..0cb6dd39cc 100644
> > --- a/arch/arm/cpu/armv7/start.S
> > +++ b/arch/arm/cpu/armv7/start.S
> > @@ -205,6 +205,15 @@ ENTRY(cpu_init_cp15)
> >  	mov	r2, r3, lsl #4		@ shift variant field for combined value
> >  	orr	r2, r4, r2		@ r2 has combined CPU variant + revision
> >  
> > +/* Early stack for ERRATA that needs into call C code */
> > +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK)
> > +	ldr	r0, =(CONFIG_SPL_STACK)
> > +#else
> > +	ldr	r0, =(CONFIG_SYS_INIT_SP_ADDR)
> > +#endif
> > +	bic	r0, r0, #7	/* 8-byte alignment for ABI compliance */
> > +	mov	sp, r0
> > +
> 
> Dumb q:
> Is this a little too late? bl cpu_init_cp15 gets invoked from reset..
> doesnt sp need to be setup prior to the call in?

OK. I guess I will answer my own dumb question -> we don't push till we
get here! Sigh.. I should have figured that when i introduced the
series!

I guess I introduced the bug in c616a0df297e ("ARM: Introduce erratum
workaround for 798870", just a mere 3 years ago :(...

Apologies, but not sure if intermediate stack setup should be something
folks prefer earlier or not.. will let ARM folks comment.

Reviewed-by: Nishanth Menon <nm at ti.com>

-- 
Regards,
Nishanth Menon


More information about the U-Boot mailing list