Paul Floyd [Fri, 12 Apr 2024 18:14:18 +0000 (20:14 +0200)]
regtest arm64: fixes for arm64 clang, part 2
More clang moans about using int where long long is expected
Also clang assembler refuses to accept opcodes like sub x21,x22,x23,sxtb
According to the arm manual it is right and it should be
sub x21,x22,w23,sxtb.
I asked on the LLVM discourse and they said they preferred to be strict
and unambiguous.
Paul Floyd [Fri, 12 Apr 2024 17:59:35 +0000 (19:59 +0200)]
regtest arm64: fixes for arm64 clang, part 1
clang warns about using integers where long longs are expected.
Secondly a few of the tests read the executable text. clang uses
different registers than GCC which causes a diff. Hence another
expected. The tests are potentially flaky so if we see instability
we need to modify the test.
Mark Wielaard [Thu, 11 Apr 2024 17:48:22 +0000 (19:48 +0200)]
Add __set_vma_name suppression to drd/tests/std_thread2.supp
glibc uses a atomic var to set whether the kernel supports
PR_SET_VMA_ANON_NAME. This looks like a conflicting access to drd.
Suppress it for this testcase.
Paul Floyd [Fri, 29 Mar 2024 06:33:29 +0000 (07:33 +0100)]
regtest: rename none/tests/arm64/memory
This directory now contains a C++ test. 'memory' is also the name
of a C++ header. The include paths include ".". All that means that
if 'memory' builds before 'bug484426' then bug484426.cpp will try to
include the binary executable file 'memory' from the same directory
and not the header somewhere under /usr/include.
Andreas Arnez [Wed, 27 Mar 2024 18:35:43 +0000 (19:35 +0100)]
s390x: Update tracking of implemented insns for z16
List the instructions first introduced with z16 in s390-opcodes.csv. Also
mention the unimplemented ones in guest_s390_toIR.c and add new extended
mnemonics to the script s390-check-opcodes.pl. For ease of use, add
support for invoking the script without command line arguments.
Andreas Arnez [Wed, 27 Mar 2024 11:44:37 +0000 (12:44 +0100)]
s390x: Add support for NNPA facility vector instructions
Add support for the vector instructions introduced with the NNPA facility,
i.e, VCNF, VCLFNH, VCFN, VCLFNL, and VCRNF. These instructions convert
floating-point data between the usual binary FP format (IEEE) and the
NNPA-specific format. Implement them with dirty helpers.
The NNPA instruction itself will be addressed with a separate patch.
Paul Floyd [Wed, 27 Mar 2024 14:53:42 +0000 (15:53 +0100)]
Dawrin regtest: mostly more filtering
Changed str_tester to always call memcmp. Apple clang 10 seems
to evaluate some of these at compile time, and gets it wrong.
The runtime gets it right.
Eyal Soha [Tue, 2 Mar 2021 21:42:38 +0000 (14:42 -0700)]
Bug 474160 - If errors-for-leak-kinds is specified, exit-on-first-error should only exit on one of the listed errors.
It's possible for the user to specify in the memcheck that some errors
should not cause an exit with the error-exitcode value. For those
errors which would not cause an error exitcode, do not count them for
the purposes of exiting after the first error.
Julian Seward [Mon, 11 Mar 2024 16:53:14 +0000 (17:53 +0100)]
Handle gcc __builtin_strcmp using 128/256 bit vectors with sse4.1, avx/avx2
* amd64 front end: redo the translation into IR for PTEST, so as to
use only IROps which we know Memcheck can do exact instrumentation
for. Handling for both the 128- and 256-bit cases is has been
changed.
* ir_opt.c: add some constant folding rules to support the above. In
particular, for the case `ptest %reg, %reg` (the same reg twice), we
want rflags.C to be set to a defined-1 even if %reg is completely
undefined. Doing that requires folding `x and not(x)` to zero when
x has type V128 or V256.
* memcheck/tests/amd64/rh2257546_{128,256}.c: new test cases
Mark Wielaard [Fri, 15 Mar 2024 11:55:23 +0000 (12:55 +0100)]
Make sure socket file is created in socket_close testcase
If the socket file already existed the path name wouldn't be recorded.
Explicitly unlink it before opening and binding the socket. Adjust
none/tests/socket_close.stderr.exp for new path name and line numbers.
Paul Floyd [Thu, 14 Mar 2024 07:12:23 +0000 (08:12 +0100)]
regtest: un-inline fdleak close_inherited
I don't understand why but clang on FreeBSD arm64 seemed to
optimize away the 'stat' check. That caused failures due
to incorrect duplicate close errors.
Andreas Arnez [Wed, 13 Mar 2024 16:47:59 +0000 (17:47 +0100)]
s390x: Fix definedness of syscall return value register
The memcheck test case for the close_range syscall showed that Valgrind on
s390x doesn't correctly set the definedness of the return value register
after having invoked a system call. Fix this.
With --track-fds=yes warn when file descriptor is closed a second time
We moved the record_fd_close call from POST to PRE sys_close handler,
because the POST handler is only called on success. Even if the close
syscall fails the file descriptor is still really closed/invalid.
In the PRE handler the file descriptor is about to be closed, but hasn't
been yet so we can capture also the description.
This patch add new field fd_closed to OpenFd structure to record if
the file descriptor was already closed.
We now capture a backtrace when closing file descriptors to be able to
print it in a case of a double close. Always add '<' brackets '>' around
"unbound" in the description for consistency.
getsockdetails now takes and returns a buffer describing the socket
because we want to record it, not just print it.
Note that close_range is handled similar to closing each descriptor
individually. But the case when the close_range is called with an
infinite end (~0U) is treated special. Add a new record_fd_close_range
function which handles close_range with an infinite end so double
close by close_range isn't an error because we don't want to loop
over such a wide range.
Add a new test cases:
- none/tests/socket_close.vgtest
- tests double closing a socket
- none/tests/double_close_range.vgtest
- uses close_range to double close the file descriptors
- none/tests/file_dclose.vgtest
- double closing regular file with regular close syscall
Paul Floyd [Wed, 13 Mar 2024 08:06:31 +0000 (09:06 +0100)]
FreeBSD: fixed file mappings revisited
Revert to using the ELF fixed file flag, but keep the first
mapping so that it gets recorded to keep parse_procselfmaps
and ML_(read_elf_object) happy with what they see.
Mark Wielaard [Thu, 7 Mar 2024 16:40:54 +0000 (17:40 +0100)]
Move close_range test from memcheck/tests/freebsd to memcheck/tests
The close_range call is also available under linux and we already
have an appropriate configure call to test it. The only difference
is how the syscall arguments are called.
Paul Floyd [Wed, 6 Mar 2024 20:19:23 +0000 (21:19 +0100)]
FreeBSD syscall: fixes for semctl
On FreeBSD, the libc semctl function takes a union semun argument
for commands that take 4 arguments. It then gets that argument
via va_args and takes a pointer to it. That's what gets passed
to the sysctl - a pointer to union semun.
Previously we were handling the 4th argument as if it were
directly a union semun. This seems to have worked OK for years,
possibly due to luck concerning the way that va_args works
and/or the fact that the union is basically a union of
pointers. Recently I've been working on arm64 and there it
most definitely does not work.
Paul Floyd [Mon, 4 Mar 2024 20:09:16 +0000 (21:09 +0100)]
FreeBSD and macOS: change detection of when carry flag is being set
FreeBSD and macOS syscalls both have two return registers and
use the carry flag for the status. So syscall for client
needs to set the carry flag in the VexGuestArchState. That's
a bit much to do all in asm so we call VEX funtions.
But that doesn't play well with interrupts. There are labels
in ML_(do_syscall_for_client_WRK) so that we can work out
what to do if we get interrupted there. But there are no asm
labels in the VEX functions. Getting the address of the start
of the extern function is easy. There's no way in C to get
the length, and getting the address for the static helpers
is also messy.
I did bodge a solution whereby I put a dummy function in the
source file and scientifically crossed my fingers and hoped
that the compiler would lay out the object file in the same
way. And it did, at least for amd64 FreeBSD amd64 Darwin and
x86 FreeBSD (I don't have easy access to Darwin with working
x86).
Still, it's UB.
I recently tried the same thing for arm64 FreeBSD. And there
the functions are all over the shop in the object file.
So, time to do something a bit cleaner. I've removed all of
the hacky dummy functions and put a flag in the guest vex
state. For both amd64 and x86 there were spare padding
UInts that I've used. Arm64 won't be so lucky when I get there,
no spare padding words.
Mark Wielaard [Tue, 27 Feb 2024 12:36:39 +0000 (13:36 +0100)]
Add Unlicense to coregrind/m_debuginfo/tinfl.c
The tinfl.c file comes from the public domain miniz project.
Upstream added an explicit Public Domain declaration using
the Unlicense. No other changes were made, so all our valgrind
specific changes still apply. This doesn't really change the
license as used for our derived version, which is distributed
under GPLv2+. But it adds some history and a legal statement
that is more clear than just saying "public domain".
Paul Floyd [Sun, 25 Feb 2024 18:10:37 +0000 (19:10 +0100)]
FreeBSD: experimental fix for --sanity-level=3 and above
Previously this failed due to split mmap mappings for MAP_STACK.
This change tries to piece together such stack mappings. This
mainly affects multithreaded apps when they create their thread
stacks.
Paul Floyd [Sun, 25 Feb 2024 13:50:57 +0000 (14:50 +0100)]
FreeBSD: clean up guest stack creation code
At one time I thought of using sysctls to get the same stack
max size and growth size as the OS uses. But that won't work
for x86 on amd64. So I've just cleaned the code a bit and
added more comments explaining what is going on.
Paul Floyd [Fri, 23 Feb 2024 20:43:16 +0000 (21:43 +0100)]
FreeBSD: another load of changes for FreeBSD 15
One more default suppession.
The new libsys.so was causing problems, and it needs to be
loaded before libthr.so in order to be able to get the tid
for the main thread on startup.
The bar_bad testcase for both helgrind and drd was giving a lot of
trouble (inclusing an assert in DRD_(barrier_pre_wait) ). The
sleeps in the testcase were not assuring the expected order.
So I changed the sleeps to 1ms nanosleeps in loops. That's a
bit more realistic and it also gives much more chances to the
scheduler to context switch.
Paul Floyd [Fri, 23 Feb 2024 19:07:53 +0000 (20:07 +0100)]
FreeBSD: updates for FreeBSD 15 libsys
FreeBSD 15 has moved all libc functions that are just syscall
wrappers into libsys. That changes quite a few callstacks, so
I've added a load of filtering to make it look like the old
libc callstacks.
I'm also seeing new conflicts in _umtx_op_err for both DRD
and Helgrind that needed supressing.
Paul Floyd [Fri, 23 Feb 2024 08:33:24 +0000 (09:33 +0100)]
FreeBSD: changes for building with GCC
Use MARK_STACK_NO_EXEC (it's a null macro on non-linux platforms).
GCC complains if it's not used.
parse_procselfmaps yet again.
The hack that I added in 6fdd59afb5e473b30e7ad1fbadcf9a397253fed4
only works for clang/ld.lld. This change makes it also work with
GCC/ld.bfd. Still a hack though.
Paul Floyd [Sat, 17 Feb 2024 20:37:00 +0000 (21:37 +0100)]
Darwin: various fixes
Fix building a couple of regtests.
bmi.c - Apple clang puts a funky underscore before symbols which you
have to add explicitly in asm.
mmap_o_direct.c - there is no O_DIRECT on macOS
syswrap - make csrctl messages a bit more userland-y rather than
kernel-y