提交 1d74f6bc 编写于 作者: R Ralf Baechle

__compute_return_epc() uses CFC1 instruction which might result in a

coprocessor unusable exception since the process can lose its fpu
context by preemption.
Signed-off-by: NRalf Baechle <ralf@linux-mips.org>
上级 d547c5cc
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <asm/branch.h> #include <asm/branch.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/cpu-features.h> #include <asm/cpu-features.h>
#include <asm/fpu.h>
#include <asm/inst.h> #include <asm/inst.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -161,10 +162,13 @@ int __compute_return_epc(struct pt_regs *regs) ...@@ -161,10 +162,13 @@ int __compute_return_epc(struct pt_regs *regs)
* And now the FPA/cp1 branch instructions. * And now the FPA/cp1 branch instructions.
*/ */
case cop1_op: case cop1_op:
if (!cpu_has_fpu) preempt_disable();
fcr31 = current->thread.fpu.soft.fcr31; if (is_fpu_owner())
else
asm volatile("cfc1\t%0,$31" : "=r" (fcr31)); asm volatile("cfc1\t%0,$31" : "=r" (fcr31));
else
fcr31 = current->thread.fpu.hard.fcr31;
preempt_enable();
bit = (insn.i_format.rt >> 2); bit = (insn.i_format.rt >> 2);
bit += (bit != 0); bit += (bit != 0);
bit += 23; bit += 23;
......
...@@ -80,9 +80,14 @@ do { \ ...@@ -80,9 +80,14 @@ do { \
#define clear_fpu_owner() clear_thread_flag(TIF_USEDFPU) #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) 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) static inline void own_fpu(void)
...@@ -127,7 +132,7 @@ static inline void restore_fp(struct task_struct *tsk) ...@@ -127,7 +132,7 @@ static inline void restore_fp(struct task_struct *tsk)
static inline fpureg_t *get_fpu_regs(struct task_struct *tsk) static inline fpureg_t *get_fpu_regs(struct task_struct *tsk)
{ {
if (cpu_has_fpu) { if (cpu_has_fpu) {
if ((tsk == current) && is_fpu_owner()) if ((tsk == current) && __is_fpu_owner())
_save_fp(current); _save_fp(current);
return tsk->thread.fpu.hard.fpr; return tsk->thread.fpu.hard.fpr;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册