Index: sys/powerpc/powerpc/swtch64.S =================================================================== --- sys/powerpc/powerpc/swtch64.S (revision 345243) +++ sys/powerpc/powerpc/swtch64.S (working copy) @@ -122,13 +122,13 @@ mr %r13,%r4 /* and the new thread ptr in curthread*/ mr %r16,%r5 /* and the new lock */ mr %r17,%r6 /* and the PCB */ + + //stdu %r1,-48(%r1) /* Reserve a stack frame to isolate stack. */ - stdu %r1,-48(%r1) - lwz %r7, PCB_FLAGS(%r17) andi. %r7, %r7, PCB_CDSCR beq .L0 - /* Custom DSCR was set. Reseting it to enter kernel */ + /* Custom DSCR was set. Resetting it to enter kernel */ li %r7, 0x0 mtspr SPR_DSCR, %r7 @@ -159,18 +159,30 @@ cpu_switchin: #if defined(SMP) && defined(SCHED_ULE) /* Wait for the new thread to become unblocked */ - ld %r6,TOC_REF(blocked_lock)(%r2) + addis %r6,%r2,TOC_REF(blocked_lock)@ha + ld %r6,TOC_REF(blocked_lock)@l(%r6) blocked_loop: ld %r7,TD_LOCK(%r13) cmpd %r6,%r7 beq- blocked_loop isync + sync /* Ensure PCB is synced. */ #endif 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 */ + ld %r7,PCB_SP(%r17) /* Load the stack pointer */ + cmpdi %r7,0 + bne+ 0f + trap +0: + //addi %r7,%r7,-48 /* Remember about cpu_switch stack frame */ + mr %r1,%r7 /* Atomically switch stacks. */ + //addi %r1,%r1,-48 /* Remember about cpu_switch stack frame */ + mflr %r7 + std %r7,16(%r1) + stdu %r1,-48(%r1) + /* Release old thread now that we have a stack pointer set up */ cmpdi %r14,0 beq- 1f @@ -212,7 +224,7 @@ /* thread to restore is in r3 */ .L4: - addi %r1,%r1,48 + ld %r1,0(%r1) /* Remove the protection frame. */ mr %r3,%r17 /* Recover PCB ptr */ ld %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs. */ ld %r14,PCB_CONTEXT+2*8(%r3)