[Top] [All Lists]

fpu_emulator can lose fpu on get_user/put_user

Subject: fpu_emulator can lose fpu on get_user/put_user
From: Atsushi Nemoto <>
Date: Wed, 06 Oct 2004 10:19:20 +0900 (JST)
Original-recipient: rfc822;
I found a potential problem in math emulation.  The math-emu uses
put_user/get_user to fetch the instruction or to emulate load/store
fp-regs.  The put_user/get_user can sleep then we can lose fpu
ownership on it.  It it happened, subsequent restore_fp will cause CpU
exception which not allowed in kernel.

Here is a quick fix.  Can be applied bath 2.4 and 2.6.  Could you apply?

--- linux-mips/arch/mips/kernel/traps.c Sat Aug 14 19:55:20 2004
+++ linux/arch/mips/kernel/traps.c      Wed Oct  6 09:50:26 2004
@@ -509,6 +509,10 @@
                /* Run the emulator */
                sig = fpu_emulator_cop1Handler (0, regs,
+               if (!is_fpu_owner()) {
+                       /* We might lose fpu in fpu_emulator. */
+                       own_fpu();
+               }
                 * We can't allow the emulated instruction to leave any of

Also, there is another problem in the math-emu.  While math-emu is not
reentrant, it will not work properly if a process lose ownership in
the math-emu and another process uses the math-emu.  One possible fix
is to save/restore ieee754_csr on get_user/put_user.  I will post a
patch later.

Atsushi Nemoto

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