Re: system.h asm fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux