>>>>> On Wed, 15 Aug 2001 11:06:34 -0700, Daniel Jacobowitz <dan@debian.org> said: >> Index: linux/arch/mips/kernel/signal.c > >> @@ -353,12 +355,11 @@ >> owned_fp = (current == last_task_used_math); >> err |= __put_user(owned_fp, &sc->sc_ownedfp); >> >> - if (current->used_math) { /* fp is active. */ >> + if (owned_fp) { /* fp is active. */ >> set_cp0_status(ST0_CU1); >> err |= save_fp_context(sc); >> last_task_used_math = NULL; >> regs->cp0_status &= ~ST0_CU1; >> - current->used_math = 0; >> } >> >> return err; dan> This is absolutely not right. It's righter than the status quo. dan> If we don't own the FP, you don't save the FP. Then we can use dan> FP in the signal handler, corrupting the process's original dan> floating point context. I also am trying to fix this problem. How about my patch? restore_sigcontext() can be more optimized, but I think this is a smallest patch to fix the problem. --- Atsushi Nemoto
diff -ur linux.sgi/arch/mips/kernel/signal.c linux/arch/mips/kernel/signal.c --- linux.sgi/arch/mips/kernel/signal.c Mon Jun 25 22:56:56 2001 +++ linux/arch/mips/kernel/signal.c Thu Aug 16 13:09:28 2001 @@ -350,11 +350,18 @@ err |= __put_user(regs->cp0_cause, &sc->sc_cause); err |= __put_user(regs->cp0_badvaddr, &sc->sc_badvaddr); - owned_fp = (current == last_task_used_math); + /* restore_sigcontext must restore the fp context even if this + process was not last_task_used_math. */ + owned_fp = current->used_math; err |= __put_user(owned_fp, &sc->sc_ownedfp); if (current->used_math) { /* fp is active. */ +#if 0 + /* Do not set CU1 here. If this process does not + owned fp, save_fp_context causes lazy_fpu_switch + (and fp-owner's context will saved). */ set_cp0_status(ST0_CU1); +#endif err |= save_fp_context(sc); last_task_used_math = NULL; regs->cp0_status &= ~ST0_CU1;