Florian Krohm [Fri, 21 Mar 2025 23:08:49 +0000 (23:08 +0000)]
s390x: Fix disassembly for vector insns
This was painful because there is a lot of irregularity in the
extended mnemonics. There is also a double-maintenance issue because
S390_DISASM is used both in guest_s390_to_IR.c and in the 'emit'
functions in host_s390_defs.c. It might be worth exploring whether
the objdump disassembler can be extracted from binutils and re-used
here. That way the disassembly would be correct by construction.
And the double maintenance would go away.
Fix a few things alongside:
- In s390_format_VRI_VIM: is is a signed 16-bit value. So it needs to be
sign-extended. Fixes disassembly for VLEI[BHFG]
- Fix function dvb_operand. v0 is not special.
- In s390_format_VRX_VRRDM pass forgotten m3 to S390_DISASM.
- In s390_irgen_VCNF: remove s390_insn_assert. VCNF does not have
specification exceptions.
- Opcope VFLL has no mask m5. So s390_format_VRRa_VVMMM is the wrong format
function. Change it to s390_format_VRRa_VVMM.
In s390_irgen_VFLL: the value of m5 is not used in s390_vector_fp_convert
because rounding == False. So, essentially, m5 is a don't care.
- Add VRR_v3 and use it when a vector register is meant (instead of VRR_r3)
- Add VRR_v4 and use it when a vector register is meant (instead of VRR_m4)
- Add VRS_r3 and use it when a GPR is meant (instead of VRS_v3)
- Add VRR_r2 and use it when a GPR is meant (instead of VRR_v2)
- Add field-access macros for the VRV opcode format. Use them.
- Add field-access macros for the VRIb opcode format. Use them.
- Add field-access macros for the VRIc opcode format. Use them.
- Add field-access macros for the VRSc opcode format. Use them.
Part of fixing https://bugs.kde.org/show_bug.cgi?id=495817
Martin Cermak [Tue, 18 Mar 2025 17:17:30 +0000 (18:17 +0100)]
Wrap linux specific userfaultfd syscall
userfaultfd takes a flags argument and returns a file descriptor.
It shows up in the Linux Test Project syscalls tests as unhandled.
Declare a sys_userfaultfd wrapper in priv_syswrap-linux.h and hook it
for {amd64,arm,arm64,mips64,nanomips,ppc32,ppc64,riscv64,s390x,x86}-linux
using LINXY with PRE/POST handlers in syswrap-linux.c.
Define __NR_userfaultfd in vki-scnums-s390x-linux.h. It was already
defined for all other arches.
Florian Krohm [Sat, 15 Mar 2025 23:18:59 +0000 (23:18 +0000)]
s390x: Rework s390_disasm interface (BZ 498942)
The way extended mnemonics were communicated to s390_disasm was a bit messy
and, more importantly, error prone. The primary reason is that extended
mnemonics were added late in the game (at the time) and sort of force-fitted
on top of the existing scheme. Here are a few examples showing the new
way of doing things:
The arguments to S390_DISASM are essentially constructors for the various
opcode fields. They appear in the same order as written in Principles of Ops.
Florian Krohm [Sat, 15 Mar 2025 22:29:30 +0000 (22:29 +0000)]
s390x: misc. fixes pertaining to vector insns
This patch is fall-out from working on fixing the disassembly for
the vector insns.
Specifically:
1) replace vassert with s390_insn_assert where appropriate
2) add missing s390_insn_asserts (many)
3) remove incorrect s390_insn_asserts (few)
4) check availability of vector opcodes based on hardware capabilities
and issue an emulation failure if opcode is not available
5) fix a typo in a mnemonic: vfspo -> vfpso
6) inline function s390_vr_get_n_elem
Part of fixing https://bugs.kde.org/show_bug.cgi?id=495817
Florian Krohm [Wed, 12 Mar 2025 23:10:06 +0000 (23:10 +0000)]
s390x: Fix BZ 496950
Adding a new hardware capability requires changes in several places.
Generally for a new FOO hardware capability:
- add VEX_HWCAPS_S390X_FOO and update VEX_HWCAPS_S390X_ALL in libvex.h
- test the corresponding facility bit in m_machine.c
- add s390_host_has_foo in host_s390_defs.h
- if an insn requiring FOO cannot be implemented on the host by other means
- add EmFail_S390X_foo in libvex_emnote.h
- handle EmFail_S390X_foo in main_main.c
- update function show_hwcaps_s390x
Occasionally something gets forgotten and this patch adds the forgotten
pieces.
Also add new hardware capabilities vxe2, vxd, msa, msa4, msa8, msa9
Mark Wielaard [Wed, 12 Mar 2025 12:57:19 +0000 (13:57 +0100)]
add_hardwired_spec for ld-linux-x86-64.so.2 memcmp
With RPATH processing ld.so compiled for x86-64-v3 uses an optimized
avx2 memcmp (bcmp) which causes (false postive) memcheck invalid reads
of size 32 warnings.
Fix this my adding a hardwire spec with a simpler memcmp for
ld-linux-x86-64.so.2.
Florian Krohm [Mon, 10 Mar 2025 12:36:21 +0000 (12:36 +0000)]
s390x: disasm-test: Fix thinko
Remove verbiage about limited support for opcodes with optional operands.
Optional operands are of no concern for disassembly. The reason is that
disassembly sees as its input only a sequence of bytes which have no
indication as to whether some of its bits were explicitly specified or not.
We're testing the disassembler here - not the assembler.
Mark Wielaard [Sun, 9 Mar 2025 15:46:50 +0000 (16:46 +0100)]
docs/Makefile.am: Make sure xml catalog file exists for xmllint check
When XML_CATALOG_FILES don't exist on the system xmllint will have to
query those files through various websites. When there is a network
error xmllint will fail. So make sure to only run the validity tests
when both xmllint and XML_CATALOG_FILES exists.
Mark Wielaard [Sun, 9 Mar 2025 14:59:29 +0000 (15:59 +0100)]
coregrind/m_debuginfo: don't try to examine zero sized mmapped files
When run on an nfs filesystem memcheck/tests/pointer-trace fails
because it generates warnings "connection to image failed". This is
caused by trying to mmap a deleted file which the nfs file system
represents as a (hidden) regular file. This is normally not a problem
except when that file is empty.
Fix this by not trying to check whether a file is an ELF or MACHO
against an empty (regular) file in di_notify_mmap. An empty file is
never a valid ELF or MACHO file (and cannot be represented as
DiImage).
Paul Floyd [Fri, 7 Mar 2025 06:00:26 +0000 (07:00 +0100)]
FreeBSD regtest: getrlimitusage on arm64
Resident memory isn't stable even when truncated to a
multiple of ten milllion. I.e., zero digits of useful precision.
So just set this field to zero like the other flaky values.
Florian Krohm [Thu, 6 Mar 2025 17:42:05 +0000 (17:42 +0000)]
s390x: Add disassembly checker (Bug 498037)
Add program disasm-test to check that s390_disasm generates the same
disassembly for a given insn than objdump -d does. The focus is on insns
that have extended mnemonics most of which are vector insns.
The checker resides in none/tests/s390x/disasm-test with comprehensive
documentation in the README file there.
It is integrated into the regression testing framework but currently
disabled, because s390_disasm has not been fixed yet.
Mark Wielaard [Sat, 28 Dec 2024 00:29:58 +0000 (01:29 +0100)]
riscv64: Add hardwire for ld-linux-riscv64-lp64d.so.1 strcmp
When using dlopen ld.so can end up in glibc strcmp_unaligned_loop
which causes undefined reads. Hardwire strcmp for ld.so with a simple
assembly implementation.
Mark Wielaard [Sat, 14 Dec 2024 22:11:57 +0000 (22:11 +0000)]
VEX/priv/guest_riscv64_toIR.c: Recognize both fence and fence.tso
fence.tso is used for __atomic_thread_fence (__ATOMIC_ACQ_REL)
There are 3 fence variants.
fence.tso fm set to 1000 and pred and succ both set to 0011.
fence with fm set to 0000 and pred and succ both set to 1111.
fence with fm set to 0000 and pred and succ with some iorw flags set.
Mark Wielaard [Tue, 24 Dec 2024 23:36:53 +0000 (00:36 +0100)]
none/tests/riscv64/integer.c: replace zero by a1
Using zero will produce an gas Error: illegal operands `la zero,0'
https://sourceware.org/bugzilla/show_bug.cgi?id=32496
Simplest seems to be to replace the usage of "zero" in the branch
instruction tests by "a1". It seems that does test something similar
that isn't tested before.
Petr Pavlu [Tue, 11 Apr 2023 19:30:43 +0000 (19:30 +0000)]
riscv64: Add initial support: test modifications
The following people contributed to the initial RISC-V support:
Petr Pavlu <petr.pavlu@dagobah.cz>
Xeonacid <h.dwwwwww@gmail.com>
laokz <laokz@foxmail.com>
Chelsea E. Manning <me@xychelsea.is>
zhaomingxin <zhaomingxin.zmx@alibaba-inc.com>
Jojo R <rjiejie@linux.alibaba.com>
Some integration fixes were added by Mark Wielaard <mark@klomp.org>
- helgrind/tests/tc11_XCHG.c: Fix XCHG_M_R guard
Petr Pavlu [Tue, 11 Apr 2023 19:30:43 +0000 (19:30 +0000)]
riscv64: Add initial support: VEX modifications
The following people contributed to the initial RISC-V support:
Petr Pavlu <petr.pavlu@dagobah.cz>
Xeonacid <h.dwwwwww@gmail.com>
laokz <laokz@foxmail.com>
Chelsea E. Manning <me@xychelsea.is>
zhaomingxin <zhaomingxin.zmx@alibaba-inc.com>
Jojo R <rjiejie@linux.alibaba.com>
The following people contributed to the initial RISC-V support:
Petr Pavlu <petr.pavlu@dagobah.cz>
Xeonacid <h.dwwwwww@gmail.com>
laokz <laokz@foxmail.com>
Chelsea E. Manning <me@xychelsea.is>
zhaomingxin <zhaomingxin.zmx@alibaba-inc.com>
Jojo R <rjiejie@linux.alibaba.com>
Petr Pavlu [Tue, 11 Apr 2023 19:30:42 +0000 (19:30 +0000)]
riscv64: Add initial support: new port-specific test files
The following people contributed to the initial RISC-V support:
Petr Pavlu <petr.pavlu@dagobah.cz>
Xeonacid <h.dwwwwww@gmail.com>
laokz <laokz@foxmail.com>
Chelsea E. Manning <me@xychelsea.is>
zhaomingxin <zhaomingxin.zmx@alibaba-inc.com>
Jojo R <rjiejie@linux.alibaba.com>
Petr Pavlu [Tue, 11 Apr 2023 19:30:42 +0000 (19:30 +0000)]
riscv64: Add initial support: new port-specific VEX files
The following people contributed to the initial RISC-V support:
Petr Pavlu <petr.pavlu@dagobah.cz>
Xeonacid <h.dwwwwww@gmail.com>
laokz <laokz@foxmail.com>
Chelsea E. Manning <me@xychelsea.is>
zhaomingxin <zhaomingxin.zmx@alibaba-inc.com>
Jojo R <rjiejie@linux.alibaba.com>
Some integration fixes were added by Mark Wielaard <mark@klomp.org>
- Handle Ity_I1, Iex.Const (boolean)
Petr Pavlu [Tue, 11 Apr 2023 19:30:42 +0000 (19:30 +0000)]
riscv64: Add initial support: new port-specific Valgrind files
The following people contributed to the initial RISC-V support:
Petr Pavlu <petr.pavlu@dagobah.cz>
Xeonacid <h.dwwwwww@gmail.com>
laokz <laokz@foxmail.com>
Chelsea E. Manning <me@xychelsea.is>
zhaomingxin <zhaomingxin.zmx@alibaba-inc.com>
Jojo R <rjiejie@linux.alibaba.com>
Some integration fixes were added by Mark Wielaard <mark@klomp.org>
- Remove POST handler from sys_close
- Define VKI_O_DIRECT in vki-riscv64-linux.h
- Wrap riscv64-linux mlock2
- Add POST handler for sys_readlinkat
Paul Floyd [Sun, 16 Feb 2025 08:36:54 +0000 (09:36 +0100)]
Illumos regtest: update bug487993 testcase
As I said in bugzilla, "Not tested on Solaris". Now I've tested it
and Illumos libc doesn't use 16byte alignment (or at least the assert
that alignment is 16bytes fails).
Paul Floyd [Fri, 14 Feb 2025 19:45:02 +0000 (20:45 +0100)]
Bug 496370 - Illumos: signal handling is broken
This isn't a great fix, it just turns off optimization for
a couple of signal frame functions. If ever I have time I'll try
to find out out which part of -O1 is responsible, and maybe from
that also exactly what part of the code.
Paul Floyd [Tue, 4 Feb 2025 19:34:57 +0000 (20:34 +0100)]
FreeBSD syscall: improve utrace wrapper
The public wrapper is just a void pointer and length.
Internally, the struct used has holes which generate
errors (since ld.so which is probably the only user
of this syscall doesn't memset the struct to zero). Added
the struct definition and PRE_MEM_READ for each field.
Let gdbserver the support of 'x' packet by adding binary-upload+ in qSupported.
Following the incompatible implementation of the 'x' packet between
lldb and gdb, gdb now only uses the x packet if the gdbserver
reports binary-upload+ in qSupported.
Tested with gdb 16.1, gdb 16 branch and gdb 17 trunk, each time checking
the 'x' packet was effectively used.
Paul Floyd [Sat, 25 Jan 2025 19:09:40 +0000 (20:09 +0100)]
regtest: slacken timing in none/tests/bug492678
With a 1us interval some systems intermittently (but quite
frequently) hang. Increasing it to 5us seems to make it
consistent. Will keep an eye on this one.
Mark Wielaard [Thu, 23 Jan 2025 21:59:42 +0000 (22:59 +0100)]
memcheck/tests/amd64/rh2257546_256.c: use xmm instead of ymm in clobbers
Older gcc (4.8.5) doesn't recognize yym registers as clobbers. Use xmm
instead, as in the AVX configure checks, which are the same register
(half) just with a different name.
Mark Wielaard [Thu, 23 Jan 2025 18:33:57 +0000 (19:33 +0100)]
Check for and compile using -std=gnu11 (or higher)
Use gnulib m4/std-gnu11.m4 for that.
Also update the minimum autoconf version to 2.69. And the minimum
automake to 1.13. This lets us clean up configure.ac a little.
We would really like 2.70+ so we don't need the gnulib gnu11.m4. But
2.69 still seems in use on various stable systems. autoconf 2.70
was released end of 2020, autoconf 2.69 in 2012.
Mark Wielaard [Thu, 23 Jan 2025 14:50:52 +0000 (15:50 +0100)]
Treat all inherited file descriptors the same with --track-fds.
We used to special case 0, 1, 2 (stdin/out/err) specially even when
they were not inherited (anymore). Now the --track-fds=[yes|all]
option treats all inherited file descriptors the same. And if any
inherited file descriptor gets closed and reopened then they are
now treated as normal non-inherited file descriptors.
Paul Floyd [Sat, 11 Jan 2025 11:20:12 +0000 (12:20 +0100)]
FreeBSD regtest: rename testcase
Running on VirtualBox, this bug452274 runs extremely slowly. Not sure why.
On real hardware it runs in a second or less. When looking at it I saw that
it uses the wrong bugzilla ID, so fix that.
Mark Wielaard [Tue, 24 Dec 2024 18:11:17 +0000 (19:11 +0100)]
memcheck/tests/sh-mem-random.c: Set huge_addr to 240GB
https://www.kernel.org/doc/html/next/riscv/vm-layout.html
Says RISC-V Linux Kernel SV39 user-space virtual memory ends at 256GB.
So try at 240GB. This seems a reasonable value for other arches too.