From: Paul Floyd Date: Sat, 20 Sep 2025 17:20:50 +0000 (+0200) Subject: FreeBSD amd64: amd64 syscalls only ever need max 7 args X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0700c69d4f0fd9982c7fb31d84e35a2f91780898;p=thirdparty%2Fvalgrind.git FreeBSD amd64: amd64 syscalls only ever need max 7 args The only possible exception would be a syscall0 of SYS_sendfile done by the host. Since we're never going to do that reduce the number of arguments to 7. --- diff --git a/coregrind/m_syscall.c b/coregrind/m_syscall.c index c76f1df81..18a592059 100644 --- a/coregrind/m_syscall.c +++ b/coregrind/m_syscall.c @@ -768,7 +768,6 @@ extern UWord do_syscall_WRK ( UWord a5, /* %r9 */ UWord a6, /* 8(%rsp) */ UWord a7, /* 16(%rsp) */ - UWord a8, /* 24(%rsp) */ UInt *flags, /* 32(%rsp) */ UWord *rv2 /* 40(%rsp) */ ); @@ -784,20 +783,18 @@ asm( " movq %r8, %r10\n" /* a4 */ " movq %r9, %r8\n" /* a5 */ " movq 16(%rbp), %r9\n" /* a6 last register arg from stack, account for %rbp */ -" movq 32(%rbp), %r11\n" /* a8 from stack */ -" pushq %r11\n" " movq 24(%rbp), %r11\n" /* a7 from stack */ -" pushq %r11\n" +" pushq %r11\n" " subq $8,%rsp\n" /* fake return addr */ " syscall\n" " jb 1f\n" -" movq 48(%rbp),%rsi\n" /* success */ +" movq 40(%rbp),%rsi\n" /* success */ " movq %rdx, (%rsi)\n" /* second return value */ " movq %rbp, %rsp\n" " popq %rbp\n" " ret\n" "1:\n" /* error path */ -" movq 40(%rbp), %rsi\n" /* flags */ +" movq 32(%rbp), %rsi\n" /* flags */ " movl $1,(%rsi)\n" " movq %rbp, %rsp\n" " popq %rbp\n" @@ -1231,7 +1228,7 @@ SysRes VG_(do_syscall) ( UWord sysno, RegWord a1, RegWord a2, RegWord a3, UWord val2 = 0; UInt err = 0; val = do_syscall_WRK(sysno, a1, a2, a3, a4, a5, - a6, a7, a8, &err, &val2); + a6, a7, &err, &val2); return VG_(mk_SysRes_amd64_freebsd)( val, val2, (err & 1) != 0 ? True : False); # elif defined(VGP_arm64_freebsd) diff --git a/coregrind/m_syswrap/syscall-amd64-freebsd.S b/coregrind/m_syswrap/syscall-amd64-freebsd.S index d1516b106..14cd4ee90 100644 --- a/coregrind/m_syswrap/syscall-amd64-freebsd.S +++ b/coregrind/m_syswrap/syscall-amd64-freebsd.S @@ -112,17 +112,9 @@ ML_(do_syscall_for_client_WRK): movq OFFSET_amd64_R10(%r11), %r10 movq OFFSET_amd64_R8(%r11), %r8 movq OFFSET_amd64_R9(%r11), %r9 - /* 2 stack parameters plus return address (ignored by syscall) */ - /* @todo PJF there is a potential bug here - * syscall can take up to 8 arguments - * but when syscall0 or syscall198 is being used - * one argument is used for the syscall0/198 id - * and one for the actual id and in this case - * there could be 3 stack parameters. - * However, only mmap takes 8 arguments - * and only on x86. It would be an unlikely combination, - * but this might break one day. */ + /* get RSP */ movq OFFSET_amd64_RSP(%r11), %r11 /* r11 = simulated RSP */ + /* 2 stack parameters */ movq 16(%r11), %rax pushq %rax movq 8(%r11), %rax