Print this page
_locore_start needs to set up an 8-byte aligned stack
Sadly, during removal of special early-boot stacks
(027eb01d0ff8f66be55208b58ecd7cb2b7b27714) the stack passed into mlsetup
lost its 8-byte aligned-ness.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/armv6/ml/glocore.s
          +++ new/usr/src/uts/armv6/ml/glocore.s
↓ open down ↓ 115 lines elided ↑ open up ↑
 116  116           * Bit 12 is for the I cache
 117  117           * Bit 22 is for unaligned access
 118  118           */
 119  119          mrc     p15, 0, r0, c1, c0, 0
 120  120          orr     r0, #0x02
 121  121          orr     r0, #0x1000
 122  122          orr     r0, #0x400000
 123  123          mcr     p15, 0, r0, c1, c0, 0
 124  124  
 125  125          /*
 126      -         * mlsetup() takes the struct regs as an argument. main doesn't take any
 127      -         * and should never return. After the push below, we should have a
 128      -         * 8-byte aligned stack pointer. This is why we subtracted four earlier
 129      -         * on if we were 8-byte aligned.
      126 +         * mlsetup() takes the struct regs as an argument. main doesn't take
      127 +         * any and should never return. Currently, we have an 8-byte aligned
      128 +         * stack.  We want to push a zero frame pointer to terminate any
      129 +         * stack walking, but that would cause us to end up with only a
      130 +         * 4-byte aligned stack.  So, to keep things nice and correct, we
      131 +         * push a zero value twice - it's similar to a typical function
      132 +         * entry:
      133 +         *      push { r9, lr }
 130  134           */
 131  135          mov     r9,#0
 132      -        push    { r9 }
      136 +        push    { r9 }          /* link register */
      137 +        push    { r9 }          /* frame pointer */
 133  138          mov     r0, sp
 134  139          bl      mlsetup
 135  140          bl      main
 136  141          /* NOTREACHED */
 137  142          ldr     r0,=__return_from_main
 138  143          ldr     r0,[r0]
 139  144          bl      panic
 140  145          SET_SIZE(_locore_start)
 141  146  
 142  147  __return_from_main:
 143  148          .string "main() returned"
 144  149  #endif  /* __lint */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX