Linux MIPS Architecture development
 help / color / mirror / Atom feed
* system.h asm fixes
@ 2002-06-17 18:20 Justin Carlson
  2002-06-17 19:43 ` Daniel Jacobowitz
  2002-06-17 20:44 ` Ralf Baechle
  0 siblings, 2 replies; 8+ messages in thread
From: Justin Carlson @ 2002-06-17 18:20 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

Looks to me like we're missing some proper asm clobber markers:

diff -u -r1.13 system.h
--- system.h	4 Feb 2002 17:35:51 -0000	1.13
+++ system.h	17 Jun 2002 18:18:56 -0000
@@ -41,7 +41,8 @@
 		"__sti"
 		: /* no outputs */
 		: /* no inputs */
-		: "memory");
+		: "$1","memory"
+		);
 }
 
 /*
@@ -73,7 +74,7 @@
 		"__cli"
 		: /* no outputs */
 		: /* no inputs */
-		: "memory");
+		: "$1","memory");
 }
 
 __asm__ (
@@ -110,7 +111,7 @@
 	"__save_and_cli\t%0"						\
 	: "=r" (x)							\
 	: /* no inputs */						\
-	: "memory")
+	: "$1","memory")
 
 __asm__(".macro\t__restore_flags flags\n\t"
 	".set\tpush\n\t"
@@ -136,7 +137,7 @@
 		"__restore_flags\t%0"					\
 		: "=r" (__tmp1)						\
 		: "0" (flags)						\
-		: "memory");						\
+		: "$1","memory");					\
 } while(0)
 
 #ifdef CONFIG_SMP

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: system.h asm fixes
  2002-06-17 18:20 system.h asm fixes Justin Carlson
@ 2002-06-17 19:43 ` Daniel Jacobowitz
  2002-06-17 19:58   ` Thiemo Seufer
  2002-06-17 20:44 ` Ralf Baechle
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2002-06-17 19:43 UTC (permalink / raw)
  To: Justin Carlson; +Cc: linux-mips, ralf

On Mon, Jun 17, 2002 at 11:20:42AM -0700, Justin Carlson wrote:
> Looks to me like we're missing some proper asm clobber markers:

Not really, I think those actually caused a problem at some point but
that might be my imagination.  They certainly aren't necessary.  The
compiler can not use $1 for anything, because it doesn't know what the
assembler might be doing with it.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: system.h asm fixes
  2002-06-17 19:43 ` Daniel Jacobowitz
@ 2002-06-17 19:58   ` Thiemo Seufer
  0 siblings, 0 replies; 8+ messages in thread
From: Thiemo Seufer @ 2002-06-17 19:58 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Justin Carlson, linux-mips, ralf

Daniel Jacobowitz wrote:
> On Mon, Jun 17, 2002 at 11:20:42AM -0700, Justin Carlson wrote:
> > Looks to me like we're missing some proper asm clobber markers:
> 
> Not really, I think those actually caused a problem at some point but
> that might be my imagination.  They certainly aren't necessary.  The
> compiler can not use $1 for anything, because it doesn't know what the
> assembler might be doing with it.

But other assembler routines which run in the meantime may do.


Thiemo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: system.h asm fixes
  2002-06-17 18:20 system.h asm fixes Justin Carlson
  2002-06-17 19:43 ` Daniel Jacobowitz
@ 2002-06-17 20:44 ` Ralf Baechle
  2002-06-17 22:36   ` Thiemo Seufer
  1 sibling, 1 reply; 8+ messages in thread
From: Ralf Baechle @ 2002-06-17 20:44 UTC (permalink / raw)
  To: Justin Carlson; +Cc: linux-mips

In-Reply-To: <1024338042.1463.21.camel@localhost.localdomain>; from justin@cs.cmu.edu on Mon, Jun 17, 2002 at 11:20:42AM -0700

You may consider configuring a hostname for your machine :)

On Mon, Jun 17, 2002 at 11:20:42AM -0700, Justin Carlson wrote:

> Looks to me like we're missing some proper asm clobber markers:

No, as per convention $1 is never used by the compiler per convention,
so clobbering not necessary.  I recently removed all "$1" clobbers to
make the code a bit easier to read.

  Ralf

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: system.h asm fixes
  2002-06-17 20:44 ` Ralf Baechle
@ 2002-06-17 22:36   ` Thiemo Seufer
  2002-06-17 22:57     ` Justin Carlson
  2002-06-18  0:52     ` Ralf Baechle
  0 siblings, 2 replies; 8+ messages in thread
