import CS valgrind-3.21.0-8.el8

This commit is contained in:
eabdullin 2023-09-27 14:18:24 +00:00
parent 5774bc117a
commit 3fa14c83dc
12 changed files with 692 additions and 33 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/valgrind-3.19.0.tar.bz2
SOURCES/valgrind-3.21.0.tar.bz2

View File

@ -1 +1 @@
294c341b421b4d9534e42e8125f509c148f48c17 SOURCES/valgrind-3.19.0.tar.bz2
817d769743d278b5d07526e85115082054e9bf9c SOURCES/valgrind-3.21.0.tar.bz2

View File

@ -35,19 +35,6 @@ index 1b7842b..e211eec 100644
if HAVE_DLINFO_RTLD_DI_TLS_MODID
getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDADD = $(LDADD) -ldl
endif
diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am
index f572741..1c07e50 100644
--- a/cachegrind/Makefile.am
+++ b/cachegrind/Makefile.am
@@ -27,7 +27,7 @@ cg_merge_SOURCES = cg_merge.c
cg_merge_CPPFLAGS = $(AM_CPPFLAGS_PRI)
cg_merge_CFLAGS = $(AM_CFLAGS_PRI) -fstack-protector-strong
cg_merge_CCASFLAGS = $(AM_CCASFLAGS_PRI)
-cg_merge_LDFLAGS = $(AM_CFLAGS_PRI)
+cg_merge_LDFLAGS = $(AM_CFLAGS_PRI) -Wl,-z,now
# If there is no secondary platform, and the platforms include x86-darwin,
# then the primary platform must be x86-darwin. Hence:
if ! VGCONF_HAVE_PLATFORM_SEC
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 3c73210..fb6b7bb 100644
--- a/coregrind/Makefile.am

View File

@ -35,19 +35,6 @@ index 56cc5ef..1b7842b 100644
getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_CCASFLAGS = $(AM_CCASFLAGS_PRI)
getoff_@VGCONF_ARCH_PRI@_@VGCONF_OS@_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@
if HAVE_DLINFO_RTLD_DI_TLS_MODID
diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am
index f8447a1..f572741 100644
--- a/cachegrind/Makefile.am
+++ b/cachegrind/Makefile.am
@@ -25,7 +25,7 @@ bin_PROGRAMS = cg_merge
cg_merge_SOURCES = cg_merge.c
cg_merge_CPPFLAGS = $(AM_CPPFLAGS_PRI)
-cg_merge_CFLAGS = $(AM_CFLAGS_PRI)
+cg_merge_CFLAGS = $(AM_CFLAGS_PRI) -fstack-protector-strong
cg_merge_CCASFLAGS = $(AM_CCASFLAGS_PRI)
cg_merge_LDFLAGS = $(AM_CFLAGS_PRI)
# If there is no secondary platform, and the platforms include x86-darwin,
diff --git a/configure.ac b/configure.ac
index f8c798b..ccc8f52 100755
--- a/configure.ac

View File

