PPC64: fix TOC behavior on process initialization
Set stack pointer to correct value after thread's stack pointer restore Restoring new thread's stack pointer caused stack corruption because restored stack pointer didn't point to callee (cpu_switch) stack frame but caller stack frame. As a result we had mysterious errors in caller function (sched_switch). Solution: simply set stack pointer to correct value Also, initialize TOC to a valid pointer once the thread is being created. Created by: Patryk Duda <pdk@semihalf.com> Submitted by: Wojciech Macek <wma@semihalf.com> Obtained from: Semihalf Reviewed by: nwhitehorn Differential revision: https://reviews.freebsd.org/D13947 Sponsored by: QCM Technologies
This commit is contained in:
parent
6362070dc8
commit
b6338c1a07
@ -160,6 +160,7 @@ blocked_loop:
|
||||
|
||||
ld %r17,TD_PCB(%r13) /* Get new PCB */
|
||||
ld %r1,PCB_SP(%r17) /* Load the stack pointer */
|
||||
addi %r1,%r1,-48 /* Remember about cpu_switch stack frame */
|
||||
|
||||
/* Release old thread now that we have a stack pointer set up */
|
||||
cmpdi %r14,0
|
||||
|
@ -190,6 +190,9 @@ cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
|
||||
|
||||
cf = (struct callframe *)td->td_pcb->pcb_sp;
|
||||
|
||||
#if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF == 1)
|
||||
cf->cf_toc = ((register_t *)func)[1];
|
||||
#endif
|
||||
cf->cf_func = (register_t)func;
|
||||
cf->cf_arg0 = (register_t)arg;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user