linux-mips
[Top] [All Lists]

Re: fpu_emulator can lose fpu on get_user/put_user

To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Subject: Re: fpu_emulator can lose fpu on get_user/put_user
From: Jun Sun <jsun@junsun.net>
Date: Wed, 6 Oct 2004 15:09:36 -0700
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org
In-reply-to: <20041006.101920.126571873.nemoto@toshiba-tops.co.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20041006.101920.126571873.nemoto@toshiba-tops.co.jp>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.4i
On Wed, Oct 06, 2004 at 10:19:20AM +0900, Atsushi Nemoto wrote:
> 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?
> 

I don't feel good about this patch.  If emulator loses FPU ownership it should
get it back, not the caller of emulator.

Jun
 
> --- 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,
>                       &current->thread.fpu.soft);
> +             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>