On Sat, Apr 02, 2016 at 12:44:15PM -0700, Philip Guenther wrote:
> On Sat, Apr 2, 2016 at 5:19 AM, Patrick Wildt <patr...@blueri.se> wrote:
> > the Procedure Call Standard used in EABI requires the stack pointer to
> > be 8-byte aligned by
> >
> >   * exception handlers, before calling AAPCS-conforming code.
> >   * the OS, before giving control to an application.
> >
> > This diff makes sure our kernel interfaces adhere to that requirement.
> >
> > Can someone make sure this doesn't break armish/zaurus?
> 
> The changes to cpu_switchto(), savectx(), and switchframe seem odd;
> those are leaf functions, no?  When would their frame layouts result
> in misaligned stacks for EABI-expecting code?
> 
> The placement of if_pad is suspect: you're adjusting right before
> pushing sp, so shouldn't it be between if_sp and if_pc?  If that's off
> then the CLKF_PC() macro will access the padding instead of the pushed
> pc, which would break profiling.

Don't confuse the access to the "lr" register with the irqframe members
called lr!

A branch with link saves the current PC into the LR register.  So
basically the LR tells us where we came from.  This is basically the
PC of the process we came from, so we save it in the frame's PC member.

This means the trapframe is made by doing:

  1. pad -> if_pad
  2. push process' PC by storing the current LR -> if_pc
  3. push SVC's LR/SP if needed -> if_svc_*
  4. push the user mode registers -> up until spsr
  5. push the user mode cpsr (current spsr) -> if_spsr

> 
> 
> Philip Guenther
> 

Reply via email to