Mark Wielaard [Fri, 9 May 2025 11:46:44 +0000 (13:46 +0200)]
Add workaround for missing riscv_hwprobe syscall (258)
On riscv newer glibc (2.41) will probe instruction support using the
riscv_hwprobe syscall. Since Valgrind currently doesn't have a wrapper
for riscv_hwprobe that causes a Warning. Since the RISC-V Hardware
Probing Interface is non-trivial and we don't really implement
extended riscv instructions anyway work around that by "implementing"
riscv_hwprobe as sys_ni_syscall so it generates an ENOSYS and glibc
will silently fall back to not using any extended instructions.
Mark Wielaard [Thu, 8 May 2025 22:21:25 +0000 (00:21 +0200)]
mount syscall param filesystemtype may be NULL
On Linux the mount syscall, depending on flags provided, the source,
type and data my be ignored. We already don't check data and allow
source to be NULL. Normally when type is ignored an application will
provide an empty string "". But sometimes NULL is passed (like for
source). So we now also allow type to be NULL to prevent false
positives.
Adjust the linux/scalar.c tests so the type param is still
unaddressable.
But the disasm-test parser assumed there could only be one
address including a symbol name on a given line. It stopped
comparison beyond that point.
The line
Said patch removes the resteering machinery which allowed chasing through
unconditional jumps/calls during IR generation.
There were two fixme's related to this which are now removed.
Also eliminate functions 'call_function_and_chase' and
'always_goto_and_chase' which no longer are meaningful. Use
'call_function' and 'always_goto' instead.
Florian Krohm [Sun, 4 May 2025 21:29:34 +0000 (21:29 +0000)]
s390x: Add disassembly for special insns
Surely we want to see this when tracing the frintend.
Also: new function s390_irgen_inject_ir to wrap the handling of
the special insn for IR injection.
Mark Wielaard [Sun, 4 May 2025 18:16:26 +0000 (20:16 +0200)]
ltp-excludes: Add fork14, futex_cmp_requeue and pidfd_send_signal
There are a few more linux test project syscall tests that seem to
cause some trouble for some buildbots. The fork14 test uses a lot of
memory, as do the futex_cmp_requeue tests (at least on ppc64le). And
the pidfd_send_signal tests, when run inside a container, seem to kill
the test wrapper (and the container it runs in).
Paul Floyd [Tue, 22 Apr 2025 05:22:42 +0000 (07:22 +0200)]
Regtest: clean up warning and compilation of bug290061.c
On some platforms there was a 'defined but not used' warning.
When I fixed that I got a link error from clang. Using a
_LDFLAGS option causes automake to split building the test into
separate compile and link commands and clang was optimizing away
the unused static 'meh' symbol.
Paul Floyd [Mon, 21 Apr 2025 18:44:31 +0000 (20:44 +0200)]
Illumos regtest: add an expected for none/tests/fdleak_socketpair_xml.stderr
illumos socketpair doesn't get the next two fds (3 and 4), instead it
gets 4 and 5. That looks like it's because this is done in two steps in libc.
so_socket gets called twice returnning fds 3 and 4 the so_socketpair takes
those and does some rebinding(?) resulting in fds 4 and 5.
Mark Wielaard [Fri, 18 Apr 2025 10:22:29 +0000 (12:22 +0200)]
Add auxprogs/ltp-excludes.txt
There are a couple of ltp testcases that take a very long time to run
(under valgrind). Add a file auxprogs/ltp-excludes.txt that is used to
exclude them from a make ltpchecks run, containing 10 tests:
Martin Cermak [Thu, 17 Apr 2025 14:14:19 +0000 (16:14 +0200)]
Use LTP for testing valgrind
Add a new top level make target ltpchecks which will fetch the latest
linux test project (ltp) release as defined by the LTP_VERSION and
LTP_SHA256 variables in auxprogs/Makefile.am (update those when a new
version of ltp is released). If the ltp tar.xz has already been
downloaded, or it has already been unpacked and build, the (cached)
file and build will be reused.
The actual testing is done through the auxprogs/ltp-tester.sh script.
It takes all executable tests from the ltp testcases under
kernel/syscalls and runs them 3 times. Once directly, not under
valgrind, once with -q --tool=none and once with -q
--tool=memcheck. It then checks that valgrind didn't produce any
messages with the none tool, that there were no fatal errors produced
(as defined in auxprogs/ltp-error-patterns.txt) and that the ltp
results are the same with and without valgrind.
Currently there are 1472 test binaries and running them all (serially)
takes more than three hours and detects various missing or incomplete
syscall handlers in valgrind, plus various crashers.
Paul Floyd [Thu, 17 Apr 2025 19:26:24 +0000 (21:26 +0200)]
Illumos: increase coverage of --modify-fds syscalls
It looks like Solaris/Illumos is missing some F_DUP* coverage
and we aren't handling syscalls that reaturn 2 fds (pipe, socketpair).
Otherwise this should cover most Illumos cases at least.
Normally a newly recreated file descriptor gets the lowest number
available. This might cause old file descriptor numbers to be reused
and hides bad file descriptor accesses (because the old number is
new again).
When enabled, when the program opens a new file descriptor,
the highest available file descriptor is returned instead of the
lowest one.
Add the none/tests/track_new.stderr.exp test to test this new option.
Adjust none/tests/filter_fdleak to filter the track_new.vgtest,
removing some internal glibc functions from the backtraces and remove
symbol versioning. The output of the use_after_close test also had to
be adjusted. Also adjust the none/tests/cmdline1 and
none/tests/cmdline2 output as the new --modify-fds=no|high is
displayed.
Paul Floyd [Tue, 15 Apr 2025 18:39:22 +0000 (20:39 +0200)]
nightly: fix check for Illumos libc
On Illumos `uname -o` outputs "illumos". We weren't testing for
that so it fell through to the Linux block which runs libc.so to
get the version string. On Illumos that outputs
s390x: Regtest integration of none/tests/s390x/disasm-test
The checker requires objdump --version >= 2.44
Add command line flag --check-prereq to disasm-test and use it in
disasm-test.vgtest.
New file none/tests/s390x/disasm-test/disasm-test.post.exp as the
checker is run in the "post" hook.
This patch makes VEX disassembly match objdump disassembly for
objdump versions >= 2.44. Prior objdump versions did not handle the
nuances of the "rotate and ..." set of opcodes and there was also a
bug disassembling BC insns.
Paul Floyd [Sat, 12 Apr 2025 21:57:58 +0000 (23:57 +0200)]
Illumos regtest: use LC_ALL=C for execx test
There's an uninitialized read in /usr/bin/printf when using the
default en_US.UTF-8 locale. This isn't a printf test, and using
the C locale makes the error go away.
4095 is not a valid bfp rounding mode and the old implementation of
s390_irgen_SRNMB let it slide by with a warning. However, POP calls for a
specification exception in this case. This is what this patch changes.i
It also eliminates the s390_irgen_srnmb_wrapper function along the way.
While adjusting none/tests/s390x/srnmb.* I noticed that the line
number shown in the specification exception is incorrect. This
is not a regression. It has been incorrect before as well.
I have opened https://bugs.kde.org/show_bug.cgi?id=502729 fro the line
number issue.
Paul Floyd [Sat, 12 Apr 2025 16:27:06 +0000 (18:27 +0200)]
Illumos regtest: add 'illumos' to os_test and turn off a few tests
The threadname tests fail on Illumos. Solaris has a syscall,
sys_lwp_name, which we intercept and record. Illumos doesn't
have that, with the pthread name functions looking ofr the name in /proc
That's not implemented in Valgrind so I'm turning those 2 tests off.
The other 3 are all based on none faultstatus. This test checks 4 things,
one of which is reading from a 32k mmap that is PRIVATE and READ but is
only backed by a 16k file. All other OSes generate a SIGBUS. Illumos
just reads 0 from the address.
Paul Floyd [Wed, 9 Apr 2025 06:49:52 +0000 (08:49 +0200)]
Helgrind: Fixes for ETIMEDOUT
pthread_rwlock_timedrdlock and pthread_rwlock_clockrdlock were
generating API errors if they timed out. This fixes that and
only generates API errors for non-zero and non-ETIMEDOUT
return codes.
Paul Floyd [Thu, 3 Apr 2025 17:56:51 +0000 (19:56 +0200)]
Illumos helgrind: fix for pthread_rwlock_timedrdlock and pthread_rwlock_timedrwlock
On Illumos these two functions are implemented by calling
pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock respectively.
Since we intercept both it was appearing as though the lock was being
taken recursively when it wasn't. Fixed it by using a static flag for each
and not callinng the client requests if already in a call to the timed
functions.
I think that musl also does this but, ho-hum, Helgrind has never worked on musl.
Andreas Arnez [Thu, 3 Apr 2025 15:40:03 +0000 (17:40 +0200)]
s390x: Support the PPA instruction
The perform processor assist (PPA) instruction provides the CPU with
special execution hints. It belongs to the processor-assist facility,
which shares facility bit 49 with the execution-hint and load-and-trap
facilities and with the miscellaneous-instruction-extensions facility 1.
Implementing PPA enables setting facility bit 49 to one. Similar to other
execution hint instructions, implement PPA as a no-op for now.
Andreas Arnez [Thu, 3 Apr 2025 17:07:32 +0000 (19:07 +0200)]
s390x: Reflect renaming of DFP insns in opcode checker
After renaming various DFP instructions to their new name, reflect this in
s390-check-opcodes.pl by ignoring their old names, so the checker doesn't
complain about mismatches.
Also, add the missing documentation in s390-opcodes.csv about the fact
that the "with rounding mode" instruction versions cgdtra, cgxtra, and
cxgtra are implemented.
s390x: Add missing s390_insn_assert for non-vector opcodes
Based on the specification in disasm-test/opcode.c
With a few corrections:
- kma: tighten up the assert
- cdftr, cxftr: no emulation failure when floating-point-extension
facility is not installed
- cgdtra, cgxtra: check for floating-point-extension facility
- ltdtr, ltxtr, lxdtr: check for DFP facility
Andreas Arnez [Wed, 2 Apr 2025 17:52:26 +0000 (19:52 +0200)]
Bug 502324 - Add test case for TMx memcheck false positives
Add a regression test for Bug 502324. Before the bug was fixed, this test
failed with various "conditional jump or move depends on uninitialised
value(s)" messages.
Andreas Arnez [Wed, 2 Apr 2025 17:52:26 +0000 (19:52 +0200)]
Bug 502324 - s390x: Fix memcheck false positives with TM/TMY
If the condition code of TM/TMY is generated in a different block than it
is used, memcheck can yield false positives for a partially initialized
value even if the checked bits are all defined.
Fix this by storing the operand ANDed with the mask in the flags thunk,
instead of the unmodified operand. This enables memcheck to track the
defined bits correctly.
Andreas Arnez [Wed, 2 Apr 2025 17:52:26 +0000 (19:52 +0200)]
Bug 502324 - s390x: Fix memcheck false positives with TMxx
The 16-bit "test under mask" instructions TMLL, TMLH, TMHL, and TMHH can
yield memcheck false positives when:
* some of the operand bits in the tested 16-bit chunk (but outside the
mask) are undefined
* the resulting condition code is used in a different block
In this case the condition code is computed by the helper
s390_call_calculate_cond, with the full 16-bit chunk and the given mask as
arguments. Since the 16-bit chunk is not fully defined, memcheck
complains.
To fix this, AND the operand with the given mask before storing it for use
as a helper argument. Also, optimize the frequent case of testing a
single bit. For this purpose, add S390_CC_OP_BITWISE2 as a new way of
computing the condition code.
Andreas Arnez [Tue, 1 Apr 2025 15:21:16 +0000 (17:21 +0200)]
Bug 502288 - s390x: Fix false positive with NNPA pad elements
The size of the non-pad elements in the last dimension of NNPA tensors is
computed incorrectly. This can lead to memcheck false positives that look
like this:
==3180208== Syscall param NNPA(in_tensor_1) points to uninitialised byte(s)
Andreas Arnez [Tue, 1 Apr 2025 14:25:05 +0000 (16:25 +0200)]
s390x: Reflect ppno -> prno renaming in opcode checker
After consequently renaming ppno to prno, the tool s390-check-opcodes.pl
complains:
*** opcode prno is implemented but CSV file does not say so
*** opcode ppno is not implemented but CSV file says so
*** opcode ppno is not handled by the decoder
Fix this by renaming to "prno" in s390-opcodes.csv as well and declaring
"ppno" instead of "prno" as an alias in s390-check-opcodes.pl.
Andreas Arnez [Tue, 1 Apr 2025 14:25:05 +0000 (16:25 +0200)]
Bug 498421 - s390x: Add BPP, BPRP, and NIAI insns
Add support for the branch prediction preload (BPP), branch prediction
relative preload (BPRP), and next instruction access intent (NIAI)
instructions. These instructions just provide performance hints to the
CPU and have no other effect on program execution. Thus implement them as
no-ops.
Florian Krohm [Sun, 30 Mar 2025 21:20:01 +0000 (21:20 +0000)]
s390x disasm-text: Update to support all implemented opcodes
A few opcodes are commented out in opcode.c because test generation
cannot handle the constraint.
For some opcodes (e.g. fixbra) VEX runs out of memory. Work around
that by calling vex_reset. Also add a tweak so we won't segfault
when generating tests for EXRL.
Change function names from e.g. s390_irgen/emit_LDXBR to
s390_irgen/emit_LDXBRA because LDXBR does not have m3 and m4 operands.
Adjust the returned mnemonic accordingly.
New function s390_format_RRF_UUFF2 for FI[DEX]BRA.
Add adtra_like_disasm to disassemble opcodes for DFP arithmetic.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=495817
Mark Wielaard [Sun, 30 Mar 2025 15:38:21 +0000 (17:38 +0200)]
Handle top __syscall_cancel frames when getting stack traces
Since glibc 2.41 there are extra frames inserted before doing a
syscall to support proper thread cancellation. This breaks various
suppressions and regtests involving checking syscall arguments.
Solve this by removing those extra frames from the top of the call
stack when we are processing a linux system call.
Mark Wielaard [Sun, 30 Mar 2025 11:08:55 +0000 (13:08 +0200)]
filter_gdb.in: filter out __libc_do_syscall
On i386 and armhf __libc_do_syscall might be used to invoke a syscall.
Replace __libc_do_syscall with "in syscall ..." and filter out
possible extra (assembly) source file lines containing
libc-do-syscall.S from the gdb output.
Change function names from e.g. s390_irgen/emit_CEFBR to
s390_irgen/emit_CEFBRA because CFEBR does not have m3 and m4 operands.
Adjust the returned mnemonic accordingly.
New functions fp_convf_disasm and fp_convt_disasm.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=495817
Mark Wielaard [Fri, 28 Mar 2025 12:44:35 +0000 (13:44 +0100)]
filter_gdb.in: __syscall_cancel_arch is just in a syscall
Since glibc 2.41 some extra syscall_cancel frames are inserted before
that actual syscall is made. Just filter out __syscall_cancel_arch
from the gdb output and replace it with "in syscall ..." to make the
regtest .exp match.
Florian Krohm [Thu, 27 Mar 2025 16:30:03 +0000 (16:30 +0000)]
s390x: PRNO tidy
The mnemonics PRNO and PPNO denote the same opcode. Both names were used
in the code. Not anymore. From now on: consistent naming PRNO / prno
While I was at it:
- Remove left-overs from the early days when PRNO was implemented by means
of dirty helpers.
- Fix disassembly to use "prno".
- Fix a bug in s390_irgen_DFLTCC which was using "ppno" as mnemonic.
Florian Krohm [Mon, 24 Mar 2025 21:53:11 +0000 (21:53 +0000)]
s390x: disasm-test: prepare for AR and FPR register support
- New function random_reg to replace random_gpr, random_vr.
- New function unique_reg to replace unique_gpr, unique_vr.
- New function choose_reg_and_iterate to handle register operands whose
values are constrained, e.g. only even registers.
- Do not call unique_reg for a register operand whose values are constrained.