]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 470978 - s390x: Link the tools with -Wl,--s390-pgste
authorAndreas Arnez <arnez@linux.ibm.com>
Thu, 15 Jun 2023 15:24:53 +0000 (17:24 +0200)
committerAndreas Arnez <arnez@linux.ibm.com>
Fri, 16 Jun 2023 16:04:22 +0000 (18:04 +0200)
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
NEWS
configure.ac

index df95029138347748f966792176b3d3001ed86023..4ce6d5ab0d435c79692d5fec9e23abfd8c089a44 100644 (file)
@@ -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/NEWS b/NEWS
index c22c82131dfa988ba4e8f2eaf8aa4bc06444eb4f..a4e7533115f8ac7bda4e276862c03d6f8bc35a45 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
         (Bool vgPlain_realpath(const HChar *, HChar *)):
         Assertion 'resolved' failed
 470830  Don't print actions vgdb me ... continue for vgdb --multi mode
+470978  s390x: Valgrind cannot start qemu-kvm when "sysctl vm.allocate_pgste=0"
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 0cf84a1c00be295042f8f1f0d26b703170fe8aa7..1d4164a7d82c27c9c414891cebe9d5e33968c6e1 100755 (executable)
@@ -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])