[PATCH 2/4] aarch64: Re-implement setcontext without sigreturn syscall

Catalin Marinas Catalin.Marinas@arm.com
Tue Mar 18 17:21:00 GMT 2014


On 18 Mar 2014, at 15:35, Will Newton <will.newton@linaro.org> wrote:
> On 17 March 2014 17:48, Marcus Shawcroft <marcus.shawcroft@gmail.com> wrote:
> > On 13 March 2014 10:45, Will Newton <will.newton@linaro.org> wrote:
> > 
> > +       /* Restore the general purpose registers.  */
> > +       mov     x0, x9
> > 
> > Looks like this code is treating x9 as callee saved over the kernel
> > call. While this is true with the current implementation of the
> > kernel, the glibc port for AArch64 currently treats only the argument
> > registers as preserved.  This is a hang over from the early days of
> > the AArch64 port when the kernel guys wanted the glibc port to be
> > conservative in this respect in order that they have the opportunity
> > to be selective in what was restored on exit from the kernel.
> 
> Really, is that true? It seems to me you would have to save/restore in
> userland anyway so I am not sure what would actually be saved by
> making syscalls behave so differently from function calls.

I think Marcus and I had several debates some time ago and I really
don’t remember what we decided is the most optimal way. Currently
Linux saves all the registers on syscall entry and restores all apart
from the return value.

> > Catalin, Can you comment on the above paragraph?  Is it still
> > important that glibc / user space be conservative in its assumptions
> > about which registers are preserved over system call or can we now
> > relax this position and exploit the fact that the kernel preserves
> > x9-x30 over kernel calls?

The kernel tradition is that once stuff got into mainline it is
considered user/kernel ABI (usually even if it is buggy) and cannot be
changed. So you can relax the use code and assume that everything is
preserved by the kernel (apart from x0 which is the return value).

Catalin



More information about the Libc-alpha mailing list