Commit 3086a7d5 authored by Anton Blanchard's avatar Anton Blanchard

ppc64: put paca in r13 and fix non zero boot cpu

parent a1c90320
...@@ -64,7 +64,8 @@ _GLOBAL(DoSyscall) ...@@ -64,7 +64,8 @@ _GLOBAL(DoSyscall)
#ifdef SHOW_SYSCALLS_TASK #ifdef SHOW_SYSCALLS_TASK
LOADBASE(r31,show_syscalls_task) LOADBASE(r31,show_syscalls_task)
ld r31,show_syscalls_task@l(r31) ld r31,show_syscalls_task@l(r31)
cmp 0,r13,r31 ld r10,PACACURRENT(r13)
cmp 0,r10,r31
bne 1f bne 1f
#endif #endif
LOADADDR(r3,7f) LOADADDR(r3,7f)
...@@ -78,7 +79,7 @@ _GLOBAL(DoSyscall) ...@@ -78,7 +79,7 @@ _GLOBAL(DoSyscall)
LOADADDR(r3,77f) LOADADDR(r3,77f)
ld r4,GPR8(r1) ld r4,GPR8(r1)
ld r5,GPR9(r1) ld r5,GPR9(r1)
mr r6,r13 ld r6, PACACURRENT(r13)
bl .printk bl .printk
ld r0,GPR0(r1) ld r0,GPR0(r1)
ld r3,GPR3(r1) ld r3,GPR3(r1)
...@@ -129,7 +130,8 @@ _GLOBAL(ret_from_syscall_1) ...@@ -129,7 +130,8 @@ _GLOBAL(ret_from_syscall_1)
20: std r3,RESULT(r1) /* Save result */ 20: std r3,RESULT(r1) /* Save result */
#ifdef SHOW_SYSCALLS #ifdef SHOW_SYSCALLS
#ifdef SHOW_SYSCALLS_TASK #ifdef SHOW_SYSCALLS_TASK
cmp 0,r13,r31 ld r10, PACACURRENT(13)
cmp 0,r10,r31
bne 91f bne 91f
#endif #endif
mr r4,r3 mr r4,r3
...@@ -289,9 +291,8 @@ _GLOBAL(_switch) ...@@ -289,9 +291,8 @@ _GLOBAL(_switch)
std r23,_CCR(r1) std r23,_CCR(r1)
std r1,KSP(r3) /* Set old stack pointer */ std r1,KSP(r3) /* Set old stack pointer */
mfspr r5,SPRG3 /* Get paca */ addi r6,r4,-THREAD /* Convert THREAD to 'current' */
addi r13,r4,-THREAD /* Convert THREAD to 'current' */ std r6,PACACURRENT(r13) /* Set new 'current' */
std r13,PACACURRENT(r5) /* Set new 'current' */
#ifdef CONFIG_PPC_ISERIES #ifdef CONFIG_PPC_ISERIES
#error fixme #error fixme
...@@ -335,6 +336,7 @@ irq_recheck: ...@@ -335,6 +336,7 @@ irq_recheck:
CHECKANYINT(r3,r4) CHECKANYINT(r3,r4)
beq+ 4f /* skip do_IRQ if no interrupts */ beq+ 4f /* skip do_IRQ if no interrupts */
#warning FIX ISERIES
mfspr r5,SPRG3 mfspr r5,SPRG3
li r3,0 li r3,0
stb r3,PACAPROCENABLED(r5) /* ensure we are disabled */ stb r3,PACAPROCENABLED(r5) /* ensure we are disabled */
...@@ -370,9 +372,15 @@ recheck: ...@@ -370,9 +372,15 @@ recheck:
bne do_work bne do_work
addi r0,r1,INT_FRAME_SIZE /* size of frame */ addi r0,r1,INT_FRAME_SIZE /* size of frame */
std r0,THREAD+KSP(r13) /* save kernel stack pointer */ ld r4,PACACURRENT(r13)
mfspr r4,SPRG3 /* current task's PACA */ std r0,THREAD+KSP(r4) /* save kernel stack pointer */
std r1,PACAKSAVE(r4) /* save exception stack pointer */ std r1,PACAKSAVE(r13) /* save exception stack pointer */
/*
* r13 is our per cpu area, only restore it if we are returning to
* userspace
*/
REST_GPR(13,r1)
restore: restore:
ld r3,_CTR(r1) ld r3,_CTR(r1)
...@@ -389,25 +397,33 @@ restore: ...@@ -389,25 +397,33 @@ restore:
stdcx. r0,0,r1 /* to clear the reservation */ stdcx. r0,0,r1 /* to clear the reservation */
#ifdef DO_SOFT_DISABLE #ifdef DO_SOFT_DISABLE
/* XXX do this in do_work, r13 isnt valid here */
ld r0,SOFTE(r1) ld r0,SOFTE(r1)
stb r0,PACAPROCENABLED(r13) stb r0,PACAPROCENABLED(r13)
#endif #endif
ld r0,_MSR(r1) ld r0,_MSR(r1)
mtspr SRR1,r0 mtspr SRR1,r0
ld r2,_CCR(r1) ld r2,_CCR(r1)
mtcrf 0xFF,r2 mtcrf 0xFF,r2
ld r2,_NIP(r1) ld r2,_NIP(r1)
mtspr SRR0,r2 mtspr SRR0,r2
REST_GPR(13,r1)
ld r0,GPR0(r1) ld r0,GPR0(r1)
ld r2,GPR2(r1) ld r2,GPR2(r1)
ld r3,GPR3(r1) ld r3,GPR3(r1)
ld r4,GPR4(r1) ld r4,GPR4(r1)
ld r1,GPR1(r1) ld r1,GPR1(r1)
/*
* What if we took an exception and stole this segment, we may
* fault on the above addresses and globber SRR0/1. Should check RI
* bit and repeat - Anton
*/
rfid rfid
/* Note: this must change if we start using the TIF_NOTIFY_RESUME bit */
do_work: do_work:
/* Enable interrupts */ /* Enable interrupts */
ori r10,r10,MSR_EE|MSR_RI ori r10,r10,MSR_EE|MSR_RI
...@@ -419,15 +435,12 @@ do_work: ...@@ -419,15 +435,12 @@ do_work:
b recheck b recheck
1: andi. r0,r3,_TIF_SIGPENDING 1: andi. r0,r3,_TIF_SIGPENDING
beq 2f beq recheck
li r3,0 li r3,0
addi r4,r1,STACK_FRAME_OVERHEAD addi r4,r1,STACK_FRAME_OVERHEAD
bl .do_signal bl .do_signal
b recheck b recheck
2: /* nobody uses the TIF_NOTIFY_RESUME bit yet */
b recheck
/* /*
* On CHRP, the Run-Time Abstraction Services (RTAS) have to be * On CHRP, the Run-Time Abstraction Services (RTAS) have to be
* called with the MMU off. * called with the MMU off.
...@@ -446,7 +459,7 @@ _GLOBAL(enter_rtas) ...@@ -446,7 +459,7 @@ _GLOBAL(enter_rtas)
* RTAS might touch to the stack. (r0, r3-r13 are caller saved) * RTAS might touch to the stack. (r0, r3-r13 are caller saved)
*/ */
SAVE_GPR(2, r1) /* Save the TOC */ SAVE_GPR(2, r1) /* Save the TOC */
SAVE_GPR(13, r1) /* Save current */ SAVE_GPR(13, r1) /* Save paca */
SAVE_8GPRS(14, r1) /* Save the non-volatiles */ SAVE_8GPRS(14, r1) /* Save the non-volatiles */
SAVE_10GPRS(22, r1) /* ditto */ SAVE_10GPRS(22, r1) /* ditto */
...@@ -465,14 +478,13 @@ _GLOBAL(enter_rtas) ...@@ -465,14 +478,13 @@ _GLOBAL(enter_rtas)
mfsrr1 r10 mfsrr1 r10
std r10,_SRR1(r1) std r10,_SRR1(r1)
/* Unfortunatly, the stack pointer and the MSR are also clobbered, /* Unfortunately, the stack pointer and the MSR are also clobbered,
* so they are saved in the PACA (SPRG3) which allows us to restore * so they are saved in the PACA which allows us to restore
* our original state after RTAS returns. * our original state after RTAS returns.
*/ */
mfspr r4,SPRG3 /* Get PACA */ std r1,PACAR1(r13)
std r1,PACAR1(r4)
mfmsr r6 mfmsr r6
std r6,PACASAVEDMSR(r4) std r6,PACASAVEDMSR(r13)
/* Setup our real return addr */ /* Setup our real return addr */
SET_REG_TO_LABEL(r4,.rtas_return_loc) SET_REG_TO_LABEL(r4,.rtas_return_loc)
...@@ -516,13 +528,11 @@ _STATIC(rtas_return_loc) ...@@ -516,13 +528,11 @@ _STATIC(rtas_return_loc)
_STATIC(rtas_restore_regs) _STATIC(rtas_restore_regs)
/* relocation is on at this point */ /* relocation is on at this point */
REST_GPR(2, r1) /* Restore the TOC */ REST_GPR(2, r1) /* Restore the TOC */
REST_GPR(13, r1) /* Restore current */ REST_GPR(13, r1) /* Restore paca */
REST_8GPRS(14, r1) /* Restore the non-volatiles */ REST_8GPRS(14, r1) /* Restore the non-volatiles */
REST_10GPRS(22, r1) /* ditto */ REST_10GPRS(22, r1) /* ditto */
/* put back current in r13 */ mfspr r13,SPRG3
mfspr r4,SPRG3
ld r13,PACACURRENT(r4)
ld r4,_CCR(r1) ld r4,_CCR(r1)
mtcr r4 mtcr r4
...@@ -555,7 +565,7 @@ _GLOBAL(enter_prom) ...@@ -555,7 +565,7 @@ _GLOBAL(enter_prom)
* PROM might touch to the stack. (r0, r3-r13 are caller saved) * PROM might touch to the stack. (r0, r3-r13 are caller saved)
*/ */
SAVE_8GPRS(2, r1) /* Save the TOC & incoming param(s) */ SAVE_8GPRS(2, r1) /* Save the TOC & incoming param(s) */
SAVE_GPR(13, r1) /* Save current */ SAVE_GPR(13, r1) /* Save paca */
SAVE_8GPRS(14, r1) /* Save the non-volatiles */ SAVE_8GPRS(14, r1) /* Save the non-volatiles */
SAVE_10GPRS(22, r1) /* ditto */ SAVE_10GPRS(22, r1) /* ditto */
...@@ -600,7 +610,7 @@ _GLOBAL(enter_prom) ...@@ -600,7 +610,7 @@ _GLOBAL(enter_prom)
isync isync
REST_8GPRS(2, r1) /* Restore the TOC & param(s) */ REST_8GPRS(2, r1) /* Restore the TOC & param(s) */
REST_GPR(13, r1) /* Restore current */ REST_GPR(13, r1) /* Restore paca */
REST_8GPRS(14, r1) /* Restore the non-volatiles */ REST_8GPRS(14, r1) /* Restore the non-volatiles */
REST_10GPRS(22, r1) /* ditto */ REST_10GPRS(22, r1) /* ditto */
blrl /* Entering PROM here... */ blrl /* Entering PROM here... */
...@@ -611,7 +621,7 @@ _GLOBAL(enter_prom) ...@@ -611,7 +621,7 @@ _GLOBAL(enter_prom)
isync isync
REST_GPR(2, r1) /* Restore the TOC */ REST_GPR(2, r1) /* Restore the TOC */
REST_GPR(13, r1) /* Restore current */ REST_GPR(13, r1) /* Restore paca */
REST_8GPRS(14, r1) /* Restore the non-volatiles */ REST_8GPRS(14, r1) /* Restore the non-volatiles */
REST_10GPRS(22, r1) /* ditto */ REST_10GPRS(22, r1) /* ditto */
......
This diff is collapsed.
...@@ -66,6 +66,7 @@ _GLOBAL(get_sp) ...@@ -66,6 +66,7 @@ _GLOBAL(get_sp)
#ifdef CONFIG_PPC_ISERIES #ifdef CONFIG_PPC_ISERIES
/* unsigned long __no_use_save_flags(void) */ /* unsigned long __no_use_save_flags(void) */
_GLOBAL(__no_use_save_flags) _GLOBAL(__no_use_save_flags)
#warning FIX ISERIES
mfspr r4,SPRG3 mfspr r4,SPRG3
lbz r3,PACAPROCENABLED(r4) lbz r3,PACAPROCENABLED(r4)
blr blr
...@@ -78,6 +79,7 @@ _GLOBAL(__no_use_restore_flags) ...@@ -78,6 +79,7 @@ _GLOBAL(__no_use_restore_flags)
* sense anyway. * sense anyway.
* -- Cort * -- Cort
*/ */
#warning FIX ISERIES
mfspr r6,SPRG3 mfspr r6,SPRG3
lbz r5,PACAPROCENABLED(r6) lbz r5,PACAPROCENABLED(r6)
/* Check if things are setup the way we want _already_. */ /* Check if things are setup the way we want _already_. */
...@@ -99,6 +101,7 @@ _GLOBAL(__no_use_restore_flags) ...@@ -99,6 +101,7 @@ _GLOBAL(__no_use_restore_flags)
blr blr
_GLOBAL(__no_use_cli) _GLOBAL(__no_use_cli)
#warning FIX ISERIES
mfspr r5,SPRG3 mfspr r5,SPRG3
lbz r3,PACAPROCENABLED(r5) lbz r3,PACAPROCENABLED(r5)
li r4,0 li r4,0
...@@ -106,6 +109,7 @@ _GLOBAL(__no_use_cli) ...@@ -106,6 +109,7 @@ _GLOBAL(__no_use_cli)
blr /* Done */ blr /* Done */
_GLOBAL(__no_use_sti) _GLOBAL(__no_use_sti)
#warning FIX ISERIES
mfspr r6,SPRG3 mfspr r6,SPRG3
li r3,1 li r3,1
stb r3,PACAPROCENABLED(r6) stb r3,PACAPROCENABLED(r6)
......
...@@ -175,9 +175,8 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp, ...@@ -175,9 +175,8 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
childregs = (struct pt_regs *) sp; childregs = (struct pt_regs *) sp;
*childregs = *regs; *childregs = *regs;
if ((childregs->msr & MSR_PR) == 0) { if ((childregs->msr & MSR_PR) == 0) {
/* for kernel thread, set `current' and stackptr in new task */ /* for kernel thread, set stackptr in new task */
childregs->gpr[1] = sp + sizeof(struct pt_regs); childregs->gpr[1] = sp + sizeof(struct pt_regs);
childregs->gpr[13] = (unsigned long) p;
p->thread.regs = NULL; /* no user register state */ p->thread.regs = NULL; /* no user register state */
clear_ti_thread_flag(p->thread_info, TIF_32BIT); clear_ti_thread_flag(p->thread_info, TIF_32BIT);
#ifdef CONFIG_PPC_ISERIES #ifdef CONFIG_PPC_ISERIES
......
...@@ -152,6 +152,7 @@ static void smp_iSeries_probe(void) ...@@ -152,6 +152,7 @@ static void smp_iSeries_probe(void)
for (i=0; i < MAX_PACAS; ++i) { for (i=0; i < MAX_PACAS; ++i) {
lpPaca = paca[i].xLpPacaPtr; lpPaca = paca[i].xLpPacaPtr;
if ( lpPaca->xDynProcStatus < 2 ) { if ( lpPaca->xDynProcStatus < 2 ) {
paca[i].active = 1;
++np; ++np;
paca[i].next_jiffy_update_tb = paca[0].next_jiffy_update_tb; paca[i].next_jiffy_update_tb = paca[0].next_jiffy_update_tb;
} }
......
...@@ -269,7 +269,7 @@ int timer_interrupt(struct pt_regs * regs) ...@@ -269,7 +269,7 @@ int timer_interrupt(struct pt_regs * regs)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
smp_local_timer_interrupt(regs); smp_local_timer_interrupt(regs);
#endif #endif
if (cpu == 0) { if (cpu == boot_cpuid) {
write_lock(&xtime_lock); write_lock(&xtime_lock);
tb_last_stamp = lpaca->next_jiffy_update_tb; tb_last_stamp = lpaca->next_jiffy_update_tb;
do_timer(regs); do_timer(regs);
......
#ifndef _PPC64_CURRENT_H #ifndef _PPC64_CURRENT_H
#define _PPC64_CURRENT_H #define _PPC64_CURRENT_H
#include <asm/paca.h>
/* /*
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -10,6 +12,9 @@ ...@@ -10,6 +12,9 @@
* Use r13 for current since the ppc64 ABI reserves it - Anton * Use r13 for current since the ppc64 ABI reserves it - Anton
*/ */
register struct task_struct *current asm ("r13"); #include <asm/thread_info.h>
#define get_current() ((struct task_struct *)(get_paca()->xCurrent))
#define current get_current()
#endif /* !(_PPC64_CURRENT_H) */ #endif /* !(_PPC64_CURRENT_H) */
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
#define MAX_PACAS MAX_PROCESSORS * 2 #define MAX_PACAS MAX_PROCESSORS * 2
extern struct paca_struct paca[]; extern struct paca_struct paca[];
#define get_paca() ((struct paca_struct *)mfspr(SPRG3)) register struct paca_struct *local_paca asm("r13");
#define get_paca() local_paca
/*============================================================================ /*============================================================================
* Name_______: paca * Name_______: paca
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment