import valgrind-3.16.0-2.el8

This commit is contained in:
CentOS Sources 2020-07-28 05:26:09 -04:00 committed by Stepan Oksanichenko
parent e6bd7825cc
commit 1e409e08c4
19 changed files with 118 additions and 2048 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/valgrind-3.15.0.tar.bz2
SOURCES/valgrind-3.16.0.tar.bz2

View File

@ -1 +1 @@
4cc014e2390c4bcecb11aa00b37aa52d352db97f SOURCES/valgrind-3.15.0.tar.bz2
cf9fba00b597d9baa3f673cc0960b23a40473ff1 SOURCES/valgrind-3.16.0.tar.bz2

View File

@ -1,45 +0,0 @@
commit 89423f5d8ba05a099c2c62227a00a4f4eec59eb3
Author: Mark Wielaard <mark@klomp.org>
Date: Tue May 7 21:20:04 2019 +0200
Intercept stpcpy also in ld.so for arm64
On other arches stpcpy () is intercepted for both libc.so and ld.so.
But not on arm64, where it is only intercepted for libc.so.
This can cause memcheck warnings about the use of stpcpy () in ld.so
when called through dlopen () because ld.so contains its own copy of
that functions.
Fix by introducing VG_Z_LD_LINUX_AARCH64_SO_1 (the encoded name of
ld.so on arm64) and using that in vg_replace_strmem.c to intercept
stpcpy.
https://bugs.kde.org/show_bug.cgi?id=407307
diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h
index c97941f..15ba67f 100644
--- a/include/pub_tool_redir.h
+++ b/include/pub_tool_redir.h
@@ -313,7 +313,9 @@
#define VG_Z_LD_SO_1 ldZdsoZd1 // ld.so.1
#define VG_U_LD_SO_1 "ld.so.1"
+#define VG_Z_LD_LINUX_AARCH64_SO_1 ldZhlinuxZhaarch64ZdsoZd1
#define VG_U_LD_LINUX_AARCH64_SO_1 "ld-linux-aarch64.so.1"
+
#define VG_U_LD_LINUX_ARMHF_SO_3 "ld-linux-armhf.so.3"
#endif
diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c
index 89a7dcc..19143cf 100644
--- a/shared/vg_replace_strmem.c
+++ b/shared/vg_replace_strmem.c
@@ -1160,6 +1160,7 @@ static inline void my_exit ( int x )
STPCPY(VG_Z_LIBC_SONAME, __stpcpy_sse2_unaligned)
STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy)
STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy)
+ STPCPY(VG_Z_LD_LINUX_AARCH64_SO_1,stpcpy)
#elif defined(VGO_darwin)
//STPCPY(VG_Z_LIBC_SONAME, stpcpy)

View File

@ -1,95 +0,0 @@
commit 791fe5ecf909d573bcbf353b677b9404f9da0ed4
Author: Mark Wielaard <mark@klomp.org>
Date: Mon May 27 22:19:27 2019 +0200
Expose rdrand and f16c through cpuid also if the host only has avx.
The amd64 CPUID dirtyhelpers are mostly static since they emulate some
existing CPU "family". The avx2 ("i7-4910MQ") CPUID variant however
can "dynamicly" enable rdrand and/or f16c if the host supports them.
Do the same for the avx_and_cx16 ("i5-2300") CPUID variant.
https://bugs.kde.org/show_bug.cgi?id=408009
diff --git a/VEX/priv/guest_amd64_defs.h b/VEX/priv/guest_amd64_defs.h
index 4f34b41..a5de527 100644
--- a/VEX/priv/guest_amd64_defs.h
+++ b/VEX/priv/guest_amd64_defs.h
@@ -165,7 +165,9 @@ extern void amd64g_dirtyhelper_storeF80le ( Addr/*addr*/, ULong/*data*/ );
extern void amd64g_dirtyhelper_CPUID_baseline ( VexGuestAMD64State* st );
extern void amd64g_dirtyhelper_CPUID_sse3_and_cx16 ( VexGuestAMD64State* st );
extern void amd64g_dirtyhelper_CPUID_sse42_and_cx16 ( VexGuestAMD64State* st );
-extern void amd64g_dirtyhelper_CPUID_avx_and_cx16 ( VexGuestAMD64State* st );
+extern void amd64g_dirtyhelper_CPUID_avx_and_cx16 ( VexGuestAMD64State* st,
+ ULong hasF16C,
+ ULong hasRDRAND );
extern void amd64g_dirtyhelper_CPUID_avx2 ( VexGuestAMD64State* st,
ULong hasF16C, ULong hasRDRAND );
diff --git a/VEX/priv/guest_amd64_helpers.c b/VEX/priv/guest_amd64_helpers.c
index e4cf7e2..182bae0 100644
--- a/VEX/priv/guest_amd64_helpers.c
+++ b/VEX/priv/guest_amd64_helpers.c
@@ -3141,8 +3141,11 @@ void amd64g_dirtyhelper_CPUID_sse42_and_cx16 ( VexGuestAMD64State* st )
address sizes : 36 bits physical, 48 bits virtual
power management:
*/
-void amd64g_dirtyhelper_CPUID_avx_and_cx16 ( VexGuestAMD64State* st )
+void amd64g_dirtyhelper_CPUID_avx_and_cx16 ( VexGuestAMD64State* st,
+ ULong hasF16C, ULong hasRDRAND )
{
+ vassert((hasF16C >> 1) == 0ULL);
+ vassert((hasRDRAND >> 1) == 0ULL);
# define SET_ABCD(_a,_b,_c,_d) \
do { st->guest_RAX = (ULong)(_a); \
st->guest_RBX = (ULong)(_b); \
@@ -3157,9 +3160,14 @@ void amd64g_dirtyhelper_CPUID_avx_and_cx16 ( VexGuestAMD64State* st )
case 0x00000000:
SET_ABCD(0x0000000d, 0x756e6547, 0x6c65746e, 0x49656e69);
break;
- case 0x00000001:
- SET_ABCD(0x000206a7, 0x00100800, 0x1f9ae3bf, 0xbfebfbff);
+ case 0x00000001: {
+ // As a baseline, advertise neither F16C (ecx:29) nor RDRAND (ecx:30),
+ // but patch in support for them as directed by the caller.
+ UInt ecx_extra
+ = (hasF16C ? (1U << 29) : 0) | (hasRDRAND ? (1U << 30) : 0);
+ SET_ABCD(0x000206a7, 0x00100800, (0x1f9ae3bf | ecx_extra), 0xbfebfbff);
break;
+ }
case 0x00000002:
SET_ABCD(0x76035a01, 0x00f0b0ff, 0x00000000, 0x00ca0000);
break;
diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c
index 56e992c..96dee38 100644
--- a/VEX/priv/guest_amd64_toIR.c
+++ b/VEX/priv/guest_amd64_toIR.c
@@ -22007,7 +22007,8 @@ Long dis_ESC_0F (
vassert(fName); vassert(fAddr);
IRExpr** args = NULL;
- if (fAddr == &amd64g_dirtyhelper_CPUID_avx2) {
+ if (fAddr == &amd64g_dirtyhelper_CPUID_avx2
+ || fAddr == &amd64g_dirtyhelper_CPUID_avx_and_cx16) {
Bool hasF16C = (archinfo->hwcaps & VEX_HWCAPS_AMD64_F16C) != 0;
Bool hasRDRAND = (archinfo->hwcaps & VEX_HWCAPS_AMD64_RDRAND) != 0;
args = mkIRExprVec_3(IRExpr_GSPTR(),
diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c
index 3536e57..56a28d1 100644
--- a/coregrind/m_machine.c
+++ b/coregrind/m_machine.c
@@ -1076,10 +1076,10 @@ Bool VG_(machine_get_hwcaps)( void )
have_avx2 = (ebx & (1<<5)) != 0; /* True => have AVX2 */
}
- /* Sanity check for RDRAND and F16C. These don't actually *need* AVX2, but
- it's convenient to restrict them to the AVX2 case since the simulated
- CPUID we'll offer them on has AVX2 as a base. */
- if (!have_avx2) {
+ /* Sanity check for RDRAND and F16C. These don't actually *need* AVX, but
+ it's convenient to restrict them to the AVX case since the simulated
+ CPUID we'll offer them on has AVX as a base. */
+ if (!have_avx) {
have_f16c = False;
have_rdrand = False;
}

View File

@ -1,374 +0,0 @@
commit 5f00db054a6f59502e9deeeb59ace2261207ee31
Author: Alexandra Hajkova <ahajkova@redhat.com>
Date: Thu May 2 08:24:02 2019 -0400
Add support for the copy_file_range syscall
Support amd64, x86, arm64, ppc64, ppc32 and s390x architectures.
Also add sys-copy_file_range test case.
diff --git a/configure.ac b/configure.ac
index d043ce3..3528925 100755
--- a/configure.ac
+++ b/configure.ac
@@ -4172,6 +4172,7 @@ AC_CHECK_FUNCS([ \
utimensat \
process_vm_readv \
process_vm_writev \
+ copy_file_range \
])
# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
@@ -4187,6 +4188,8 @@ AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
[test x$ac_cv_func_pthread_spin_lock = xyes])
AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
[test x$ac_cv_func_pthread_setname_np = xyes])
+AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
+ [test x$ac_cv_func_copy_file_range = xyes])
if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
-o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
index f76191a..1edf9eb 100644
--- a/coregrind/m_syswrap/priv_syswrap-linux.h
+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
@@ -379,6 +379,7 @@ DECL_TEMPLATE(linux, sys_getsockname);
DECL_TEMPLATE(linux, sys_getpeername);
DECL_TEMPLATE(linux, sys_socketpair);
DECL_TEMPLATE(linux, sys_kcmp);
+DECL_TEMPLATE(linux, sys_copy_file_range);
// Some arch specific functions called from syswrap-linux.c
extern Int do_syscall_clone_x86_linux ( Word (*fn)(void *),
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
index 30e7d0e..0c1d8d1 100644
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
@@ -863,6 +863,8 @@ static SyscallTableEntry syscall_table[] = {
LINXY(__NR_statx, sys_statx), // 332
LINX_(__NR_membarrier, sys_membarrier), // 324
+
+ LINX_(__NR_copy_file_range, sys_copy_file_range), // 326
};
SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
index 290320a..f66be2d 100644
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
@@ -819,7 +819,7 @@ static SyscallTableEntry syscall_main_table[] = {
// (__NR_userfaultfd, sys_ni_syscall), // 282
LINX_(__NR_membarrier, sys_membarrier), // 283
// (__NR_mlock2, sys_ni_syscall), // 284
- // (__NR_copy_file_range, sys_ni_syscall), // 285
+ LINX_(__NR_copy_file_range, sys_copy_file_range), // 285
// (__NR_preadv2, sys_ni_syscall), // 286
// (__NR_pwritev2, sys_ni_syscall), // 287
// (__NR_pkey_mprotect, sys_ni_syscall), // 288
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 73ef98d..cd0ee74 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -12093,6 +12093,36 @@ POST(sys_bpf)
}
}
+PRE(sys_copy_file_range)
+{
+ PRINT("sys_copy_file_range (%lu, %lu, %lu, %lu, %lu, %lu)", ARG1, ARG2, ARG3,
+ ARG4, ARG5, ARG6);
+
+ PRE_REG_READ6(vki_size_t, "copy_file_range",
+ int, "fd_in",
+ vki_loff_t *, "off_in",
+ int, "fd_out",
+ vki_loff_t *, "off_out",
+ vki_size_t, "len",
+ unsigned int, "flags");
+
+ /* File descriptors are "specially" tracked by valgrind.
+ valgrind itself uses some, so make sure someone didn't
+ put in one of our own... */
+ if (!ML_(fd_allowed)(ARG1, "copy_file_range(fd_in)", tid, False) ||
+ !ML_(fd_allowed)(ARG3, "copy_file_range(fd_in)", tid, False)) {
+ SET_STATUS_Failure( VKI_EBADF );
+ } else {
+ /* Now see if the offsets are defined. PRE_MEM_READ will
+ double check it can dereference them. */
+ if (ARG2 != 0)
+ PRE_MEM_READ( "copy_file_range(off_in)", ARG2, sizeof(vki_loff_t));
+ if (ARG4 != 0)
+ PRE_MEM_READ( "copy_file_range(off_out)", ARG4, sizeof(vki_loff_t));
+ }
+}
+
+
#undef PRE
#undef POST
diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c
index f812f1f..71f208d 100644
--- a/coregrind/m_syswrap/syswrap-ppc32-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c
@@ -1021,6 +1021,8 @@ static SyscallTableEntry syscall_table[] = {
LINXY(__NR_getrandom, sys_getrandom), // 359
LINXY(__NR_memfd_create, sys_memfd_create), // 360
+ LINX_(__NR_copy_file_range, sys_copy_file_range), // 379
+
LINXY(__NR_statx, sys_statx), // 383
};
diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
index eada099..1a42c1f 100644
--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
@@ -1007,6 +1007,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_membarrier, sys_membarrier), // 365
+ LINX_(__NR_copy_file_range, sys_copy_file_range), // 379
+
LINXY(__NR_statx, sys_statx), // 383
};
diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
index ad78384..41ada8d 100644
--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
@@ -854,6 +854,8 @@ static SyscallTableEntry syscall_table[] = {
LINXY(__NR_recvmsg, sys_recvmsg), // 372
LINX_(__NR_shutdown, sys_shutdown), // 373
+ LINX_(__NR_copy_file_range, sys_copy_file_range), // 375
+
LINXY(__NR_statx, sys_statx), // 379
};
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index f05619e..f8d97ea 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -1608,6 +1608,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_membarrier, sys_membarrier), // 375
+ LINX_(__NR_copy_file_range, sys_copy_file_range), // 377
+
LINXY(__NR_statx, sys_statx), // 383
/* Explicitly not supported on i386 yet. */
diff --git a/memcheck/tests/linux/Makefile.am b/memcheck/tests/linux/Makefile.am
index d7515d9..00e99a5 100644
--- a/memcheck/tests/linux/Makefile.am
+++ b/memcheck/tests/linux/Makefile.am
@@ -20,6 +20,7 @@ EXTRA_DIST = \
stack_switch.stderr.exp stack_switch.vgtest \
syscalls-2007.vgtest syscalls-2007.stderr.exp \
syslog-syscall.vgtest syslog-syscall.stderr.exp \
+ sys-copy_file_range.vgtest sys-copy_file_range.stderr.exp \
sys-openat.vgtest sys-openat.stderr.exp sys-openat.stdout.exp \
sys-statx.vgtest sys-statx.stderr.exp \
timerfd-syscall.vgtest timerfd-syscall.stderr.exp \
@@ -49,6 +50,10 @@ if HAVE_AT_FDCWD
check_PROGRAMS += sys-openat
endif
+if HAVE_COPY_FILE_RANGE
+ check_PROGRAMS += sys-copy_file_range
+endif
+
AM_CFLAGS += $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
diff --git a/memcheck/tests/linux/sys-copy_file_range.c b/memcheck/tests/linux/sys-copy_file_range.c
new file mode 100644
index 0000000..83981c6
--- /dev/null
+++ b/memcheck/tests/linux/sys-copy_file_range.c
@@ -0,0 +1,67 @@
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+ int fd_in, fd_out;
+ struct stat stat;
+ loff_t len, ret;
+
+ fd_in = open("copy_file_range_source", O_CREAT | O_RDWR);
+ if (fd_in == -1) {
+ perror("open copy_file_range_source");
+ exit(EXIT_FAILURE);
+ }
+
+ if (write(fd_in, "foo bar\n", 8) != 8) {
+ perror("writing to the copy_file_range_source");
+ exit(EXIT_FAILURE);
+ }
+ lseek(fd_in, 0, SEEK_SET);
+
+ if (fstat(fd_in, &stat) == -1) {
+ perror("fstat");
+ exit(EXIT_FAILURE);
+ }
+
+ len = stat.st_size;
+
+ fd_out = open("copy_file_range_dest", O_CREAT | O_WRONLY | O_TRUNC, 0644);
+ if (fd_out == -1) {
+ perror("open copy_file_range_dest");
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check copy_file_range called with the correct arguments works. */
+ do {
+ ret = copy_file_range(fd_in, NULL, fd_out, NULL, len, 0);
+ if (ret == -1) {
+ perror("copy_file_range");
+ exit(EXIT_FAILURE);
+ }
+
+ len -= ret;
+ } while (len > 0);
+
+ /* Check valgrind will produce expected warnings for the
+ various wrong arguments. */
+ do {
+ void *t;
+ void *z = (void *) -1;
+
+ ret = copy_file_range(fd_in, t, fd_out, NULL, len, 0);
+ ret = copy_file_range(fd_in, NULL, fd_out, z, len, 0);
+ ret = copy_file_range(- 1, NULL, - 1, NULL, len, 0);
+ } while (0);
+
+ close(fd_in);
+ close(fd_out);
+ unlink("copy_file_range_source");
+ unlink("copy_file_range_dest");
+ exit(EXIT_SUCCESS);
+}
diff --git a/memcheck/tests/linux/sys-copy_file_range.stderr.exp b/memcheck/tests/linux/sys-copy_file_range.stderr.exp
new file mode 100644
index 0000000..1aa4dc2
--- /dev/null
+++ b/memcheck/tests/linux/sys-copy_file_range.stderr.exp
@@ -0,0 +1,21 @@
+
+Syscall param copy_file_range("off_in") contains uninitialised byte(s)
+ ...
+ by 0x........: main (sys-copy_file_range.c:57)
+
+Syscall param copy_file_range(off_out) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-copy_file_range.c:58)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Warning: invalid file descriptor -1 in syscall copy_file_range(fd_in)()
+
+HEAP SUMMARY:
+ in use at exit: 0 bytes in 0 blocks
+ total heap usage: 0 allocs, 0 frees, 0 bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+Use --track-origins=yes to see where uninitialised values come from
+For lists of detected and suppressed errors, rerun with: -s
+ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
diff --git a/memcheck/tests/linux/sys-copy_file_range.vgtest b/memcheck/tests/linux/sys-copy_file_range.vgtest
new file mode 100644
index 0000000..b7741e8
--- /dev/null
+++ b/memcheck/tests/linux/sys-copy_file_range.vgtest
@@ -0,0 +1,2 @@
+prereq: test -e sys-copy_file_range
+prog: sys-copy_file_range
commit bd27ad3ff31555484b7fdb310c4b033620882e44
Author: Mark Wielaard <mark@klomp.org>
Date: Sun May 5 16:01:41 2019 +0200
Hook linux copy_file_range syscall on arm.
diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c
index 9f1bdab..9ba0665 100644
--- a/coregrind/m_syswrap/syswrap-arm-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm-linux.c
@@ -1016,6 +1016,8 @@ static SyscallTableEntry syscall_main_table[] = {
LINXY(__NR_getrandom, sys_getrandom), // 384
LINXY(__NR_memfd_create, sys_memfd_create), // 385
+ LINX_(__NR_copy_file_range, sys_copy_file_range), // 391
+
LINXY(__NR_statx, sys_statx), // 397
};
commit c212b72a63e43be323a4e028bbdbe8b023c22be8
Author: Mark Wielaard <mark@klomp.org>
Date: Wed May 15 21:30:00 2019 +0200
Explicitly make testcase variable for sys-copy_file_range undefined.
On some systems an extra warning could occur when a variable in
the memcheck/tests/linux/sys-copy_file_range testcase was undefined,
but (accidentially) pointed to known bad memory. Fix by defining the
variable as 0, but then marking it explicitly undefined using memcheck
VALGRIND_MAKE_MEM_UNDEFINED.
Followup for https://bugs.kde.org/show_bug.cgi?id=407218
diff --git a/memcheck/tests/linux/sys-copy_file_range.c b/memcheck/tests/linux/sys-copy_file_range.c
index 83981c6..589399c 100644
--- a/memcheck/tests/linux/sys-copy_file_range.c
+++ b/memcheck/tests/linux/sys-copy_file_range.c
@@ -3,8 +3,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
-#include <sys/syscall.h>
#include <unistd.h>
+#include "../../memcheck.h"
int main(int argc, char **argv)
{
@@ -51,7 +51,7 @@ int main(int argc, char **argv)
/* Check valgrind will produce expected warnings for the
various wrong arguments. */
do {
- void *t;
+ void *t = 0; VALGRIND_MAKE_MEM_UNDEFINED (&t, sizeof (void *));
void *z = (void *) -1;
ret = copy_file_range(fd_in, t, fd_out, NULL, len, 0);
commit 033d013bebeb3471c0da47060deb9a5771e6c913
Author: Mark Wielaard <mark@klomp.org>
Date: Fri May 24 21:51:31 2019 +0200
Fix memcheck/tests/linux/sys-copy_file_range open call (mode).
sys-copy_file_range.c calls open with O_CREAT flag and so must provide
a mode argument. valgrind memcheck actually caught this ommission on
some arches (fedora rawhide i686 specifically).
This is a small additional fixup for
https://bugs.kde.org/show_bug.cgi?id=407218
diff --git a/memcheck/tests/linux/sys-copy_file_range.c b/memcheck/tests/linux/sys-copy_file_range.c
index 589399c..3022fa1 100644
--- a/memcheck/tests/linux/sys-copy_file_range.c
+++ b/memcheck/tests/linux/sys-copy_file_range.c
@@ -12,7 +12,7 @@ int main(int argc, char **argv)
struct stat stat;
loff_t len, ret;
- fd_in = open("copy_file_range_source", O_CREAT | O_RDWR);
+ fd_in = open("copy_file_range_source", O_CREAT | O_RDWR, 0644);
if (fd_in == -1) {
perror("open copy_file_range_source");
exit(EXIT_FAILURE);

View File

@ -1,34 +0,0 @@
diff -ur valgrind-3.14.0.orig/VEX/priv/guest_s390_helpers.c valgrind-3.14.0/VEX/priv/guest_s390_helpers.c
--- valgrind-3.14.0.orig/VEX/priv/guest_s390_helpers.c 2019-01-10 17:00:57.203206690 +0100
+++ valgrind-3.14.0/VEX/priv/guest_s390_helpers.c 2019-01-10 17:06:23.335253900 +0100
@@ -2469,7 +2469,7 @@
/*--- Dirty helper for vector instructions ---*/
/*------------------------------------------------------------*/
-#if defined(VGA_s390x)
+#if defined(VGA_s390x) && 0 /* disable for old binutils */
ULong
s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state,
const ULong serialized)
diff -ur valgrind-3.14.0.orig/none/tests/s390x/Makefile.am valgrind-3.14.0/none/tests/s390x/Makefile.am
--- valgrind-3.14.0.orig/none/tests/s390x/Makefile.am 2019-01-10 17:00:57.411202894 +0100
+++ valgrind-3.14.0/none/tests/s390x/Makefile.am 2019-01-10 17:10:28.963776813 +0100
@@ -18,8 +18,7 @@
spechelper-cr spechelper-clr \
spechelper-ltr spechelper-or \
spechelper-icm-1 spechelper-icm-2 spechelper-tmll \
- spechelper-tm laa vector lsc2 ppno vector_string vector_integer \
- vector_float
+ spechelper-tm laa
if BUILD_DFP_TESTS
INSN_TESTS += dfp-1 dfp-2 dfp-3 dfp-4 dfptest dfpext dfpconv srnmt pfpo
@@ -68,8 +67,3 @@
fixbr_CFLAGS = $(AM_CFLAGS) @FLAG_MLONG_DOUBLE_128@
fpext_CFLAGS = $(AM_CFLAGS) @FLAG_MLONG_DOUBLE_128@
ex_clone_LDADD = -lpthread
-vector_CFLAGS = $(AM_CFLAGS) -march=z13
-lsc2_CFLAGS = -march=z13 -DS390_TESTS_NOCOLOR
-vector_string_CFLAGS = $(AM_CFLAGS) -march=z13 -DS390_TEST_COUNT=5
-vector_integer_CFLAGS = $(AM_CFLAGS) -march=z13 -DS390_TEST_COUNT=4
-vector_float_CFLAGS = $(AM_CFLAGS) -march=z13 -DS390_TEST_COUNT=4

View File

@ -1,29 +0,0 @@
commit 59784c512ec40e588b21cf5ae8e31e9c4f99d6b8
Author: Mark Wielaard <mark@klomp.org>
Date: Sat May 18 14:55:50 2019 +0200
aarch64 (arm64) isn't a supported architecture for exp-sgcheck.
exp-sgcheck/pc_main.c contains:
#if defined(VGA_arm) || defined(VGA_arm64)
VG_(printf)("SGCheck doesn't work on ARM yet, sorry.\n");
VG_(exit)(1);
#endif
But exp-sgcheck/tests/is_arch_supported checked against uname -m
which returns aarch64 (not arm64). Fix the test check so the
exp-sgcheck tests are skipped instead of producing failures.
diff --git a/exp-sgcheck/tests/is_arch_supported b/exp-sgcheck/tests/is_arch_supported
index 818cc61..d4c6191 100755
--- a/exp-sgcheck/tests/is_arch_supported
+++ b/exp-sgcheck/tests/is_arch_supported
@@ -10,6 +10,6 @@
# architectures.
case `uname -m` in
- ppc*|arm*|s390x|mips*) exit 1;;
+ ppc*|aarch64|arm*|s390x|mips*) exit 1;;
*) exit 0;;
esac

View File

@ -1,226 +0,0 @@
commit b064131bdf099d3647b4501e5d15391e1e9623e6
Author: Mark Wielaard <mark@klomp.org>
Date: Thu May 30 00:29:58 2019 +0200
linux x86 and amd64 memory protection key syscalls.
This implements minimal support for the pkey_alloc, pkey_free and
pkey_mprotect syscalls. pkey_alloc will simply indicate that pkeys
are not supported. pkey_free always fails. pkey_mprotect works just
like mprotect if the special pkey -1 is provided.
https://bugs.kde.org/show_bug.cgi?id=408091
diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h
index 88530f0..3e1c8b6 100644
--- a/coregrind/m_syswrap/priv_syswrap-generic.h
+++ b/coregrind/m_syswrap/priv_syswrap-generic.h
@@ -106,6 +106,10 @@ extern Bool
ML_(handle_auxv_open)(SyscallStatus *status, const HChar *filename,
int flags);
+/* Helper function for generic mprotect and linux pkey_mprotect. */
+extern void handle_sys_mprotect (ThreadId tid, SyscallStatus *status,
+ Addr *addr, SizeT *len, Int *prot);
+
DECL_TEMPLATE(generic, sys_ni_syscall); // * P -- unimplemented
DECL_TEMPLATE(generic, sys_exit);
DECL_TEMPLATE(generic, sys_fork);
diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
index 5cf5407..2471524 100644
--- a/coregrind/m_syswrap/priv_syswrap-linux.h
+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
@@ -299,6 +299,11 @@ DECL_TEMPLATE(linux, sys_bpf);
// Linux-specific (new in Linux 4.11)
DECL_TEMPLATE(linux, sys_statx);
+// Linux-specific memory protection key syscalls (since Linux 4.9)
+DECL_TEMPLATE(linux, sys_pkey_alloc);
+DECL_TEMPLATE(linux, sys_pkey_free);
+DECL_TEMPLATE(linux, sys_pkey_mprotect);
+
/* ---------------------------------------------------------------------
Wrappers for sockets and ipc-ery. These are split into standalone
procedures because x86-linux hides them inside multiplexors
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
index d4fe413..2d6b95f 100644
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
@@ -863,6 +863,10 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_membarrier, sys_membarrier), // 324
LINX_(__NR_copy_file_range, sys_copy_file_range), // 326
+
+ LINXY(__NR_pkey_mprotect, sys_pkey_mprotect), // 329
+ LINX_(__NR_pkey_alloc, sys_pkey_alloc), // 330
+ LINX_(__NR_pkey_free, sys_pkey_free), // 331
};
SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno )
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index 0b64919..01191f6 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -3842,12 +3842,28 @@ PRE(sys_mprotect)
PRE_REG_READ3(long, "mprotect",
unsigned long, addr, vki_size_t, len, unsigned long, prot);
- if (!ML_(valid_client_addr)(ARG1, ARG2, tid, "mprotect")) {
+ Addr addr = ARG1;
+ SizeT len = ARG2;
+ Int prot = ARG3;
+
+ handle_sys_mprotect (tid, status, &addr, &len, &prot);
+
+ ARG1 = addr;
+ ARG2 = len;
+ ARG3 = prot;
+}
+/* This will be called from the generic mprotect, or the linux specific
+ pkey_mprotect. Pass pointers to ARG1, ARG2 and ARG3 as addr, len and prot,
+ they might be adjusted and have to assigned back to ARG1, ARG2 and ARG3. */
+void handle_sys_mprotect(ThreadId tid, SyscallStatus* status,
+ Addr *addr, SizeT *len, Int *prot)
+{
+ if (!ML_(valid_client_addr)(*addr, *len, tid, "mprotect")) {
SET_STATUS_Failure( VKI_ENOMEM );
}
#if defined(VKI_PROT_GROWSDOWN)
else
- if (ARG3 & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP)) {
+ if (*prot & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP)) {
/* Deal with mprotects on growable stack areas.
The critical files to understand all this are mm/mprotect.c
@@ -3862,8 +3878,8 @@ PRE(sys_mprotect)
The sanity check provided by the kernel is that the vma must
have the VM_GROWSDOWN/VM_GROWSUP flag set as appropriate. */
- UInt grows = ARG3 & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP);
- NSegment const *aseg = VG_(am_find_nsegment)(ARG1);
+ UInt grows = *prot & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP);
+ NSegment const *aseg = VG_(am_find_nsegment)(*addr);
NSegment const *rseg;
vg_assert(aseg);
@@ -3874,10 +3890,10 @@ PRE(sys_mprotect)
&& rseg->kind == SkResvn
&& rseg->smode == SmUpper
&& rseg->end+1 == aseg->start) {
- Addr end = ARG1 + ARG2;
- ARG1 = aseg->start;
- ARG2 = end - aseg->start;
- ARG3 &= ~VKI_PROT_GROWSDOWN;
+ Addr end = *addr + *len;
+ *addr = aseg->start;
+ *len = end - aseg->start;
+ *prot &= ~VKI_PROT_GROWSDOWN;
} else {
SET_STATUS_Failure( VKI_EINVAL );
}
@@ -3887,8 +3903,8 @@ PRE(sys_mprotect)
&& rseg->kind == SkResvn
&& rseg->smode == SmLower
&& aseg->end+1 == rseg->start) {
- ARG2 = aseg->end - ARG1 + 1;
- ARG3 &= ~VKI_PROT_GROWSUP;
+ *len = aseg->end - *addr + 1;
+ *prot &= ~VKI_PROT_GROWSUP;
} else {
SET_STATUS_Failure( VKI_EINVAL );
}
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 810ca24..5452b8d 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -12120,6 +12120,76 @@ PRE(sys_copy_file_range)
}
}
+PRE(sys_pkey_alloc)
+{
+ PRINT("pkey_alloc (%lu, %lu)", ARG1, ARG2);
+
+ PRE_REG_READ2(long, "pkey_alloc",
+ unsigned long, "flags",
+ unsigned long, "access_rights");
+
+ /* The kernel says: pkey_alloc() is always safe to call regardless of
+ whether or not the operating system supports protection keys. It can be
+ used in lieu of any other mechanism for detecting pkey support and will
+ simply fail with the error ENOSPC if the operating system has no pkey
+ support.
+
+ So we simply always return ENOSPC to signal memory protection keys are
+ not supported under valgrind, unless there are unknown flags, then we
+ return EINVAL. */
+ unsigned long pkey_flags = ARG1;
+ if (pkey_flags != 0)
+ SET_STATUS_Failure( VKI_EINVAL );
+ else
+ SET_STATUS_Failure( VKI_ENOSPC );
+}
+
+PRE(sys_pkey_free)
+{
+ PRINT("pkey_free (%" FMT_REGWORD "u )", ARG1);
+
+ PRE_REG_READ1(long, "pkey_free",
+ unsigned long, "pkey");
+
+ /* Since pkey_alloc () can never succeed, see above, freeing any pkey is
+ always an error. */
+ SET_STATUS_Failure( VKI_EINVAL );
+}
+
+PRE(sys_pkey_mprotect)
+{
+ PRINT("sys_pkey_mprotect ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %"
+ FMT_REGWORD "u %" FMT_REGWORD "u )", ARG1, ARG2, ARG3, ARG4);
+ PRE_REG_READ4(long, "pkey_mprotect",
+ unsigned long, addr, vki_size_t, len, unsigned long, prot,
+ unsigned long, pkey);
+
+ Addr addr = ARG1;
+ SizeT len = ARG2;
+ Int prot = ARG3;
+ Int pkey = ARG4;
+
+ /* Since pkey_alloc () can never succeed, see above, any pkey is
+ invalid. Except for -1, then pkey_mprotect acts just like mprotect. */
+ if (pkey != -1)
+ SET_STATUS_Failure( VKI_EINVAL );
+ else
+ handle_sys_mprotect (tid, status, &addr, &len, &prot);
+
+ ARG1 = addr;
+ ARG2 = len;
+ ARG3 = prot;
+}
+
+POST(sys_pkey_mprotect)
+{
+ Addr addr = ARG1;
+ SizeT len = ARG2;
+ Int prot = ARG3;
+
+ ML_(notify_core_and_tool_of_mprotect)(addr, len, prot);
+}
+
#undef PRE
#undef POST
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index ad54cf6..3829fa4 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -1608,6 +1608,9 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_copy_file_range, sys_copy_file_range), // 377
+ LINXY(__NR_pkey_mprotect, sys_pkey_mprotect), // 380
+ LINX_(__NR_pkey_alloc, sys_pkey_alloc), // 381
+ LINX_(__NR_pkey_free, sys_pkey_free), // 382
LINXY(__NR_statx, sys_statx), // 383
/* Explicitly not supported on i386 yet. */

View File

@ -1,22 +0,0 @@
commit b1cc37ddb660afc536131227a9fb452ac9328972
Author: Alexandra Hájková <ahajkova@redhat.com>
Date: Mon Apr 15 15:34:12 2019 +0200
filter_gdb: add regexp to filter out names which starts with a "."
such names are used for "function descriptors" on ppc64
https://bugs.kde.org/show_bug.cgi?id=406561
diff --git a/gdbserver_tests/filter_gdb b/gdbserver_tests/filter_gdb
index 6eff229..fd2e8e7 100755
--- a/gdbserver_tests/filter_gdb
+++ b/gdbserver_tests/filter_gdb
@@ -119,6 +119,7 @@ sed -e '/Remote debugging using/,/vgdb launched process attached/d'
-e 's/in select ()$/in syscall .../' \
-e 's/in \.__select ()$/in syscall .../' \
-e 's/in select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../' \
+ -e 's/in \.__select () at \.\.\/sysdeps\/unix\/syscall-template\.S.*$/in syscall .../' \
-e '/^[ ]*at \.\.\/sysdeps\/unix\/syscall-template\.S/d' \
-e '/^[ ]*in \.\.\/sysdeps\/unix\/syscall-template\.S/d' \
-e '/^[1-9][0-9]*[ ]*\.\.\/sysdeps\/unix\/syscall-template\.S/d' \

View File

