Subject: Re: ath hal and reserved register r23
To: None <ad@netbsd.org>
From: Paul Koning <pkoning@equallogic.com>
List: port-mips
Date: 07/25/2007 10:18:42
>>>>> "Andrew" == Andrew Doran <ad@netbsd.org> writes:

 Andrew> On Tue, Jul 24, 2007 at 04:58:42PM -0400, Paul Koning wrote:
 >> r23 is s7, and that has been a "preserved across function calls"
 >> register in the standard MIPS ABI forever.

 Andrew> True but the Atheros HAL still cannot change it (even if it
 Andrew> restores it) as interrupt handlers can legitimately inspect
 Andrew> the value of curlwp. They rely on it to point to an lwp
 Andrew> structure.

But that way of using S7 isn't ABI conformant.  The ABI says a
function can use it but must restore it on exit.  If you change that
to say the register must at all times point to foo, that's
nonstandard.

>>>>> "Stephen" == Stephen M Rumble <stephen.rumble@utoronto.ca> writes:

 >>  r23 is s7, and that has been a "preserved across function calls"
 >> register in the standard MIPS ABI forever.  I can't think of any
 >> switch to GCC to treat it differently.  (I'm sure it could be done
 >> with a change to the code generator, probably a fairly easy one,
 >> but I wouldn't expect it to be a feature of any standard
 >> compiler.)

 Stephen> I think it's just '-ffixed-23'.

Not in the stock GCC...

 >> I suppose it would be possible to hack code, or hack the compiler,
 >> to accommodate someone who is violating this ABI, but if they are
 >> so badly confused, what else did they get wrong?  Wouldn't it make
 >> more sense to say "hey, go fix your broken code"?

 Stephen> Since we control (most of) the kernel, we don't really have
 Stephen> to follow any ABI, no?

You still do, unless (a) you want to have a nonstandard compiler and
(b) you are willing to rewrite any assembly language code or binary
code that comes in from the outside and expects its environment to
conform to some known ABI.

Is that kind of trouble worth having an xyz pointer wired into one of
the GPRs?  It's not at all clear that it increases performance at all,
much less by an interesting amount.

     paul