Bug 511713

Summary: Refactor syscall argument handling
Product: [Developer tools] valgrind Reporter: Paul Floyd <pjfloyd>
Component: generalAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: All   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

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