[MIPS] FPU ownership management & preemption fixes
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
committed by
Ralf Baechle
parent
c6a2f46793
commit
53dc80287d
@@ -82,6 +82,7 @@ int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
||||
{
|
||||
int err = 0;
|
||||
int i;
|
||||
unsigned int used_math;
|
||||
|
||||
err |= __put_user(regs->cp0_epc, &sc->sc_pc);
|
||||
|
||||
@@ -104,22 +105,18 @@ int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
||||
err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
|
||||
}
|
||||
|
||||
err |= __put_user(!!used_math(), &sc->sc_used_math);
|
||||
used_math = !!used_math();
|
||||
err |= __put_user(used_math, &sc->sc_used_math);
|
||||
|
||||
if (used_math()) {
|
||||
if (used_math) {
|
||||
/*
|
||||
* Save FPU state to signal context. Signal handler
|
||||
* will "inherit" current FPU state.
|
||||
*/
|
||||
preempt_disable();
|
||||
|
||||
if (!is_fpu_owner()) {
|
||||
own_fpu();
|
||||
restore_fp(current);
|
||||
}
|
||||
own_fpu(1);
|
||||
enable_fp_in_kernel();
|
||||
err |= save_fp_context(sc);
|
||||
|
||||
preempt_enable();
|
||||
disable_fp_in_kernel();
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@@ -188,20 +185,18 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
||||
err |= __get_user(used_math, &sc->sc_used_math);
|
||||
conditional_used_math(used_math);
|
||||
|
||||
preempt_disable();
|
||||
|
||||
if (used_math()) {
|
||||
if (used_math) {
|
||||
/* restore fpu context if we have used it before */
|
||||
own_fpu();
|
||||
own_fpu(0);
|
||||
enable_fp_in_kernel();
|
||||
if (!err)
|
||||
err = check_and_restore_fp_context(sc);
|
||||
disable_fp_in_kernel();
|
||||
} else {
|
||||
/* signal handler may have used FPU. Give it up. */
|
||||
lose_fpu();
|
||||
lose_fpu(0);
|
||||
}
|
||||
|
||||
preempt_enable();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user