@ -1,751 +0,0 @@
commit b0861063a8d2a55bb7423e90d26806bab0f78a12
Author: Alexandra Hájková <ahajkova@redhat.com>
Date: Tue Jun 4 13:47:14 2019 +0200
Add support for preadv2 and pwritev2 syscalls
Support for amd64, x86 - 64 and 32 bit, arm64, ppc64, ppc64le,
s390x, mips64. This should work identically on all
arches, tested on x86 32bit and 64bit one, but enabled on all.
Refactor the code to be reusable between old/new syscalls. Resolve TODO
items in the code. Add the testcase for the preadv2/pwritev2 and also
add the (similar) testcase for the older preadv/pwritev syscalls.
Trying to test handling an uninitialized flag argument for the v2 syscalls
does not work because the flag always comes out as defined zero.
Turns out glibc does this deliberately on 64bit architectures because
the kernel does actually have a low_offset and high_offset argument, but
ignores the high_offset/assumes it is zero.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=601cc11d054ae4b5e9b5babec3d8e4667a2cb9b5
https://bugs.kde.org/408414
diff --git a/configure.ac b/configure.ac
index 352892565..3596d2fec 100755
--- a/configure.ac
+++ b/configure.ac
@@ -4173,6 +4173,10 @@ AC_CHECK_FUNCS([ \
process_vm_readv \
process_vm_writev \
copy_file_range \
+ preadv \
+ pwritev \
+ preadv2 \
+ pwritev2 \
])
# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
@@ -4190,6 +4194,10 @@ AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
[test x$ac_cv_func_pthread_setname_np = xyes])
AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
[test x$ac_cv_func_copy_file_range = xyes])
+AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
+ [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
+AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
+ [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
-o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
diff --git a/coregrind/m_syswrap/priv_syswrap-generic.h b/coregrind/m_syswrap/priv_syswrap-generic.h
index 3e1c8b682..73f9224f7 100644
--- a/coregrind/m_syswrap/priv_syswrap-generic.h
+++ b/coregrind/m_syswrap/priv_syswrap-generic.h
@@ -109,6 +109,19 @@ ML_(handle_auxv_open)(SyscallStatus *status, const HChar *filename,
/* Helper function for generic mprotect and linux pkey_mprotect. */
extern void handle_sys_mprotect (ThreadId tid, SyscallStatus *status,
Addr *addr, SizeT *len, Int *prot);
+/* Helper functions for preadv/preadv2. */
+extern
+void handle_pre_sys_preadv(ThreadId tid, SyscallStatus* status,
+ Int fd, Addr vector, Int count,
+ const char *str);
+extern
+void handle_post_sys_preadv(ThreadId tid, SyscallStatus* status, Addr vector, Int count);
+
+/* Helper function for pwritev/pwritev2. */
+extern
+void handle_sys_pwritev(ThreadId tid, SyscallStatus* status,
+ Int fd, Addr vector, Int count,
+ const char *str);
DECL_TEMPLATE(generic, sys_ni_syscall); // * P -- unimplemented
DECL_TEMPLATE(generic, sys_exit);
diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h
index be2f9bdde..8ce8ef3d5 100644
--- a/coregrind/m_syswrap/priv_syswrap-linux.h
+++ b/coregrind/m_syswrap/priv_syswrap-linux.h
@@ -46,7 +46,9 @@ DECL_TEMPLATE(linux, sys_oldumount);
DECL_TEMPLATE(linux, sys_umount);
DECL_TEMPLATE(linux, sys_perf_event_open);
DECL_TEMPLATE(linux, sys_preadv);
+DECL_TEMPLATE(linux, sys_preadv2);
DECL_TEMPLATE(linux, sys_pwritev);
+DECL_TEMPLATE(linux, sys_pwritev2);
DECL_TEMPLATE(linux, sys_sendmmsg);
DECL_TEMPLATE(linux, sys_recvmmsg);
DECL_TEMPLATE(linux, sys_dup3);
diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c
index 382dc65cf..9b8068d0f 100644
--- a/coregrind/m_syswrap/syswrap-amd64-linux.c
+++ b/coregrind/m_syswrap/syswrap-amd64-linux.c
@@ -857,6 +857,8 @@ static SyscallTableEntry syscall_table[] = {
// LIN__(__NR_kexec_file_load, sys_ni_syscall), // 320
LINXY(__NR_bpf, sys_bpf), // 321
+ LINXY(__NR_preadv2, sys_preadv2), // 327
+ LINX_(__NR_pwritev2, sys_pwritev2), // 328
LINXY(__NR_statx, sys_statx), // 332
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
index c700e3dbe..d12d40632 100644
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
@@ -818,8 +818,8 @@ static SyscallTableEntry syscall_main_table[] = {
LINX_(__NR_membarrier, sys_membarrier), // 283
// (__NR_mlock2, sys_ni_syscall), // 284
LINX_(__NR_copy_file_range, sys_copy_file_range), // 285
- // (__NR_preadv2, sys_ni_syscall), // 286
- // (__NR_pwritev2, sys_ni_syscall), // 287
+ LINX_(__NR_preadv2, sys_ni_syscall), // 286
+ LINX_(__NR_pwritev2, sys_ni_syscall), // 287
// (__NR_pkey_mprotect, sys_ni_syscall), // 288
// (__NR_pkey_alloc, sys_ni_syscall), // 289
// (__NR_pkey_free, sys_ni_syscall), // 290
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 36d09d6e0..2fe15d97b 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -5501,12 +5501,57 @@ POST(sys_open_by_handle_at)
/* ---------------------------------------------------------------------
p{read,write}v wrappers
------------------------------------------------------------------ */
+/* This handles the common part of the PRE macro for preadv and preadv2. */
+void handle_pre_sys_preadv(ThreadId tid, SyscallStatus* status,
+ Int fd, Addr vector, Int count, const char *str)
+{
+ struct vki_iovec * vec;
+ Int i;
+ /* safe size for the "preadv/preadv2(vector[i])" string */
+ char tmp[30];
+
+ if (!ML_(fd_allowed)(fd, str, tid, False)) {
+ SET_STATUS_Failure( VKI_EBADF );
+ } else if (count > 0) {
+ VG_(strcpy) (tmp, str);
+ VG_(strcat) (tmp, "(vector)");
+ PRE_MEM_READ( tmp, vector, count * sizeof(struct vki_iovec) );
+
+ if (ML_(safe_to_deref) ((void *)(Addr)vector,
+ count * sizeof(struct vki_iovec))) {
+ vec = (struct vki_iovec *)(Addr)vector;
+ for (i = 0; i < count; i++) {
+ VG_(snprintf) (tmp, 30, "%s(vector[%d])", str, i);
+ PRE_MEM_WRITE( tmp, (Addr)vec[i].iov_base, vec[i].iov_len );
+ }
+ }
+ }
+}
+
+/* This handles the common part of the POST macro for preadv and preadv2. */
+void handle_post_sys_preadv(ThreadId tid, SyscallStatus* status, Addr vector, Int count)
+{
+ vg_assert(SUCCESS);
+ if (RES > 0) {
+ Int i;
+ struct vki_iovec * vec = (struct vki_iovec *)(Addr)vector;
+ Int remains = RES;
+
+ /* RES holds the number of bytes read. */
+ for (i = 0; i < count; i++) {
+ Int nReadThisBuf = vec[i].iov_len;
+ if (nReadThisBuf > remains) nReadThisBuf = remains;
+ POST_MEM_WRITE( (Addr)vec[i].iov_base, nReadThisBuf );
+ remains -= nReadThisBuf;
+ if (remains < 0) VG_(core_panic)("preadv: remains < 0");
+ }
+ }
+}
PRE(sys_preadv)
{
- Int i;
- struct vki_iovec * vec;
*flags |= SfMayBlock;
+ const char *str = "preadv";
#if VG_WORDSIZE == 4
/* Note that the offset argument here is in lo+hi order on both
big and little endian platforms... */
@@ -5525,45 +5570,89 @@ PRE(sys_preadv)
#else
# error Unexpected word size
#endif
- if (!ML_(fd_allowed)(ARG1, "preadv", tid, False)) {
- SET_STATUS_Failure( VKI_EBADF );
- } else {
- PRE_MEM_READ( "preadv(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) );
+ Int fd = ARG1;
+ Addr vector = ARG2;
+ Int count = ARG3;
+
+ handle_pre_sys_preadv(tid, status, fd, vector, count, str);
- if (ARG2 != 0) {
- /* ToDo: don't do any of the following if the vector is invalid */
- vec = (struct vki_iovec *)(Addr)ARG2;
- for (i = 0; i < (Int)ARG3; i++)
- PRE_MEM_WRITE( "preadv(vector[...])",
- (Addr)vec[i].iov_base, vec[i].iov_len );
- }
- }
}
POST(sys_preadv)
{
- vg_assert(SUCCESS);
- if (RES > 0) {
- Int i;
- struct vki_iovec * vec = (struct vki_iovec *)(Addr)ARG2;
- Int remains = RES;
+ Addr vector = ARG2;
+ Int count = ARG3;
- /* RES holds the number of bytes read. */
- for (i = 0; i < (Int)ARG3; i++) {
- Int nReadThisBuf = vec[i].iov_len;
- if (nReadThisBuf > remains) nReadThisBuf = remains;
- POST_MEM_WRITE( (Addr)vec[i].iov_base, nReadThisBuf );
- remains -= nReadThisBuf;
- if (remains < 0) VG_(core_panic)("preadv: remains < 0");
+ handle_post_sys_preadv(tid, status, vector, count);
+}
+
+PRE(sys_preadv2)
+{
+ *flags |= SfMayBlock;
+ const char *str = "preadv2";
+#if VG_WORDSIZE == 4
+ /* Note that the offset argument here is in lo+hi order on both
+ big and little endian platforms... */
+ PRINT("sys_preadv2 ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD
+ "u, %lld, %" FMT_REGWORD "u )",
+ ARG1, ARG2, ARG3, (Long)LOHI64(ARG4,ARG5), ARG6);
+ PRE_REG_READ6(ssize_t, "preadv2",
+ unsigned long, fd, const struct iovec *, vector,
+ unsigned long, count, vki_u32, offset_low,
+ vki_u32, offset_high, unsigned long, flags);
+#elif VG_WORDSIZE == 8
+ PRINT("sys_preadv2 ( %lu, %#lx, %lu, %ld, %lu )", ARG1, ARG2, ARG3, SARG4, ARG5);
+ PRE_REG_READ5(ssize_t, "preadv2",
+ unsigned long, fd, const struct iovec *, vector,
+ unsigned long, count, Word, offset, unsigned long, flags);
+#else
+# error Unexpected word size
+#endif
+ Int fd = ARG1;
+ Addr vector = ARG2;
+ Int count = ARG3;
+
+ handle_pre_sys_preadv(tid, status, fd, vector, count, str);
+}
+
+POST(sys_preadv2)
+{
+ Addr vector = ARG2;
+ Int count = ARG3;
+
+ handle_post_sys_preadv(tid, status, vector, count);
+}
+
+/* This handles the common part of the PRE macro for pwritev and pwritev2. */
+void handle_sys_pwritev(ThreadId tid, SyscallStatus* status,
+ Int fd, Addr vector, Int count, const char *str)
+{
+ Int i;
+ struct vki_iovec * vec;
+ /* safe size for the "preadv/preadv2(vector[i])" string */
+ char tmp[30];
+
+ if (!ML_(fd_allowed)(fd, str, tid, False)) {
+ SET_STATUS_Failure( VKI_EBADF );
+ } else if (count > 0) {
+ VG_(strcpy) (tmp, str);
+ VG_(strcat) (tmp, "(vector)");
+ PRE_MEM_READ( tmp, vector, count * sizeof(struct vki_iovec) );
+ if (ML_(safe_to_deref) ((void *)(Addr)vector,
+ count * sizeof(struct vki_iovec))) {
+ vec = (struct vki_iovec *)(Addr)vector;
+ for (i = 0; i < count; i++) {
+ VG_(snprintf) (tmp, 30, "%s(vector[%d])", str, i);
+ PRE_MEM_READ( tmp, (Addr)vec[i].iov_base, vec[i].iov_len );
+ }
}
}
}
PRE(sys_pwritev)
{
- Int i;
- struct vki_iovec * vec;
*flags |= SfMayBlock;
+ const char *str = "pwritev";
#if VG_WORDSIZE == 4
/* Note that the offset argument here is in lo+hi order on both
big and little endian platforms... */
@@ -5581,19 +5670,41 @@ PRE(sys_pwritev)
#else
# error Unexpected word size
#endif
- if (!ML_(fd_allowed)(ARG1, "pwritev", tid, False)) {
- SET_STATUS_Failure( VKI_EBADF );
- } else {
- PRE_MEM_READ( "pwritev(vector)",
- ARG2, ARG3 * sizeof(struct vki_iovec) );
- if (ARG2 != 0) {
- /* ToDo: don't do any of the following if the vector is invalid */
- vec = (struct vki_iovec *)(Addr)ARG2;
- for (i = 0; i < (Int)ARG3; i++)
- PRE_MEM_READ( "pwritev(vector[...])",
- (Addr)vec[i].iov_base, vec[i].iov_len );
- }
- }
+ Int fd = ARG1;
+ Addr vector = ARG2;
+ Int count = ARG3;
+
+ handle_sys_pwritev(tid, status, fd, vector, count, str);
+}
+
+PRE(sys_pwritev2)
+{
+ *flags |= SfMayBlock;
+ const char *str = "pwritev2";
+#if VG_WORDSIZE == 4
+ /* Note that the offset argument here is in lo+hi order on both
+ big and little endian platforms... */
+ PRINT("sys_pwritev2 ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD
+ "u, %lld, %" FMT_REGWORD "u )",
+ ARG1, ARG2, ARG3, (Long)LOHI64(ARG4,ARG5), ARG6);
+ PRE_REG_READ6(ssize_t, "pwritev2",
+ unsigned long, fd, const struct iovec *, vector,
+ unsigned long, count, vki_u32, offset_low,
+ vki_u32, offset_high, unsigned long, flags);
+#elif VG_WORDSIZE == 8
+ /* Note offset_high isn't actually used? */
+ PRE_REG_READ6(ssize_t, "pwritev2",
+ unsigned long, fd, const struct iovec *, vector,
+ unsigned long, count, Word, offset,
+ Word, offset_high, unsigned long, flags);
+#else
+# error Unexpected word size
+#endif
+ Int fd = ARG1;
+ Addr vector = ARG2;
+ Int count = ARG3;
+
+ handle_sys_pwritev(tid, status, fd, vector, count, str);
}
/* ---------------------------------------------------------------------
diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c
index baa2934ab..d65a664dd 100644
--- a/coregrind/m_syswrap/syswrap-ppc64-linux.c
+++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c
@@ -1006,6 +1006,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_membarrier, sys_membarrier), // 365
LINX_(__NR_copy_file_range, sys_copy_file_range), // 379
+ LINX_(__NR_preadv2, sys_preadv2), // 380
+ LINX_(__NR_pwritev2, sys_pwritev2), // 381
LINXY(__NR_statx, sys_statx), // 383
};
diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c
index 1481e768b..3354d41c0 100644
--- a/coregrind/m_syswrap/syswrap-s390x-linux.c
+++ b/coregrind/m_syswrap/syswrap-s390x-linux.c
@@ -853,6 +853,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_shutdown, sys_shutdown), // 373
LINX_(__NR_copy_file_range, sys_copy_file_range), // 375
+ LINXY(__NR_preadv2, sys_preadv2), // 376
+ LINX_(__NR_pwritev2, sys_pwritev2), // 377
LINXY(__NR_statx, sys_statx), // 379
};
diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c
index 9ff53a92a..33d1213a3 100644
--- a/coregrind/m_syswrap/syswrap-x86-linux.c
+++ b/coregrind/m_syswrap/syswrap-x86-linux.c
@@ -1607,6 +1607,8 @@ static SyscallTableEntry syscall_table[] = {
LINX_(__NR_membarrier, sys_membarrier), // 375
LINX_(__NR_copy_file_range, sys_copy_file_range), // 377
+ LINXY(__NR_preadv2, sys_preadv2), // 378
+ LINX_(__NR_pwritev2, sys_pwritev2), // 379
LINXY(__NR_pkey_mprotect, sys_pkey_mprotect), // 380
LINX_(__NR_pkey_alloc, sys_pkey_alloc), // 381
diff --git a/memcheck/tests/linux/Makefile.am b/memcheck/tests/linux/Makefile.am
index 00e99a52a..e13325869 100644
--- a/memcheck/tests/linux/Makefile.am
+++ b/memcheck/tests/linux/Makefile.am
@@ -26,7 +26,9 @@ EXTRA_DIST = \
timerfd-syscall.vgtest timerfd-syscall.stderr.exp \
with-space.stderr.exp with-space.stdout.exp with-space.vgtest \
proc-auxv.vgtest proc-auxv.stderr.exp getregset.vgtest \
- getregset.stderr.exp getregset.stdout.exp
+ getregset.stderr.exp getregset.stdout.exp \
+ sys-preadv_pwritev.vgtest sys-preadv_pwritev.stderr.exp \
+ sys-preadv2_pwritev2.vgtest sys-preadv2_pwritev2.stderr.exp
check_PROGRAMS = \
brk \
@@ -54,6 +56,14 @@ if HAVE_COPY_FILE_RANGE
check_PROGRAMS += sys-copy_file_range
endif
+if HAVE_PREADV_PWRITEV
+ check_PROGRAMS += sys-preadv_pwritev
+endif
+
+if HAVE_PREADV2_PWRITEV2
+ check_PROGRAMS += sys-preadv2_pwritev2
+endif
+
AM_CFLAGS += $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
diff --git a/memcheck/tests/linux/sys-preadv2_pwritev2.c b/memcheck/tests/linux/sys-preadv2_pwritev2.c
new file mode 100644
index 000000000..942eab68b
--- /dev/null
+++ b/memcheck/tests/linux/sys-preadv2_pwritev2.c
@@ -0,0 +1,79 @@
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/uio.h>
+#include <string.h>
+#include "../../memcheck.h"
+
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+ char str0[] = "hello ";
+ char str1[] = "world\n";
+ struct iovec iov[2];
+ int fd;
+
+ fd = open("prwv2_source", O_CREAT | O_RDWR, 0644);
+ if (fd == -1) {
+ perror("prwv2_source");
+ exit(EXIT_FAILURE);
+ }
+
+ iov[0].iov_base = str0;
+ iov[0].iov_len = strlen(str0);
+ iov[1].iov_base = str1;
+ iov[1].iov_len = strlen(str1);
+
+ /* Check pwritev2 and preadv2 called with the correct arguments works. */
+ if (pwritev2(fd, iov, 2, 0, 0) == -1) {
+ perror("pwritev2");
+ exit(EXIT_FAILURE);
+ }
+
+ if (preadv2(fd, iov, 2, 0, 0) == -1) {
+ perror("preadv2");
+ printf("errno: %d\n", errno);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check valgrind will produce expected warnings for the
+ various wrong arguments. */
+ do {
+ /* always allocate 16 bytes to not to have different .exps for different reg sizes */
+ char *mem = malloc(16);
+ void *t = (void *) &mem[0];
+ void *z = (void *) -1;
+ int c = *((int *) &mem[4]);
+ int flag = *((int *) &mem[8]);
+ pwritev2(fd, NULL, 2, 0, 0);
+ pwritev2(fd, z, 2, 0, 0);
+ pwritev2(fd, t, 2, 0, 0);
+ pwritev2(fd, iov, -1, 0, 0);
+ pwritev2(fd, iov, c, 0, 0);
+ pwritev2(fd, iov, 2, -5, 0);
+ pwritev2(-1, iov, 2, -5, 0);
+ pwritev2(fd, iov, 2, -5, flag);
+
+ preadv2(fd, NULL, 2, 0, 0);
+ preadv2(fd, z, 2, 0, 0);
+ preadv2(fd, t, 2, 0, 0);
+ preadv2(fd, iov, -1, 0, 0);
+ preadv2(fd, iov, c, 0, 0);
+ preadv2(fd, iov, 2, -5, 0);
+ preadv2(-1, iov, 2, -5, 0);
+
+ iov[1].iov_base = (void *) -1;
+ pwritev2(fd, iov, 2, 0, 0);
+ preadv2(fd, iov, 2, 0, 0);
+ free(mem);
+ } while (0);
+
+ close(fd);
+ unlink("prwv2_source");
+ exit(EXIT_SUCCESS);
+}
diff --git a/memcheck/tests/linux/sys-preadv2_pwritev2.stderr.exp b/memcheck/tests/linux/sys-preadv2_pwritev2.stderr.exp
new file mode 100644
index 000000000..e11f2a51d
--- /dev/null
+++ b/memcheck/tests/linux/sys-preadv2_pwritev2.stderr.exp
@@ -0,0 +1,56 @@
+Syscall param pwritev2(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:53)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param pwritev2(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:54)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param pwritev2(vector) points to uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:55)
+ Address 0x........ is 0 bytes inside a block of size 16 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (sys-preadv2_pwritev2.c:48)
+
+Syscall param pwritev2(count) contains uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:57)
+
+Syscall param pwritev2(flags) contains uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:60)
+
+Syscall param preadv2(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:62)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param preadv2(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:63)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param preadv2(vector) points to uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:64)
+ Address 0x........ is 0 bytes inside a block of size 16 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (sys-preadv2_pwritev2.c:48)
+
+Syscall param preadv2(count) contains uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:66)
+
+Syscall param pwritev2(vector[1]) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:71)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param preadv2(vector[1]) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv2_pwritev2.c:72)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
diff --git a/memcheck/tests/linux/sys-preadv2_pwritev2.vgtest b/memcheck/tests/linux/sys-preadv2_pwritev2.vgtest
new file mode 100644
index 000000000..5cd23aacd
--- /dev/null
+++ b/memcheck/tests/linux/sys-preadv2_pwritev2.vgtest
@@ -0,0 +1,3 @@
+prereq: test -e sys-preadv2_pwritev2
+prog: sys-preadv2_pwritev2
+vgopts: -q
diff --git a/memcheck/tests/linux/sys-preadv_pwritev.c b/memcheck/tests/linux/sys-preadv_pwritev.c
new file mode 100644
index 000000000..f5087dddc
--- /dev/null
+++ b/memcheck/tests/linux/sys-preadv_pwritev.c
@@ -0,0 +1,77 @@
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/uio.h>
+#include <string.h>
+#include "../../memcheck.h"
+
+#include <errno.h>
+
+int main(int argc, char **argv)
+{
+ char str0[] = "hello ";
+ char str1[] = "world\n";
+ struct iovec iov[2];
+ int fd;
+
+ fd = open("prwv_source", O_CREAT | O_RDWR, 0644);
+ if (fd == -1) {
+ perror("prwv2_source");
+ exit(EXIT_FAILURE);
+ }
+
+ iov[0].iov_base = str0;
+ iov[0].iov_len = strlen(str0);
+ iov[1].iov_base = str1;
+ iov[1].iov_len = strlen(str1);
+
+ /* Check pwritev and preadv called with the correct arguments works. */
+ if (pwritev(fd, iov, 2, 0) == -1) {
+ perror("pwritev");
+ exit(EXIT_FAILURE);
+ }
+
+ if (preadv(fd, iov, 2, 0) == -1) {
+ perror("preadv");
+ printf("errno: %d\n", errno);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Check valgrind will produce expected warnings for the
+ various wrong arguments. */
+ do {
+ /* always allocate 16 bytes to not to have different .exps for different reg sizes */
+ char *mem = malloc(16);
+ void *t = (void *) &mem[0];
+ void *z = (void *) -1;
+ int c = *((int *) &mem[4]);
+ pwritev(fd, NULL, 2, 0);
+ pwritev(fd, z, 2, 0);
+ pwritev(fd, t, 2, 0);
+ pwritev(fd, iov, -1, 0);
+ pwritev(fd, iov, c, 0);
+ pwritev(fd, iov, 2, -5);
+ pwritev(-1, iov, 2, -5);
+
+ preadv(fd, NULL, 2, 0);
+ preadv(fd, z, 2, 0);
+ preadv(fd, t, 2, 0);
+ preadv(fd, iov, -1, 0);
+ preadv(fd, iov, c, 0);
+ preadv(fd, iov, 2, -5);
+ preadv(-1, iov, 2, -5);
+
+ iov[1].iov_base = (void *) -1;
+ pwritev(fd, iov, 2, 0);
+ preadv(fd, iov, 2, 0);
+ free(mem);
+ } while (0);
+
+ close(fd);
+ unlink("prwv_source");
+ exit(EXIT_SUCCESS);
+}
diff --git a/memcheck/tests/linux/sys-preadv_pwritev.stderr.exp b/memcheck/tests/linux/sys-preadv_pwritev.stderr.exp
new file mode 100644
index 000000000..4fede44d8
--- /dev/null
+++ b/memcheck/tests/linux/sys-preadv_pwritev.stderr.exp
@@ -0,0 +1,52 @@
+Syscall param pwritev(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:52)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param pwritev(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:53)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param pwritev(vector) points to uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:54)
+ Address 0x........ is 0 bytes inside a block of size 16 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (sys-preadv_pwritev.c:48)
+
+Syscall param pwritev(count) contains uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:56)
+
+Syscall param preadv(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:60)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param preadv(vector) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:61)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param preadv(vector) points to uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:62)
+ Address 0x........ is 0 bytes inside a block of size 16 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (sys-preadv_pwritev.c:48)
+
+Syscall param preadv(count) contains uninitialised byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:64)
+
+Syscall param pwritev(vector[1]) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:69)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
+Syscall param preadv(vector[1]) points to unaddressable byte(s)
+ ...
+ by 0x........: main (sys-preadv_pwritev.c:70)
+ Address 0x........ is not stack'd, malloc'd or (recently) free'd
+
diff --git a/memcheck/tests/linux/sys-preadv_pwritev.vgtest b/memcheck/tests/linux/sys-preadv_pwritev.vgtest
new file mode 100644
index 000000000..f07dc2935
--- /dev/null
+++ b/memcheck/tests/linux/sys-preadv_pwritev.vgtest
@@ -0,0 +1,3 @@
+prereq: test -e sys-preadv_pwritev
+prog: sys-preadv_pwritev
+vgopts: -q
commit 514f899388e05142513ff3f679a9e0131145e34e
Author: Mark Wielaard <mark@klomp.org>
Date: Wed Jul 3 10:27:17 2019 +0200
Hook up preadv2 and pwritev2 correctly for arm64.
Use the correct generic linux sys wrapper.
Followup for https://bugs.kde.org/408414
diff --git a/coregrind/m_syswrap/syswrap-arm64-linux.c b/coregrind/m_syswrap/syswrap-arm64-linux.c
index d12d40632..91329b682 100644
--- a/coregrind/m_syswrap/syswrap-arm64-linux.c
+++ b/coregrind/m_syswrap/syswrap-arm64-linux.c
@@ -818,8 +818,8 @@ static SyscallTableEntry syscall_main_table[] = {
LINX_(__NR_membarrier, sys_membarrier), // 283
// (__NR_mlock2, sys_ni_syscall), // 284
LINX_(__NR_copy_file_range, sys_copy_file_range), // 285
- LINX_(__NR_preadv2, sys_ni_syscall), // 286
- LINX_(__NR_pwritev2, sys_ni_syscall), // 287
+ LINXY(__NR_preadv2, sys_preadv2), // 286
+ LINX_(__NR_pwritev2, sys_pwritev2), // 287
// (__NR_pkey_mprotect, sys_ni_syscall), // 288
// (__NR_pkey_alloc, sys_ni_syscall), // 289
// (__NR_pkey_free, sys_ni_syscall), // 290

View File

@ -1,194 +0,0 @@
From bfa89eae00ba7067445bc0532e1f17405c062954 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Thu, 23 May 2019 17:17:43 +0200
Subject: [PATCH] Bug 407764 - s390x: drd fails on z13 due to function wrapping
issue
The s390x-specific inline assembly macros for function wrapping in
include/valgrind.h have a few issues.
When the compiler uses vector registers, such as with "-march=z13", all
vector registers must be declared as clobbered by the callee. Because
this is missing, many drd test failures are seen with "-march=z13".
Also, the inline assemblies write the return value into the target
register before restoring r11. If r11 is used as the target register,
this means that the restore operation corrupts the result. This bug
causes failures with memcheck's "wrap6" test case.
These bugs are fixed. The clobber list is extended by the vector
registers (if appropriate), and the target register is now written at the
end, after restoring r11.
---
include/valgrind.h | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/include/valgrind.h b/include/valgrind.h
index f071bd392..815efa893 100644
--- a/include/valgrind.h
+++ b/include/valgrind.h
@@ -4687,8 +4687,16 @@ typedef
r14 in s390_irgen_noredir (VEX/priv/guest_s390_irgen.c) to give the
function a proper return address. All others are ABI defined call
clobbers. */
-#define __CALLER_SAVED_REGS "0","1","2","3","4","5","14", \
- "f0","f1","f2","f3","f4","f5","f6","f7"
+#if defined(__VX__) || defined(__S390_VX__)
+#define __CALLER_SAVED_REGS "0", "1", "2", "3", "4", "5", "14", \
+ "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", \
+ "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \
+ "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \
+ "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
+#else
+#define __CALLER_SAVED_REGS "0", "1", "2", "3", "4", "5", "14", \
+ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7"
+#endif
/* Nb: Although r11 is modified in the asm snippets below (inside
VALGRIND_CFI_PROLOGUE) it is not listed in the clobber section, for
@@ -4710,9 +4718,9 @@ typedef
"aghi 15,-160\n\t" \
"lg 1, 0(1)\n\t" /* target->r1 */ \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,160\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "d" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7" \
@@ -4734,9 +4742,9 @@ typedef
"lg 2, 8(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,160\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7" \
@@ -4759,9 +4767,9 @@ typedef
"lg 3,16(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,160\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7" \
@@ -4786,9 +4794,9 @@ typedef
"lg 4,24(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,160\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7" \
@@ -4815,9 +4823,9 @@ typedef
"lg 5,32(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,160\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"7" \
@@ -4846,9 +4854,9 @@ typedef
"lg 6,40(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,160\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
@@ -4880,9 +4888,9 @@ typedef
"mvc 160(8,15), 48(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,168\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
@@ -4916,9 +4924,9 @@ typedef
"mvc 168(8,15), 56(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,176\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
@@ -4954,9 +4962,9 @@ typedef
"mvc 176(8,15), 64(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,184\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
@@ -4994,9 +5002,9 @@ typedef
"mvc 184(8,15), 72(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,192\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
@@ -5036,9 +5044,9 @@ typedef
"mvc 192(8,15), 80(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,200\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
@@ -5080,9 +5088,9 @@ typedef
"mvc 200(8,15), 88(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,208\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
@@ -5126,9 +5134,9 @@ typedef
"mvc 208(8,15), 96(1)\n\t" \
"lg 1, 0(1)\n\t" \
VALGRIND_CALL_NOREDIR_R1 \
- "lgr %0, 2\n\t" \
"aghi 15,216\n\t" \
VALGRIND_CFI_EPILOGUE \
+ "lgr %0, 2\n\t" \
: /*out*/ "=d" (_res) \
: /*in*/ "a" (&_argvec[0]) __FRAME_POINTER \
: /*trash*/ "cc", "memory", __CALLER_SAVED_REGS,"6","7" \
--
2.17.0

View File

@ -1,83 +0,0 @@
commit 917e423073c5eacffbad83008c27c8e61e0e342a
Author: Mark Wielaard <mark@klomp.org>
Date: Mon May 20 00:09:59 2019 +0200
Make memcheck/tests/arm64-linux/scalar test work under root.
Running the testsuite as root isn't really recommended.
But lets not make tests fail unnecessarily when running as root.
Pass really invalid arguments to setuid, setgid, acct and fchown.
Make setresgid, setresuid, setregid and setreuid always succeed.
diff --git a/memcheck/tests/arm64-linux/scalar.c b/memcheck/tests/arm64-linux/scalar.c
index fd49db6..622ea1c 100644
--- a/memcheck/tests/arm64-linux/scalar.c
+++ b/memcheck/tests/arm64-linux/scalar.c
@@ -136,7 +136,7 @@ int main(void)
// __NR_setuid 23
GO(__NR_setuid, "1s 0m");
- SY(__NR_setuid, x0); FAIL;
+ SY(__NR_setuid, x0-1); FAIL;
// __NR_getuid 24
GO(__NR_getuid, "0s 0m");
@@ -229,7 +229,7 @@ int main(void)
// __NR_setgid 46
GO(__NR_setgid, "1s 0m");
- SY(__NR_setgid, x0); FAIL;
+ SY(__NR_setgid, x0-1); FAIL;
// __NR_getgid 47
GO(__NR_getgid, "0s 0m");
@@ -249,7 +249,7 @@ int main(void)
// __NR_acct 51
GO(__NR_acct, "1s 1m");
- SY(__NR_acct, x0); FAIL;
+ SY(__NR_acct, x0-1); FAIL;
// __NR_umount2 52
GO(__NR_umount2, "2s 1m");
@@ -340,11 +340,11 @@ int main(void)
// __NR_setreuid 70
GO(__NR_setreuid, "2s 0m");
- SY(__NR_setreuid, x0, x0); FAIL;
+ SY(__NR_setreuid, x0-1, x0-1); SUCC;
// __NR_setregid 71
GO(__NR_setregid, "2s 0m");
- SY(__NR_setregid, x0, x0); FAIL;
+ SY(__NR_setregid, x0-1, x0-1); SUCC;
// __NR_sigsuspend arm64 only has rt_sigsuspend
// XXX: how do you use this function?
@@ -447,7 +447,7 @@ int main(void)
// __NR_fchown 95
GO(__NR_fchown, "3s 0m");
- SY(__NR_fchown, x0, x0, x0); FAIL;
+ SY(__NR_fchown, x0-1, x0, x0); FAIL;
// __NR_getpriority 96
GO(__NR_getpriority, "2s 0m");
@@ -733,7 +733,7 @@ int main(void)
// __NR_setresuid 164
GO(__NR_setresuid, "3s 0m");
- SY(__NR_setresuid, x0, x0, x0); FAIL;
+ SY(__NR_setresuid, x0-1, x0-1, x0-1); SUCC;
// __NR_getresuid 165
GO(__NR_getresuid, "3s 3m");
@@ -757,7 +757,7 @@ int main(void)
// __NR_setresgid 170
GO(__NR_setresgid, "3s 0m");
- SY(__NR_setresgid, x0, x0, x0); FAIL;
+ SY(__NR_setresgid, x0-1, x0-1, x0-1); SUCC;
// __NR_getresgid 171
GO(__NR_getresgid, "3s 3m");

View File

@ -1,137 +0,0 @@
commit abc09f23e1ad55a07beb827aef969acfe6c496ef
Author: Mark Wielaard <mark@klomp.org>
Date: Mon May 20 13:08:41 2019 +0200
Make memcheck/tests/x86-linux/scalar test work under root.
Running the testsuite as root isn't really recommended.
But lets not make tests fail unnecessarily when running as root.
Similar to the arm64-linux/scalar fixes. Plus 32bit variants that
don't exist on arm64.
Pass really invalid arguments to setuid[32], setgid[32], acct, fchown[32].
Make setresgid[32], setresuid[32], setregid[32], setreuid[32] always succeed.
diff --git a/memcheck/tests/x86-linux/scalar.c b/memcheck/tests/x86-linux/scalar.c
index 213a5ad..52f0d4e 100644
--- a/memcheck/tests/x86-linux/scalar.c
+++ b/memcheck/tests/x86-linux/scalar.c
@@ -145,7 +145,7 @@ int main(void)
// __NR_setuid 23
GO(__NR_setuid, "1s 0m");
- SY(__NR_setuid, x0); FAIL;
+ SY(__NR_setuid, x0-1); FAIL;
// __NR_getuid 24
GO(__NR_getuid, "0s 0m");
@@ -238,7 +238,7 @@ int main(void)
// __NR_setgid 46
GO(__NR_setgid, "1s 0m");
- SY(__NR_setgid, x0); FAIL;
+ SY(__NR_setgid, x0-1); FAIL;
// __NR_getgid 47
GO(__NR_getgid, "0s 0m");
@@ -258,7 +258,7 @@ int main(void)
// __NR_acct 51
GO(__NR_acct, "1s 1m");
- SY(__NR_acct, x0); FAIL;
+ SY(__NR_acct, x0-1); FAIL;
// __NR_umount2 52
GO(__NR_umount2, "2s 1m");
@@ -349,11 +349,11 @@ int main(void)
// __NR_setreuid 70
GO(__NR_setreuid, "2s 0m");
- SY(__NR_setreuid, x0, x0); FAIL;
+ SY(__NR_setreuid, x0-1, x0-1); SUCC;
// __NR_setregid 71
GO(__NR_setregid, "2s 0m");
- SY(__NR_setregid, x0, x0); FAIL;
+ SY(__NR_setregid, x0-1, x0-1); SUCC;
// __NR_sigsuspend 72
// XXX: how do you use this function?
@@ -456,7 +456,7 @@ int main(void)
// __NR_fchown 95
GO(__NR_fchown, "3s 0m");
- SY(__NR_fchown, x0, x0, x0); FAIL;
+ SY(__NR_fchown, x0-1, x0, x0); FAIL;
// __NR_getpriority 96
GO(__NR_getpriority, "2s 0m");
@@ -742,7 +742,7 @@ int main(void)
// __NR_setresuid 164
GO(__NR_setresuid, "3s 0m");
- SY(__NR_setresuid, x0, x0, x0); FAIL;
+ SY(__NR_setresuid, x0-1, x0-1, x0-1); SUCC;
// __NR_getresuid 165
GO(__NR_getresuid, "3s 3m");
@@ -766,7 +766,7 @@ int main(void)
// __NR_setresgid 170
GO(__NR_setresgid, "3s 0m");
- SY(__NR_setresgid, x0, x0, x0); FAIL;
+ SY(__NR_setresgid, x0-1, x0-1, x0-1); SUCC;
// __NR_getresgid 171
GO(__NR_getresgid, "3s 3m");
@@ -923,11 +923,11 @@ int main(void)
// __NR_setreuid32 203
GO(__NR_setreuid32, "2s 0m");
- SY(__NR_setreuid32, x0, x0); FAIL;
+ SY(__NR_setreuid32, x0-1, x0-1); SUCC;
// __NR_setregid32 204
GO(__NR_setregid32, "2s 0m");
- SY(__NR_setregid32, x0, x0); FAIL;
+ SY(__NR_setregid32, x0-1, x0-1); SUCC;
// __NR_getgroups32 205
GO(__NR_getgroups32, "2s 1m");
@@ -939,11 +939,11 @@ int main(void)
// __NR_fchown32 207
GO(__NR_fchown32, "3s 0m");
- SY(__NR_fchown32, x0, x0, x0); FAIL;
+ SY(__NR_fchown32, x0-1, x0, x0); FAIL;
// __NR_setresuid32 208
GO(__NR_setresuid32, "3s 0m");
- SY(__NR_setresuid32, x0, x0, x0); FAIL;
+ SY(__NR_setresuid32, x0-1, x0-1, x0-1); SUCC;
// __NR_getresuid32 209
GO(__NR_getresuid32, "3s 3m");
@@ -951,7 +951,7 @@ int main(void)
// __NR_setresgid32 210
GO(__NR_setresgid32, "3s 0m");
- SY(__NR_setresgid32, x0, x0, x0); FAIL;
+ SY(__NR_setresgid32, x0-1, x0-1, x0-1); SUCC;
// __NR_getresgid32 211
GO(__NR_getresgid32, "3s 3m");
@@ -963,11 +963,11 @@ int main(void)
// __NR_setuid32 213
GO(__NR_setuid32, "1s 0m");
- SY(__NR_setuid32, x0); FAIL;
+ SY(__NR_setuid32, x0-1); FAIL;
// __NR_setgid32 214
GO(__NR_setgid32, "1s 0m");
- SY(__NR_setgid32, x0); FAIL;
+ SY(__NR_setgid32, x0-1); FAIL;
// __NR_setfsuid32 215
GO(__NR_setfsuid32, "1s 0m");

View File

@ -0,0 +1,64 @@
commit 6aa4f7e7e76b40c183fb29650540d119ce1b4a4a
Author: Julian Seward <jseward@acm.org>
Date: Thu Jun 11 09:01:52 2020 +0200
expr_is_guardable, stmt_is_guardable, add_guarded_stmt_to_end_of: handle GetI/PutI cases.
This fixes #422715.
diff --git a/VEX/priv/guest_generic_bb_to_IR.c b/VEX/priv/guest_generic_bb_to_IR.c
index 2f204c5b0..0cee970e4 100644
--- a/VEX/priv/guest_generic_bb_to_IR.c
+++ b/VEX/priv/guest_generic_bb_to_IR.c
@@ -425,6 +425,7 @@ static Bool expr_is_guardable ( const IRExpr* e )
case Iex_ITE:
case Iex_CCall:
case Iex_Get:
+ case Iex_GetI:
case Iex_Const:
case Iex_RdTmp:
return True;
@@ -450,6 +451,7 @@ static Bool stmt_is_guardable ( const IRStmt* st )
case Ist_NoOp:
case Ist_IMark:
case Ist_Put:
+ case Ist_PutI:
return True;
// These are definitely not guardable, or at least it's way too much
// hassle to do so.
@@ -506,7 +508,7 @@ static void add_guarded_stmt_to_end_of ( /*MOD*/IRSB* bb,
// Put(offs, e) ==> Put(offs, ITE(guard, e, Get(offs, sizeof(e))))
// Which when flattened out is:
// t1 = Get(offs, sizeof(e))
- // t2 = ITE(guard, e, t2)
+ // t2 = ITE(guard, e, t1)
// Put(offs, t2)
Int offset = st->Ist.Put.offset;
IRExpr* e = st->Ist.Put.data;
@@ -519,6 +521,26 @@ static void add_guarded_stmt_to_end_of ( /*MOD*/IRSB* bb,
addStmtToIRSB(bb, IRStmt_Put(offset, IRExpr_RdTmp(t2)));
break;
}
+ case Ist_PutI: {
+ // PutI(descr,ix,bias, e) ==> Put(descr,ix,bias, ITE(guard, e, GetI(descr,ix,bias)))
+ // Which when flattened out is:
+ // t1 = GetI(descr,ix,bias)
+ // t2 = ITE(guard, e, t1)
+ // PutI(descr,ix,bias, t2)
+ IRPutI* details = st->Ist.PutI.details;
+ IRRegArray* descr = details->descr;
+ IRExpr* ix = details->ix;
+ Int bias = details->bias;
+ IRExpr* e = details->data;
+ IRType ty = typeOfIRExpr(bb->tyenv, e);
+ IRTemp t1 = newIRTemp(bb->tyenv, ty);
+ IRTemp t2 = newIRTemp(bb->tyenv, ty);
+ addStmtToIRSB(bb, IRStmt_WrTmp(t1, IRExpr_GetI(descr,ix,bias)));
+ addStmtToIRSB(bb, IRStmt_WrTmp(t2, IRExpr_ITE(IRExpr_RdTmp(guard),
+ e, IRExpr_RdTmp(t1))));
+ addStmtToIRSB(bb, IRStmt_PutI(mkIRPutI(descr,ix,bias, IRExpr_RdTmp(t2))));
+ break;
+ }
case Ist_Exit: {
// Exit(xguard, dst, jk, offsIP)
// ==> t1 = And1(xguard, guard)

View File

@ -0,0 +1,29 @@
commit fb6f7abcbc92506d302fb18a2c5fc853d2929248
Author: Carl Love <cel@us.ibm.com>
Date: Tue Jun 9 10:42:03 2020 -0500
Power PC Fix extraction of the L field for sync instruction
The L field is currently a two bit[22:21] field in ISA 3.0. The size of the
L field has changed over time.
Currently the ISA 3.0 Valgrind sync instruction support code sets the
flag_L for the instruction L field to a five bit value that includes bits
that are marked reserved the sync instruction. This patch fixes the issue for ISA 3.0
to only setting flag_L the specified two bits.
Valgrind bugzilla: https://bugs.kde.org/show_bug.cgi?id=422677
diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c
index 582c59ec0..c4965a19e 100644
--- a/VEX/priv/guest_ppc_toIR.c
+++ b/VEX/priv/guest_ppc_toIR.c
@@ -8777,7 +8777,7 @@ static Bool dis_memsync ( UInt theInstr )
/* X-Form, XL-Form */
UChar opc1 = ifieldOPC(theInstr);
UInt b11to25 = IFIELD(theInstr, 11, 15);
- UChar flag_L = ifieldRegDS(theInstr);
+ UChar flag_L = IFIELD(theInstr, 21, 2); //ISA 3.0
UInt b11to20 = IFIELD(theInstr, 11, 10);
UInt M0 = IFIELD(theInstr, 11, 5);
UChar rD_addr = ifieldRegDS(theInstr);

View File

@ -2,8 +2,8 @@
Summary: Tool for finding memory management bugs in programs
Name: %{?scl_prefix}valgrind
Version: 3.15.0
Release: 10%{?dist}
Version: 3.16.0
Release: 2%{?dist}
Epoch: 1
License: GPLv2+
URL: http://www.valgrind.org/
@ -86,47 +86,19 @@ Patch3: valgrind-3.9.0-ldso-supp.patch
# We want all executables and libraries in libexec instead of lib
# so they are only available for valgrind usage itself and so the
# same directory is used independent of arch.
Patch4: valgrind-3.15.0-pkglibexecdir.patch
# KDE#398649 s390x z13 support doesn't build with older gcc/binutils
# Disable z13 support (on rhel6)
Patch5: valgrind-3.15.0-disable-s390x-z13.patch
Patch4: valgrind-3.16.0-pkglibexecdir.patch
# Add some stack-protector
Patch6: valgrind-3.15.0-some-stack-protector.patch
# KDE#406561 mcinfcallWSRU gdbserver_test fails on ppc64
Patch7: valgrind-3.15.0-ppc64-filter_gdb.patch
# KDE#407218 Add support for the copy_file_range syscall
Patch8: valgrind-3.15.0-copy_file_range.patch
# KDE#407307 Intercept stpcpy also in ld.so for arm64
Patch9: valgrind-3.15.0-arm64-ld-stpcpy.patch
# commit 59784c aarch64 (arm64) isn't a supported architecture for exp-sgcheck.
Patch10: valgrind-3.15.0-exp-sgcheck-no-aarch64.patch
# commit 917e42 Make memcheck/tests/arm64-linux/scalar work under root
Patch11: valgrind-3.15.0-scalar-arm64.patch
# commit abc09f Make memcheck/tests/x86-linux/scalar test work under root.
Patch12: valgrind-3.15.0-scalar-x86.patch
# KDE#407764 s390x: drd fails on z13 due to function wrapping issue
Patch13: valgrind-3.15.0-s390x-wrap-drd.patch
Patch5: valgrind-3.16.0-some-stack-protector.patch
# Add some -Wl,z,now.
Patch14: valgrind-3.15.0-some-Wl-z-now.patch
Patch6: valgrind-3.16.0-some-Wl-z-now.patch
# KDE#408009 Expose rdrand and f16c even on avx if host cpu supports them
Patch15: valgrind-3.15.0-avx-rdrand-f16c.patch
# KDE#422677 PPC sync instruction L field should only be 2 bits in ISA 3.0
Patch7: valgrind-3.16.0-ppc-L-field.patch
# KDE#408091 Missing pkey syscalls
Patch16: valgrind-3.15.0-pkey.patch
# KDE#408414 Add support for preadv2 and pwritev2 syscalls
Patch17: valgrind-3.15.0-preadv2-pwritev2.patch
# KDE#422715 x86: vex: the `impossible' happened: expr_is_guardable
Patch8: valgrind-3.16.0-387-float.patch
BuildRequires: glibc-devel
@ -154,6 +126,9 @@ BuildRequires: perl(Getopt::Long)
BuildRequires: automake
BuildRequires: autoconf
# For make check validating the documentation
BuildRequires: docbook-dtds
%{?scl:Requires:%scl_runtime}
# We need to fixup selinux file context when doing a scl build.
@ -253,32 +228,14 @@ Valgrind User Manual for details.
%patch3 -p1
%patch4 -p1
# Disable s390x z13 support on old rhel, binutils is just too old.
%if 0%{?rhel} == 6
%patch5 -p1
%endif
# Old rhel gcc doesn't have -fstack-protector-strong.
%if 0%{?fedora} || 0%{?rhel} >= 7
%patch5 -p1
%patch6 -p1
%endif
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
# This depends on patch6, old rhel gcc doesn't have -fstack-protector-strong.
%if 0%{?fedora} || 0%{?rhel} >= 7
%patch14 -p1
%endif
%patch15 -p1
%patch16 -p1
%patch17 -p1
%build
@ -499,6 +456,16 @@ fi
%endif
%changelog
* Wed Jun 24 2020 Mark Wielaard <mjw@redhat.com> - 3.16.0-2
- Add valgrind-3.16.0-ppc-L-field.patch
- Add valgrind-3.16.0-387-float.patch
* Thu May 28 2020 Mark Wielaard <mjw@redhat.com> - 3.16.0-1
- Update to upstream valgrind 3.16.0 final.
* Fri Feb 14 2020 Mark Wielaard <mjw@redhat.com> - 3.15.0-11
- Add valgrind-3.15.0-s390x-HRcVec128.patch
* Mon Aug 5 2019 Mark Wielaard <mjw@redhat.com> - 3.15.0-10
- Add valgrind-3.15.0-preadv2-pwritev2.patch