]> git.ipfire.org Git - thirdparty/valgrind.git/log
thirdparty/valgrind.git
5 years agoBug 417281 - s390x: Fix register usage of conditional moves
Andreas Arnez [Wed, 18 Mar 2020 11:24:25 +0000 (12:24 +0100)] 
Bug 417281 - s390x: Fix register usage of conditional moves

The s390x register usage callback marks the target register of a
conditional move as HRmWrite only.  It fails to mention the fact that the
target register is also an input to the insn (unless the condition is
"never" or "always").

This was discovered while investigating "grail" failures on s390x and
fixes the majority of them.

5 years agos390x: Actually use "load on condition" for conditional moves
Andreas Arnez [Fri, 13 Mar 2020 16:20:20 +0000 (17:20 +0100)] 
s390x: Actually use "load on condition" for conditional moves

Although the implementation of the cond_move insn is prepared to emit
"load on condition" instructions, it doesn't, because of a reversed check.
The check is supposed to prevent emitting LOCx instructions when the
condition code mask is set to "always", but it's accidentally negated.
Fix the reversal of the check, so LOCx instructions are actually emitted
when applicable.

5 years agos390x: Mark register usage with HRmModify when applicable
Andreas Arnez [Mon, 9 Mar 2020 16:26:26 +0000 (17:26 +0100)] 
s390x: Mark register usage with HRmModify when applicable

Instead of marking register usage for the same register with HRmRead and
HRmWrite separately, use HRmModify instead.  This makes the code a bit
easier to read.

5 years agos390x: Enable 1- and 2-byte operands for v-test
Andreas Arnez [Mon, 9 Mar 2020 14:14:16 +0000 (15:14 +0100)] 
s390x: Enable 1- and 2-byte operands for v-test

The v-test operation tests its operand against zero and sets the condition
code accordingly.  So far the operation was only supported for 4- and
8-byte operands.

Lift this restriction and enable 1- and 2-byte operands for v-test, using
the z/Architecture "test under mask" instructions TM, TMY, and TMLL.
Exploit this in the instruction selector, getting rid of the conversion to
a 4-byte operand.  This slightly reduces the generated code on s390x.

5 years agos390x: Support And1/Or1, improve handling of Int1 expressions
Andreas Arnez [Wed, 5 Feb 2020 17:18:49 +0000 (18:18 +0100)] 
s390x: Support And1/Or1, improve handling of Int1 expressions

This provides an instruction selector for Int1-expressions that supports
And1 and Or1.  This implementation tries to keep values in registers as
much as possible, to avoid too many conversions from a Boolean value to a
condition code or vice versa.  To this end, the new function
s390_isel_int1_expr() is added, which handles bit-typed expressions that
are supposed to end up in a register.

Also change the representation of Int1 values in registers and always
sign-extend them to 64 bits.

5 years agoUpdate vbit-test after move from Clz to ClzNat on s390x
Andreas Arnez [Mon, 2 Mar 2020 18:45:29 +0000 (19:45 +0100)] 
Update vbit-test after move from Clz to ClzNat on s390x

After removing support of Iop_Clz64 and defining Iop_ClzNat64 instead (see
commit #bb594e098b75ae6309), this needs to be reflected in vbit-test.

5 years agos390x: Fix down-cast from memory operand with size < 8
Andreas Arnez [Tue, 10 Mar 2020 16:18:48 +0000 (17:18 +0100)] 
s390x: Fix down-cast from memory operand with size < 8

A down-cast always copies 8 bytes from the source operand, even if the
operand is actually smaller.  This doesn't matter for register operands,
but it does for memory operands.  Fix this and copy the correct number of
bytes instead.

5 years agos390x: Mark VRs as clobbered by helper calls
Andreas Arnez [Fri, 13 Mar 2020 16:18:55 +0000 (17:18 +0100)] 
s390x: Mark VRs as clobbered by helper calls

According to the s390x ABI, all vector registers are call-clobbered
(except for their portions that overlap with the call-saved FPRs).  But
the s390x backend doesn't mark them as such when determining the register
usage of helper call insns.

Fix this in s390_insn_get_reg_usage when handling S390_INSN_HELPER_CALL.

5 years agoUpdate bug status.
Julian Seward [Fri, 13 Mar 2020 13:35:59 +0000 (14:35 +0100)] 
Update bug status.

5 years agoFix out-of-range shift warnings in simd_v81.c.
Julian Seward [Thu, 12 Mar 2020 10:23:08 +0000 (11:23 +0100)] 
Fix out-of-range shift warnings in simd_v81.c.

5 years agoBug 418702 - ARMv8.1 Paired register compare-and-swap instructions are not supported.
Julian Seward [Wed, 11 Mar 2020 14:07:32 +0000 (15:07 +0100)] 
Bug 418702 - ARMv8.1 Paired register compare-and-swap instructions are not supported.

These are the test cases.
Patch by Assad Hashmi <assad.hashmi@linaro.org>.

5 years agoBug 418702 - ARMv8.1 Paired register compare-and-swap instructions are not supported.
Julian Seward [Wed, 11 Mar 2020 14:05:02 +0000 (15:05 +0100)] 
Bug 418702 - ARMv8.1 Paired register compare-and-swap instructions are not supported.

Implementation only; tests to follow.
Patch by Assad Hashmi <assad.hashmi@linaro.org>.

5 years agoBug 415136 - ARMv8.1 Compare-and-Swap instructions are not supported. (TEST CASES).
Julian Seward [Mon, 9 Mar 2020 08:22:31 +0000 (09:22 +0100)] 
Bug 415136 - ARMv8.1 Compare-and-Swap instructions are not supported.  (TEST CASES).

This commit provides test cases for ARMv8.1 CAS instructions, support for
which was added in the previous commit.
Patch by Assad Hashmi <assad.hashmi@linaro.org>.

5 years agoBug 415136 - ARMv8.1 Compare-and-Swap instructions are not supported.
Julian Seward [Mon, 9 Mar 2020 08:18:09 +0000 (09:18 +0100)] 
Bug 415136 - ARMv8.1 Compare-and-Swap instructions are not supported.

This commit implements ARMv8.1 CAS instructions.  It does not contain
test cases; those will be in a subsequent commit.
Patch by Assad Hashmi <assad.hashmi@linaro.org>.

5 years agoUpdate bug status.
Julian Seward [Mon, 9 Mar 2020 08:08:28 +0000 (09:08 +0100)] 
Update bug status.

5 years agoBug 418435 - s390x: Avoid extra value dependency in CLC implementation
Andreas Arnez [Mon, 2 Mar 2020 15:22:59 +0000 (16:22 +0100)] 
Bug 418435 - s390x: Avoid extra value dependency in CLC implementation

The test memcheck/tests/memcmp currently fails on s390x because it yields
the expected "conditional jump or move depends on uninitialised value(s)"
message twice instead of just once.

This is caused by the handling of the s390x instruction CLC, see
s390_irgen_CLC_EX().  When comparing two bytes from the two input strings,
the implementation uses the comparison result for a conditional branch to
the next instruction.  But if no further bytes need to be compared, the
comparison result is also used for generating the resulting condition
code.

There are two cases: Either the inputs are equal; then the resulting
condition code is zero.  This is what happens in the memcmp test case.  Or
the inputs are different; then the resulting condition code is 1 or 2 if
the first or second operand is greater, respectively.

At least in the first case it is easy to avoid the additional dependency,
by clearing the condition code explicitly.  Just do this.

5 years agoAdd 32bit time64 syscalls for arm, mips32, ppc32 and x86.
Mark Wielaard [Fri, 28 Feb 2020 12:36:31 +0000 (13:36 +0100)] 
Add 32bit time64 syscalls for arm, mips32, ppc32 and x86.

This patch adds sycall wrappers for the following syscalls which
use a 64bit time_t on 32bit arches: gettime64, settime64,
clock_getres_time64, clock_nanosleep_time64, timer_gettime64,
timer_settime64, timerfd_gettime64, timerfd_settime64,
utimensat_time64, pselect6_time64, ppoll_time64, recvmmsg_time64,
mq_timedsend_time64, mq_timedreceive_time64, semtimedop_time64,
rt_sigtimedwait_time64, futex_time64 and sched_rr_get_interval_time64.

Still missing are clock_adjtime64 and io_pgetevents_time64.

For the more complicated syscalls futex[_time64], pselect6[_time64]
and ppoll[_time64] there are shared pre and/or post helper functions.
Other functions just have their own PRE and POST handler.

Note that the vki_timespec64 struct really is the struct as used by
by glibc (it internally translates a 32bit timespec struct to a 64bit
timespec64 struct before passing it to any of the time64 syscalls).
The kernel uses a 64-bit signed int, but is ignoring the upper 32 bits
of the tv_nsec field. It does always write the full struct though.
So avoid checking the padding is only needed for PRE_MEM_READ.
There are two helper pre_read_timespec64 and pre_read_itimerspec64
to check the new structs.

https://bugs.kde.org/show_bug.cgi?id=416753

5 years agoAdd suppressions for glibc DTV leaks
Mark Wielaard [Wed, 4 Mar 2020 13:23:37 +0000 (14:23 +0100)] 
Add suppressions for glibc DTV leaks

The glibc DTV (Dynamic Thread Vector) for the main thread is never
released, not even through __libc_freeres. This causes it to always
show up as a reachable block when used, and sometimes, when it is
extended and then reduced, as a possible leak when memcheck cannot
find a pointer to the start of the block.

https://bugzilla.redhat.com/show_bug.cgi?id=1796433
https://bugzilla.redhat.com/show_bug.cgi?id=1796559

https://bugs.kde.org/show_bug.cgi?id=417578

5 years agoImprove line info tracing, in particular when using lto.
Philippe Waroquiers [Tue, 18 Feb 2020 20:35:44 +0000 (21:35 +0100)] 
Improve line info tracing, in particular when using lto.

With gcc 9 and --enable-lto, we now have spurious warnings telling
that the line information in the debug info has huge line numbers,
greater than the (valgrind) maximum of 2^20.

These spurious warnings make that all tests are failing.

This change modifies the tracing/debugging of the line info to:
  * disable by default the warning for line info greater than 2^20.
    When using -d, such warnings are however still shown (once).
  * allow to see all such warnings, when using at least -d -d -d -d

5 years agoAllow valgrind to find debug info in a 'usr merge' setup.
Philippe Waroquiers [Sun, 1 Mar 2020 21:43:31 +0000 (22:43 +0100)] 
Allow valgrind to find debug info in a 'usr merge' setup.

On ubuntu 19.10, valgrind fails telling that it cannot find
the mandatory redirection for strlen in ld-linux-x86-64.so.2.

This is due to /bin being a symlink to usr/bin: ld is found
in /usr/lib/x86_64-linux-gnu/ld-2.30.so
but its debug info is
in /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.30.so

Without this patch, valgrind searches the debug info (a.o.)
in /usr/lib/debug/usr/lib/x86_64-linux-gnu/ld-2.30.so
so using the concatenation of  /usr/lib/debug
and /usr/lib/x86_64-linux-gnu/ld-2.30.so,
but the debug info is located at the concatenation of
/usr/lib/debug and /lib/x86_64-linux-gnu/ld-2.30.so
(so without the leading /usr).
Modify the debug info search so as to try with and without the /usr.

Patch derived from the patch done by Mathieu Trudel-Lapierre
to solve https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/1808508

5 years agos390x: Add CPU model for z15
Andreas Arnez [Thu, 27 Feb 2020 14:52:53 +0000 (15:52 +0100)] 
s390x: Add CPU model for z15

Make the z15 CPU models known to Valgrind.  Add test case output for z15
to the "ecag" test.  Also ensure that the facility bits for CPU facilities
unsupported by Valgrind are unset, particularly for the new
deflate-conversion facility.

5 years agomips: Amend none/tests/mips64/test_math.stdout.exp-older-gcc
Stefan Maksimovic [Thu, 27 Feb 2020 17:11:59 +0000 (17:11 +0000)] 
mips: Amend none/tests/mips64/test_math.stdout.exp-older-gcc

This is a follow up to:

commit 3e0e34aecdd73511c97133bdcf3ef1dfca325179
Author: Stefan Maksimovic <stefan.maksimovic@rt-rk.com>
Date:   Fri Jan 17 12:58:07 2020 +0000

    mips64: rework math tests to take into account allowed approximation

5 years agomips: Fix linking errors for none/tests/mips[32|64]/msa_fpu
Stefan Maksimovic [Thu, 27 Feb 2020 17:06:05 +0000 (17:06 +0000)] 
mips: Fix linking errors for none/tests/mips[32|64]/msa_fpu

Some older toolchains (e.g. Codescape GNU Tools 2016.05-03 for MIPS
MTI Linux 4.9.2) require explicit inclusion of the "math" library in
order to link to the fpclassify() function.

fpclassify() is used in this test since 3e0e34a.

5 years agos390x: Fix possible false positives with mul-z14 test case
Andreas Arnez [Wed, 26 Feb 2020 16:46:45 +0000 (17:46 +0100)] 
s390x: Fix possible false positives with mul-z14 test case

The output of the tests for msrkc and msgrkc in "none/tests/s390x/mul-z14"
can differ from the expected output, because it depends on undetermined
data.  The test always prints the register pair r2/r3, but the
instructions msrkc and msgrkc only write to r2, and msrkc even affects
only its lowest half.

Fix the undetermined output by initializing r2 and r3 with zero first.

5 years agos390x: Exploit LOCGHI for converting from CC to Int1
Andreas Arnez [Wed, 5 Feb 2020 18:28:53 +0000 (19:28 +0100)] 
s390x: Exploit LOCGHI for converting from CC to Int1

Whenever converting a condition code to a Boolean value, the current
implementation in s390_insn_cc2bool_emit() generates six instructions
including "insert program mask" (IPM).  On systems with the
load/store-on-condition facility 2, this can be done in two instructions
instead, using "load halfword immediate on condition" (LOCGHI).

Add the new hardware capability VEX_HWCAPS_S390X_LSC2 and the respective
macro s390_host_has_lsc2.  In s390_insn_cc2bool_emit(), check for the
facility and exploit it if available.

A conditional move from an immediate value can be slightly improved with
LOCGHI as well, so do that in s390_insn_cond_move_emit() if possible.

5 years agos390x: Replace use of deprecated Iop_Clz64 operator
Andreas Arnez [Tue, 25 Feb 2020 14:54:46 +0000 (15:54 +0100)] 
s390x: Replace use of deprecated Iop_Clz64 operator

The operator Iop_Clz64 has been deprecated.  Drop it in the s390x backend
and replace it by Iop_ClzNat64.  Previously s390_irgen_FLOGR() handled the
value zero specially and replaced it by 1 before applying Iop_Clz64.  With
Iop_ClzNat64 this is no longer needed, so remove this special-case
handling.

5 years agoPPC64, fix for alignment of the rt_sigframe data structure.
Carl Love [Fri, 21 Feb 2020 23:22:26 +0000 (17:22 -0600)] 
PPC64, fix for alignment of the rt_sigframe data structure.

The PPC64 implementation checks that the data structure is aligned.  The
changes in commit listed below breaks the alignment.  This patch adds an
explicit alignment directive to ensure the data structure is allocated
with the required alignment.  This fixes 31 stderr failures, 10 stdout
failures on the Power 7, Power 8 and Power 9 platforms.

commit 3bac39a10abf292d332bb20ab58c6dd5c28f9108
Author: Eugene Syromyatnikov <evgsyr@gmail.com>
Date:   Fri Mar 8 04:07:00 2019 +0100

    include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64

    As it turned out, the size of vki_siginfo_t is incorrect on these 64-bit
    architectures:

        (gdb) p sizeof(vki_siginfo_t)
        $1 = 136
        (gdb) ptype struct vki_siginfo
        type = struct vki_siginfo {
            int si_signo;
            int si_errno;
            int si_code;
            union {
                int _pad[29];
                struct {...} _kill;
                struct {...} _timer;
                struct {...} _rt;
                struct {...} _sigchld;
                struct {...} _sigfault;
                struct {...} _sigpoll;
            } _sifields;
        }
  etc.

5 years agoFlip the default value of `--auto` and `--show-percs` to `yes`.
Nicholas Nethercote [Sun, 16 Feb 2020 22:40:26 +0000 (09:40 +1100)] 
Flip the default value of `--auto` and `--show-percs` to `yes`.

In both `cg_annotate` and `callgrind_annotate`.

5 years agoMark returned descriptor as valid when CLONE_PIDFD is used
Tom Hughes [Thu, 20 Feb 2020 09:18:17 +0000 (09:18 +0000)] 
Mark returned descriptor as valid when CLONE_PIDFD is used

When CLONE_PIDFD is set the descriptor is returned via the
argument otherwise used for the parent thread id.

5 years agoAllow clone with CLONE_VFORK and no CLONE_VM
Tom Hughes [Thu, 20 Feb 2020 09:14:24 +0000 (09:14 +0000)] 
Allow clone with CLONE_VFORK and no CLONE_VM

The CLONE_VFORK flag causes the parent to suspend until the child
exits or execs so without the memory sharing CLONE_VM would give
this is really closer to fork but we convert vfork to fork by
removing CLONE_VM anyway so there is no reason not to allow this.

Fixes BZ#417906

5 years agoSynchronise CLONE_xxx flags with kernel source
Tom Hughes [Thu, 20 Feb 2020 08:43:58 +0000 (08:43 +0000)] 
Synchronise CLONE_xxx flags with kernel source

5 years agoBug 417452 - s390x: Force 12-bit amode for vector stores in isel
Andreas Arnez [Wed, 12 Feb 2020 13:13:55 +0000 (14:13 +0100)] 
Bug 417452 - s390x: Force 12-bit amode for vector stores in isel

It was seen that the s390 instruction selector chose a wrong addressing
mode for storing a vector register.  The VST instruction only handles
short (12-bit unsigned) displacements, but a long (20-bit signed)
displacement was generated instead, resulting in a panic:

vex: the `impossible' happened:
   s390_insn_store_emit: unknown dst->tag for HRcVec128

The fix prevents long displacements for vector store operations.  It also
optimizes vector store operations from an Iex_Get, by converting them to a
memory copy.  This optimization was already performed for integer
registers.

5 years agos390x: Fix printing of virtual register numbers
Andreas Arnez [Mon, 10 Feb 2020 12:37:03 +0000 (13:37 +0100)] 
s390x: Fix printing of virtual register numbers

As noticed by Julian Seward, the code for printing s390x register names
currently does not show the virtual register numbers correctly.  Although
it distinguishes between virtual and real registers, it uses the hardware
register number for both cases.  This is fixed.

5 years agoAdd option -T to vgdb to output timestamps in vgdb information/error messages
Philippe Waroquiers [Sat, 8 Feb 2020 12:01:24 +0000 (13:01 +0100)] 
Add option -T to vgdb to output timestamps in vgdb information/error messages

Also cleanup some trailink blanks.

5 years agoBug 416301 - s390x: Support "compare and signal" instructions
Andreas Arnez [Thu, 16 Jan 2020 12:49:10 +0000 (13:49 +0100)] 
Bug 416301 - s390x: Support "compare and signal" instructions

Add VEX support for the s390x "compare and signal" instructions KEBR,
KDBR, KXBR, KEB, and KDB.  For now, let them behave exactly like their
non-signalling counterparts.  Enhance the bfp-4 test case to cover these
instructions as well.  Update the list of supported instructions in
s390-opcodes.csv.  Add a disclaimer to README.s390, explaining that FP
signalling is not handled accurately on s390x at the moment.

5 years agoUpdate .gitignore with none/tests/x86/bswapw
Rhys Kidd [Wed, 29 Jan 2020 12:55:15 +0000 (23:55 +1100)] 
Update .gitignore with none/tests/x86/bswapw

Add
  none/tests/x86/bswapw

to .gitignore.

Fixes: 6e0573777 ("Bug 415757 - vex x86->IR: unhandled instruction bytes: 0x66 0xF 0xCE (bswapw).")
5 years agodrd/tests/pth_detached3: Make pthread_detach() call portable across platforms
Khem Raj [Tue, 28 Jan 2020 03:50:04 +0000 (19:50 -0800)] 
drd/tests/pth_detached3: Make pthread_detach() call portable across platforms

pthread_t is opaque type therefore we can not apply simple arithmetic to
variables of pthread_t type this test needs to pass a invalid pthread_t
handle, typcasting to uintptr_t works too and is portable across glibc and
musl

Fixes
| pth_detached3.c:24:25: error: invalid use of undefined type 'struct __pthread'
|    24 |   pthread_detach(thread + 8);
|       |                         ^

[ bvanassche: reformatted patch description and fixed up line numbers ]

5 years agoPPC64: Fix assembler constraints.
Carl Love [Tue, 28 Jan 2020 18:17:16 +0000 (12:17 -0600)] 
PPC64: Fix assembler constraints.

The PPC64 assembler constraints "ws", "wa" and "ww" have changed to "wa"
in GCC 10.  Update the ppc64 tests test_isa_2_07_part1.c and test_isa_3_0.c.

5 years agoFix non-glibc build of the test suite with s390x_features
Rhys Kidd [Tue, 28 Jan 2020 08:33:03 +0000 (19:33 +1100)] 
Fix non-glibc build of the test suite with s390x_features

s390x_features is built unconditionally on a range of platforms, accordingly
any non-portable or glibc-specific functionality must be guarded.

Fixes error reported when running 'make check' or 'make regtest' on a platform
with an alternative libc that Valgrind supports, in this case Apple's libc:

  s390x_features.c:13:10: fatal error: 'features.h' file not found
  #include <features.h>  // __GLIBC_PREREQ
           ^
  1 error generated.

Fixes: 161d22f0a ("s390x: Fix vector facility (vx) check in test suite")
5 years agos390x: Fix some typos in s390-opcodes.csv
Andreas Arnez [Thu, 16 Jan 2020 12:47:17 +0000 (13:47 +0100)] 
s390x: Fix some typos in s390-opcodes.csv

Some lines in s390-opcodes.csv contain entries that look like this:

    ...,"arch12"implemented",...

They are probably introduced by some cut-and-paste error.  This is fixed.

5 years agoUpdate bug status.
Julian Seward [Sun, 26 Jan 2020 15:40:40 +0000 (16:40 +0100)] 
Update bug status.

5 years agox86 and amd64 tests: Use .text and .previous around all top-level asm.
Mark Wielaard [Sat, 25 Jan 2020 17:34:58 +0000 (18:34 +0100)] 
x86 and amd64 tests: Use .text and .previous around all top-level asm.

GCC10 defaults to -fno-common which exposes some latent bugs in
some of the top-level asm code in various .c test files. Some of the
tests started to segfault (even if not run under valgrind). Such code
needs to be wrapped inside a .text and a .previous asm statement to
make sure the code is generated in the .text code section and to
make sure the compiler doesn't lose track of the section currently
being used to generate data or code in. Without it code might be
generated inside a data section or the other way around.

5 years agoRevert accidentially added changes in commit ce094ba912
Mark Wielaard [Sat, 25 Jan 2020 16:44:43 +0000 (17:44 +0100)] 
Revert accidentially added changes in commit ce094ba912

These changes were part of my local testing of bug 416667
gcc10 ppc64le impossible constraint in 'asm' in test_isa
And shouldn't have been committed yet before review.

5 years agonone/tests/amd64/avx_estimate_insn.vgtest: Add missing prereq.
Mark Wielaard [Sat, 25 Jan 2020 16:19:11 +0000 (17:19 +0100)] 
none/tests/amd64/avx_estimate_insn.vgtest: Add missing prereq.

This test only works when the processor actually implements AVX.

5 years agoarm: Hook up preadv2 and pwritev2 syscalls.
Mark Wielaard [Sat, 25 Jan 2020 14:10:22 +0000 (15:10 +0100)] 
arm: Hook up preadv2 and pwritev2 syscalls.

They work the same as on other linux architectures.

5 years agoguest_generic_bb_to_IR.c (stmt_is_guardable): Handle Ist_LoadG.
Mark Wielaard [Sat, 25 Jan 2020 14:00:29 +0000 (15:00 +0100)] 
guest_generic_bb_to_IR.c (stmt_is_guardable): Handle Ist_LoadG.

Triggers on Fedora 31 armv7hl with glibc 2.30 in _dl_relocate_object.

5 years agoFix tests/x86/incdec_alt.c asm for GCC10.
Mark Wielaard [Fri, 24 Jan 2020 10:26:25 +0000 (11:26 +0100)] 
Fix tests/x86/incdec_alt.c asm for GCC10.

Thanks to Jakub Jelinek. The test is broken. It blindly assumes the
toplevel inline asm is placed into some sensible section, but that is
a wrong assumption. The right thing is to start the inline asm with
.text directive and end with .previous. The reason gcc 10 breaks it
is the -fno-common default, the int r1, ... vars are emitted into .bss
section and that is the section that is current when the inline asm is
emitted previously they were in .common at the end of the assembly file.

5 years agoWork around apparently-bogus warning from gcc 10.
Julian Seward [Fri, 24 Jan 2020 10:02:53 +0000 (11:02 +0100)] 
Work around apparently-bogus warning from gcc 10.

5 years agoFix GCC10 issue in guest_s390_defs.h typedef enum type s390x_vec_op_t.
Mark Wielaard [Thu, 23 Jan 2020 20:30:59 +0000 (21:30 +0100)] 
Fix GCC10 issue in guest_s390_defs.h typedef enum type s390x_vec_op_t.

GCC10 defaults to -fno-common which produces this error:

  guest_s390_defs.h:291: multiple definition of `s390x_vec_op_t

This is because GCC10 detects there are multiple definitions of the
variable s390x_vec_op_t. We don't want to define a variable though.
We had wanted to define a type (one that currently isn't used).
Fix this by making it a typedef enum.

https://bugzilla.redhat.com/show_bug.cgi?id=1794482

5 years agomips: update none/tests/mips32/msa_fpu.c
Stefan Maksimovic [Thu, 23 Jan 2020 13:32:56 +0000 (13:32 +0000)] 
mips: update none/tests/mips32/msa_fpu.c

Guard withinEpsOf[FD] within none/tests/mips32/msa_fpu.c

Enclose the recently introduced functions with preprocessor guards,
much like the rest of the code is inside the main function.
Also mark the functions as static.
Minor code formatting.

5 years agoFix some spelling errors found by Lintian. Patch from Alessandro Ghedini <ghedo...
Julian Seward [Thu, 23 Jan 2020 09:53:36 +0000 (10:53 +0100)] 
Fix some spelling errors found by Lintian.  Patch from Alessandro Ghedini <ghedo@debian.org>.

5 years agoiselV128Expr_wrk: handle Iex_ITE. This is needed by the recent 'grail' changes....
Julian Seward [Wed, 22 Jan 2020 10:39:53 +0000 (11:39 +0100)] 
iselV128Expr_wrk: handle Iex_ITE.  This is needed by the recent 'grail' changes.  n-i-bz.

5 years agoarm64 front end: add support for 'dc civac', handling it the same as 'dc cvau'.
Julian Seward [Wed, 22 Jan 2020 10:21:53 +0000 (11:21 +0100)] 
arm64 front end: add support for 'dc civac', handling it the same as 'dc cvau'.

This partially fixes #412377.

5 years agoEnable sys_adjtimex() on arm-linux. Fixes #412408.
Julian Seward [Wed, 22 Jan 2020 10:03:54 +0000 (11:03 +0100)] 
Enable sys_adjtimex() on arm-linux.  Fixes #412408.

5 years agoBug 407376 - Update Xen support to 4.12 (4.13, actually) and add more coverage.
Julian Seward [Wed, 22 Jan 2020 09:55:33 +0000 (10:55 +0100)] 
Bug 407376 - Update Xen support to 4.12 (4.13, actually) and add more coverage.

Patch from Tamas K Lengyel (tamas@tklengyel.com).

5 years agoBug 416464 - Handle ioctl PR_CAPBSET_READ/DROP.
Julian Seward [Wed, 22 Jan 2020 09:45:40 +0000 (10:45 +0100)] 
Bug 416464 - Handle ioctl PR_CAPBSET_READ/DROP.

Patch from Stefan Bruens (stefan.bruens@rwth-aachen.de).

5 years agoBug 385386 - Assertion failed "szB >= CACHE_ENTRY_SIZE" on m_debuginfo/image.c:517.
Julian Seward [Wed, 22 Jan 2020 09:32:31 +0000 (10:32 +0100)] 
Bug 385386 - Assertion failed "szB >= CACHE_ENTRY_SIZE" on m_debuginfo/image.c:517.

Patch from Reimar Doeffinger (kde@reimardoeffinger.de).

5 years agoBug 415757 - vex x86->IR: unhandled instruction bytes: 0x66 0xF 0xCE (bswapw).
Julian Seward [Wed, 22 Jan 2020 08:26:43 +0000 (09:26 +0100)] 
Bug 415757 - vex x86->IR: unhandled instruction bytes: 0x66 0xF 0xCE (bswapw).

Implement bswapw, even though the instruction does not officially exist.  Patch
from Alex Henrie (alexhenrie24@gmail.com).

5 years agoUpdate bug lists.
Julian Seward [Wed, 22 Jan 2020 08:08:54 +0000 (09:08 +0100)] 
Update bug lists.

5 years agoAdd bugs 416239 and 416387 to NEWS.
Mark Wielaard [Sat, 18 Jan 2020 01:09:49 +0000 (02:09 +0100)] 
Add bugs 416239 and 416387 to NEWS.

commit 58fc707804b9c1db66124737f5dcbb2715b230e1
416239  valgrind crashes when handling clock_adjtime

commit 7d4071fe8530fa1c217bb775b0e19fd97d871502
416387  finit_module and bpf syscalls are unhandled on arm64

5 years agoarm64: hook up finit_module and bpf syscalls
Alexandra Hajkova [Fri, 17 Jan 2020 11:59:11 +0000 (06:59 -0500)] 
arm64: hook up finit_module and bpf syscalls

This fixes "WARNING: unhandled arm64-linux syscall" in
delete_module01 and bpf_prog01 tests in the LTP test suite.

5 years agomips64: fix assert in host_mips_defs.c for Malu_MADD
Stefan Maksimovic [Fri, 17 Jan 2020 13:19:44 +0000 (13:19 +0000)] 
mips64: fix assert in host_mips_defs.c for Malu_MADD

Mark the immediate as signed for Iex_Get and Ist_Put for Ity_V128 on BE.

The Malu_MADD case in emit_MIPSInst in VEX/priv/host_mips_defs.c expects a
signed immediate, hence the change.

This fixes an assert in host_mips_defs.c.

5 years agomips64: rework math tests to take into account allowed approximation
Stefan Maksimovic [Fri, 17 Jan 2020 12:58:07 +0000 (12:58 +0000)] 
mips64: rework math tests to take into account allowed approximation

Change the math tests to check whether the results are approximate to the
expected values instead of checking for exact matches since the calculations
in question are allowed to be approximate.

This fixes
  /none/tests/mips64/test_math and
  /none/tests/mips64/msa_fpu

on mips64r6.

5 years agodrd/tests/std_mutex: Add a unit test for std::mutex
Bart Van Assche [Thu, 16 Jan 2020 03:23:02 +0000 (19:23 -0800)] 
drd/tests/std_mutex: Add a unit test for std::mutex

5 years agodrd: Fix 'conflicting load' error on std::mutex::lock()
Bart Van Assche [Thu, 16 Jan 2020 03:59:44 +0000 (19:59 -0800)] 
drd: Fix 'conflicting load' error on std::mutex::lock()

5 years agodrd/tests/Makefile.am: Fix indentation
Bart Van Assche [Thu, 16 Jan 2020 03:55:47 +0000 (19:55 -0800)] 
drd/tests/Makefile.am: Fix indentation

5 years agopriv/guest_generic_bb_to_IR.c stmt_is_guardable(): Add Ist_Dirty.
Mark Wielaard [Wed, 15 Jan 2020 16:43:15 +0000 (17:43 +0100)] 
priv/guest_generic_bb_to_IR.c stmt_is_guardable(): Add Ist_Dirty.

This might happen when the source contains something like
if (something_involving_pcmpxstrx && foo) { .. }
which might use amd64g_dirtyhelper_PCMPxSTRx.

5 years agosyswrap-linux.c: fix clock_adjtime handling
Alexandra Hájková [Mon, 13 Jan 2020 17:29:55 +0000 (12:29 -0500)] 
syswrap-linux.c: fix clock_adjtime handling

Not checking whether valgrind can dereference timex pointer
casues VALGRIND INTERNAL ERROR while handling clock_adjtime.

5 years agomips: Implement Iex_CCall for nanoMIPS
Petar Jovanovic [Tue, 14 Jan 2020 17:45:00 +0000 (17:45 +0000)] 
mips: Implement Iex_CCall for nanoMIPS

Implement Iex_CCall for nanoMIPS.

This fixes none/tests/nestedfns.

Patch by Stefan Maksimovic.

5 years agomips: Fix BEQC[16] and BNEC[16] instructions for nanoMIPS
Petar Jovanovic [Tue, 14 Jan 2020 17:37:21 +0000 (17:37 +0000)] 
mips: Fix BEQC[16] and BNEC[16] instructions for nanoMIPS

Instruction decoding was not correct. In some cases, BEQC has been decoded
as BNEC and vice versa.

It caused problems with musl malloc() function.

Patch by Stefan Maksimovic.

5 years agomips: Fix return from syscall mechanism for nanoMIPS
Aleksandar Rikalo [Tue, 14 Jan 2020 17:24:29 +0000 (17:24 +0000)] 
mips: Fix return from syscall mechanism for nanoMIPS

- Restore guest sigmask in VG_(sigframe_destroy)
- Use "syscall[32]" asm idiom instead of "syscall" with immediate parameter
  in VG_(nanomips_linux_SUBST_FOR_rt_sigreturn)
- Call ML_(fixup_guest_state_to_restart_syscall) from PRE(sys_rt_sigreturn)
- Tiny code refactor of sigframe-nanomips-linux.c

This fixes none/tests/thread-exits.

5 years agomips: Add membarrier syscall for nanoMIPS
Petar Jovanovic [Tue, 14 Jan 2020 12:43:13 +0000 (12:43 +0000)] 
mips: Add membarrier syscall for nanoMIPS

This fixes none/tests/linux/membarrier.

5 years agomips: Add Iop_ROTX for nanoMIPS
Petar Jovanovic [Tue, 14 Jan 2020 12:40:09 +0000 (12:40 +0000)] 
mips: Add Iop_ROTX for nanoMIPS

Implement Iop_ROTX and use it for ROTX instruction.
Fixes libvexmultiarch_test and libvex_test.

Patch by: Aleksandra Karadzic and Nikola Milutinovic.

5 years agomips: Fix UASWM and UALWM instructions for nanoMIPS
Aleksandar Rikalo [Tue, 14 Jan 2020 12:09:18 +0000 (12:09 +0000)] 
mips: Fix UASWM and UALWM instructions for nanoMIPS

UASWM and UALWM have not been implemented correctly.
Code used to implement SWM and LWM has been reused without making all of
the required adjustments.

This fixes memcpy() and memset() libc functions.

5 years agomips: Change client request convention for nanoMIPS
Aleksandar Rikalo [Tue, 14 Jan 2020 12:07:11 +0000 (12:07 +0000)] 
mips: Change client request convention for nanoMIPS

Use a7/t0 register pair for for client requests. The same convention is
used throughout the rest of the code, as well as for mips32/64.

5 years agomips: Fix Ist_CAS for nanoMIPS
Aleksandar Rikalo [Tue, 14 Jan 2020 12:04:31 +0000 (12:04 +0000)] 
mips: Fix Ist_CAS for nanoMIPS

This code portion introduced a SEGFAULT:

-  if (&i->NMin.Cas.sz){
+  if (i->NMin.Cas.sz == 8) {

The implementation of Ist_Cas has been fixed and missing logging has been
added as well.

5 years agomips: Fix SAVE instruction for nanoMIPS
Aleksandar Rikalo [Tue, 14 Jan 2020 11:54:15 +0000 (11:54 +0000)] 
mips: Fix SAVE instruction for nanoMIPS

During a save (push) instruction adjusting the SP is required before doing
a store, otherwise Memcheck reports warning because of a write operation
outside of the stack area.

5 years agomips: Fix BRSC and BALRSC instructions for nanoMIPS
Petar Jovanovic [Tue, 14 Jan 2020 09:48:56 +0000 (09:48 +0000)] 
mips: Fix BRSC and BALRSC instructions for nanoMIPS

Basic blocks should be terminated after detecting branch instruction.

5 years agomips: Fix clone syscall for nanoMIPS
Petar Jovanovic [Tue, 14 Jan 2020 09:31:48 +0000 (09:31 +0000)] 
mips: Fix clone syscall for nanoMIPS

- Reset syscall return register (a0) in clone_new_thread()
- Use "syscall[32]" asm idiom instead of "syscall" with immediate parameter
  in ML_ (call_on_new_stack_0_1)()
- Optimize stack usage in ML_ (call_on_new_stack_0_1)()
- Code refactor of ML_ (call_on_new_stack_0_1)()

It partially fixes all tests which use clone system call, e.g. none/tests/pth_atfork1.

Patch by Aleksandar Rikalo.

5 years agomips: add IOP_And1 and Iop_Or1 for nanoMIPS
Petar Jovanovic [Thu, 9 Jan 2020 18:28:57 +0000 (18:28 +0000)] 
mips: add IOP_And1 and Iop_Or1 for nanoMIPS

Support IOP_And1 and Iop_Or1 in iselWordExpr_R_wrk().

5 years agomips: Implement Iop_CmpNEZ32, Iop_CmpNEZ64, Iop_And1 and Iop_Or1
Petar Jovanovic [Thu, 9 Jan 2020 18:05:07 +0000 (19:05 +0100)] 
mips: Implement Iop_CmpNEZ32, Iop_CmpNEZ64, Iop_And1 and Iop_Or1

Implement Iop_CmpNEZ32, Iop_CmpNEZ64, Iop_And1 and Iop_Or1
and fix broken Memcheck for mips32/64.

5 years agomips: update NEWS and README.mips
Petar Jovanovic [Mon, 6 Jan 2020 16:51:37 +0000 (16:51 +0000)] 
mips: update NEWS and README.mips

Patches from Bug #400872 (Add nanoMIPS support to Valgrind) have been
merged.

Update README.mips with a correct configure line applicable for the latest
nanomips toolchain package in public.

5 years agomips: Add tests for nanoMIPS instruction set
Petar Jovanovic [Fri, 3 Jan 2020 17:29:11 +0000 (17:29 +0000)] 
mips: Add tests for nanoMIPS instruction set

Patch by Tamara Vlahovic, Aleksandar Rikalo and Dimitrije Nikolic.

Related KDE issue: #400872.

5 years agosys_statx: don't complain if both |filename| and |buf| are NULL.
Julian Seward [Thu, 2 Jan 2020 13:27:24 +0000 (14:27 +0100)] 
sys_statx: don't complain if both |filename| and |buf| are NULL.

So as to work around the Rust library's dubious use of statx.

5 years agoamd64 insn selector: improved handling of Or1/And1 trees.
Julian Seward [Thu, 2 Jan 2020 08:32:19 +0000 (09:32 +0100)] 
amd64 insn selector: improved handling of Or1/And1 trees.

This splits function iselCondCode into iselCondCode_C and iselCondCode_R, the
former of which is the old one that computes boolean expressions into an amd64
condition code, but the latter being new, and computes boolean expressions
into the lowest bit of an integer register.  This enables much better code
generation for Or1/And1 trees, which now result quite commonly from the new
&&-recovery machinery in the front end.

5 years agoamd64 back end: generate 32-bit shift instructions for 32-bit IR shifts.
Julian Seward [Thu, 2 Jan 2020 08:23:46 +0000 (09:23 +0100)] 
amd64 back end: generate 32-bit shift instructions for 32-bit IR shifts.

Until now these have been handled by possibly widening the value to 64 bits,
if necessary, followed by a 64-bit shift.  That wastes instructions and code
space.

5 years agoEnable expensive handling of CmpEQ64/CmpNE64 for amd64 by default.
Julian Seward [Thu, 2 Jan 2020 08:10:06 +0000 (09:10 +0100)] 
Enable expensive handling of CmpEQ64/CmpNE64 for amd64 by default.

This has unfortunately become necessary because optimising compilers are
generating 64-bit equality comparisons on partially defined values on this
target.  There will shortly be two followup commits which partially mitigate
the resulting performance loss.

5 years agoFold Iop_CmpEQ32x8(x,x) to all-1s ..
Julian Seward [Thu, 2 Jan 2020 07:00:07 +0000 (08:00 +0100)] 
Fold Iop_CmpEQ32x8(x,x) to all-1s ..

    .. hence treating it as a dependency-breaking idiom.  Also handle the
    resulting IRConst_V256(0xFFFFFFFF) in the amd64 insn selector.

(dup of 96de5118f5332ae145912ebe91b8fa143df74b8d from 'grail')

Possibly fixes #409429.

5 years ago'grail' fixes for MIPS:
Julian Seward [Sun, 15 Dec 2019 19:14:37 +0000 (20:14 +0100)] 
'grail' fixes for MIPS:

This isn't a good result.  It merely disables the new functionality on MIPS
because enabling it causes segfaults, even with --tool=none, the cause of
which are not obvious.  It is only chasing through conditional branches that
is disabled, though.  Chasing through unconditional branches (jumps and calls
to known destinations) is still enabled.

* guest_generic_bb_to_IR.c bb_to_IR(): Disable, hopefully temporarily, the key
  &&-recovery transformation on MIPS.

* VEX/priv/host_mips_isel.c iselWordExpr_R_wrk(), iselCondCode_wrk():

  - add support for Iop_And1, Iop_Or1, and IRConst_U1.  This code is my best
    guess about what is correct, but is #if 0'd for now.

  - Properly guard some Iex_Binop cases that lacked a leading check that the
    expression actually was a Binop.

5 years ago'grail' fixes for s390x:
Julian Seward [Sun, 1 Dec 2019 06:01:20 +0000 (07:01 +0100)] 
'grail' fixes for s390x:

This isn't a good result.  It merely disables the new functionality on s390x,
for the reason stated below.

* guest_generic_bb_to_IR.c bb_to_IR(): Disable, hopefully temporarily, the key
  &&-recovery transformation on s390x, since it causes Memcheck to crash for
  reasons I couldn't figure out.  It also exposes some missing Iex_ITE cases
  in the s390x insn selector, although those shouldn't be a big deal to fix.

  Maybe it's some strangeness to do with the s390x "ex" instruction.  I don't
  exactly understand how that trickery works, but from some study of it, I
  didn't see anything obviously wrong.

  It is only chasing through conditional branches that is disabled for s390x.
  Chasing through unconditional branches (jumps and calls to known
  destinations) is still enabled.

* host_s390_isel.c s390_isel_cc(): No functional change.  Code has been added
  here to handle the new Iop_And1 and Iop_Or1, and it is somewhat tested, but
  is not needed until conditional branch chasing is enabled on s390x.

5 years ago'grail' fixes for ppc32 and ppc64:
Julian Seward [Wed, 27 Nov 2019 07:52:45 +0000 (08:52 +0100)] 
'grail' fixes for ppc32 and ppc64:

* do_minimal_initial_iropt_BB: for ppc64, flatten rather than assert flatness.
  (Kludge. Sigh.)

* priv/host_ppc_isel.c iselCondCode_wrk(): handle And1 and Or1, the
  not-particularly-optimal way

* priv/host_ppc_isel.c iselCondCode_wrk(): handle Ico_U1(0).

5 years ago'grail' fixes for arm32:
Julian Seward [Wed, 27 Nov 2019 05:37:42 +0000 (06:37 +0100)] 
'grail' fixes for arm32:

* priv/guest_generic_bb_to_IR.c expr_is_guardable(), stmt_is_guardable():
  add some missing cases

* do_minimal_initial_iropt_BB: add comment (no functional change)

* priv/host_arm_isel.c iselCondCode_wrk(): handle And1 and Or1, the
  not-particularly-optimal way

5 years ago'grail' fixes for arm64:
Julian Seward [Sun, 24 Nov 2019 14:13:54 +0000 (15:13 +0100)] 
'grail' fixes for arm64:

* guest_arm64_toIR.c: use |sigill_diag| to guard auxiliary diagnostic printing
  in case of decode failure

* guest_generic_bb_to_IR.c expr_is_guardable(), stmt_is_guardable(): handle a
  few more cases that didn't turn up so far on x86 or amd64

* host_arm64_defs.[ch]:

  - new instruction ARM64Instr_Set64, to copy a condition code value into a
    register (the CSET instruction)

  - use this to reimplement Iop_And1 and Iop_Or1

5 years agobb_to_IR(): Avoid causing spurious SIGILL-diagnostic messages ..
Julian Seward [Fri, 22 Nov 2019 18:27:43 +0000 (19:27 +0100)] 
bb_to_IR(): Avoid causing spurious SIGILL-diagnostic messages ..

.. when speculating into conditional-branch destinations.  A simple change
requiring a big comment explaining the rationale.

5 years agoImplement And1 and Or1 for the x86 insn selector.
Julian Seward [Fri, 22 Nov 2019 07:32:03 +0000 (08:32 +0100)] 
Implement And1 and Or1 for the x86 insn selector.

5 years agoTidy up ir_opt.c aspects relating to the 'grail' work. In particular:
Julian Seward [Thu, 21 Nov 2019 19:03:47 +0000 (20:03 +0100)] 
Tidy up ir_opt.c aspects relating to the 'grail' work.  In particular:

* Rewrite do_minimal_initial_iropt_BB so it doesn't do full constant folding;
  that is unnecessary expense at this point, and later passes will do it
  anyway

* do_iropt_BB: don't flatten the incoming block, because
  do_minimal_initial_iropt_BB will have run earlier and done so.  But at least
  for the moment, assert that it really is flat.

* VEX/priv/guest_generic_bb_to_IR.c create_self_checks_as_needed: generate
  flat IR so as not to fail the abovementioned assertion.

I believe this completes the target-independent aspects of this work, and also
the x86_64 specifics (of which there are very few).

5 years agoAdd statistics printing for the new trace construction algorithm.
Julian Seward [Thu, 21 Nov 2019 07:55:43 +0000 (08:55 +0100)] 
Add statistics printing for the new trace construction algorithm.

5 years agoAdd a change that should have been part of 6e4db6e9172a55a983105c8e73c89987ce97308a.
Julian Seward [Tue, 19 Nov 2019 07:20:31 +0000 (08:20 +0100)] 
Add a change that should have been part of 6e4db6e9172a55a983105c8e73c89987ce97308a.

5 years agoRationalise --vex-guest* flags in the new IRSB construction framework
Julian Seward [Mon, 18 Nov 2019 18:12:49 +0000 (19:12 +0100)] 
Rationalise --vex-guest* flags in the new IRSB construction framework

* removes --vex-guest-chase-cond=no|yes.  This was never used in practice.

* rename --vex-guest-chase-thresh=<0..99> to --vex-guest-chase=no|yes.  In
  otherwords, downgrade it from a numeric flag to a boolean one, that can
  simply disable all chasing if required.  (Some tools, notably Callgrind,
  force-disable block chasing, so this functionality at least needs to be
  retained).

5 years agoinsn_has_no_other_exits_or_PUTs_to_PC: also check Ist_PutI and Ist_Dirty for writes...
Julian Seward [Wed, 13 Nov 2019 14:45:11 +0000 (15:45 +0100)] 
insn_has_no_other_exits_or_PUTs_to_PC: also check Ist_PutI and Ist_Dirty for writes to the PC.