diff mbox

[U-Boot,PATCHv2,1/2] mpc85xx: Initial SP alignment is wrong.

Message ID 1343077083-13983-1-git-send-email-Joakim.Tjernlund@transmode.se
State Accepted, archived
Delegated to: Andy Fleming
Headers show

Commit Message

Joakim Tjernlund July 23, 2012, 8:58 p.m. UTC
PowerPC mandates SP to be 16 bytes aligned.
Furthermore, a stack frame is added, pointing to the reset vector
which may in the way when gdb is walking the stack because
the reset vector may not accessible depending on emulator settings.
Also use a temp register so gdb doesn't pick up intermediate values.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---

 v2 - Address Scott Wood's comments
 arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

Comments

Joakim Tjernlund Aug. 14, 2012, 8:55 p.m. UTC | #1
Ping?

>
> PowerPC mandates SP to be 16 bytes aligned.
> Furthermore, a stack frame is added, pointing to the reset vector
> which may in the way when gdb is walking the stack because
> the reset vector may not accessible depending on emulator settings.
> Also use a temp register so gdb doesn't pick up intermediate values.
>
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>
>  v2 - Address Scott Wood's comments
>  arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
>  1 files changed, 5 insertions(+), 11 deletions(-)
>
> diff --git arch/powerpc/cpu/mpc85xx/start.S arch/powerpc/cpu/mpc85xx/start.S
> index 8d66cf1..4973682 100644
> --- arch/powerpc/cpu/mpc85xx/start.S
> +++ arch/powerpc/cpu/mpc85xx/start.S
> @@ -848,18 +848,12 @@ version_string:
>     .globl   _start_cont
>  _start_cont:
>     /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
> -   lis   r1,CONFIG_SYS_INIT_RAM_ADDR@h
> -   ori   r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l
> -
> +   lis   r3,(CONFIG_SYS_INIT_RAM_ADDR)@h
> +   ori   r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */
>     li   r0,0
> -   stwu   r0,-4(r1)
> -   stwu   r0,-4(r1)      /* Terminate call chain */
> -
> -   stwu   r1,-8(r1)      /* Save back chain and move SP */
> -   lis   r0,RESET_VECTOR@h   /* Address of reset vector */
> -   ori   r0,r0,RESET_VECTOR@l
> -   stwu   r1,-8(r1)      /* Save back chain and move SP */
> -   stw   r0,+12(r1)      /* Save return addr (underflow vect) */
> +   stw   r0,0(r3)   /* Terminate Back Chain */
> +   stw   r0,+4(r3)   /* NULL return address. */
> +   mr   r1,r3      /* Transfer to SP(r1) */
>
>     GET_GOT
>     bl   cpu_init_early_f
> --
> 1.7.3.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Scott Wood Aug. 14, 2012, 9:01 p.m. UTC | #2
On 08/14/2012 03:55 PM, Joakim Tjernlund wrote:
> Ping?
> 
>>
>> PowerPC mandates SP to be 16 bytes aligned.
>> Furthermore, a stack frame is added, pointing to the reset vector
>> which may in the way when gdb is walking the stack because
>> the reset vector may not accessible depending on emulator settings.
>> Also use a temp register so gdb doesn't pick up intermediate values.
>>
>> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
>> ---
>>
>>  v2 - Address Scott Wood's comments
>>  arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
>>  1 files changed, 5 insertions(+), 11 deletions(-)

Andy Fleming is the 85xx custodian, but you didn't CC him.

-Scott
Kumar Gala Aug. 14, 2012, 9:28 p.m. UTC | #3
On Jul 23, 2012, at 3:58 PM, Joakim Tjernlund wrote:

> PowerPC mandates SP to be 16 bytes aligned.
> Furthermore, a stack frame is added, pointing to the reset vector
> which may in the way when gdb is walking the stack because
> the reset vector may not accessible depending on emulator settings.
> Also use a temp register so gdb doesn't pick up intermediate values.
> 
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
> 
> v2 - Address Scott Wood's comments
> arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
> 1 files changed, 5 insertions(+), 11 deletions(-)

Acked-by: Kumar Gala <galak@kernel.crashing.org>

- k
Joakim Tjernlund Aug. 15, 2012, 7:05 a.m. UTC | #4
Scott Wood <scottwood@freescale.com> wrote on 2012/08/14 23:01:47:
>
> On 08/14/2012 03:55 PM, Joakim Tjernlund wrote:
> > Ping?
> >
> >>
> >> PowerPC mandates SP to be 16 bytes aligned.
> >> Furthermore, a stack frame is added, pointing to the reset vector
> >> which may in the way when gdb is walking the stack because
> >> the reset vector may not accessible depending on emulator settings.
> >> Also use a temp register so gdb doesn't pick up intermediate values.
> >>
> >> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> >> ---
> >>
> >>  v2 - Address Scott Wood's comments
> >>  arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
> >>  1 files changed, 5 insertions(+), 11 deletions(-)
>
> Andy Fleming is the 85xx custodian, but you didn't CC him.

