Paul Floyd [Sun, 14 Dec 2025 19:23:10 +0000 (20:23 +0100)]
Darwin DRD: redirs for semaphore functions
Like 2802b31ae644301ee641dcae20d1f84373615d54 for Helgrind.
Use the DRD script supported_sem_init in Helgrind tests that use
semaphores, it's clearer than just using tests/os_test
Paul Floyd [Sun, 14 Dec 2025 17:21:19 +0000 (18:21 +0100)]
Darwin helgrind: redirs for semaphore functions
The semaphore functions are not in the pthread library (similar to FreeBSD).
Change the redirs to use libsystem_kernel.dylib
Unfortunately this doesn't help much. Darwin has deprecated these functions
so the tests will compile (with a warning) but at runtime they all fail
with errors like ENOSYS and EBADF.
Paul Floyd [Sun, 14 Dec 2025 12:31:18 +0000 (13:31 +0100)]
Darwin fdleaks: fix handling of recvmsg cmsg
In the Darwin headers the macro __DARWIN_ALIGN32 is used for
the CMSG macros. We were using just ALIGN which looks like
it uses __DARWIN_ALIGN for 8 byte alignment. Using the
wrong alignment gate a wrong count of fds and check_cmsg_for_fds
was only calling ML_(record_fd_open_named) for one fd. The result
was fd errors when writing to a second fd that should have been
recorded.
Paul Floyd [Sun, 14 Dec 2025 09:05:04 +0000 (10:05 +0100)]
Darwin regtest: update none ioctl_moans
This testcase needs IOCTL_REQUEST_BASE to be set to some bogus
value with the platform dependent "no direction" flag set.
That flag wasn't being set for Darwin and so the testcase was
failing.
Andreas Arnez [Fri, 5 Dec 2025 17:01:22 +0000 (18:01 +0100)]
s390x: Simplify single multiplications
So far the single-multiplication instructions are implemented by taking
the low half of a widening multiply. This pattern is then recognized by
the instruction selector, which combines it to a single multiplication
again.
This is unnecessarily complicated, since single-multiply operations can be
expressed directly by Iop_Mul32 and Iop_Mul64 instead. So do this,
simplifying the code generation.
Also, since Iop_Mul32 and Iop_Mul64 haven't really been used before, the
instruction selector generates sub-optimal code for them. Fix that.
Paul Floyd [Thu, 11 Dec 2025 08:06:38 +0000 (09:06 +0100)]
Darwin regtest: update a few expecteds
One predated correct redirection of the C++ library operator new
One has a few line number changes plus I removed an assert that is firing
(asserts firing in tests is never a good thing). And the last one is just
line number changes.
Paul Floyd [Thu, 11 Dec 2025 08:03:08 +0000 (09:03 +0100)]
Darwin libcproc: fix for VG_(read_millisecond_timer)
This function had some peculiar workaround for how the result
was handled. That peculiarity seems to have gone away (some time
before Darwin 17). Now use 'normal' handling for the result for
Darwin 17+.
This was causing some DRD timed mutex testcases to fail.
Paul Floyd [Wed, 10 Dec 2025 07:58:25 +0000 (08:58 +0100)]
Darwin regtest: numerous bits of Darwin 18 cleanup
Add a few more ignore-fn options to the massif tests for the
extra leaks that are in Darwin 18.
Add some suppressions to a couple of memcheck tests that use
num-callers of 2 or 3. The shorter callsteack means some of the
many Darwin default suppressions don't match which was causing
these tests to fail.
Add more DRD suppressions for getaddrinfo. There seems to be a never
ending amount of conflicts in dyld.
Support pmaxsb, pminsb, pmaxuw, pminuw, pmaxud and pminud instructions
in guest_x86_toIR.c and host_x86_isel.c. Move test functions from
amd64/sse4-64.c to sse4-common.h and update none/tests/x86/sse4-x86.c
and sse4-x86.stdout.exp to test all min/max instructions.
Paul Floyd [Tue, 9 Dec 2025 06:33:49 +0000 (07:33 +0100)]
Darwin suppressions: merge old suppression files to darwin-legacy.supp
Merge files for Darwin 10 to 16 into a legacy file. Rename the Darwin 17
file as just darwin.supp. I'll add suppressions to that file, at least for
10.14 and 10.15. When I get to Darwin 20 and the dyld shared cache
we'll see, that might need a new set of suppression files.
Remove freebsd-helgrind-dbgrtld.supp. I thought that it would be useful
but it wasn't. When I merged the Darwin suppression files I wrote a little
duplication detection tool (only for exact duplicates). This found one
duplicate in solaris12.supp that I've removed.
Martin Cermak [Mon, 8 Dec 2025 12:20:25 +0000 (13:20 +0100)]
Wrap new lsm_get_self_attr and lsm_set_self_attr syscalls
Create a system call lsm_get_self_attr() to provide the security
module maintained attributes of the current process.
Create a system call lsm_set_self_attr() to set a security
module maintained attribute of the current process.
Historically these attributes have been exposed to user space via
entries in procfs under /proc/self/attr.
Declare lsm_get_self_attr and lsm_set_self_attr wrappers in
priv_syswrap-linux.h and hook it for {amd64,arm,arm64,mips64,\
ppc32,ppc64,riscv64,s390x,x86}-linux.
Paul Floyd [Mon, 8 Dec 2025 07:24:46 +0000 (08:24 +0100)]
Darwin suppressions: start cleaning up the suppression files
This commit moves DRD suppressions from darwin17.supp to darwin10-drd.supp.
It also removes some pthread lib suppressions. There's an obj suppression
at the top level for libsystem_pthread.dylib that should cover all that.
I want to avoid having 20+ Darwin suppression files (and rising with
every new version). I'd like to have something a bit more like FreeBSD,
with one suppression file for memcheck, one for DRD and one for Helgrind.
That might be a bit optimistic (especially when DSC support lands). So
what I'll do to begin with is to merge all of the Darwin <= 16 memcheck
files into one darwin-legacy.supp, split out a new darwin-helgrind.supp
file and rename darwin10-drd.supp to just darwin-drd.supp. That leaves
darwin9-drd.supp which I'll either rename or merge.
Paul Floyd [Sun, 7 Dec 2025 21:11:19 +0000 (22:11 +0100)]
Darwin: make fixup_macho_loadcmds.c less version dependent
Remove a load of DARWIN_VERS checks. It's a pointless maintenance
burden. Add suppport for SDK >= 10.4.6. First step to adding
macOS 10.14 Mojave support.
Paul Floyd [Sun, 7 Dec 2025 20:59:40 +0000 (21:59 +0100)]
FreeBSD and Darwin: clean up fake sigreturn syscall numbers
Firstly make them a bit more similar. Secondly, switch Darwin
from using __NR_MAXSYSCALL which changes with every Darwin version
to using 1000 like FreeBSD.
Change NEWS for macOS 10.13, it has now progressed beyond
'preliminary'.
Paul Floyd [Sun, 7 Dec 2025 08:52:04 +0000 (09:52 +0100)]
Darwin syscall: initial wrapper for mach_voucher_extract_attr_recipe
It doesn't do any checking yet. However, with this change running
TextEditor with --tool=none gets as far as drawing a white box on
the screen. Then it fails because there is a missing mach trap handler
for
Paul Floyd [Sun, 7 Dec 2025 07:50:32 +0000 (08:50 +0100)]
Darwin mach_msg_host: move assign_port_name to post
There's a GrP comment saying that assign_port_name should only be called on success.
And indeed when it is called in the PRE and it can't find the info for the port
then the code will assert.
Paul Floyd [Sun, 7 Dec 2025 06:54:23 +0000 (07:54 +0100)]
Darwin stacktraces: add a hack to prevent segfault when dereferencing bp
Can now turn a couple more helgrind tests back on.
Need to get to the bottom of the bp dereferencing issue. There is a test
already so it us supposed to be safe.
Paul Floyd [Sat, 6 Dec 2025 09:50:38 +0000 (10:50 +0100)]
FreeBSD client stack: add an assert to check the stringtable doesn't get overwritten
There's already an assert that the stringsize calculated matches the
stringsize writte. This adds a check that the pointer table area
does not overwrite the stringtable (that is, that the NULL pointer after the
last auxv entry pointer does not overwrite the first string [either the
interpreter or argv[0])
Paul Floyd [Fri, 5 Dec 2025 20:59:34 +0000 (21:59 +0100)]
Darwin: also clean up client stack creation
Make stringbase and strtab be based off clstack_end + 1
rather than clstack_end. clstack_end is the address of the
last byte of the stack, not one past the end of the stack.
That means that it is not word aligned. Adding 1 makes
the calculation word aligned.
Depending on the length of the string table with rounding
it could happen that the executable_path pointer would
overwrite the start of argv[0] in the string table.
I think that that there are supposed to be 0-16 bytes between
the end of the pointers and the string table (or is that
ELF?).
Paul Floyd [Fri, 5 Dec 2025 12:47:19 +0000 (13:47 +0100)]
Darwin: no need to turn off alignment assert in leak check
Mixed up 2 files with previous commit. This also contains
a missing proto and the previous commit fixes issues with badly formed
segments. Needs more investigation.
Florian Krohm [Wed, 3 Dec 2025 22:26:57 +0000 (22:26 +0000)]
Change the data type of libvex_Backend::emit.
Both the s390 and arm insn emitters need to know the host's hardware
capabilities. Today, these are provided by means of global variables
s390_host_hwcaps and arm_hwcaps. To eliminate that kludge the emit
function is changed. Instead of passing VexEndness we now pass a pointer
to VexArchInfo which provides both the endianess and hardware capabilities.
Those global variables will be removed in a followup patch.
Now that the stfle insn is available we can use it to tell uas how
many double words are needed to store all facility bits. Hence,
S390_NUM_FACILITY_DW can go.
Paul Floyd [Thu, 27 Nov 2025 06:22:18 +0000 (07:22 +0100)]
Darwin: many fixes for OSX 10.13
Most of these changes are from Louis Brunner's GitHub repo.
The most imortant changes are to the memory space and to the code
related to getting the host filename during startup. This means
that when Valgrind crashes or hits an assert we now get a legible
host stacktrrace.
Paul Floyd [Thu, 27 Nov 2025 12:14:43 +0000 (13:14 +0100)]
Massif regtest: filter ignore functions, part 1
This is mainly for Darwin which has numerous leaks that
need to be ignored. This filter removes all --ignore-fn options
from the "out" expecteds. This should allow adding endless
functions to ignore in the vgtest files without having to
also update the out.exp files as well.
Part 2 will be for the verbose output which adds ignore files
to the stderr.exp references.
Martin Cermak [Thu, 27 Nov 2025 08:25:07 +0000 (09:25 +0100)]
Provide missing syswraps for file_getattr and file_setattr
The syscalls take fd and path. If path is absolute, fd is not
used. If path is empty, fd can be AT_FDCWD or any valid fd which
will be used to get/set attributes on.
Paul Floyd [Wed, 26 Nov 2025 20:22:51 +0000 (21:22 +0100)]
Darwin new/delete wrappers: fix on x86
Untested code is always full of surprises.
Darwin x86 doesn't use size_t for the size (where 32bit
size_t is unsigned int and 64but size_t is unsigned long).
Instead it uses unsigned long on both platforms.
That changes the mangled name. It's all 'm' for unsigned long
rather than 32bit 'j' for unsigned short and 64bit 'm'
for unsigned long.
Support pmaxsd and pminsd instructions in guest_x86_toIR.c and host_x86_isel.c
and modify the none/tests/x86/sse4-x86.stdout.exp to match pmaxsd and
pminsd support.
Refactor none/tests/amd64/sse4-64.c and none/tests/x86/sse4-x86.c
to use a common none/tests/sse4-common.h header. This eliminates
code redundancies and makes it easier to add new SSE4 tests for both
architectures more easily. The shared header contains common helper functions,
type definitions, and test macros previously duplicated in both files.
Paul Floyd [Tue, 25 Nov 2025 20:04:17 +0000 (21:04 +0100)]
FreeBSD regtest: turn off a few gdbserver tests on systems with sysctl debug.ptrace_attach_transparent
FreeBSD 15 (out soon) and 16 (the dev branch) have changed the behaviour
of ptrace. When vgdb uses ptrace to get Valgrind to poll gdbserver
to get out of blocking syscalls the client may return a bogus result
from the syscall.
Setting the syscall to 0 turns off this change and all 3 affected testcases
should return to normal behaviour. However, setting the syscall needs root
privileges. So I've added a test to see if the syscall is present and set
to 1. If it is the prereq is not satisfied.
Paul Floyd [Tue, 25 Nov 2025 20:03:35 +0000 (21:03 +0100)]
FreeBSD startup: do not skip exename if it is not present
Don't remember why this code was there. Allowing no exename
is a bad idea (argv[0] will be NULL). I don't think there is
a need any more for this permissiveness.
Martin Cermak [Tue, 25 Nov 2025 14:07:09 +0000 (15:07 +0100)]
Memory allegedly uninitialized after ioctl(PROCMAP_QUERY)
Fix ioctl(fd, PROCMAP_QUERY, ...) so that valgrind correctly considers
memory referenced by vma_name_size and vma_name_addr members of struct
procmap_query as initialized by ioctl().
Extend ioctl syscall wrappers with needed PRE_MEM_WRITE() and
mainly POST_MEM_WRITE(). Add a testcase.
Florian Krohm [Tue, 25 Nov 2025 13:50:37 +0000 (13:50 +0000)]
s390: PFPO facility related cleanups (BZ 509562)
The PFPO facility is always present on the supported machines.
- Remove VEX_HWCAPS_S390X_PFPO, s390_host_has_pfpo and EmFail_S390X_pfpo
- Update tests/s390x_features.c and none/tests/s390x/pfpo
- Update memcheck/tests/vbit-test
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Tue, 25 Nov 2025 13:23:52 +0000 (13:23 +0000)]
s390: load/store-on-condition / high-word facility related cleanups (BZ 509562)
The load/store-on-condition / high-word facility is always present on the
supported machines.
- Remove VEX_HWCAPS_S390X_LSC and s390_host_has_lsc
- Update tests/s390x_features.c and none/tests/s390x/high-word
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Tue, 25 Nov 2025 13:03:37 +0000 (13:03 +0000)]
s390: floating-point-support-enhancement facility related cleanups (BZ 509562)
The floating-point-support-enhancement facility is always present on the
supported machines.
- Remove VEX_HWCAPS_S390X_FGX and s390_host_has_fgx
- Remove wrapper functions: s390_emit_LGDRw, s390_emit_LDGRw
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Tue, 25 Nov 2025 09:14:11 +0000 (09:14 +0000)]
s390: general-instructions-extension facility related cleanups (BZ 509562)
The general-instructions-extension facility is always present on the
supported machines.
- Remove VEX_HWCAPS_S390X_GIE and s390_host_has_gie
- Remove wrapper functions: s390_emit_MFYw, s390_emit_MHYw, s390_emit_MSFIw
- Update tests/s390x_features.c
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Paul Floyd [Tue, 25 Nov 2025 07:20:06 +0000 (08:20 +0100)]
Bug 512571 - regtest problems with darwin dsymuti
There was alrwady a stderr filter for dsymutil, but only for DRD.
So I moved that to tests/filter_stderr_basic.in
I added single quotes around $dir in tests/vg_regtest.in for
arch_test and os_test. That now prevents directory names containing
spaces from being seen as more than one argument.
Florian Krohm [Mon, 24 Nov 2025 18:39:39 +0000 (18:39 +0000)]
s390: ETF2/ETF3-enhancement facilities related cleanups (BZ 509562)
The ETF2/ETF3-enhancement facilities are always present on
the supported machines.
- Remove VEX_HWCAPS_S390X_ETF2 and s390_host_has_etf2
- Remove VEX_HWCAPS_S390X_ETF3 and s390_host_has_etf3
- Update tests/s390x_features.c
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Mon, 24 Nov 2025 18:16:22 +0000 (18:16 +0000)]
s390: message-security-assist facility related cleanups (BZ 509562)
The message-security-assist facility is always present on
the supported machines.
- Remove VEX_HWCAPS_S390X_MSA and s390_host_has_msa
- Remove EmFail_S390X_msa
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Mon, 24 Nov 2025 17:56:44 +0000 (17:56 +0000)]
s390: MSA4 facility related cleanups (BZ 509562)
The message-security-assist-extension-4 facility is always present on
the supported machines.
- Remove VEX_HWCAPS_S390X_MSA4 and s390_host_has_msa4
- Remove EmFail_S390X_msa4
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Mon, 24 Nov 2025 16:40:23 +0000 (16:40 +0000)]
s390: decimal-floating-point facility related cleanups (BZ 509562)
The decimal-floating-point facility is always present on the supported
machines.
- Remove VEX_HWCAPS_S390X_DFP and s390_host_has_dfp
- Remove EmFail_S390X_DFP_insn
- Update tests/s390x_features.c
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Paul Floyd [Mon, 24 Nov 2025 11:55:15 +0000 (12:55 +0100)]
Darwin regtest: make a variant of none require-text-symbol-2
This test looks for a bogus symbol in libc.so. But Darwin
has no libc.so, so make this variant that looks in libsystem_c.dylib.
The -2 variant now has a !os_test darwin prereq and the new -3 variant
has an os_test darwin prereq.
Florian Krohm [Sun, 23 Nov 2025 22:51:53 +0000 (22:51 +0000)]
s390: floating-point-extension facility related cleanups (BZ 509562)
The floating-point-extension facility is always present on the supported
machines.
- Remove s390_host_has_fpext and VEX_HWCAPS_S390X_FPEXT
- Remove EmWarn_S390X_fpext_rounding and EmFail_S390X_fpext
- Remove testscases none/tests/s390x/fpext_fail and fpext_warn
- Update tests/s390x_features.c and memcheck/tests/vbit-test
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Paul Floyd [Fri, 21 Nov 2025 21:02:41 +0000 (22:02 +0100)]
Darwin syscalls: correctly set EIP/RIP in ML_(fixup_guest_state_to_restart_syscall)
The code was using arch->vex.guest_IP_AT_SYSCALL but that got cleaned out on amd64
a while ago. Use EIP/RIP - 2 instead, like other x86 and amd64 platforms.