yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-trace-use-STAP_SDT_V2-to-work-around-symbol-visibili.patch

8fced6
From ba3068eb1a349ec4ed8b7ccdae76450f0c315be9 Mon Sep 17 00:00:00 2001
8fced6
From: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
Date: Thu, 19 Nov 2020 17:23:11 -0500
8fced6
Subject: [PATCH 18/18] trace: use STAP_SDT_V2 to work around symbol visibility
8fced6
MIME-Version: 1.0
8fced6
Content-Type: text/plain; charset=UTF-8
8fced6
Content-Transfer-Encoding: 8bit
8fced6
8fced6
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
Message-id: <20201119172311.942629-2-stefanha@redhat.com>
8fced6
Patchwork-id: 99779
8fced6
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] trace: use STAP_SDT_V2 to work around symbol visibility
8fced6
Bugzilla: 1898700
8fced6
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
8fced6
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
8fced6
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8fced6
8fced6
QEMU binaries no longer launch successfully with recent SystemTap
8fced6
releases. This is because modular QEMU builds link the sdt semaphores
8fced6
into the main binary instead of into the shared objects where they are
8fced6
used. The symbol visibility of semaphores is 'hidden' and the dynamic
8fced6
linker prints an error during module loading:
8fced6
8fced6
  $ ./configure --enable-trace-backends=dtrace --enable-modules ...
8fced6
  ...
8fced6
  Failed to open module: /builddir/build/BUILD/qemu-4.2.0/s390x-softmmu/../block-curl.so: undefined symbol: qemu_curl_close_semaphore
8fced6
8fced6
The long-term solution is to generate per-module dtrace .o files and
8fced6
link them into the module instead of the main binary.
8fced6
8fced6
In the short term we can define STAP_SDT_V2 so dtrace(1) produces a .o
8fced6
file with 'default' symbol visibility instead of 'hidden'. This
8fced6
workaround is small and easier to merge for QEMU 5.2 and downstream
8fced6
backports.
8fced6
8fced6
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1898700
8fced6
Cc: wcohen@redhat.com
8fced6
Cc: fche@redhat.com
8fced6
Cc: kraxel@redhat.com
8fced6
Cc: rjones@redhat.com
8fced6
Cc: ddepaula@redhat.com
8fced6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
8fced6
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8fced6
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
8fced6
8fced6
(cherry picked from commit 4b265c79a85bb35abe19aacea6954c1616521639)
8fced6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
8fced6
Conflicts:
8fced6
  trace/meson.build
8fced6
  Downstream uses makefiles, so move the dtrace invocation changes to
8fced6
  rules.mak and Makefile.
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 Makefile  | 4 ++--
8fced6
 configure | 7 +++++++
8fced6
 rules.mak | 2 +-
8fced6
 3 files changed, 10 insertions(+), 3 deletions(-)
8fced6
8fced6
diff --git a/Makefile b/Makefile
8fced6
index ff05c309497..29b01a13ee3 100644
8fced6
--- a/Makefile
8fced6
+++ b/Makefile
8fced6
@@ -198,7 +198,7 @@ tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
8fced6
 		$< > $@,"GEN","$(@:%-timestamp=%)")
8fced6
 
8fced6
 %/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
8fced6
-	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
8fced6
+	$(call quiet-command,dtrace -o $@ -DSTAP_SDT_V2 -h -s $<, "GEN","$@")
8fced6
 
8fced6
 %/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
8fced6
 
8fced6
@@ -258,7 +258,7 @@ trace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config
8fced6
 		$< > $@,"GEN","$(@:%-timestamp=%)")
8fced6
 
8fced6
 trace-dtrace-root.h: trace-dtrace-root.dtrace
8fced6
-	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
8fced6
+	$(call quiet-command,dtrace -o $@ -DSTAP_SDT_V2 -h -s $<, "GEN","$@")
8fced6
 
8fced6
 trace-dtrace-root.o: trace-dtrace-root.dtrace
8fced6
 
8fced6
diff --git a/configure b/configure
8fced6
index 5120c1409a7..c62b61403f6 100755
8fced6
--- a/configure
8fced6
+++ b/configure
8fced6
@@ -5275,6 +5275,13 @@ if have_backend "dtrace"; then
8fced6
   trace_backend_stap="no"
8fced6
   if has 'stap' ; then
8fced6
     trace_backend_stap="yes"
8fced6
+
8fced6
+    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
8fced6
+    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
8fced6
+    # instead. QEMU --enable-modules depends on this because the SystemTap
8fced6
+    # semaphores are linked into the main binary and not the module's shared
8fced6
+    # object.
8fced6
+    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
8fced6
   fi
8fced6
 fi
8fced6
 
8fced6
diff --git a/rules.mak b/rules.mak
8fced6
index 967295dd2b6..bdfc223a5a1 100644
8fced6
--- a/rules.mak
8fced6
+++ b/rules.mak
8fced6
@@ -101,7 +101,7 @@ LINK = $(call quiet-command, $(LINKPROG) $(QEMU_LDFLAGS) $(QEMU_CFLAGS) $(CFLAGS
8fced6
 	       -c -o $@ $<,"OBJC","$(TARGET_DIR)$@")
8fced6
 
8fced6
 %.o: %.dtrace
8fced6
-	$(call quiet-command,dtrace -o $@ -G -s $<,"GEN","$(TARGET_DIR)$@")
8fced6
+	$(call quiet-command,dtrace -o $@ -DSTAP_SDT_V2 -G -s $<,"GEN","$(TARGET_DIR)$@")
8fced6
 
8fced6
 DSO_OBJ_CFLAGS := -fPIC -DBUILD_DSO
8fced6
 module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS)
8fced6
-- 
8fced6
2.27.0
8fced6