Oh, didn't notice that Andy was the custodian, there isn't
an entry in MAINTAINERS.

Andy, you think you can pick up
[PATCHv2 1/2] mpc85xx: Initial SP alignment is wrong.

 Jocke
Joakim Tjernlund Aug. 15, 2012, 7:10 a.m. UTC | #5
Kumar Gala <galak@kernel.crashing.org> wrote on 2012/08/14 23:28:45:
>
>
> On Jul 23, 2012, at 3:58 PM, Joakim Tjernlund wrote:
>
> > PowerPC mandates SP to be 16 bytes aligned.
> > Furthermore, a stack frame is added, pointing to the reset vector
> > which may in the way when gdb is walking the stack because
> > the reset vector may not accessible depending on emulator settings.
> > Also use a temp register so gdb doesn't pick up intermediate values.
> >
> > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> > ---
> >
> > v2 - Address Scott Wood's comments
> > arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
> > 1 files changed, 5 insertions(+), 11 deletions(-)
>
> Acked-by: Kumar Gala <galak@kernel.crashing.org>

Thanks Kumar

Will you pick up?
 [PATCHv2 2/2] powerpc: Stack Pointer not properly aligned

It is not 85xx specific but for all PowerPC

  Jocke
Scott Wood Aug. 15, 2012, 5:13 p.m. UTC | #6
On 08/15/2012 02:10 AM, Joakim Tjernlund wrote:
> Kumar Gala <galak@kernel.crashing.org> wrote on 2012/08/14 23:28:45:
>>
>>
>> On Jul 23, 2012, at 3:58 PM, Joakim Tjernlund wrote:
>>
>>> PowerPC mandates SP to be 16 bytes aligned.
>>> Furthermore, a stack frame is added, pointing to the reset vector
>>> which may in the way when gdb is walking the stack because
>>> the reset vector may not accessible depending on emulator settings.
>>> Also use a temp register so gdb doesn't pick up intermediate values.
>>>
>>> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
>>> ---
>>>
>>> v2 - Address Scott Wood's comments
>>> arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
>>> 1 files changed, 5 insertions(+), 11 deletions(-)
>>
>> Acked-by: Kumar Gala <galak@kernel.crashing.org>
> 
> Thanks Kumar
> 
> Will you pick up?
>  [PATCHv2 2/2] powerpc: Stack Pointer not properly aligned
> 
> It is not 85xx specific but for all PowerPC

I don't think Kumar has a U-Boot tree to pull it into.  There's no
general PPC custodian.  Probably both patches should go via Andy.

-Scott
Andy Fleming Aug. 16, 2012, 11:40 p.m. UTC | #7
I will pull them. Possibly tomorrow. I'm currently buried in other work, but Friday is supposed to be my U-Boot Custodian day. :)

Andy
On Aug 15, 2012, at 12:13 PM, Scott Wood wrote:

> On 08/15/2012 02:10 AM, Joakim Tjernlund wrote:
>> Kumar Gala <galak@kernel.crashing.org> wrote on 2012/08/14 23:28:45:
>>> 
>>> 
>>> On Jul 23, 2012, at 3:58 PM, Joakim Tjernlund wrote:
>>> 
>>>> PowerPC mandates SP to be 16 bytes aligned.
>>>> Furthermore, a stack frame is added, pointing to the reset vector
>>>> which may in the way when gdb is walking the stack because
>>>> the reset vector may not accessible depending on emulator settings.
>>>> Also use a temp register so gdb doesn't pick up intermediate values.
>>>> 
>>>> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
>>>> ---
>>>> 
>>>> v2 - Address Scott Wood's comments
>>>> arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
>>>> 1 files changed, 5 insertions(+), 11 deletions(-)
>>> 
>>> Acked-by: Kumar Gala <galak@kernel.crashing.org>
>> 
>> Thanks Kumar
>> 
>> Will you pick up?
>> [PATCHv2 2/2] powerpc: Stack Pointer not properly aligned
>> 
>> It is not 85xx specific but for all PowerPC
> 
> I don't think Kumar has a U-Boot tree to pull it into.  There's no
> general PPC custodian.  Probably both patches should go via Andy.
> 
> -Scott
>
Andy Fleming Aug. 22, 2012, 9:08 p.m. UTC | #8
On Mon, Jul 23, 2012 at 3:58 PM, Joakim Tjernlund
<Joakim.Tjernlund@transmode.se> wrote:
> PowerPC mandates SP to be 16 bytes aligned.
> Furthermore, a stack frame is added, pointing to the reset vector
> which may in the way when gdb is walking the stack because
> the reset vector may not accessible depending on emulator settings.
> Also use a temp register so gdb doesn't pick up intermediate values.
>
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> ---
>
>  v2 - Address Scott Wood's comments
>  arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
>  1 files changed, 5 insertions(+), 11 deletions(-)
>
> diff --git arch/powerpc/cpu/mpc85xx/start.S arch/powerpc/cpu/mpc85xx/start.S


