Skip to contentSkip to conversation

stubs: Fix notify-event stub linkage error on MinGW

PATCH In review Philippe Mathieu-Daudé 4 participants 7 messages Aug 5, 2020

lore
Share & tools
lore
#0 lore raw

v3 cover stubs: Fix notify-event stub linkage error on MinGW

2 trivial patches to fix the link error reported by Thomas:

LINK tests/test-timed-average.exe
libqemuutil.a(main-loop.o): In function `qemu_notify_event':
util/main-loop.c:139: multiple definition of `qemu_notify_event' tests/test-timed-average.o:/builds/huth/qemu/tests/../stubs/notify-event.c:5: first defined here
collect2: error: ld returned 1 exit status
rules.mak:124: recipe for target 'tests/test-timed-average.exe' failed

Since v2:
- Remove incorrectly added abort() in qemu_timer_notify_cb()

Philippe Mathieu-Daudé (2):
exec: Restrict icount to softmmu
stubs: Remove qemu_notify_event()

 include/sysemu/cpus.h  | 4 ++++
 exec.c                 | 4 ----
 softmmu/cpus.c         | 7 +++++++
 stubs/cpu-get-icount.c | 2 +-
 stubs/notify-event.c   | 6 ------
 stubs/Makefile.objs    | 1 -
 6 files changed, 12 insertions(+), 12 deletions(-)
 delete mode 100644 stubs/notify-event.c
Signature · 1 line
2.21.3
#1 lore raw

PATCH v3 1/2 exec: Restrict icount to softmmu

'icount' feature is only meaningful when using softmmu. Move it out of the globally used exec.c, and define it as 'false' in user-mode emulation.

---
 include/sysemu/cpus.h | 4 ++++
 exec.c                | 4 ----
 softmmu/cpus.c        | 7 +++++++
 3 files changed, 11 insertions(+), 4 deletions(-)
include/sysemu/cpus.h +4 -0
index 3c1da6a018..d8442aa9f0 100644
@@ -11,9 +11,13 @@ void pause_all_vcpus(void);
 void cpu_stop_current(void);
 void cpu_ticks_init(void);
 
+#if !defined(CONFIG_USER_ONLY)
 void configure_icount(QemuOpts *opts, Error **errp);
 extern int use_icount;
 extern int icount_align_option;
+#else
+#define use_icount false
+#endif
 
 /* drift information for info jit command */
 extern int64_t max_delay;
exec.c +0 -4
index 6f381f98e2..a89ffa93c1 100644
@@ -102,10 +102,6 @@ uintptr_t qemu_host_page_size;
 intptr_t qemu_host_page_mask;
 
 #if !defined(CONFIG_USER_ONLY)
-/* 0 = Do not count executed instructions.
-   1 = Precise instruction counting.
-   2 = Adaptive rate instruction counting.  */
-int use_icount;
 
 typedef struct PhysPageEntry PhysPageEntry;
 
softmmu/cpus.c +7 -0
index a802e899ab..a4772034c0 100644
@@ -81,6 +81,13 @@
 
 #endif /* CONFIG_LINUX */
 
+/*
+ * 0 = Do not count executed instructions.
+ * 1 = Precise instruction counting.
+ * 2 = Adaptive rate instruction counting.
+ */
+int use_icount;
+
 static QemuMutex qemu_global_mutex;
 
 int64_t max_delay;
Signature · 1 line
2.21.3
#2 lore raw

Re: [PATCH-for-5.1 v3 1/2] exec: Restrict icount to softmmu

Hi Philippe,

could you take a look if this series already addresses the issue?

https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00067.html

Everything icount related is already moved to softmmu and made TCG only.

I will post a new version of the series today with a couple changes;

the series could then be ready if HVF is already ready with its synchronize_state implementation? Otherwise we'd have to hold back the HVF patch.

Thanks!

Claudio

Quoted 63 lines · Philippe Mathieu-Daudé

'icount' feature is only meaningful when using softmmu. Move it out of the globally used exec.c, and define it as 'false' in user-mode emulation.

---
 include/sysemu/cpus.h | 4 ++++
 exec.c                | 4 ----
 softmmu/cpus.c        | 7 +++++++
 3 files changed, 11 insertions(+), 4 deletions(-)
include/sysemu/cpus.h +4 -0
index 3c1da6a018..d8442aa9f0 100644
@@ -11,9 +11,13 @@ void pause_all_vcpus(void);
 void cpu_stop_current(void);
 void cpu_ticks_init(void);
 
+#if !defined(CONFIG_USER_ONLY)
 void configure_icount(QemuOpts *opts, Error **errp);
 extern int use_icount;
 extern int icount_align_option;
+#else
+#define use_icount false
+#endif
 
 /* drift information for info jit command */
 extern int64_t max_delay;
exec.c +0 -4
index 6f381f98e2..a89ffa93c1 100644
@@ -102,10 +102,6 @@ uintptr_t qemu_host_page_size;
 intptr_t qemu_host_page_mask;
 
 #if !defined(CONFIG_USER_ONLY)
-/* 0 = Do not count executed instructions.
-   1 = Precise instruction counting.
-   2 = Adaptive rate instruction counting.  */
-int use_icount;
 
 typedef struct PhysPageEntry PhysPageEntry;
 
softmmu/cpus.c +7 -0
index a802e899ab..a4772034c0 100644
@@ -81,6 +81,13 @@
 
 #endif /* CONFIG_LINUX */
 
+/*
+ * 0 = Do not count executed instructions.
+ * 1 = Precise instruction counting.
+ * 2 = Adaptive rate instruction counting.
+ */
+int use_icount;
+
 static QemuMutex qemu_global_mutex;
 
 int64_t max_delay;
#3 lore raw

Re: [PATCH-for-5.1 v3 1/2] exec: Restrict icount to softmmu

Quoted 5 lines · Claudio Fontana

Hi Philippe,

could you take a look if this series already addresses the issue?

https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00067.html

I had tagged this series as "after-release" review and hadn't looked at it yet :)

Quoted 2 lines

Everything icount related is already moved to softmmu and made TCG only.

Good. I was looking for a surgical change for 5.1, but I think it is too late to have the WHPX CI running now (Thomas?). So we'll probably ignore my surgical series and proceed with yours when 5.2 development window opens.

Quoted 75 lines

I will post a new version of the series today with a couple changes;

the series could then be ready if HVF is already ready with its synchronize_state implementation? Otherwise we'd have to hold back the HVF patch.

Thanks!

Claudio

Quoted 63 lines · Philippe Mathieu-Daudé

'icount' feature is only meaningful when using softmmu. Move it out of the globally used exec.c, and define it as 'false' in user-mode emulation.

---
 include/sysemu/cpus.h | 4 ++++
 exec.c                | 4 ----
 softmmu/cpus.c        | 7 +++++++
 3 files changed, 11 insertions(+), 4 deletions(-)
include/sysemu/cpus.h +4 -0
index 3c1da6a018..d8442aa9f0 100644
@@ -11,9 +11,13 @@ void pause_all_vcpus(void);
 void cpu_stop_current(void);
 void cpu_ticks_init(void);
 
+#if !defined(CONFIG_USER_ONLY)
 void configure_icount(QemuOpts *opts, Error **errp);
 extern int use_icount;
 extern int icount_align_option;
+#else
+#define use_icount false
+#endif
 
 /* drift information for info jit command */
 extern int64_t max_delay;
exec.c +0 -4
index 6f381f98e2..a89ffa93c1 100644
@@ -102,10 +102,6 @@ uintptr_t qemu_host_page_size;
 intptr_t qemu_host_page_mask;
 
 #if !defined(CONFIG_USER_ONLY)
-/* 0 = Do not count executed instructions.
-   1 = Precise instruction counting.
-   2 = Adaptive rate instruction counting.  */
-int use_icount;
 
 typedef struct PhysPageEntry PhysPageEntry;
 
softmmu/cpus.c +7 -0
index a802e899ab..a4772034c0 100644
@@ -81,6 +81,13 @@
 
 #endif /* CONFIG_LINUX */
 
+/*
+ * 0 = Do not count executed instructions.
+ * 1 = Precise instruction counting.
+ * 2 = Adaptive rate instruction counting.
+ */
+int use_icount;
+
 static QemuMutex qemu_global_mutex;
 
 int64_t max_delay;
Reviewed-by on v3 1/2
#4 lore raw

Re: [PATCH-for-5.1 v3 1/2] exec: Restrict icount to softmmu

In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

'icount' feature is only meaningful when using softmmu. Move it out of the globally used exec.c, and define it as 'false' in user-mode emulation.

---
 include/sysemu/cpus.h | 4 ++++
 exec.c                | 4 ----
 softmmu/cpus.c        | 7 +++++++
 3 files changed, 11 insertions(+), 4 deletions(-)

r~

#5 lore raw

PATCH v3 2/2 stubs: Remove qemu_notify_event()

In reply to Philippe Mathieu-Daudé

We don't need the qemu_notify_event() stub anymore.

---
 stubs/cpu-get-icount.c | 2 +-
 stubs/notify-event.c   | 6 ------
 stubs/Makefile.objs    | 1 -
 3 files changed, 1 insertion(+), 8 deletions(-)
 delete mode 100644 stubs/notify-event.c
stubs/cpu-get-icount.c +1 -1
index b35f844638..4578217fe2 100644
@@ -17,5 +17,5 @@ int64_t cpu_get_icount_raw(void)
 
 void qemu_timer_notify_cb(void *opaque, QEMUClockType type)
 {
-    qemu_notify_event();
+    /* Nothing to do. */
 }
stubs/notify-event.c deleted +0 -6
deleted file mode 100644
index 827bb52d1a..0000000000
@@ -1,6 +0,0 @@
-#include "qemu/osdep.h"
-#include "qemu/main-loop.h"
-
-void qemu_notify_event(void)
-{
-}
stubs/Makefile.objs +0 -1
index d42046afe4..cb374c96db 100644
@@ -12,7 +12,6 @@ stub-obj-y += isa-bus.o
 stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o
 stub-obj-y += monitor-core.o
-stub-obj-y += notify-event.o
 stub-obj-y += pci-bus.o
 stub-obj-y += qmp_memory_device.o
 stub-obj-y += qtest.o
Signature · 1 line
2.21.3
#6 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

2 trivial patches to fix the link error reported by Thomas:

LINK tests/test-timed-average.exe
libqemuutil.a(main-loop.o): In function `qemu_notify_event':
util/main-loop.c:139: multiple definition of `qemu_notify_event' tests/test-timed-average.o:/builds/huth/qemu/tests/../stubs/notify-event.c:5: first defined here
collect2: error: ld returned 1 exit status
rules.mak:124: recipe for target 'tests/test-timed-average.exe' failed

Since v2:
- Remove incorrectly added abort() in qemu_timer_notify_cb()

Works for me (tested here:
https://gitlab.com/huth/qemu/-/pipelines/174503835 ) ... but I wonder whether there is a code path that uses the stub from stubs/cpu-get-icount.c but the qemu_notify_event() from util/main-loop.c ?

Thomas