@ -0,0 +1,152 @@
From e3602b3eec0696b183722ea21da14588cf205c74 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Sun, 14 May 2023 23:34:05 +0200
Subject: [PATCH] Add --with-gdbscripts-dir=PATH configure option
Currently the gdb valgrind scripts are installed under VG_LIBDIR
which is normally pkglibexecdir which is likely not in the default
gdb safe-path (a list of directories from which it is safe to
auto-load files). So users will have to add the directory to their
.gdbinit file.
This patch adds a --with-gdbscripts-dir=PATH configure option that
sets VG_GDBSCRIPTS_DIR to the given PATH (${libexecdir}/valgrind if
not given). A user can also configure --without-gdbscripts-dir to
disable adding a .debug_gdb_scripts section to the vgpreload library
and installing the valgrind-monitor python scripts completely.
Use VG_GDBSCRIPTS_DIR as gdbscriptsdir to install the valgrind-monitor
python files and pass it with CPPFLAGS when building vg_preloaded.c
and vgdb.c to use instead of VG_LIBDIR.
https://bugs.kde.org/show_bug.cgi?id=469768
---
NEWS | 8 ++++++++
configure.ac | 17 +++++++++++++++++
coregrind/Makefile.am | 20 +++++++++++++++-----
coregrind/vg_preloaded.c | 4 +++-
coregrind/vgdb.c | 9 +++++++--
5 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index 15fbf5ea2..0cf84a1c0 100755
--- a/configure.ac
+++ b/configure.ac
@@ -1198,6 +1198,23 @@ AC_MSG_RESULT([$xcodedir])
AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
AC_SUBST(XCODE_DIR, [$xcodedir])])
+#----------------------------------------------------------------------------
+# Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir)
+#----------------------------------------------------------------------------
+AC_MSG_CHECKING([where gdb scripts are installed])
+AC_ARG_WITH(gdbscripts-dir,
+ [ --with-gdbscripts-dir=PATH Specify path to install gdb scripts],
+ [gdbscriptsdir=${withval}],
+ [gdbscriptsdir=${libexecdir}/valgrind])
+AC_MSG_RESULT([$gdbscriptsdir])
+if test "x$gdbscriptsdir" != "xno"; then
+ AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir])
+ AM_CONDITIONAL(GDBSCRIPTS, true)
+else
+ AC_SUBST(VG_GDBSCRIPTS_DIR, [])
+ AM_CONDITIONAL(GDBSCRIPTS, false)
+fi
+
#----------------------------------------------------------------------------
# Libc and suppressions
#----------------------------------------------------------------------------
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index 553211782..8a7f753a6 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -101,7 +101,7 @@
vgdb_SOURCES += vgdb-invoker-freebsd.c
endif
-vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI)
+vgdb_CPPFLAGS = $(AM_CPPFLAGS_PRI) $(GDB_SCRIPTS_DIR)
vgdb_CFLAGS = $(AM_CFLAGS_PRI) $(LTO_CFLAGS) -fstack-protector-strong
vgdb_CCASFLAGS = $(AM_CCASFLAGS_PRI)
vgdb_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ -Wl,-z,now
@@ -624,9 +624,15 @@ if VGCONF_OS_IS_DARWIN
noinst_DSYMS = $(noinst_PROGRAMS)
endif
+if GDBSCRIPTS
+ GDB_SCRIPTS_DIR=-DVG_GDBSCRIPTS_DIR="\"@VG_GDBSCRIPTS_DIR@\""
+else
+ GDB_SCRIPTS_DIR=
+endif
+
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CPPFLAGS = \
- $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
+ $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) $(GDB_SCRIPTS_DIR)
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_CFLAGS = \
$(AM_CFLAGS_PSO_@VGCONF_PLATFORM_PRI_CAPS@)
vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS = \
@@ -634,7 +640,7 @@ vgpreload_core_@VGCONF_ARCH_PRI@_@VGCONF_OS@_so_LDFLAGS = \
if VGCONF_HAVE_PLATFORM_SEC
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_SOURCES = vg_preloaded.c
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CPPFLAGS = \
- $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@)
+ $(AM_CPPFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) $(GDBSCRIPTS_DIR)
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_CFLAGS = \
$(AM_CFLAGS_PSO_@VGCONF_PLATFORM_SEC_CAPS@)
vgpreload_core_@VGCONF_ARCH_SEC@_@VGCONF_OS@_so_LDFLAGS = \
@@ -766,8 +772,12 @@ GDBSERVER_XML_FILES = \
# so as to make sure these get copied into the install tree
vglibdir = $(pkglibexecdir)
vglib_DATA = $(GDBSERVER_XML_FILES)
-vglib_DATA += m_gdbserver/valgrind-monitor.py
-vglib_DATA += m_gdbserver/valgrind-monitor-def.py
+
+if GDBSCRIPTS
+gdbscriptsdir = @VG_GDBSCRIPTS_DIR@
+gdbscripts_DATA = m_gdbserver/valgrind-monitor.py
+gdbscripts_DATA += m_gdbserver/valgrind-monitor-def.py
+endif
# so as to make sure these get copied into the tarball
EXTRA_DIST += $(GDBSERVER_XML_FILES)
diff --git a/coregrind/vg_preloaded.c b/coregrind/vg_preloaded.c
index d6e05898c..86f6ac5a2 100644
--- a/coregrind/vg_preloaded.c
+++ b/coregrind/vg_preloaded.c
@@ -61,7 +61,9 @@
.popsection \n\
");
-DEFINE_GDB_PY_SCRIPT(VG_LIBDIR "/valgrind-monitor.py")
+#ifdef VG_GDBSCRIPTS_DIR
+DEFINE_GDB_PY_SCRIPT(VG_GDBSCRIPTS_DIR "/valgrind-monitor.py")
+#endif
#endif
#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd)
diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c
index 8ec424077..56a969de7 100644
--- a/coregrind/vgdb.c
+++ b/coregrind/vgdb.c
@@ -1982,10 +1982,15 @@ void usage(void)
" -d arg tells to show debug info. Multiple -d args for more debug info\n"
"\n"
" -h --help shows this message\n"
+#ifdef VG_GDBSCRIPTS_DIR
" The GDB python code defining GDB front end valgrind commands is:\n %s\n"
+#endif
" To get help from the Valgrind gdbserver, use vgdb help\n"
-"\n", vgdb_prefix_default(), VG_LIBDIR "/valgrind-monitor.py"
- );
+"\n", vgdb_prefix_default()
+#ifdef VG_GDBSCRIPTS_DIR
+ , VG_GDBSCRIPTS_DIR "/valgrind-monitor.py"
+#endif
+ );
invoker_restrictions_msg();
}
--
2.31.1

View File

@ -0,0 +1,12 @@
diff --git a/callgrind/callgrind_control.in b/callgrind/callgrind_control.in
index 083ffa29f..eb50c16ad 100644
--- a/callgrind/callgrind_control.in
+++ b/callgrind/callgrind_control.in
@@ -22,7 +22,6 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-use strict;
use warnings;
use File::Basename;

View File

@ -0,0 +1,22 @@
diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c
index b32f13f76..464e8d4ca 100644
--- a/shared/vg_replace_strmem.c
+++ b/shared/vg_replace_strmem.c
@@ -1128,7 +1128,7 @@ static inline void my_exit ( int x )
MEMMOVE_OR_MEMCPY(20181, soname, fnname, 0)
#define MEMCPY(soname, fnname) \
- MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1)
+ MEMMOVE_OR_MEMCPY(20180, soname, fnname, 0) /* See KDE bug #402833 */
#if defined(VGO_linux)
/* For older memcpy we have to use memmove-like semantics and skip
@@ -1714,8 +1714,6 @@ static inline void my_exit ( int x )
RECORD_COPY(len); \
if (len == 0) \
return dst; \
- if (is_overlap(dst, src, len, len)) \
- RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \
if ( dst > src ) { \
d = (HChar *)dst + len - 1; \
s = (const HChar *)src + len - 1; \

View File

@ -0,0 +1,73 @@
From 56f1bd12c92806fd18337ba4cd3c0a8d714d0e94 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Thu, 15 Jun 2023 17:24:53 +0200
Subject: [PATCH] Bug 470978 - s390x: Link the tools with -Wl,--s390-pgste
Programs that require the PGSTE mode to be enabled may currently fail
under Valgrind. In particular this affects qemu-kvm.
While it is also possible to enable the PGSTE mode globally with
sysctl vm.allocate_psgte=1
the problem can more easily be prevented by linking the Valgrind tools
with -Wl,--s390-pgste. Add a configure check if the linker supports this,
and activate the flag if it does.
To verify the intended result, the following shell command can be used to
list the executables having this flag set:
find . -type f -perm -u+x -execdir \
/bin/sh -c 'readelf -lW $0 2>/dev/null | grep PGSTE' {} \; -print
---
Makefile.tool.am | 2 +-
configure.ac | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Makefile.tool.am b/Makefile.tool.am
index df9502913..4ce6d5ab0 100644
--- a/Makefile.tool.am
+++ b/Makefile.tool.am
@@ -78,7 +78,7 @@ TOOL_LDFLAGS_ARM64_LINUX = \
$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@
TOOL_LDFLAGS_S390X_LINUX = \
- $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@
+ $(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@ @FLAG_S390_PGSTE@
TOOL_LDFLAGS_X86_DARWIN = \
$(TOOL_LDFLAGS_COMMON_DARWIN) -arch i386
diff --git a/configure.ac b/configure.ac
index 0cf84a1c0..1d4164a7d 100755
--- a/configure.ac
+++ b/configure.ac
@@ -3096,6 +3096,26 @@ AC_SUBST([FLAG_NO_BUILD_ID], [""])
fi
CFLAGS=$safe_CFLAGS
+# On s390x, if the linker supports -Wl,--s390-pgste, then we build the
+# tools with that flag. This enables running programs that need it, such
+# as qemu-kvm.
+if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then
+AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste])
+safe_CFLAGS=$CFLAGS
+CFLAGS="-Wl,--s390-pgste"
+
+AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([ ], [return 0;])],
+[
+ AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"])
+ AC_MSG_RESULT([yes])
+], [
+ AC_SUBST([FLAG_S390_PGSTE], [""])
+ AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+fi
+
# does the ppc assembler support "mtocrf" et al?
AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
--
2.40.1

View File

@ -0,0 +1,167 @@
From b904112d7084227f8d6fab322bc360a8a6240a51 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 1 Jun 2023 16:10:56 +0200
Subject: [PATCH] memcheck: Handle Err_ReallocSizeZero in MC_(eq_Error)
When an realloc size zero error is emitted MC_(eq_Error) is called to
see if the errors can be deduplicated. This crashed since
Err_ReallocSizeZero wasn't handled. Handle it like Err_Free.
Also add a testcase for this case and test with both
--realloc-zero-bytes-frees=yes and
--realloc-zero-bytes-frees=no.
Which will report a different number of errors.
https://bugs.kde.org/show_bug.cgi?id=470520
---
memcheck/mc_errors.c | 1 +
memcheck/tests/Makefile.am | 7 +++++++
memcheck/tests/realloc_size_zero_again.c | 15 +++++++++++++++
.../realloc_size_zero_again_no.stderr.exp | 18 ++++++++++++++++++
.../realloc_size_zero_again_no.stdout.exp | 0
.../tests/realloc_size_zero_again_no.vgtest | 2 ++
.../realloc_size_zero_again_yes.stderr.exp | 18 ++++++++++++++++++
.../realloc_size_zero_again_yes.stdout.exp | 0
.../tests/realloc_size_zero_again_yes.vgtest | 2 ++
9 files changed, 63 insertions(+)
create mode 100644 memcheck/tests/realloc_size_zero_again.c
create mode 100644 memcheck/tests/realloc_size_zero_again_no.stderr.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_no.stdout.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_no.vgtest
create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stderr.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_yes.stdout.exp
create mode 100644 memcheck/tests/realloc_size_zero_again_yes.vgtest
diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c
index 00d6ec301..65210a220 100644
--- a/memcheck/mc_errors.c
+++ b/memcheck/mc_errors.c
@@ -1041,6 +1041,7 @@ Bool MC_(eq_Error) ( VgRes res, const Error* e1, const Error* e2 )
case Err_IllegalMempool:
case Err_Overlap:
case Err_Cond:
+ case Err_ReallocSizeZero:
return True;
case Err_FishyValue:
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index 71c38acba..5a17fd35d 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -291,8 +291,14 @@ EXTRA_DIST = \
realloc_size_zero.vgtest \
realloc_size_zero_yes.stderr.exp realloc_size_zero_yes.stdout.exp \
realloc_size_zero_yes.vgtest \
+ realloc_size_zero_again_yes.stderr.exp \
+ realloc_size_zero_again_yes.stdout.exp \
+ realloc_size_zero_again_yes.vgtest \
realloc_size_zero_no.stderr.exp realloc_size_zero_no.stdout.exp \
realloc_size_zero_no.vgtest \
+ realloc_size_zero_again_no.stderr.exp \
+ realloc_size_zero_again_no.stdout.exp \
+ realloc_size_zero_again_no.vgtest \
realloc_size_zero_off.stderr.exp realloc_size_zero_off.stdout.exp \
realloc_size_zero_off.vgtest \
realloc_size_zero_mismatch.stderr.exp \
@@ -459,6 +465,7 @@ check_PROGRAMS = \
posix_memalign \
post-syscall \
realloc_size_zero realloc_size_zero_mismatch \
+ realloc_size_zero_again \
realloc1 realloc2 realloc3 \
recursive-merge \
resvn_stack \
diff --git a/memcheck/tests/realloc_size_zero_again.c b/memcheck/tests/realloc_size_zero_again.c
new file mode 100644
index 000000000..782d4bde5
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again.c
@@ -0,0 +1,15 @@
+#include <stdlib.h>
+
+int
+main ()
+{
+ char *p = malloc (1024);
+ for (int i = 3; i >= 0; i--)
+ for (int j = 0; j <= 3; j++)
+ {
+ char *q = realloc (p, i * j * 512);
+ p = q;
+ }
+
+ free (p);
+}
diff --git a/memcheck/tests/realloc_size_zero_again_no.stderr.exp b/memcheck/tests/realloc_size_zero_again_no.stderr.exp
new file mode 100644
index 000000000..b9c061d1a
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_no.stderr.exp
@@ -0,0 +1,18 @@
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0)
+
+7 errors in context 1 of 1:
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0)
diff --git a/memcheck/tests/realloc_size_zero_again_no.stdout.exp b/memcheck/tests/realloc_size_zero_again_no.stdout.exp
new file mode 100644
index 000000000..e69de29bb
diff --git a/memcheck/tests/realloc_size_zero_again_no.vgtest b/memcheck/tests/realloc_size_zero_again_no.vgtest
new file mode 100644
index 000000000..f1757b6c1
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_no.vgtest
@@ -0,0 +1,2 @@
+prog: realloc_size_zero_again
+vgopts: -q -s --realloc-zero-bytes-frees=no
diff --git a/memcheck/tests/realloc_size_zero_again_yes.stderr.exp b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp
new file mode 100644
index 000000000..d40aa2455
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_yes.stderr.exp
@@ -0,0 +1,18 @@
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0)
+
+5 errors in context 1 of 1:
+realloc() with size 0
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ ...
+ Address 0x........ is 0 bytes inside a block of size 1,024 alloc'd
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ ...
+
+ERROR SUMMARY: 5 errors from 1 contexts (suppressed: 0 from 0)
diff --git a/memcheck/tests/realloc_size_zero_again_yes.stdout.exp b/memcheck/tests/realloc_size_zero_again_yes.stdout.exp
new file mode 100644
index 000000000..e69de29bb
diff --git a/memcheck/tests/realloc_size_zero_again_yes.vgtest b/memcheck/tests/realloc_size_zero_again_yes.vgtest
new file mode 100644
index 000000000..215392ed6
--- /dev/null
+++ b/memcheck/tests/realloc_size_zero_again_yes.vgtest
@@ -0,0 +1,2 @@
+prog: realloc_size_zero_again
+vgopts: -q -s --realloc-zero-bytes-frees=yes
--
2.40.1

View File

@ -0,0 +1,105 @@
From 21f7a2af2805a02a144c81f12895c134f4a171a3 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Mon, 22 May 2023 19:49:08 +0200
Subject: [PATCH 2/2] Bug 470132 - s390x: Increase test coverage for VGM
Add more tests for the VGM instruction, to verify the fix for the VGM
wrap-around case. Also test setting unused bits in the I2 and I3 fields,
to check that Valgrind ignores them as it should.
---
none/tests/s390x/vec2.c | 44 ++++++++++++++++++++++++++++++++
none/tests/s390x/vec2.stdout.exp | 20 +++++++++++++++
2 files changed, 64 insertions(+)
diff --git a/none/tests/s390x/vec2.c b/none/tests/s390x/vec2.c
index 73b04dee4..c473a2a9a 100644
--- a/none/tests/s390x/vec2.c
+++ b/none/tests/s390x/vec2.c
@@ -301,6 +301,49 @@ static void test_all_fp_int_conversions()
#undef TEST_EXEC
#undef TEST_GENERATE
+/* -- Vector generate mask -- */
+
+#define TEST_GENERATE(insn, i2, i3, m4) \
+ static void test_vgm_##i2##_##i3##_##m4(void) \
+ { \
+ ulong_v out = vec_ini; \
+ __asm__("vgm %[out]," #i2 "," #i3 "," #m4 : [out] "+v"(out) : :); \
+ printf("\t%016lx %016lx\n", out[0], out[1]); \
+ }
+
+#define TEST_EXEC(insn, i2, i3, m4) \
+ do { \
+ puts(#insn " " #i2 "," #i3 "," #m4); \
+ test_vgm_##i2##_##i3##_##m4(); \
+ } while (0)
+
+#define INSNS \
+ XTEST(vgmb, 2, 1, 0); \
+ XTEST(vgmb, 0xf7, 0x30, 0); \
+ XTEST(vgmb, 0, 0, 0); \
+ XTEST(vgmh, 3, 2, 1); \
+ XTEST(vgmh, 15, 15, 1); \
+ XTEST(vgmf, 4, 3, 2); \
+ XTEST(vgmf, 16, 17, 2); \
+ XTEST(vgmg, 55, 63, 3); \
+ XTEST(vgmg, 43, 55, 3); \
+ XTEST(vgmg, 63, 2, 3);
+
+#define XTEST TEST_GENERATE
+INSNS
+#undef XTEST
+
+static void test_all_generate_mask()
+{
+#define XTEST TEST_EXEC
+ INSNS
+#undef XTEST
+}
+
+#undef INSNS
+#undef TEST_EXEC
+#undef TEST_GENERATE
+
int main()
{
@@ -310,5 +353,6 @@ int main()
test_all_double_bitshifts();
test_all_int_fp_conversions();
test_all_fp_int_conversions();
+ test_all_generate_mask();
return 0;
}
diff --git a/none/tests/s390x/vec2.stdout.exp b/none/tests/s390x/vec2.stdout.exp
index b32cbe1bc..2c9ac21c1 100644
--- a/none/tests/s390x/vec2.stdout.exp
+++ b/none/tests/s390x/vec2.stdout.exp
@@ -166,3 +166,23 @@ vcsfp 0
vcsfp 8
00ffffff - - -
00000004 - - -
+vgmb 2,1,0
+ ffffffffffffffff ffffffffffffffff
+vgmb 0xf7,0x30,0
+ 8181818181818181 8181818181818181
+vgmb 0,0,0
+ 8080808080808080 8080808080808080
+vgmh 3,2,1
+ ffffffffffffffff ffffffffffffffff
+vgmh 15,15,1
+ 0001000100010001 0001000100010001
+vgmf 4,3,2
+ ffffffffffffffff ffffffffffffffff
+vgmf 16,17,2
+ 0000c0000000c000 0000c0000000c000
+vgmg 55,63,3
+ 00000000000001ff 00000000000001ff
+vgmg 43,55,3
+ 00000000001fff00 00000000001fff00
+vgmg 63,2,3
+ e000000000000001 e000000000000001
--
2.40.1

View File

@ -0,0 +1,99 @@
From 70ef4417837b690755feede0088331a28b102c65 Mon Sep 17 00:00:00 2001
From: Andreas Arnez <arnez@linux.ibm.com>
Date: Mon, 22 May 2023 18:57:35 +0200
Subject: [PATCH 1/2] Bug 470132 - s390x: Fix the wrap-around case in VGM
Valgrind's implementation of VGM is incomplete:
* It doesn't support generating a wrap-around bit mask. Such a mask
should result when the ending bit position is smaller than the starting
bit position. Valgrind runs into an assertion failure instead.
* It doesn't ignore unused bits in the I2 and I3 fields of the
instruction, as it should.
Fix this by re-implementing the main logic in s390_irgen_VGM().
---
VEX/priv/guest_s390_toIR.c | 57 +++++++++++++++-----------------------
1 file changed, 22 insertions(+), 35 deletions(-)
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
index 11dda41ef..d9d746c38 100644
--- a/VEX/priv/guest_s390_toIR.c
+++ b/VEX/priv/guest_s390_toIR.c
@@ -16388,50 +16388,37 @@ s390_irgen_VGBM(UChar v1, UShort i2, UChar m3 __attribute__((unused)))
static const HChar *
s390_irgen_VGM(UChar v1, UShort i2, UChar m3)
{
- UChar from = (i2 & 0xff00) >> 8;
- UChar to = (i2 & 0x00ff);
- ULong value = 0UL;
- IRType type = s390_vr_get_type(m3);
- vassert(from <= to);
-
- UChar maxIndex = 0;
- switch (type) {
- case Ity_I8:
- maxIndex = 7;
- break;
- case Ity_I16:
- maxIndex = 15;
- break;
- case Ity_I32:
- maxIndex = 31;
- break;
- case Ity_I64:
- maxIndex = 63;
- break;
- default:
- vpanic("s390_irgen_VGM: unknown type");
- }
-
- for(UChar index = from; index <= to; index++) {
- value |= (1ULL << (maxIndex - index));
- }
-
- IRExpr *fillValue;
- switch (type) {
- case Ity_I8:
+ s390_insn_assert("vgm", m3 <= 3);
+
+ UChar max_idx = (8 << m3) - 1;
+ UChar from = max_idx & (i2 >> 8);
+ UChar to = max_idx & i2;
+ ULong all_one = (1ULL << max_idx << 1) - 1;
+ ULong value = (all_one >> from) ^ (all_one >> to >> 1);
+
+ /* In case of wrap-around we now have a value that needs inverting:
+ to from
+ V V
+ 00000111111111110000000000000000 */
+ if (to < from)
+ value ^= all_one;
+
+ IRExpr* fillValue;
+ switch (m3) {
+ case 0:
fillValue = mkU8(value);
break;
- case Ity_I16:
+ case 1:
fillValue = mkU16(value);
break;
- case Ity_I32:
+ case 2:
fillValue = mkU32(value);
break;
- case Ity_I64:
+ case 3:
fillValue = mkU64(value);
break;
default:
- vpanic("s390_irgen_VGM: unknown type");
+ vpanic("s390_irgen_VGM: unknown element size");
}
s390_vr_fill(v1, fillValue);
--
2.40.1

View File

@ -2,15 +2,13 @@
Summary: Dynamic analysis tools to detect memory or thread bugs and profile
Name: %{?scl_prefix}valgrind
Version: 3.19.0
Release: 1%{?dist}
Version: 3.21.0
Release: 8%{?dist}
Epoch: 1
License: GPLv2+
URL: https://www.valgrind.org/
Group: Development/Debuggers
# Only necessary for RHEL, will be ignored on Fedora
# Are we building for a Software Collection?
%{?scl:%global is_scl 1}
%{!?scl:%global is_scl 0}
@ -86,6 +84,31 @@ Patch3: valgrind-3.16.0-some-stack-protector.patch
# Add some -Wl,z,now.
Patch4: valgrind-3.16.0-some-Wl-z-now.patch
# Workaround https://bugs.kde.org/show_bug.cgi?id=402833
# by disabling overlap checking for memcpy
Patch5: valgrind-3.21.0-no-memcpy-replace-check.patch
# Add --with-gdbscripts-dir=PATH configure option
# https://bugs.kde.org/show_bug.cgi?id=469768
Patch6: valgrind-3.21.0-Add-with-gdbscripts-dir.patch
# Can't run callgrind_control with valgrind 3.21.0 because of perl errors
# https://bugs.kde.org/show_bug.cgi?id=470121
Patch8: valgrind-3.21.0-callgrind_control-no-strict.patch
# Multiple realloc zero errors crash in MC_(eq_Error)
# https://bugs.kde.org/show_bug.cgi?id=470520
Patch9: valgrind-3.21.0-realloc-again.patch
# s390x: Assertion failure on VGM instruction
# https://bugs.kde.org/show_bug.cgi?id=470132
Patch10: valgrind-3.21.0-vgm.patch
Patch11: valgrind-3.21.0-vgm-tests.patch
# s390x: Valgrind cannot start qemu-kvm when "sysctl vm.allocate_pgste=0"
# https://bugs.kde.org/show_bug.cgi?id=470978
Patch12: valgrind-3.21.0-pgste.patch
BuildRequires: make
BuildRequires: glibc-devel
@ -123,6 +146,10 @@ BuildRequires: elfutils-debuginfod-client
Recommends: elfutils-debuginfod-client
%endif
# Some of the python scripts require python 3.9+
BuildRequires: python3.11
BuildRequires: python3.11-rpm-macros
%{?scl:Requires:%scl_runtime}
# We need to fixup selinux file context when doing a scl build.
@ -226,6 +253,15 @@ Valgrind User Manual for details.
%patch4 -p1
%endif
%patch5 -p1
%patch6 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%build
@ -291,7 +327,8 @@ export LDFLAGS
%configure \
--with-mpicc=%{mpiccpath} \
%{only_arch} \
GDB=%{_bindir}/gdb
GDB=%{_bindir}/gdb \
--without-gdbscripts-dir
make %{?_smp_mflags}
@ -451,6 +488,24 @@ fi
%endif
%changelog
* Tue Jun 27 2023 Mark Wielaard <mjw@redhat.com> - 3.21.0-8
- BuildRequire python3.11
* Fri Jun 23 2023 Mark Wielaard <mjw@redhat.com> - 3.21.0-7
- Add valgrind-3.21.0-callgrind_control-no-strict.patch
- Add valgrind-3.21.0-realloc-again.patch
- Update valgrind-3.21.0-no-memcpy-replace-check.patch (memcpy_chk)
- Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch
- Add valgrind-3.21.0-pgste.patch
* Tue May 16 2023 Alexandra Hájková <ahajkova@redhat.com> - 3.21.0-3
- Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch
* Fri May 5 2023 Mark Wielaard <mjw@redhat.com> - 3.21.0-2
- Upgrade to upstream 3.21.0
- Remove upstreamed patches
- Add valgrind-3.21.0-no-memcpy-replace-check.patch
* Tue Apr 19 2022 Mark Wielaard <mjw@redhat.com> - 3.19.0-1
- Upgrade to valgrind 3.19.0. Drop old patches.