Other stuff from my local diffs:

* kernel_text should really be in locore0.S, or in the linker script, right now 
I suspect that it would cause random ddb issues because it isn't actually 
pointing at the start of the kernel text currently.

* sys/arch/armv7/armv7/armv7_machdep.c:
  - msgbufphys should be paddr_t, not vaddr_t.

  - bootstrap_bs_map() might want to mask bpa back down to a bus_addr_t length 
variable to avoid it using alignment-sensitive ops. (I am not sure whether or 
not this is necessary in practice, but it was one of the things that was making 
me worry when I was reading through the code)


Also yeah, regarding the esym one, I hadn't been running into that one anymore 
because I had apparently moved it to locore0.S in my local and then forgot I 
had done that. Whoops!

On Tue, Feb 27, 2018, at 3:47 PM, Brandon Bergren wrote:
> 
> 
> 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.
> 
> Thanks!
> 
> > > 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)
> > >  
> > > 
> > > 
> 
> 
> -- 
>   Brandon Bergren
>   Technical Generalist
> 


-- 
  Brandon Bergren
  Technical Generalist

Reply via email to