Skip to contentSkip to conversation

system.h asm fixes

PATCH Justin Carlson 5 participants 8 messages Jun 17, 2002 – Jun 19, 2002 MIPS

lore
Share & tools
lore
#0 lore raw

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

system.h +5 -4
diff -u -r1.13 system.h
@@ -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
#1 lore raw
Quoted 1 line · Justin Carlson

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.

Signature · 2 lines
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer
#2 lore raw
Quoted 7 lines · Daniel Jacobowitz
Quoted 1 line · Justin Carlson

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

#3 lore raw
In reply to Justin Carlson

In-Reply-To: <[email protected]>; from [email protected] on Mon, Jun 17, 2002 at 11:20:42AM -0700

You may consider configuring a hostname for your machine :)

Quoted 1 line · Justin Carlson

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

#4 lore raw

Ralf Baechle wrote:
[snip]

Quoted 5 lines
Quoted 1 line

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

#5 lore raw
Quoted 11 lines · Thiemo Seufer

Ralf Baechle wrote:
[snip]

Quoted 5 lines
Quoted 1 line

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

#6 lore raw
In reply to Thiemo Seufer
Quoted 9 lines · Thiemo Seufer

Ralf Baechle wrote:
[snip]

Quoted 5 lines
Quoted 1 line

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.

Quoted 1 line

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

#7 lore raw
Quoted 4 lines · Ralf Baechle
Quoted 1 line

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".

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +