> Now the question comes is the argument long or some other type?

I believe so. Every library I've seen and the kernel itself uses long.
Other types just get typecasted to long. I think it's just supposed to
mean "register type" since all the arguments must be in registers.

> E.g. for some 32bit ABIs built on top of 64bit ISA might always
> just pass 32bits or they might allow passing the full 64bits.
> (x32 might fall under this and MIPS n32).

The registers used are documented here:

https://www.man7.org/linux/man-pages/man2/syscall.2.html

x32 uses the exact same registers as x86_64, all 64 bit:

> x86-64    rdi rsi rdx r10 r8 r9
> x32       rdi rsi rdx r10 r8 r9

MIPS calling conventions work like this:

> mips/n32,64 a0 a1 a2 a3 a4 a5
> mips/o32    a0 a1 a2 a3 ...
> mips/o32    args5-8 are passed on the stack

> Maybe you should warn/error out
> if not passed the correct sized argument.

Yes. It should be an error if the inputs are not register sized.
As far as I know all system call inputs are either register sized
values or pointers to C strings, buffers or much larger structures.

> Also do you sign or zero extend a 32bit argument for LP64 targets?

I'm not sure. System call stubs just declare these register values as
signed long so whatever happens in that case seems to be appropriate.

Reply via email to