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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Aug 11 10:40:37 2009 +0200

powerpc: do not leak MSR_FP when back to secondary mode

xnarch_enable_fpu() has to clear MSR_FP whenever a resuming Linux task
was not the original FPU owner when secondary mode was previously
left. Failing to do so would allow trap-less FPU accesses by such
task, which would end up corrupting the FP environment of the actual
owner.

---

 include/asm-powerpc/bits/pod.h |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/asm-powerpc/bits/pod.h b/include/asm-powerpc/bits/pod.h
index 359d980..d260410 100644
--- a/include/asm-powerpc/bits/pod.h
+++ b/include/asm-powerpc/bits/pod.h
@@ -200,13 +200,6 @@ static inline void xnarch_init_thread(xnarchtcb_t * tcb,
 /* No lazy FPU init on PPC. */
 #define xnarch_fpu_init_p(task) (1)
 
-static inline void xnarch_enable_fpu(xnarchtcb_t * current_tcb)
-{
-#ifdef CONFIG_XENO_HW_FPU
-       rthal_enable_fpu();
-#endif /* CONFIG_XENO_HW_FPU */
-}
-
 static void xnarch_init_fpu(xnarchtcb_t * tcb)
 {
 #ifdef CONFIG_XENO_HW_FPU
@@ -220,6 +213,18 @@ static void xnarch_init_fpu(xnarchtcb_t * tcb)
 #endif /* CONFIG_XENO_HW_FPU */
 }
 
+static inline void xnarch_enable_fpu(xnarchtcb_t *tcb)
+{
+#ifdef CONFIG_XENO_HW_FPU
+       struct task_struct *task = tcb->user_task;
+
+        if (task && task != tcb->user_fpu_owner)
+               rthal_disable_fpu();
+       else
+               rthal_enable_fpu();
+#endif /* CONFIG_XENO_HW_FPU */
+}
+
 static void xnarch_save_fpu(xnarchtcb_t * tcb)
 {
 #ifdef CONFIG_XENO_HW_FPU


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

Reply via email to