linux-mips
[Top] [All Lists]

Re: Register allocation in copy_to_user

To: tommy.christensen@eicon.com
Subject: Re: Register allocation in copy_to_user
From: Ralf Baechle <ralf@oss.sgi.com>
Date: Wed, 26 Sep 2001 00:11:36 +0200
Cc: linux-mips@oss.sgi.com, linux-mips@fnet.fr
In-reply-to: <3BB0D217.80E313F5@eicon.com>; from tommy.christensen@eicon.com on Tue, Sep 25, 2001 at 08:51:03PM +0200
References: <3BB0D217.80E313F5@eicon.com>
Sender: owner-linux-mips@oss.sgi.com
User-agent: Mutt/1.2.5i
On Tue, Sep 25, 2001 at 08:51:03PM +0200, tommy.christensen@eicon.com wrote:

> For some time, I have seen occasional corruption of tty-output (pty's and
> serial). This turned out to be caused by a register collision in read_chan
> ()
> in n_tty.c. In the expansion of copy_to_user, the compiler chose register
> "a0" to hold the value of local variable __cu_from. Since this register is
> modified in the asm statement, before __cu_from is used, the corruption
> occured.
> 
> I am not sure, whether this is a compiler-bug (egcs-2.91.66) or the code
> should prevent this from happening. Have the semantics about side-effects
> of asm statements changed?
> 
> Anyway, the attached patch solves this by explicitly building the arguments
> to __copy_user in the argument registers ;-) instead of moving them around.
> So it actually saves some instructions as well. And the compiler can
> generate better code since it now has more registers for temporary
> variables ...
> 
> Is this OK? It works just fine for me with a 2.4.9 kernel (VR5000).

Unfortunately I had to find that your bugreport is correct.   To make
things worse at the time when I implemented this code I used your approach
(which definately is the cleaner approach) and I ran into the same problem.

  Ralf

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