2
votes

How many arguments can be passed in a system call? I checked in the kernel file /asm/unistd.h and saw no system calls that contain more than 4 arguments.

1
Shouldn't it matter on the actual system call? Some takes more arguments, some takes less, some doesn't take any. - Some programmer dude
Why you want system call with more than 4 arguments? - Sathish
@KlasLindback: you are wrong. The protocol between kernel and user-space for system calls (thru VDSO or a SYSENTER machine instruction) is not the ABI calling convention. On x86, syscalls don't pass anything on the stack, only thru registers. - Basile Starynkevitch

1 Answers

8
votes

This depends on the architecture you use. For i386, you have maximum 6 arguments beside the system call number.

From syscall(2), the register you pass the system call number over:

arch/ABI   instruction          syscall #   retval Notes
───────────────────────────────────────────────────────────────────
arm/OABI   swi NR               -           a1     NR is syscall #
arm/EABI   swi 0x0              r7          r0
blackfin   excpt 0x0            P0          R0
i386       int $0x80            eax         eax
ia64       break 0x100000       r15         r10/r8 bool error/
                                                  errno value
parisc     ble 0x100(%sr2, %r0) r20         r28
s390       svc 0                r1          r2     See below
s390x      svc 0                r1          r2     See below
sparc/32   t 0x10               g1          o0
sparc/64   t 0x6d               g1          o0
x86_64     syscall              rax         rax

The arguments:

arch/ABI   arg1   arg2   arg3   arg4   arg5   arg6   arg7
──────────────────────────────────────────────────────────
arm/OABI   a1     a2     a3     a4     v1     v2     v3
arm/EABI   r0     r1     r2     r3     r4     r5     r6
blackfin   R0     R1     R2     R3     R4     R5     -
i386       ebx    ecx    edx    esi    edi    ebp    -
ia64       out0   out1   out2   out3   out4   out5   -
parisc     r26    r25    r24    r23    r22    r21    -
s390       r2     r3     r4     r5     r6     r7     -
s390x      r2     r3     r4     r5     r6     r7     -
sparc/32   o0     o1     o2     o3     o4     o5     -
sparc/64   o0     o1     o2     o3     o4     o5     -
x86_64     rdi    rsi    rdx    r10    r8     r9     -