From: David Daney <ddaney.cavm@gmail.com>
To: Rich Felker <dalias@aerifal.cx>
Cc: linux-mips@linux-mips.org
Subject: Re: Is r25 saved across syscalls?
Date: Mon, 10 Sep 2012 11:04:55 -0700 [thread overview]
Message-ID: <504E2BC7.7000108@gmail.com> (raw)
In-Reply-To: <20120910172248.GN27715@brightrain.aerifal.cx>
On 09/10/2012 10:22 AM, Rich Felker wrote:
> On Mon, Sep 10, 2012 at 07:08:30PM +0200, Ralf Baechle wrote:
>> On Sun, Sep 09, 2012 at 03:30:08PM -0400, Rich Felker wrote:
>>
>>> The kernel syscall entry/exit code seems to always save and restore
>>> r25. Is this stable/documented behavior I can rely on? If there's a
>>> reason it _needs_ to be preserved, knowing that would help convince me
>>> it's safe to assume it will always be done. The intended usage is to
>>> be able to make syscalls (where the syscall # is not a constant that
>>> could be loaded with lwi) without a stack frame, as in "move $2,$25 ;
>>> syscall".
>>
>> The basic design idea is that syscalls use a calling convention similar
>> to subroutine calls. $25 is $t9, so a temp register which is callee saved.
>>
>> So if the kernel is saving $t9 and you've been relying on that, consider
>> yourself lucky - there's not guarantee for that.
>
> Is there any documentation of what the kernel does guarantee?
Not really. The glibc souces can be used as the canonical
implementation as we cannot break it. glibc assumes $25 is clobbered.
> All
> existing syscall-making code I've seen depends at least on r4-r7 not
> being clobbered when a signal interrupts a syscall
This is an internal kernel implementation detail. Relying on it in
userspace is probably not a good idea.
> and sets it up for
> restart (since the arguments still need to be there when it's
> restarted), and seems to also depend on r4-r6 not being clobbered when
> the syscall successfully returns (since they're not listed in the
> clobber list, e.g. in uClibc's inline syscall asm).
Some versions of uClibc's inline syscall asm are buggy. So they cannot
be used as an indication of what is supported.
> 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"
David Daney
next prev parent reply other threads:[~2012-09-10 18:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 19:30 Is r25 saved across syscalls? Rich Felker
2012-09-10 17:08 ` Ralf Baechle
2012-09-10 17:22 ` Rich Felker
2012-09-10 18:04 ` David Daney [this message]
2012-09-10 18:37 ` Rich Felker
2012-09-11 8:48 ` Ralf Baechle
2012-09-11 13:32 ` Rich Felker
2012-09-11 0:29 ` Maciej W. Rozycki
2012-09-11 1:04 ` Kevin D. Kissell
2012-09-11 1:27 ` David Daney
2012-09-11 2:28 ` Rich Felker
2012-09-11 8:58 ` Ralf Baechle
2012-09-11 8:12 ` Ralf Baechle
2012-09-11 13:44 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=504E2BC7.7000108@gmail.com \
--to=ddaney.cavm@gmail.com \
--cc=dalias@aerifal.cx \
--cc=linux-mips@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox