On Tue, Feb 27, 2018, at 3:40 PM, Mark Kettenis wrote:
> > Date: Tue, 27 Feb 2018 22:30:43 +0100 (CET)
> > From: Mark Kettenis <mark.kette...@xs4all.nl>
> > > From: Brandon Bergren <open...@bdragon.rtk0.net>
> > > Date: Tue, 27 Feb 2018 15:05:43 -0600
> > >
> > > Oh geez, I just figured out what my own crash was -- svcstk is not
> > > being aligned properly in sys/arch/arm/arm/locore.S, so depending on
> > > the link order, the address of the service stack could be in some
> > > random place in .bss. I *think* it's supposed to be .align 8 anyway
> > > to be standards-compliant.
> > The stack needs 8-byte alignment, so .align 3. In a "bad" kernel I
> > have lying around the stack is properly aligned though. But esym
> > isn't because .data isn't aligned properly.
> > The diff below fixes both issues. I'll go through the other assembly
> > files and make sure the alignment of the .data and .bss is correct
> > there as well and I'll send a new diff if I find any further issues.
> > ok?
> And thanks for the cluestick. I have been banging my head on this bug
> for days...
Weeks for me. Ended up breaking down and buying a jtag interface and soldering
a connector on just so I could get a view into what was going on. My jaw
dropped when I saw that it was crashing on the first instruction of initarm()
because the stack pointer was not aligned.
I will stress test this overnight on my board.
> > Index: arch/arm/arm/locore.S
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/arm/arm/locore.S,v
> > retrieving revision 1.13
> > diff -u -p -r1.13 locore.S
> > --- arch/arm/arm/locore.S 6 Jan 2017 00:06:02 -0000 1.13
> > +++ arch/arm/arm/locore.S 27 Feb 2018 21:27:10 -0000
> > @@ -101,6 +101,7 @@ ASENTRY_NP(start)
> > .align 2
> > .bss
> > + .align 3
> > svcstk:
> > .space INIT_ARM_STACK_SIZE
> > @@ -179,6 +180,7 @@ ENTRY(longjmp)
> > mov pc, lr
> > .data
> > + .align 2
> > .global _C_LABEL(esym)
> > _C_LABEL(esym): .word _C_LABEL(end)