From b4cc7815ba722426c5456831f858a2aeceb3761f 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 +- NEWS | 1 + configure.ac | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Makefile.tool.am b/Makefile.tool.am index df95029138..4ce6d5ab0d 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/NEWS b/NEWS index c22c82131d..a4e7533115 100644 --- 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 diff --git a/configure.ac b/configure.ac index 0cf84a1c00..1d4164a7d8 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.47.2