Subject: Re: syscall() system call stub
To: David Laight <david@l8s.co.uk>
From: Andrew Doran <ad@netbsd.org>
List: port-amd64
Date: 11/04/2007 02:28:09
Hi,
On Sat, Nov 03, 2007 at 11:28:11AM +0000, David Laight wrote:
> The amd64 stub for syscall() is:
>
> ENTRY(syscall)
> movl %edi,%eax
> syscall
>
> (from libc/arch/x86_64/sys/syscall.S)
>
> This looks completely wrong to me.
> I think it needs to be:
> mov $0,%eax
> mov %rcx,%r10
> syscall
>
> probably generated by RSYSCALL(syscall)
>
> I actually suspect there are no actual calls to it in the amd64 userspace.
>
> Which is rather fortunate since there are calls lurking like:
> syscall(SYS___syscall, SYS_foo, args)
> which really isn't going to DTRT unless syscall() is implemented in
> the library - which it cannot be for some architectures like amd64 (& sparc)
> where some, but not all, of the system call arguments are passed in registers.
I'm not sure about this one. But it occurs to me syscall and _syscall can
probably be turned into proper systems calls of their own *, so we don't
have to do the tests in the syscall path. Does that make sense?
Thanks,
Andrew
* ignoring systrace and to a much lesser extent ktrace