Module: xenomai-forge
Branch: master
Commit: 2e8637695290202a868448c33b37a2332ebd5cbc
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=2e8637695290202a868448c33b37a2332ebd5cbc

Author: Philippe Gerum <[email protected]>
Date:   Wed Jan  4 14:18:59 2012 +0100

powerpc: plug race in thread context switch

Since rthal_thread_switch() is entered with hw IRQs enabled when
CONFIG_XENO_HW_UNLOCKED_SWITCH is in effect, we ought to mask them
around the register swap.

Configurations with CONFIG_XENO_HW_UNLOCKED_SWITCH disabled are immune
to this issue.

---

 kernel/cobalt/arch/powerpc/switch_32.S |    3 +++
 kernel/cobalt/arch/powerpc/switch_64.S |   12 ++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/switch_32.S 
b/kernel/cobalt/arch/powerpc/switch_32.S
index 3526ede..2239e33 100644
--- a/kernel/cobalt/arch/powerpc/switch_32.S
+++ b/kernel/cobalt/arch/powerpc/switch_32.S
@@ -40,6 +40,9 @@ _GLOBAL(rthal_thread_switch)
        SAVE_NVGPRS(r1)
        stw     r0,_NIP(r1)     /* Return to switch caller */
        mfmsr   r11
+       rlwinm  r0,r11,0,17,15  /* clear MSR_EE in r0 */
+       MTMSRD(r11)
+       isync
        li      r0,MSR_FP       /* Disable floating-point */
 #ifdef CONFIG_ALTIVEC
 BEGIN_FTR_SECTION
diff --git a/kernel/cobalt/arch/powerpc/switch_64.S 
b/kernel/cobalt/arch/powerpc/switch_64.S
index a811b5e..e7cbeba 100644
--- a/kernel/cobalt/arch/powerpc/switch_64.S
+++ b/kernel/cobalt/arch/powerpc/switch_64.S
@@ -35,10 +35,6 @@
 #include <asm/mmu.h>
 #include <asm/ptrace.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
-#error "Kernel >= 2.6.32 required"
-#endif
-       
 /*
  * void rthal_thread_switch(struct thread_struct *prev, struct thread_struct 
*next, int kthreadp)
  */
@@ -51,6 +47,14 @@ _GLOBAL(rthal_thread_switch)
        SAVE_10GPRS(22, r1)
        mflr    r20             /* Return to switch caller */
        mfmsr   r22
+#ifdef CONFIG_PPC_BOOK3E
+       wrteei  0
+#else
+       rldicl  r0,r22,48,1     /* clear MSR_EE */
+       rotldi  r0,r0,16
+       MTMSRD(r0)
+       isync
+#endif /* CONFIG_PPC_BOOK3E */
        li      r0, MSR_FP
 #ifdef CONFIG_VSX
 BEGIN_FTR_SECTION


_______________________________________________
Xenomai-git mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-git

Reply via email to