On Tue, Feb 28, 2023 at 4:26 PM Luca Dariz <l...@orpolo.org> wrote: > >> + /* check if we need to place some arguments on the stack */ > >> +_syscall64_args_stack: > >> + mov EXT(mach_trap_table)(%rax),%r10 /* get number of arguments */ > >> + subq $6,%r10 /* the first 6 args are already in > >> place */ > >> + jl _syscall64_call /* skip argument copy if >6 args */ > > > > jle? > > Right, I didn't test a 6-args syscall. > > >> + > >> + movq R_UESP(%rbx),%r11 /* get user stack pointer */ > >> + addq $8,%r11 /* Skip user return address */ > >> + > >> + mov $USER_DS,%r12 /* use user data segment for accesses > >> */ > >> + mov %r12,%fs > >> + > >> + lea (%r11,%r10,8),%r11 /* point past last argument */
Do I understand it right that for the most interesting syscall (which takes 7 args!), I *am* supposed to pass the 7th arg on the stack (in mem[rsp + 8]) -- unlike on Linux? Or in other words: do I understand it right that the ABI here is: - syscall number in rax - arguments are passed just as per x86_64 calling convention, except the 4th arg is in r10 and not rcx - return value is in rax - rcx and r11 are additionally clobbered -- or not? - nothing else is clobbered, in particular not rflags (or is the "reserved" half of rflags clobbered?) and not the registers that contain args Sergey