Module: xenomai-rpm
Branch: for-upstream
Commit: a4b04e3fbba15b69bd107bb13911057d998e63db
URL:    
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=a4b04e3fbba15b69bd107bb13911057d998e63db

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 d170df4..dfca54c 100644
--- a/ksrc/arch/powerpc/switch_32.S
+++ b/ksrc/arch/powerpc/switch_32.S
@@ -46,6 +46,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 aaafaee..d67a1cf 100644
--- a/ksrc/arch/powerpc/switch_64.S
+++ b/ksrc/arch/powerpc/switch_64.S
@@ -139,6 +139,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
@@ -274,6 +282,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@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to