From: Thiemo Seufer @ 2002-06-17 22:36 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips

Ralf Baechle wrote:
[snip]
> > Looks to me like we're missing some proper asm clobber markers:
> 
> No, as per convention $1 is never used by the compiler per convention,
> so clobbering not necessary.  I recently removed all "$1" clobbers to
> make the code a bit easier to read.

How can this work? A grep shows many instances of $1 usage,
I don't think all of this code is interrupt safe.


Thiemo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: system.h asm fixes
  2002-06-17 22:36   ` Thiemo Seufer
@ 2002-06-17 22:57     ` Justin Carlson
  2002-06-18  0:52     ` Ralf Baechle
  1 sibling, 0 replies; 8+ messages in thread
From: Justin Carlson @ 2002-06-17 22:57 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: linux-mips

On Mon, 2002-06-17 at 15:36, Thiemo Seufer wrote:
> Ralf Baechle wrote:
> [snip]
> > > Looks to me like we're missing some proper asm clobber markers:
> > 
> > No, as per convention $1 is never used by the compiler per convention,
> > so clobbering not necessary.  I recently removed all "$1" clobbers to
> > make the code a bit easier to read.
> 
> How can this work? A grep shows many instances of $1 usage,
> I don't think all of this code is interrupt safe.
> 

The "$x" clobber markers exist so that the *compiler* won't expect
values in those registers to be preserved across the asm call.  It has
nothing to do with safety across interrupts.  In other words, it's there
to prevent something like this:

	foo = 2;   // Compiler sticks foo a register, say, $2	
	asm (
		"  lw $2, baz\n"
		"  sw $2, (%0)\n"
		::"r" (sna));   // Assembly code uses $2 as a temp reg
	(*bar) = foo;      // Compiler erroneously does (*bar) = baz;

In terms of interrupt safety, there is no issue with $1; any interrupt
would save the register before mucking with it, and restore it before
returning.  The only registers for which this is not true are k0 and k1.

As others have rightly pointed out, the compiler isn't allowed to muck
with $1 anyways, as it is defined to be a temporary register for the
assembler.  So the clobber notation isn't necessary.

Make sense?

-Justin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: system.h asm fixes
  2002-06-17 22:36   ` Thiemo Seufer
  2002-06-17 22:57     ` Justin Carlson
@ 2002-06-18  0:52     ` Ralf Baechle
  2002-06-19 17:16       ` Maciej W. Rozycki
  1 sibling, 1 reply; 8+ messages in thread
From: Ralf Baechle @ 2002-06-18  0:52 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: linux-mips

On Tue, Jun 18, 2002 at 12:36:50AM +0200, Thiemo Seufer wrote:

> Ralf Baechle wrote:
> [snip]
> > > Looks to me like we're missing some proper asm clobber markers:
> > 
> > No, as per convention $1 is never used by the compiler per convention,
> > so clobbering not necessary.  I recently removed all "$1" clobbers to
> > make the code a bit easier to read.
> 
> How can this work? A grep shows many instances of $1 usage,

Uses by assembler code only, not gcc.  Therefoe we don't need to protect
C code against use of $at.

> I don't think all of this code is interrupt safe.

How this should relate to interrupts is beyond me.  Exception handlers do
their own register saving thing.

  Ralf

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: system.h asm fixes
  2002-06-18  0:52     ` Ralf Baechle
@ 2002-06-19 17:16       ` Maciej W. Rozycki
  0 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2002-06-19 17:16 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Thiemo Seufer, linux-mips

On Tue, 18 Jun 2002, Ralf Baechle wrote:

> > How can this work? A grep shows many instances of $1 usage,
> 
> Uses by assembler code only, not gcc.  Therefoe we don't need to protect
> C code against use of $at.

 Moreover, gcc assumes ".set at" is always in effect and includes macros
in its output that are known to clobber $1 and don't work with ".set
noat". 

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-06-19 17:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-17 18:20 system.h asm fixes Justin Carlson
2002-06-17 19:43 ` Daniel Jacobowitz
2002-06-17 19:58   ` Thiemo Seufer
2002-06-17 20:44 ` Ralf Baechle
2002-06-17 22:36   ` Thiemo Seufer
2002-06-17 22:57     ` Justin Carlson
2002-06-18  0:52     ` Ralf Baechle
2002-06-19 17:16       ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox