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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Jan  4 14:14:11 2012 +0100

hal/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. This is in essence an overdue fix for the
issue spotted and solved quite some time ago by Jesper Christensen,
see: https://mail.gna.org/public/xenomai-core/2011-04/msg00095.html.

Configurations with CONFIG_XENO_HW_UNLOCKED_SWITCH disabled are immune
to this issue.

---

 ksrc/arch/powerpc/switch_32.S |    3 +++
 ksrc/arch/powerpc/switch_64.S |   16 ++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/ksrc/arch/powerpc/switch_32.S b/ksrc/arch/powerpc/switch_32.S
index 3cdb372..469d27a 100644
--- a/ksrc/arch/powerpc/switch_32.S
+++ b/ksrc/arch/powerpc/switch_32.S
@@ -47,6 +47,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/ksrc/arch/powerpc/switch_64.S b/ksrc/arch/powerpc/switch_64.S
index a1daefe..992f724 100644
--- a/ksrc/arch/powerpc/switch_64.S
+++ b/ksrc/arch/powerpc/switch_64.S
@@ -140,6 +140,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
@@ -280,6 +288,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
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to