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

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