Why are your patches different from everyone else's? When I try to
apply this, I get errors because it can't find
"powerpc/cpu/mpc85xx...". git am leaves off the first directory,
because the usual practice is to send patches with these filenames:

diff --git a/arch/powerpc/cpu/mpc85xx/start.S b/arch/powerpc/cpu/mpc85xx/start.S

I fixed it by hand, but let's not make that a habit. Is there some
setting that I don't have that would make it so I could ignore this?


> index 8d66cf1..4973682 100644
> --- arch/powerpc/cpu/mpc85xx/start.S
> +++ arch/powerpc/cpu/mpc85xx/start.S
> @@ -848,18 +848,12 @@ version_string:
>         .globl  _start_cont
>  _start_cont:
>         /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
> -       lis     r1,CONFIG_SYS_INIT_RAM_ADDR@h
> -       ori     r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l
> -
> +       lis     r3,(CONFIG_SYS_INIT_RAM_ADDR)@h
> +       ori     r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */
>         li      r0,0
> -       stwu    r0,-4(r1)
> -       stwu    r0,-4(r1)               /* Terminate call chain */
> -
> -       stwu    r1,-8(r1)               /* Save back chain and move SP */
> -       lis     r0,RESET_VECTOR@h       /* Address of reset vector */
> -       ori     r0,r0,RESET_VECTOR@l
> -       stwu    r1,-8(r1)               /* Save back chain and move SP */
> -       stw     r0,+12(r1)              /* Save return addr (underflow vect) */
> +       stw     r0,0(r3)        /* Terminate Back Chain */
> +       stw     r0,+4(r3)       /* NULL return address. */
> +       mr      r1,r3           /* Transfer to SP(r1) */
>
>         GET_GOT
>         bl      cpu_init_early_f
> --
> 1.7.3.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Joakim Tjernlund Aug. 23, 2012, 7:21 a.m. UTC | #9
Andy Fleming <afleming@gmail.com> wrote on 2012/08/22 23:08:45:
>
> On Mon, Jul 23, 2012 at 3:58 PM, Joakim Tjernlund
> <Joakim.Tjernlund@transmode.se> wrote:
> > PowerPC mandates SP to be 16 bytes aligned.
> > Furthermore, a stack frame is added, pointing to the reset vector
> > which may in the way when gdb is walking the stack because
> > the reset vector may not accessible depending on emulator settings.
> > Also use a temp register so gdb doesn't pick up intermediate values.
> >
> > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> > ---
> >
> >  v2 - Address Scott Wood's comments
> >  arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
> >  1 files changed, 5 insertions(+), 11 deletions(-)
> >
> > diff --git arch/powerpc/cpu/mpc85xx/start.S arch/powerpc/cpu/mpc85xx/start.S
>
>
> Why are your patches different from everyone else's? When I try to
> apply this, I get errors because it can't find
> "powerpc/cpu/mpc85xx...". git am leaves off the first directory,
> because the usual practice is to send patches with these filenames:

Ahh, recently I set (in ny git config):
[diff]
	noprefix = true
because I got tired off stripping off that prefix each time I cut and
paste file names into emacs and similar.

Seems like git really likes to see that prefix when applying patches.
Don't know if git could learn not to complain about missing prefix?

 Jocke
