[OpenAFS-devel] What's the sparc code doing with the frame pointer in process.c?

Pavel Semerad semerad@ss1000.ms.mff.cuni.cz
Tue, 6 Feb 2001 11:42:52 +0100 (CET)


> I'm still not getting processes to correctly dispatch under 1.0.2 on
> Linux/390. 
> 
> I notice that in the process.c code, that the sparc Linux contains an
> entry for the frame pointer register as well.  However, I really don't
> understand the line that makes use of it, namely:
> 
>    jmpBuffer[LWP_FP] = (jmp_buf_type)sp; 
> 
> Why are we setting the stack pointer into the frame pointer register
> (or, I guess, into the slot that's going to become the FP register in
> the longjmp, if you want to be pedantic)?  I don't want to try this code
> on the S/390 side until I understand what's going on here.
> 
> Adam

  This part of code is initializing new thread with stack on address sp.
At PC linux is setjmp/longjmp using only SP, on sparc linux it uses SP and
also FP, so it was needed initialize both SP and FP to point to new stack.
Consult glibc sources (or disassemble glibc) to see what is saved/restored
on Linux/390.

Another thing that was necessary on sparc was modify lwp.c (calling
of savecontext) and give stack pointer argument not pointing to the end of
area, but end decreased by 0x40. This is because sparc longjmp is doing
something with "%fp + 0x38" and this way it poitnts to newly allocated
memory (without this there were memory faults).

Pavel Semerad