[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-mips
Subject:    Re: Register allocation in copy_to_user
From:       Ralf Baechle <ralf () oss ! sgi ! com>
Date:       2001-09-25 22:11:36
[Download RAW message or body]

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 list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic