Module: xenomai-head
Branch: master
Commit: 90699565cbce41f2cec193d57857bb5817efc19a
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=90699565cbce41f2cec193d57857bb5817efc19a

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Oct 27 12:48:44 2010 +0200

hal/powerpc: sanitize thread init trampoline

---

 include/asm-powerpc/bits/pod.h |   32 +++++++++++++++++---------------
 ksrc/arch/powerpc/switch_32.S  |    6 ++----
 ksrc/arch/powerpc/switch_64.S  |    8 +++-----
 3 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/include/asm-powerpc/bits/pod.h b/include/asm-powerpc/bits/pod.h
index 7093b40..fffa91f 100644
--- a/include/asm-powerpc/bits/pod.h
+++ b/include/asm-powerpc/bits/pod.h
@@ -178,32 +178,34 @@ static inline void xnarch_init_thread(xnarchtcb_t * tcb,
                                      struct xnthread *thread, char *name)
 {
        struct pt_regs *childregs;
-       unsigned long flags;
+       unsigned long sp;
 
-       rthal_local_irq_flags_hw(flags);
-       childregs = (struct pt_regs *)((unsigned long)tcb->stackbase +
-                                      tcb->stacksize - 
RTHAL_SWITCH_FRAME_SIZE);
+       sp = (unsigned long)tcb->stackbase + tcb->stacksize;
+       sp -= sizeof(struct pt_regs);
+       childregs = (struct pt_regs *)sp;
        memset(childregs, 0, sizeof(*childregs));
-       childregs->gpr[14] = flags & ~(MSR_EE | MSR_FP);
-       tcb->ts.ksp = (unsigned long)childregs - STACK_FRAME_OVERHEAD;
+       sp -= STACK_FRAME_OVERHEAD;
+
+       tcb->ts.ksp = sp;
        tcb->entry = entry;
        tcb->cookie = cookie;
        tcb->self = thread;
        tcb->imask = imask;
        tcb->name = name;
+
 #ifdef CONFIG_PPC64
-       childregs->nip = ((unsigned long *)&rthal_thread_trampoline)[0];
-       childregs->gpr[2] = ((unsigned long *)&rthal_thread_trampoline)[1];
-       childregs->gpr[15] = ((unsigned long *)&xnarch_thread_trampoline)[0];   
/* lr = entry addr. */
-       childregs->gpr[16] = ((unsigned long *)&xnarch_thread_trampoline)[1];   
/* r2 = TOC base. */
-       childregs->gpr[17] = (unsigned long)tcb;
+       childregs->nip = ((unsigned long *)rthal_thread_trampoline)[0];
+       childregs->gpr[2] = ((unsigned long *)rthal_thread_trampoline)[1];
+       childregs->gpr[22] = (unsigned long)tcb;
+       childregs->gpr[23] = ((unsigned long *)xnarch_thread_trampoline)[0];    
/* lr = entry addr. */
+       childregs->gpr[24] = ((unsigned long *)xnarch_thread_trampoline)[1];    
/* r2 = TOC base. */
        if (cpu_has_feature(CPU_FTR_SLB))
                tcb->ts.ksp_vsid = get_stack_vsid(tcb->ts.ksp);
 #else /* !CONFIG_PPC64 */
-       childregs->nip = (unsigned long)&rthal_thread_trampoline;
-       childregs->gpr[15] = (unsigned long)&xnarch_thread_trampoline;
-       childregs->gpr[16] = (unsigned long)tcb;
-#endif
+       childregs->nip = (unsigned long)rthal_thread_trampoline;
+       childregs->gpr[22] = (unsigned long)tcb;
+       childregs->gpr[23] = (unsigned long)xnarch_thread_trampoline;
+#endif /* !CONFIG_PPC64 */
 }
 
 /* No lazy FPU init on PPC. */
diff --git a/ksrc/arch/powerpc/switch_32.S b/ksrc/arch/powerpc/switch_32.S
index cbb1216..d2ab314 100644
--- a/ksrc/arch/powerpc/switch_32.S
+++ b/ksrc/arch/powerpc/switch_32.S
@@ -193,8 +193,6 @@ same_current:
 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) */
 
 _GLOBAL(rthal_thread_trampoline)
-       mtmsr   r14
-       mtlr    r15
-       mr      r3,r16
-       stwu    r1,-STACK_FRAME_OVERHEAD(r1)
+       mr      r3,r22
+       mtlr    r23
        blr
diff --git a/ksrc/arch/powerpc/switch_64.S b/ksrc/arch/powerpc/switch_64.S
index a241727..b15fa58 100644
--- a/ksrc/arch/powerpc/switch_64.S
+++ b/ksrc/arch/powerpc/switch_64.S
@@ -396,9 +396,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 #endif /* Linux >= 2.6.32 */
 
 _GLOBAL(rthal_thread_trampoline)
-       mtmsr   r14
-       mtlr    r15
-       mr      r2,r16
-       mr      r3,r17
-       stdu    r1,-STACK_FRAME_OVERHEAD(r1)
+       mr      r3,r22
+       mr      r2,r24
+       mtlr    r23
        blr


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to