Re: number of args in a syscall

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Mon, 13 Oct 2014 17:14:21 +0300
On Mon, Oct 13, 2014 at 07:29:43PM +0800, Julian Elischer wrote:
> I'm faced with porting some code that has patched the 8.0 kernel
> to accept up to 16 args in a syscall.
> It makes my skin crawl a bit but if I can't give a good reason to
> suggest that they do things differently in 10 (pass a pointer to a 
> struct maybe)
> then I'll just take the easy path and s/8/16/ in
> the appropriate line in amd64/include/proc.h and get on with life.
It should work; I assume this is for your local modifications.

A fine point in the amd64 (syscall) calling sequence is that first
6 integer arguments are passed in registers, everything else and
more overflows to memory. Syscall parameters passing conventions are
very similar of the conventions for the regular functions, stubs
do very little. The syscall arg fetch code does distinguish the
registers/memory args and performs copyin for memory portion, see
cpu_fetch_syscall_args().

> 
> I initially thought it may confuse things like ktrace or truss but I 
> haven't seen any problems..
> allocating more space on the stack is another thing but you only ever 
> do one syscall at a time.

The difference in the stack usage for 8 vs.16 args would be around
100-200 bytes.
Received on Mon Oct 13 2014 - 12:14:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:52 UTC