From b49ceb2e0dcdb03ce3abeef6ffe74152ed642843 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 23 Jun 2023 17:45:59 +0200 Subject: [PATCH] 3.21.0-7 - Add valgrind-3.21.0-pgste.patch Resolves: #2208819 [RHEL9.3][valgrind][s390x] valgrind cannot work as expected on qemu-kvm --- valgrind-3.21.0-pgste.patch | 73 +++++++++++++++++++++++++++++++++++++ valgrind.spec | 10 ++++- 2 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 valgrind-3.21.0-pgste.patch diff --git a/valgrind-3.21.0-pgste.patch b/valgrind-3.21.0-pgste.patch new file mode 100644 index 0000000..4646aa2 --- /dev/null +++ b/valgrind-3.21.0-pgste.patch @@ -0,0 +1,73 @@ +From 56f1bd12c92806fd18337ba4cd3c0a8d714d0e94 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +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 + diff --git a/valgrind.spec b/valgrind.spec index 4a30af3..ce51d29 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Dynamic analysis tools to detect memory or thread bugs and profile Name: %{?scl_prefix}valgrind Version: 3.21.0 -Release: 3%{?dist} +Release: 7%{?dist} Epoch: 1 License: GPLv2+ URL: https://www.valgrind.org/ @@ -104,6 +104,10 @@ Patch9: valgrind-3.21.0-realloc-again.patch 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 @@ -248,6 +252,7 @@ Valgrind User Manual for details. %patch9 -p1 %patch10 -p1 %patch11 -p1 +%patch12 -p1 %build @@ -481,11 +486,12 @@ fi %endif %changelog -* Fri Jun 23 2023 Mark Wielaard +* Fri Jun 23 2023 Mark Wielaard - 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á - 3.21.0-3 - Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch