patch-2.1.73 linux/arch/i386/kernel/signal.c

Next file: linux/arch/i386/math-emu/Makefile
Previous file: linux/arch/i386/kernel/ptrace.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.72/linux/arch/i386/kernel/signal.c linux/arch/i386/kernel/signal.c
@@ -156,7 +156,6 @@
 		stts();
 	}
 #endif
-	current->used_math = 1;
 	current->flags &= ~PF_USEDFPU;
 	__copy_from_user(&current->tss.i387.hard, buf, sizeof(*buf));
 }
@@ -169,8 +168,9 @@
 	if (hard_math)
 		restore_i387_hard(buf);
 	else
-		restore_i387_soft(buf);
+		restore_i387_soft(&current->tss.i387.soft, buf);
 #endif
+	current->used_math = 1;
 }
 
 static int
@@ -309,7 +309,6 @@
 #endif
 	current->tss.i387.hard.status = current->tss.i387.hard.swd;
 	copy_to_user(buf, &current->tss.i387.hard, sizeof(*buf));
-	current->used_math = 0;
 	return buf;
 }
 
@@ -318,10 +317,16 @@
 	if (!current->used_math)
 		return NULL;
 
+	/* This will cause a "finit" to be triggered by the next
+	   attempted FPU operation by the 'current' process.
+	   */
+	current->used_math = 0;
+
 #ifndef CONFIG_MATH_EMULATION
 	return save_i387_hard(buf);
 #else
-	return hard_math ? save_i387_hard(buf) : save_i387_soft(buf);
+	return hard_math ? save_i387_hard(buf)
+	  : save_i387_soft(&current->tss.i387.soft, buf);
 #endif
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov