On Tue, Sep 11, 2012 at 10:48:04AM +0200, Ralf Baechle wrote: > Note that c0_epc is made to point back to the SYSCALL instruction, > not the one preceeding the SYSCALL instructions since 8f5a00eb4 [MIPS: > Sanitize restart logics] which went in for 2.6.36. > > Relying on userland to reload $v0 was something ugly that Linux inherited > from god knows where and I'm happy to have gotten rid of that. So basically my whole question/concern is irrelevant to anything but pre-2.6.36 kernels, and all of those preserve $25, so it would have been safe to keep using $25. Thankfully I already found another solution using an "ir" constraint and "addu $2,$0,%2"; this assembles to "li" whenever the compiler can do constant propagation, and if CP fails or the syscall number is not constant, it allocates a register (either an unused argument register or a call-preserved register since all the others are already in the clobberlist or used as inputs). > > The code I'm looking at seems to match what you cited from glibc. > > > > > >These are > > > >requirements beyond the normal function call convention (which does > > > >not require the callee preserve the values of r4-r7). > > > > > > I would assume these are clobbered (from glibc sources > > > ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h): > > > > > > "$1", "$3", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25", > > > "hi", "lo" > > Which is correct but also means that the _syscallX() macros that were in > <asm/unistd.h> up to 2.6.19 were broken; the were lacking clobbers for > $25, $hi and $lo. Unfortunately these macros were copied into many > libraries and applications. I don't think the compiler will try to cache anything in $25 itself anyway. Normally it seems to only get used for its role in the function call ABI. But yes, in theory this is rather problematic, moreso that my issue of using $25 to restore $2 on restart. Rich