]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD amd64: amd64 syscalls only ever need max 7 args
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 20 Sep 2025 17:20:50 +0000 (19:20 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 20 Sep 2025 17:20:50 +0000 (19:20 +0200)
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.

coregrind/m_syscall.c
coregrind/m_syswrap/syscall-amd64-freebsd.S

index c76f1df81bcd82e4e9cda2f08b5aa3320640b6f0..18a59205937e42e0c73fc9427fd8d48ab09b941a 100644 (file)
@@ -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)
index d1516b106505573ad2788d21dc3a6baa764175ab..14cd4ee90bce7bfae1af1f4219972dd6c7393874 100644 (file)
@@ -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