Mark Wielaard [Thu, 4 Jul 2024 13:21:39 +0000 (15:21 +0200)]
Avoid dev/inode check on btrfs with --sanity-level=3
With --sanity-level=3 or higher the aspacemgr sanity checks the
device/inode numbers from /proc/self/maps to the file stat
results. These don't match on btrfs. So detect when a file is on a
btrfs volume and ignore the check in that case.
gdb on Fedora will warn not being able to load the rpm python module.
Unable to load 'rpm' module. Please install the python3-rpm package.
Filter out that message so tests don't fail.
Don't allow programs calling fnctl on valgrind's own file descriptors
Add a call to ML_(fd_allowed) in the PRE handler of fcntl and fcntl64
and block syscalls with EBADF when the file descriptor isn't allowed
to be used by the program.
Mark Wielaard [Sun, 16 Jun 2024 22:27:12 +0000 (00:27 +0200)]
Close both internal pipe fds after VG_(fork) in parent and child
An VG_fork() creates a pipe between parent and child to syncronize the
two processes. The parent wants to register the child pid before the
child can run. This is done in register_sigchld_ignore.
Make sure both the parent and the child close both the read and write
file descriptors so none leak.
Mark Wielaard [Sun, 16 Jun 2024 19:23:08 +0000 (21:23 +0200)]
Don't leave fds created with --log-file, --xml-file or --log-socket open
prepare_sink_fd and prepare_sink_socket will create a new file
descriptor for the output sink. finalize_sink_fd then copies the fd
to the safe range, so it doesn't conflict with any application fds.
If we created the original fd ourselves, it was a VgLogTo_File or
VgLogTo_Socket, not VgLogTo_Fd, finalize_sink_fd should close it.
Also close socket when connecting fails in VG_(connect_via_socket).
Add a testcase for --log-file and --xml-file which prints output to
/dev/stderr
Add a new filter_xml. Note the use of --child-silent-after-fork=yes
usage in two vgtests. Maybe this should be the default for --xml=yes?
Otherwise xml output will be "corrupted" by output from a fork.
Paul Floyd [Mon, 10 Jun 2024 05:14:40 +0000 (07:14 +0200)]
FreeBSD: fixes for version 14.1
There were several leftovers from when I split FREEBSD_14
into 14_0 and 14_1 versions.
sys_break doesn't exist on arm64
There's a really annoying conditional jump error in a static copy
of strlen in ld-elf.so.1. We can't redirect the strlen, so I've
added a suppression. But it messes up test cases that use -s
to count errors.
Finally, FreeBSD 14.1 has removed a few old FreeBSD 7 syscalls.
David Benjamin [Thu, 16 May 2024 14:12:59 +0000 (10:12 -0400)]
Extract common arm64 SIMD helpers into a single header
This was copy-pasted between two files and, with the number of
extensions in aarch64, will likely need to be in many more. As the
header file defines a bunch of static, mutable state, some functions
needed to be moved to a separate .c file, to avoid weird behaviors from
C's textual inclusion model.
This also required refreshing fp_and_simd's expected output. The
fp_and_simd and fp_and_simd_v82 copies of randV128 produced slightly
different output because fp_and_simd_v82 also checked for valid f16s.
Deduplicating the code means we now apply that across the board.
NB: The fp_and_simd expected output was synthesized from what valgrind
thought the correct output was, *not* running the executable directly.
Valgrind does not seem to actually match a real Arm machine. This
divergence already existed before this commit. The divergence is in the
fmla, fcvtxn, and fcvtxn2 instructions. Looking at the corresponding
code in guest_arm64_toIR.c, I see various comments discussion how they
don't quite round correctly, so I'm guessing this is a known bug. For
now, as before this commit, I've generated the test expectations based
on the bug.
Andreas Arnez [Wed, 15 May 2024 12:32:42 +0000 (14:32 +0200)]
s390x: Support the deflate-conversion facility (DFLTCC)
So far the DFLTCC (deflate conversion call) instruction is not supported
by Valgrind. Similar to PRNO and NNPA, it is a "complex" instruction
whose memory effects cannot be adequately expressed with a dirty helper.
Add support for the DFLTCC instruction using the new "extension" mechanism
and reflect this accordingly in the supported facilities and HWCAPs.
Andreas Arnez [Wed, 15 May 2024 12:32:42 +0000 (14:32 +0200)]
Avoid use of guest_IP_AT_SYSCALL in handle_extension()
The guest state field guest_IP_AT_SYSCALL is referenced in
handle_extension(), even though it may not be defined by all
architectures. Avoid its use altogether.
Andreas Arnez [Wed, 15 May 2024 12:32:42 +0000 (14:32 +0200)]
Fix uninitialized `err' in handle_extension()
In handle_extension(), in the case of a second return from SCHEDSETJMP the
variable `err' would be used uninitialized. Fix this by avoiding any
access to `err' in this case.
Mark Wielaard [Mon, 13 May 2024 10:30:13 +0000 (12:30 +0200)]
README_DEVELOPERS: Replace b vgPlain_do_exec with b vgPlain_do_exec_inner
When building with --enable-lto vgPlain_do_exec is optimized out.
So replace the breakpoint example with vgPlain_do_exec_inner and
add a note that this is just an example and internal symbol names
might change or get optimized out.
Paul Floyd [Wed, 1 May 2024 13:17:50 +0000 (15:17 +0200)]
FreeBSD ioctl: CAMIOCOMMAND with subcommmand XPT_DEV_MATCH
CAM is the FreeBSD disk I/O subsystem (Common Access Method).
I had picked up an implementation of this from bitbucket done
by a FreeBSD dev. It was done a long time ago, around 2013 on
Valgrind 3.8. Mercurial bitbucket is now kickbucket. There
were 2 big problems.
1. Bit rot. The CAM ioctl is versioned and the version that I
copies was 0x15 whilst the current version is 0x2a, 6 versions
later. That meant that the ioctl wrapper wasn't even getting
called. In addition, as the versioning implies, the data structures
were also out of date.
2. Might also be bit rot but the data structures were copied with
QUEUE_MACRO_DEBUG_TRACE enabled. For that to work the whole
FreeBSD system needs to be built with it turned on. With that
macro turned on in Valgrind the data structures were offset
compared to the kernel, and nothing worked correctly.
There are still a huge number of CAM ioctls unimplemented.
"camcontrol devlist" now works wihtout generating false positives.
Paul Floyd [Tue, 30 Apr 2024 05:58:38 +0000 (07:58 +0200)]
DRD regtest: try to make drd/tests/pth_mutex_signal less flaky
Use a loop of 1ms usleeps rather than a single 1s usleep.
This is usually more releable in ensuring that there's a context switch and that signals
get handled in the order that we want.
Paul Floyd [Mon, 29 Apr 2024 19:11:53 +0000 (21:11 +0200)]
Darwin regtest: don't visit dSYM directories with tests/vg_regtest
Due to the extra directory depth of dSYM directories the following line
my $dashes = "-" x (50 - length $full_dir);
generates a warning on Darwin because the length of $full_dir is more than 50
("Negative repeat count does nothing"). This change makes test_one_dir return
early if the directory contains "dSYM".
Paul Floyd [Sun, 28 Apr 2024 16:19:55 +0000 (18:19 +0200)]
fd leaks: add an assert for the error extra data
Coverity claims that it could cause a NULL dereference. I don't
think it's possible. Adding an assert will at least make things
clearer if Coverity ever turns out to be right.
One reported by Fabien Launay on valgrind-developers. The other
two found with grep. There's a fourth one, but it's in a patch
file so I've left it for now.
Andreas Arnez [Thu, 25 Apr 2024 12:38:45 +0000 (14:38 +0200)]
s390x: Add support for the `NNPA' instruction
Finalize the NNPA facility support by handling the NNPA instruction
itself, using the new "extension" approach. Also reflect NNPA facility
support in HWCAP and in the STFLE bits.
Paul Floyd [Wed, 24 Apr 2024 19:34:03 +0000 (21:34 +0200)]
FreeBSD syscall: add wrapper for kcmp
For FreeBSD 15.0-CURRENT. Will need to add for 14.1 when it is out.
Mostly the same as the Linux kcmp syscall (small differences in the
supported types).
Mark Wielaard [Wed, 24 Apr 2024 18:50:43 +0000 (20:50 +0200)]
Add prereqs for tests using python 3.9+
Adds a script tests/python_test.sh that checks whether there is a python3
binary and that it supports python version 3.9 or higher. Use this script
in the various cachegrind/tests annotate vgtests as prereq.
Paul Floyd [Wed, 24 Apr 2024 18:14:40 +0000 (20:14 +0200)]
FreeBSD syswrap: wrong length for __sysctlbyname(name)
Copied and pasted from syscall where name is a pointer to array of ints
so the size has a '*sizeof(int)'. -byname name is a char* so should not
have the *4 factor.
From
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278566
Andreas Arnez [Tue, 23 Apr 2024 14:27:11 +0000 (16:27 +0200)]
s390x: Improve operand names in trackers for PRNO
The operand names in the trackers called in the implementation of the PRNO
extension do not indicate the extension being handled. Change this by
adding the name PRNO to all these names.