Index: sys/powerpc/aim/trap_subr64.S =================================================================== --- sys/powerpc/aim/trap_subr64.S (revision 345243) +++ sys/powerpc/aim/trap_subr64.S (working copy) @@ -345,7 +345,8 @@ cpu_reset_handler: GET_TOCBASE(%r2) - ld %r1,TOC_REF(tmpstk)(%r2) /* get new SP */ + addis %r1,%r2,TOC_REF(tmpstk)@ha + ld %r1,TOC_REF(tmpstk)@l(%r1) /* get new SP */ addi %r1,%r1,(TMPSTKSZ-48) bl CNAME(cpudep_ap_early_bootstrap) /* Set PCPU */ @@ -380,7 +381,8 @@ GET_TOCBASE(%r2) /* Check for false wake up due to badly SRR1 set (eg. by OPAL) */ - ld %r3,TOC_REF(can_wakeup)(%r2) + addis %r3,%r2,TOC_REF(can_wakeup)@ha + ld %r3,TOC_REF(can_wakeup)@l(%r3) ld %r3,0(%r3) cmpdi %r3,0 beq cpu_reset_handler @@ -684,7 +686,7 @@ 1: mflr %r1 ld %r1,0(%r1) mtlr %r1 - blrl /* Branch to generictrap */ + blrl /* Branch to disitrap */ CNAME(dsiend): /* @@ -889,6 +891,7 @@ /* * Now the kdb trap catching code. + * r30, r31: scratch */ dbtrap: /* Write the trap vector to SPRG3 by computing LR & 0xff00 */ @@ -896,9 +899,17 @@ andi. %r1,%r1,0xff00 mtsprg3 %r1 - GET_TOCBASE(%r1) /* get new SP */ - ld %r1,TOC_REF(trapstk)(%r1) + /* Switch temporarily to the kernel TOC and establish stack */ + mr %r30,%r2 + GET_CPUINFO(%r31) + lwz %r31,(PC_CPUID)(%r31) + sldi %r31,%r31,12 /* pcpu offset */ + GET_TOCBASE(%r2) + addis %r1,%r2,TOC_REF(trapstk)@ha + ld %r1,TOC_REF(trapstk)@l(%r1) /* sp base */ + add %r1,%r1,%r31 /* pcpu section */ addi %r1,%r1,(TRAPSTKSZ-48) + mr %r2,%r30 /* Restore TOC */ FRAME_SETUP(PC_DBSAVE) /* Call C trap code: */ Index: sys/powerpc/aim/locore64.S =================================================================== --- sys/powerpc/aim/locore64.S (revision 345243) +++ sys/powerpc/aim/locore64.S (working copy) @@ -66,9 +66,9 @@ TOC_ENTRY(can_wakeup) #ifdef KDB -#define TRAPSTKSZ 4096 /* 4k trap stack */ +#define TRAPSTKSZ 4096 /* 4k trap stack */ GLOBAL(trapstk) - .space TRAPSTKSZ + .space TRAPSTKSZ * MAXCPU TOC_ENTRY(trapstk) #endif