linux-cvs-patches
[Top] [All Lists]

CVS Update@linux-mips.org: linux

To: linux-cvs-patches@linux-mips.org
Subject: CVS Update@linux-mips.org: linux
From: ralf@linux-mips.org
Date: Mon, 09 May 2005 14:16:13 +0100
Reply-to: linux-mips@linux-mips.org
Sender: linux-cvs-patches-bounce@linux-mips.org
CVSROOT:        /home/cvs
Module name:    linux
Changes by:     ralf@ftp.linux-mips.org 05/05/09 14:16:07

Modified files:
        arch/mips/kernel: branch.c 
        include/asm-mips: fpu.h 

Log message:
        __compute_return_epc() uses CFC1 instruction which might result in a
        coprocessor unusable exception since the process can lose its fpu
        context by preemption.

diff -urN linux/arch/mips/kernel/branch.c linux/arch/mips/kernel/branch.c
--- linux/arch/mips/kernel/branch.c     2003/12/04 00:28:59     1.15
+++ linux/arch/mips/kernel/branch.c     2005/05/09 13:16:07     1.16
@@ -12,6 +12,7 @@
 #include <asm/branch.h>
 #include <asm/cpu.h>
 #include <asm/cpu-features.h>
+#include <asm/fpu.h>
 #include <asm/inst.h>
 #include <asm/ptrace.h>
 #include <asm/uaccess.h>
@@ -161,10 +162,13 @@
         * And now the FPA/cp1 branch instructions.
         */
        case cop1_op:
-               if (!cpu_has_fpu)
-                       fcr31 = current->thread.fpu.soft.fcr31;
-               else
+               preempt_disable();
+               if (is_fpu_owner())
                        asm volatile("cfc1\t%0,$31" : "=r" (fcr31));
+               else
+                       fcr31 = current->thread.fpu.hard.fcr31;
+               preempt_enable();
+
                bit = (insn.i_format.rt >> 2);
                bit += (bit != 0);
                bit += 23;
diff -urN linux/include/asm-mips/fpu.h linux/include/asm-mips/fpu.h
--- linux/include/asm-mips/fpu.h        2003/12/04 00:28:59     1.11
+++ linux/include/asm-mips/fpu.h        2005/05/09 13:16:07     1.12
@@ -80,9 +80,14 @@
 
 #define clear_fpu_owner()      clear_thread_flag(TIF_USEDFPU)
 
+static inline int __is_fpu_owner(void)
+{
+       return test_thread_flag(TIF_USEDFPU);
+}
+
 static inline int is_fpu_owner(void)
 {
-       return cpu_has_fpu && test_thread_flag(TIF_USEDFPU); 
+       return cpu_has_fpu && __is_fpu_owner();
 }
 
 static inline void own_fpu(void)
@@ -127,7 +132,7 @@
 static inline fpureg_t *get_fpu_regs(struct task_struct *tsk)
 {
        if (cpu_has_fpu) {
-               if ((tsk == current) && is_fpu_owner()) 
+               if ((tsk == current) && __is_fpu_owner()) 
                        _save_fp(current);
                return tsk->thread.fpu.hard.fpr;
        }

<Prev in Thread] Current Thread [Next in Thread>