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.
Florian Krohm [Fri, 21 Nov 2025 16:54:13 +0000 (16:54 +0000)]
s390: STFLE related cleanups (BZ 509562)
The STFLE insn is always present on the supported machines.
- Remove s390_host_has_stfle, VEX_HWCAPS_S390X_STFLE, and EmFail_S390X_stfle
- Update tests/s390x_features.c
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Fri, 21 Nov 2025 15:51:53 +0000 (15:51 +0000)]
s390: long displacement facility related cleanups (BZ 509562)
The long displacement facilities are always present on the supported
machines.
- Remove s390_host_has_ldisp and VEX_HWCAPS_S390X_LDISP
- Update tests/s390x_features.c
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Florian Krohm [Wed, 19 Nov 2025 13:27:51 +0000 (13:27 +0000)]
s390: Set min. required machine model to z196. (BZ 509562)
Bail out if machine is too old.
This is the 1st installment of a series of patches raising the min.
required machine model to z196.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562
Paul Floyd [Wed, 19 Nov 2025 08:00:54 +0000 (09:00 +0100)]
Darwin macho debuginfo: fix RW load count
Was counting all RW loads. However, load_thing_file() has the extra
requirement that the filesize be greater than 0. If the filesize is
0 then an anon map gets done and the associated segment doesn't get
flagged as being RW.
Also add the prot value to the macho load_segment mmap traces.
Florian Krohm [Sat, 15 Nov 2025 12:27:27 +0000 (12:27 +0000)]
s390x: Support FPC rounding mode 0b111
When get_bfp_rounding_mode_from_fpc was added Irrm_PREPARE_SHORTER was
not available. The rounding mode 0x111 in the FPC was mapped to Irrm_NEAREST
with fingers crossed.
When Irrm_PREPARE_SHORTER was added later on it was forgotten to adjust this
function. Now fixed. Comments and bfp-convert testcase adjusted.
Paul Floyd [Tue, 11 Nov 2025 14:57:14 +0000 (15:57 +0100)]
Darwin: update wqthread_hijack arguments
Taken from Louis Brunner's GitHub repo.
Now when I launch TextEdit with memcheck it doesnt fail straight away.
I get a few memcheck errors and then it hangs. Looks like the 3 threads
are all running JITted code with one blocked having access errors.
Paul Floyd [Sun, 9 Nov 2025 18:28:13 +0000 (19:28 +0100)]
Darwin: rework syscall arg handling
There were numerous issues, particularly with syscall SYS_syscall
and the scalar tests. Only tested on amd64, I don't have access to
an OSX 10.12 or earlier machine to do any testing.
The key elements in VG_(client_syscall) are, when the PRE wrapper
does not handle the syscall
1. getSyscallArgsFromGuestState
2. getSyscallArgLayout
3. call PRE wrapper
What has changed
----------------
struct SyscallArgs now like FreeBSD, stores both the
canonical_sysno (which is the final syscall number, never
SYS_syscall) and the original_sysno (which can be SYS_syscall).
These get set in getSyscallArgsFromGuestState which has
changed accordingly.
getSyscallArgsFromGuestState has changed to always get the layout
coresponding to the canonical layout. This was the cause of the
problems with the scalar tests - the arguments were effectively
out by one.
Many subsequent changes to the scalar test, filter and expected.
The scalar test still isn't quite right. __NR_kevent_qos is missing
a scalar error from argument 6. That's the one with special case
handling because it is a register argument for a normal syscall
but a stack argument for syscall SYS_syscall.
Paul Floyd [Fri, 7 Nov 2025 19:40:21 +0000 (20:40 +0100)]
FreeBSD regtest: add comments for a sched_setaffinity equivalent
Trying to get a fix for nlvgdbsigqueue flakiness.
FreeBSD has cpuset_setaffinity which is similar to sched_setaffinity.
Howeever, it needs privileges in order to be used. So I've just put the
code there in a comment.
Paul Floyd [Mon, 3 Nov 2025 20:43:17 +0000 (21:43 +0100)]
regtest: rename memcheck wcpncpy
The perl script filter_memcheck removes callstack elements that
are not of interest and changes vg_replace_strmem.c/vg_replace_malloc.c
line numbers to '...'. It protects lines containing the testcase
name.
When the testcase name is the same as the C function being tested
that's not really what we want. My perl isn't really good enough
to be able to only change the line numbers when it is a 'tool file'.
Instead I'm renaming the testcase.
Paul Floyd [Sat, 1 Nov 2025 15:56:20 +0000 (16:56 +0100)]
Darwin regtest: add an expected for duplicate_align_size_errors
Also start trying to del with some redir issues.
For some libc functions the plain function gets replaced by a
checked version (not sure if this is only for debug builds).
For instance in /usr/include/secure/_string.h there are a load of macros
that look like
To defeat these macros I've put the function name in parens. That hasn't
solved the issue. In addition these seems to be an ifunc like mechanism
that resolves calls to platform functions. For instance
nm /usr/lib/system/*dylib | grep memcc 0000000000081e14 T ___memccpy_chk
U __platform_memccpy
I _memccpy (indirect for __platform_memccpy) 0000000000004eb4 T __platform_memccpy
That matches what I see in lldb (memccpy then function lookup code then _platform_memccpy).
Paul Floyd [Thu, 30 Oct 2025 20:29:28 +0000 (21:29 +0100)]
Darwin regtest: various filters
Use -q to hide Darwin leaks in HEAP SUMMARY
The pcmpgt test uses uint64_t whish is unsigned long long on Darwin
but unsigned long on all other amd64 OSes
Swap malloc_zone_memalign with posix_memalign
Paul Floyd [Thu, 30 Oct 2025 14:17:50 +0000 (15:17 +0100)]
Darwin regtest: changes to filters and sed commands
Darwin libc is quite incontinent, so use filter_xml_leak
in a few places rather than filter_xml.
Also old Darwin 17.7 sed doesn't understand "+1d" to delete the
matched line and the next line. So use N to join, s to delete the
newline and another match with d to delete the joined linbes.
Paul Floyd [Wed, 29 Oct 2025 13:25:04 +0000 (14:25 +0100)]
Darwin regtest: simplify memcheck filter_supp
The filter removes used suppression lines and duplicate lines.
Old Darwin sed doesn't understand 'M{}', so use "cat -s" to remove
duplicate blank lines instead.
Florian Krohm [Sun, 26 Oct 2025 21:45:32 +0000 (21:45 +0000)]
s390x: Enable "convert to logical" BFP test
This was disabled because I had thought that a negative
operand value should result in a condition code of 1. Not so.
Additionally the operand value must be 0 after rounding.