Bug 511713 - Refactor syscall argument handling
Summary: Refactor syscall argument handling
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources All
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-06 13:29 UTC by Paul Floyd
Modified: 2025-11-07 06:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Floyd 2025-11-06 13:29:23 UTC
The FreeBSD code for syscall argument handling is excessively complicated, especially with regards to syscalls SYS_syscall and SYS___syscall.

I don't like the 'klass' member of struct SyscallArgs, which uses VG_FREEBSD_SYSCALL0 and VG_FREEBSD_SYSCALL198. That adds no information above what we already have with __NR_syscall  and __NR___syscall.

When we call do_syscall_for_client() for blocking syscalls the syscall number gets changed to canonical and then back to the original. If we kept the original syscall number we could avoid that redundant shuffle.

As well as cleaning the code this will also lead to sharing some of this code with Darwin, which has the same requirements as FreeBSD but only partially implements them. That should fix passing the layout info to the PRE wrapper in Darwin which I believe is currently wrong, meaning that the scalar test is 'out by one' for checking syscall syscal arguments.
Comment 1 Paul Floyd 2025-11-07 06:25:43 UTC
commit e3001a5226b122fe031e73ac3d165cb7a370bda2 (HEAD -> master, origin/master, origin/HEAD)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Thu Nov 6 19:40:15 2025 +0100

    Bug 511713 - Refactor syscall argument handling