Scott Wood Aug. 23, 2012, 4:53 p.m. UTC | #10
On 08/23/2012 02:21 AM, Joakim Tjernlund wrote:
> Andy Fleming <afleming@gmail.com> wrote on 2012/08/22 23:08:45:
>>
>> On Mon, Jul 23, 2012 at 3:58 PM, Joakim Tjernlund
>> <Joakim.Tjernlund@transmode.se> wrote:
>>> PowerPC mandates SP to be 16 bytes aligned.
>>> Furthermore, a stack frame is added, pointing to the reset vector
>>> which may in the way when gdb is walking the stack because
>>> the reset vector may not accessible depending on emulator settings.
>>> Also use a temp register so gdb doesn't pick up intermediate values.
>>>
>>> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
>>> ---
>>>
>>>  v2 - Address Scott Wood's comments
>>>  arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
>>>  1 files changed, 5 insertions(+), 11 deletions(-)
>>>
>>> diff --git arch/powerpc/cpu/mpc85xx/start.S arch/powerpc/cpu/mpc85xx/start.S
>>
>>
>> Why are your patches different from everyone else's? When I try to
>> apply this, I get errors because it can't find
>> "powerpc/cpu/mpc85xx...". git am leaves off the first directory,
>> because the usual practice is to send patches with these filenames:
> 
> Ahh, recently I set (in ny git config):
> [diff]
> 	noprefix = true
> because I got tired off stripping off that prefix each time I cut and
> paste file names into emacs and similar.
> 
> Seems like git really likes to see that prefix when applying patches.
> Don't know if git could learn not to complain about missing prefix?

It's not just git, but also direct use of the patch command when a patch
fails to apply cleanly.  A user shouldn't have to inspect a patch to
determine whether to use -p0 or -p1.  -p1 is standard.

How often do you copy and paste filenames out of your own patches?

-Scott
Joakim Tjernlund Aug. 23, 2012, 6:51 p.m. UTC | #11
Scott Wood <scottwood@freescale.com> wrote on 2012/08/23 18:53:14:
>
> On 08/23/2012 02:21 AM, Joakim Tjernlund wrote:
> > Andy Fleming <afleming@gmail.com> wrote on 2012/08/22 23:08:45:
> >>
> >> On Mon, Jul 23, 2012 at 3:58 PM, Joakim Tjernlund
> >> <Joakim.Tjernlund@transmode.se> wrote:
> >>> PowerPC mandates SP to be 16 bytes aligned.
> >>> Furthermore, a stack frame is added, pointing to the reset vector
> >>> which may in the way when gdb is walking the stack because
> >>> the reset vector may not accessible depending on emulator settings.
> >>> Also use a temp register so gdb doesn't pick up intermediate values.
> >>>
> >>> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
> >>> ---
> >>>
> >>>  v2 - Address Scott Wood's comments
> >>>  arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
> >>>  1 files changed, 5 insertions(+), 11 deletions(-)
> >>>
> >>> diff --git arch/powerpc/cpu/mpc85xx/start.S arch/powerpc/cpu/mpc85xx/start.S
> >>
> >>
> >> Why are your patches different from everyone else's? When I try to
> >> apply this, I get errors because it can't find
> >> "powerpc/cpu/mpc85xx...". git am leaves off the first directory,
> >> because the usual practice is to send patches with these filenames:
> >
> > Ahh, recently I set (in ny git config):
> > [diff]
> >    noprefix = true
> > because I got tired off stripping off that prefix each time I cut and
> > paste file names into emacs and similar.
> >
> > Seems like git really likes to see that prefix when applying patches.
> > Don't know if git could learn not to complain about missing prefix?
>
> It's not just git, but also direct use of the patch command when a patch
> fails to apply cleanly.  A user shouldn't have to inspect a patch to
> determine whether to use -p0 or -p1.  -p1 is standard.

Right

>
> How often do you copy and paste filenames out of your own patches?
>

From patches seldom, from git diff to emacs every now and then.

I guess I will have to change back as I won't remember to switch this
feature off before generating patches.

 Jocke
diff mbox

Patch

diff --git arch/powerpc/cpu/mpc85xx/start.S arch/powerpc/cpu/mpc85xx/start.S
index 8d66cf1..4973682 100644
--- arch/powerpc/cpu/mpc85xx/start.S
+++ arch/powerpc/cpu/mpc85xx/start.S
@@ -848,18 +848,12 @@  version_string:
 	.globl	_start_cont
 _start_cont:
 	/* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
-	lis	r1,CONFIG_SYS_INIT_RAM_ADDR@h
-	ori	r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l
-
+	lis	r3,(CONFIG_SYS_INIT_RAM_ADDR)@h
+	ori	r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */
 	li	r0,0
-	stwu	r0,-4(r1)
-	stwu	r0,-4(r1)		/* Terminate call chain */
-
-	stwu	r1,-8(r1)		/* Save back chain and move SP */
-	lis	r0,RESET_VECTOR@h	/* Address of reset vector */
-	ori	r0,r0,RESET_VECTOR@l
-	stwu	r1,-8(r1)		/* Save back chain and move SP */
-	stw	r0,+12(r1)		/* Save return addr (underflow vect) */
+	stw	r0,0(r3)	/* Terminate Back Chain */
+	stw	r0,+4(r3)	/* NULL return address. */
+	mr	r1,r3		/* Transfer to SP(r1) */
 
 	GET_GOT
 	bl	cpu_init_early_f