* [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins)
@ 2025-01-09 17:05 Alex Bennée
2025-01-09 17:05 ` [PATCH 01/22] semihosting: add guest_error logging for failed opens Alex Bennée
` (21 more replies)
0 siblings, 22 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:05 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
This covers my remaining trees outside of testing/next and is mostly a
consolidation of patches I've pulled from other people.
For semihosting:
- a bunch of cleanups from Philippe to aide single binary builds
For gdbstub (touches system/vl.c as well):
- propagate *Error to setup functions
Ilya, I know about [PATCH v4 0/9] gdbstub: Allow late attachment and
will look at that later. I didn't want to delay the rest of my reviews
fighting with a messy re-base. If you are up for it you can post a
branch on the thread and I can potentially merge from that. Apologies
for the rug-pull between v3 and v4.
For plugins
- mostly fixes from Pierrick
- a speculative fix for cpu_io_recompile() case exposed by Julian's
discontinuity patches.
Most are already reviewed, the following remain:
accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile
system: propagate Error to gdbserver_start (and other device setups) (1 acks, 1 sobs, 0 tbs)
system: squash usb_parse into a single function
system/vl: more error exit into config enumeration code
semihosting: add guest_error logging for failed opens
There will likely be a v2 anyway once I've got testing/next merged and
Ilya's gdbstub patches. I don't think I have anything else pending but
do shout if there is.
Alex.
Alex Bennée (5):
semihosting: add guest_error logging for failed opens
system/vl: more error exit into config enumeration code
system: squash usb_parse into a single function
system: propagate Error to gdbserver_start (and other device setups)
accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile
Philippe Mathieu-Daudé (6):
semihosting/uaccess: Briefly document returned values
semihosting/syscalls: Include missing 'exec/cpu-defs.h' header
semihosting/uaccess: Include missing 'exec/cpu-all.h' header
semihosting/arm-compat: Include missing 'cpu.h' header
semihosting/console: Avoid including 'cpu.h'
semihosting/meson: Build config.o and console.o once
Pierrick Bouvier (11):
tests/tcg/plugins/insn: remove unused callback parameter
contrib/plugins/howvec: ensure we don't regress if this plugin is
extended
tests/tcg/plugins/syscall: fix 32-bit build
tests/tcg/plugins/mem: fix 32-bit build
contrib/plugins/stoptrigger: fix 32-bit build
contrib/plugins/cache: fix 32-bit build
contrib/plugins/hotblocks: fix 32-bit build
contrib/plugins/cflow: fix 32-bit build
contrib/plugins/hwprofile: fix 32-bit build
contrib/plugins/hotpages: fix 32-bit build
configure: reenable plugins by default for 32-bit hosts
configure | 21 +-------
include/exec/gdbstub.h | 8 ++-
include/semihosting/console.h | 2 -
include/semihosting/syscalls.h | 1 +
include/semihosting/uaccess.h | 55 +++++++++++++++++++
accel/tcg/translate-all.c | 5 +-
contrib/plugins/cache.c | 18 +++----
contrib/plugins/cflow.c | 17 +++---
contrib/plugins/hotblocks.c | 29 ++++++++--
contrib/plugins/hotpages.c | 6 +--
contrib/plugins/howvec.c | 7 +--
contrib/plugins/hwprofile.c | 27 ++++++----
contrib/plugins/stoptrigger.c | 48 +++++++++--------
gdbstub/system.c | 22 ++++----
gdbstub/user.c | 20 +++----
linux-user/main.c | 6 +--
monitor/hmp-cmds.c | 2 +-
semihosting/arm-compat-semi.c | 1 +
semihosting/console.c | 3 +-
semihosting/syscalls.c | 2 +
semihosting/uaccess.c | 1 +
system/vl.c | 99 ++++++++++++++--------------------
tests/tcg/plugins/insn.c | 4 +-
tests/tcg/plugins/mem.c | 6 +--
tests/tcg/plugins/syscall.c | 6 +--
semihosting/meson.build | 9 ++--
26 files changed, 243 insertions(+), 182 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 01/22] semihosting: add guest_error logging for failed opens
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
@ 2025-01-09 17:05 ` Alex Bennée
2025-01-09 18:48 ` Pierrick Bouvier
2025-01-09 17:05 ` [PATCH 02/22] semihosting/uaccess: Briefly document returned values Alex Bennée
` (20 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:05 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
This usually indicates the semihosting call was expecting to find
something but didn't.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
semihosting/syscalls.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c
index c40348f996..f6451d9bb0 100644
--- a/semihosting/syscalls.c
+++ b/semihosting/syscalls.c
@@ -7,6 +7,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/log.h"
#include "cpu.h"
#include "gdbstub/syscalls.h"
#include "semihosting/guestfd.h"
@@ -287,6 +288,7 @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
ret = open(p, host_flags, mode);
if (ret < 0) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to open %s\n", __func__, p);
complete(cs, -1, errno);
} else {
int guestfd = alloc_guestfd();
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 02/22] semihosting/uaccess: Briefly document returned values
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
2025-01-09 17:05 ` [PATCH 01/22] semihosting: add guest_error logging for failed opens Alex Bennée
@ 2025-01-09 17:05 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 03/22] semihosting/syscalls: Include missing 'exec/cpu-defs.h' header Alex Bennée
` (19 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:05 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Since it is not obvious the get/put_user*() methods
can return an error, add brief docstrings about it.
Also remind to use *unlock_user() when appropriate.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241212115413.42109-1-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
include/semihosting/uaccess.h | 55 +++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h
index c2fa5a655d..6bc90b12d6 100644
--- a/include/semihosting/uaccess.h
+++ b/include/semihosting/uaccess.h
@@ -19,41 +19,96 @@
#include "exec/tswap.h"
#include "exec/page-protection.h"
+/**
+ * get_user_u64:
+ *
+ * Returns: 0 on success, -1 on error.
+ */
#define get_user_u64(val, addr) \
({ uint64_t val_ = 0; \
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
&val_, sizeof(val_), 0); \
(val) = tswap64(val_); ret_; })
+/**
+ * get_user_u32:
+ *
+ * Returns: 0 on success, -1 on error.
+ */
#define get_user_u32(val, addr) \
({ uint32_t val_ = 0; \
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
&val_, sizeof(val_), 0); \
(val) = tswap32(val_); ret_; })
+/**
+ * get_user_u8:
+ *
+ * Returns: 0 on success, -1 on error.
+ */
#define get_user_u8(val, addr) \
({ uint8_t val_ = 0; \
int ret_ = cpu_memory_rw_debug(env_cpu(env), (addr), \
&val_, sizeof(val_), 0); \
(val) = val_; ret_; })
+/**
+ * get_user_ual:
+ *
+ * Returns: 0 on success, -1 on error.
+ */
#define get_user_ual(arg, p) get_user_u32(arg, p)
+/**
+ * put_user_u64:
+ *
+ * Returns: 0 on success, -1 on error.
+ */
#define put_user_u64(val, addr) \
({ uint64_t val_ = tswap64(val); \
cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
+/**
+ * put_user_u32:
+ *
+ * Returns: 0 on success, -1 on error.
+ */
#define put_user_u32(val, addr) \
({ uint32_t val_ = tswap32(val); \
cpu_memory_rw_debug(env_cpu(env), (addr), &val_, sizeof(val_), 1); })
+/**
+ * put_user_ual:
+ *
+ * Returns: 0 on success, -1 on error.
+ */
#define put_user_ual(arg, p) put_user_u32(arg, p)
+/**
+ * uaccess_lock_user:
+ *
+ * The returned pointer should be freed using uaccess_unlock_user().
+ */
void *uaccess_lock_user(CPUArchState *env, target_ulong addr,
target_ulong len, bool copy);
+/**
+ * lock_user:
+ *
+ * The returned pointer should be freed using unlock_user().
+ */
#define lock_user(type, p, len, copy) uaccess_lock_user(env, p, len, copy)
+/**
+ * uaccess_lock_user_string:
+ *
+ * The returned string should be freed using uaccess_unlock_user().
+ */
char *uaccess_lock_user_string(CPUArchState *env, target_ulong addr);
+/**
+ * uaccess_lock_user_string:
+ *
+ * The returned string should be freed using unlock_user().
+ */
#define lock_user_string(p) uaccess_lock_user_string(env, p)
void uaccess_unlock_user(CPUArchState *env, void *p,
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 03/22] semihosting/syscalls: Include missing 'exec/cpu-defs.h' header
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
2025-01-09 17:05 ` [PATCH 01/22] semihosting: add guest_error logging for failed opens Alex Bennée
2025-01-09 17:05 ` [PATCH 02/22] semihosting/uaccess: Briefly document returned values Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 04/22] semihosting/uaccess: Include missing 'exec/cpu-all.h' header Alex Bennée
` (18 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Philippe Mathieu-Daudé <philmd@linaro.org>
target_ulong is defined in each target "cpu-param.h",
itself included by "exec/cpu-defs.h".
Include the latter in order to avoid when refactoring:
include/semihosting/syscalls.h:26:24: error: unknown type name 'target_ulong'
26 | target_ulong fname, target_ulong fname_len,
| ^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250103171037.11265-2-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
include/semihosting/syscalls.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/semihosting/syscalls.h b/include/semihosting/syscalls.h
index b5937c619a..6627c45fb2 100644
--- a/include/semihosting/syscalls.h
+++ b/include/semihosting/syscalls.h
@@ -9,6 +9,7 @@
#ifndef SEMIHOSTING_SYSCALLS_H
#define SEMIHOSTING_SYSCALLS_H
+#include "exec/cpu-defs.h"
#include "gdbstub/syscalls.h"
/*
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 04/22] semihosting/uaccess: Include missing 'exec/cpu-all.h' header
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (2 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 03/22] semihosting/syscalls: Include missing 'exec/cpu-defs.h' header Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 05/22] semihosting/arm-compat: Include missing 'cpu.h' header Alex Bennée
` (17 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Philippe Mathieu-Daudé <philmd@linaro.org>
TLB_INVALID_MASK is defined in "exec/cpu-all.h".
Include it in order to avoid when refactoring:
../semihosting/uaccess.c:41:21: error: use of undeclared identifier 'TLB_INVALID_MASK'
41 | if (flags & TLB_INVALID_MASK) {
| ^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250103171037.11265-3-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
semihosting/uaccess.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/semihosting/uaccess.c b/semihosting/uaccess.c
index dc587d73bc..382a366ce3 100644
--- a/semihosting/uaccess.c
+++ b/semihosting/uaccess.c
@@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
+#include "exec/cpu-all.h"
#include "exec/exec-all.h"
#include "semihosting/uaccess.h"
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 05/22] semihosting/arm-compat: Include missing 'cpu.h' header
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (3 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 04/22] semihosting/uaccess: Include missing 'exec/cpu-all.h' header Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 06/22] semihosting/console: Avoid including 'cpu.h' Alex Bennée
` (16 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Philippe Mathieu-Daudé <philmd@linaro.org>
ARM semihosting implementations in "common-semi-target.h"
must de-reference the target CPUArchState, which is declared
in each target "cpu.h" header. Include it in order to avoid
when refactoring:
In file included from ../../semihosting/arm-compat-semi.c:169:
../target/riscv/common-semi-target.h:16:5: error: use of undeclared identifier 'RISCVCPU'
16 | RISCVCPU *cpu = RISCV_CPU(cs);
| ^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250103171037.11265-4-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
semihosting/arm-compat-semi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index d78c6428b9..86e5260e50 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -166,6 +166,7 @@ static LayoutInfo common_semi_find_bases(CPUState *cs)
#endif
+#include "cpu.h"
#include "common-semi-target.h"
/*
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 06/22] semihosting/console: Avoid including 'cpu.h'
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (4 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 05/22] semihosting/arm-compat: Include missing 'cpu.h' header Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 07/22] semihosting/meson: Build config.o and console.o once Alex Bennée
` (15 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Philippe Mathieu-Daudé <philmd@linaro.org>
The CPUState structure is declared in "hw/core/cpu.h",
the EXCP_HALTED definition in "exec/cpu-common.h".
Both headers are indirectly include by "cpu.h". In
order to remove "cpu.h" from "semihosting/console.h",
explicitly include them in console.c, otherwise we'd
get:
../semihosting/console.c:88:11: error: incomplete definition of type 'struct CPUState'
88 | cs->exception_index = EXCP_HALTED;
| ~~^
../semihosting/console.c:88:31: error: use of undeclared identifier 'EXCP_HALTED'
88 | cs->exception_index = EXCP_HALTED;
| ^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250103171037.11265-5-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
include/semihosting/console.h | 2 --
semihosting/console.c | 3 ++-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/semihosting/console.h b/include/semihosting/console.h
index bd78e5f03f..1c12e178ee 100644
--- a/include/semihosting/console.h
+++ b/include/semihosting/console.h
@@ -9,8 +9,6 @@
#ifndef SEMIHOST_CONSOLE_H
#define SEMIHOST_CONSOLE_H
-#include "cpu.h"
-
/**
* qemu_semihosting_console_read:
* @cs: CPUState
diff --git a/semihosting/console.c b/semihosting/console.c
index 60102bbab6..c3683a1566 100644
--- a/semihosting/console.c
+++ b/semihosting/console.c
@@ -18,14 +18,15 @@
#include "qemu/osdep.h"
#include "semihosting/semihost.h"
#include "semihosting/console.h"
+#include "exec/cpu-common.h"
#include "exec/gdbstub.h"
-#include "exec/exec-all.h"
#include "qemu/log.h"
#include "chardev/char.h"
#include "chardev/char-fe.h"
#include "qemu/main-loop.h"
#include "qapi/error.h"
#include "qemu/fifo8.h"
+#include "hw/core/cpu.h"
/* Access to this structure is protected by the BQL */
typedef struct SemihostingConsole {
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 07/22] semihosting/meson: Build config.o and console.o once
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (5 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 06/22] semihosting/console: Avoid including 'cpu.h' Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 08/22] system/vl: more error exit into config enumeration code Alex Bennée
` (14 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Philippe Mathieu-Daudé <philmd@linaro.org>
config.c and console.c don't use any target specific
headers anymore, move them from specific_ss[] to
system_ss[] so they are built once, but will also be
linked once, removing global symbol clash in a single
QEMU binary.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250103171037.11265-6-philmd@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
semihosting/meson.build | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/semihosting/meson.build b/semihosting/meson.build
index 34933e5a19..86f5004bed 100644
--- a/semihosting/meson.build
+++ b/semihosting/meson.build
@@ -4,13 +4,16 @@ specific_ss.add(when: 'CONFIG_SEMIHOSTING', if_true: files(
))
specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: files(
- 'config.c',
- 'console.c',
'uaccess.c',
))
common_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_false: files('stubs-all.c'))
-system_ss.add(when: ['CONFIG_SEMIHOSTING'], if_false: files('stubs-system.c'))
+system_ss.add(when: ['CONFIG_SEMIHOSTING'], if_true: files(
+ 'config.c',
+ 'console.c',
+), if_false: files(
+ 'stubs-system.c',
+))
specific_ss.add(when: ['CONFIG_ARM_COMPATIBLE_SEMIHOSTING'],
if_true: files('arm-compat-semi.c'))
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 08/22] system/vl: more error exit into config enumeration code
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (6 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 07/22] semihosting/meson: Build config.o and console.o once Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 18:49 ` Pierrick Bouvier
` (2 more replies)
2025-01-09 17:06 ` [PATCH 09/22] system: squash usb_parse into a single function Alex Bennée
` (13 subsequent siblings)
21 siblings, 3 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
All of the failures to configure devices will result in QEMU exiting
with an error code. In preparation for passing Error * down the chain
re-name the iterator to foreach_device_config_or_exit and exit using
&error_fatal instead of returning a failure indication.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
system/vl.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/system/vl.c b/system/vl.c
index 0843b7ab49..25d9968ccc 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1307,7 +1307,14 @@ static void add_device_config(int type, const char *cmdline)
QTAILQ_INSERT_TAIL(&device_configs, conf, next);
}
-static int foreach_device_config(int type, int (*func)(const char *cmdline))
+/**
+ * foreach_device_config_or_exit(): process per-device configs
+ * @type: device_config type
+ * @func: device specific config function, returning pass/fail
+ *
+ * Any failure is fatal and we exit with an error message.
+ */
+static void foreach_device_config_or_exit(int type, int (*func)(const char *cmdline))
{
struct device_config *conf;
int rc;
@@ -1319,10 +1326,10 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
rc = func(conf->cmdline);
loc_pop(&conf->loc);
if (rc) {
- return rc;
+ error_setg(&error_fatal, "failed to configure: %s", conf->cmdline);
+ exit(1);
}
}
- return 0;
}
static void qemu_disable_default_devices(void)
@@ -2044,12 +2051,9 @@ static void qemu_create_late_backends(void)
qemu_opts_foreach(qemu_find_opts("mon"),
mon_init_func, NULL, &error_fatal);
- if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
- exit(1);
- if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
- exit(1);
- if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
- exit(1);
+ foreach_device_config_or_exit(DEV_SERIAL, serial_parse);
+ foreach_device_config_or_exit(DEV_PARALLEL, parallel_parse);
+ foreach_device_config_or_exit(DEV_DEBUGCON, debugcon_parse);
/* now chardevs have been created we may have semihosting to connect */
qemu_semihosting_chardev_init();
@@ -2670,8 +2674,7 @@ static void qemu_create_cli_devices(void)
/* init USB devices */
if (machine_usb(current_machine)) {
- if (foreach_device_config(DEV_USB, usb_parse) < 0)
- exit(1);
+ foreach_device_config_or_exit(DEV_USB, usb_parse);
}
/* init generic devices */
@@ -2718,10 +2721,8 @@ static bool qemu_machine_creation_done(Error **errp)
exit(1);
}
- if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
- error_setg(errp, "could not start gdbserver");
- return false;
- }
+ foreach_device_config_or_exit(DEV_GDB, gdbserver_start);
+
if (!vga_interface_created && !default_vga &&
vga_interface_type != VGA_NONE) {
warn_report("A -vga option was passed but this machine "
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 09/22] system: squash usb_parse into a single function
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (7 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 08/22] system/vl: more error exit into config enumeration code Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:30 ` Philippe Mathieu-Daudé
2025-01-09 17:06 ` [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups) Alex Bennée
` (12 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
We don't need to wrap usb_device_add as usb_parse is already gated
with an if (machine_usb(current_machine)) check. Instead just assert
and directly fail if usbdevice_create returns NULL.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
system/vl.c | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/system/vl.c b/system/vl.c
index 25d9968ccc..df59cff865 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -811,31 +811,17 @@ static void configure_msg(QemuOpts *opts)
/***********************************************************/
/* USB devices */
-static int usb_device_add(const char *devname)
+static int usb_parse(const char *cmdline)
{
- USBDevice *dev = NULL;
+ g_assert(machine_usb(current_machine));
- if (!machine_usb(current_machine)) {
+ if (!usbdevice_create(cmdline)) {
+ error_report("could not add USB device '%s'", cmdline);
return -1;
}
-
- dev = usbdevice_create(devname);
- if (!dev)
- return -1;
-
return 0;
}
-static int usb_parse(const char *cmdline)
-{
- int r;
- r = usb_device_add(cmdline);
- if (r < 0) {
- error_report("could not add USB device '%s'", cmdline);
- }
- return r;
-}
-
/***********************************************************/
/* machine registration */
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups)
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (8 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 09/22] system: squash usb_parse into a single function Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 18:55 ` Pierrick Bouvier
2025-01-09 17:06 ` [PATCH 11/22] tests/tcg/plugins/insn: remove unused callback parameter Alex Bennée
` (11 subsequent siblings)
21 siblings, 1 reply; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée, Ilya Leoshkevich
This started as a clean-up to properly pass a Error handler to the
gdbserver_start so we could do the right thing for command line and
HMP invocations.
Now that we have cleaned up foreach_device_config_or_exit() in earlier
patches we can further simplify by it by passing &error_fatal instead
of checking the return value. Having a return value is still useful
for HMP though so tweak the return to use a simple bool instead.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
v2
- split some work into pre-cursor patches
---
include/exec/gdbstub.h | 8 +++++-
gdbstub/system.c | 22 ++++++++--------
gdbstub/user.c | 20 ++++++++-------
linux-user/main.c | 6 +----
monitor/hmp-cmds.c | 2 +-
system/vl.c | 58 ++++++++++++++++++++----------------------
6 files changed, 59 insertions(+), 57 deletions(-)
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index d73f424f56..0675b0b646 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -49,12 +49,18 @@ void gdb_unregister_coprocessor_all(CPUState *cpu);
/**
* gdbserver_start: start the gdb server
* @port_or_device: connection spec for gdb
+ * @errp: error handle
*
* For CONFIG_USER this is either a tcp port or a path to a fifo. For
* system emulation you can use a full chardev spec for your gdbserver
* port.
+ *
+ * The error handle should be either &error_fatal (for start-up) or
+ * &error_warn (for QMP/HMP initiated sessions).
+ *
+ * Returns true when server successfully started.
*/
-int gdbserver_start(const char *port_or_device);
+bool gdbserver_start(const char *port_or_device, Error **errp);
/**
* gdb_feature_builder_init() - Initialize GDBFeatureBuilder.
diff --git a/gdbstub/system.c b/gdbstub/system.c
index 2d9fdff2fe..8ce79fa88c 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -330,26 +330,27 @@ static void create_processes(GDBState *s)
gdb_create_default_process(s);
}
-int gdbserver_start(const char *device)
+bool gdbserver_start(const char *device, Error **errp)
{
Chardev *chr = NULL;
Chardev *mon_chr;
g_autoptr(GString) cs = g_string_new(device);
if (!first_cpu) {
- error_report("gdbstub: meaningless to attach gdb to a "
- "machine without any CPU.");
- return -1;
+ error_setg(errp, "gdbstub: meaningless to attach gdb to a "
+ "machine without any CPU.");
+ return false;
}
if (!gdb_supports_guest_debug()) {
- error_report("gdbstub: current accelerator doesn't "
- "support guest debugging");
- return -1;
+ error_setg(errp, "gdbstub: current accelerator doesn't "
+ "support guest debugging");
+ return false;
}
if (cs->len == 0) {
- return -1;
+ error_setg(errp, "gdbstub: missing connection string");
+ return false;
}
trace_gdbstub_op_start(cs->str);
@@ -374,7 +375,8 @@ int gdbserver_start(const char *device)
*/
chr = qemu_chr_new_noreplay("gdb", cs->str, true, NULL);
if (!chr) {
- return -1;
+ error_setg(errp, "gdbstub: couldn't create chardev");
+ return false;
}
}
@@ -406,7 +408,7 @@ int gdbserver_start(const char *device)
gdbserver_system_state.mon_chr = mon_chr;
gdb_syscall_reset();
- return 0;
+ return true;
}
static void register_types(void)
diff --git a/gdbstub/user.c b/gdbstub/user.c
index 0b4bfa9c48..fb8f6867ea 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -13,6 +13,7 @@
#include "qemu/bitops.h"
#include "qemu/cutils.h"
#include "qemu/sockets.h"
+#include "qapi/error.h"
#include "exec/hwaddr.h"
#include "exec/tb-flush.h"
#include "exec/gdbstub.h"
@@ -372,15 +373,15 @@ static bool gdb_accept_tcp(int gdb_fd)
return true;
}
-static int gdbserver_open_port(int port)
+static int gdbserver_open_port(int port, Error **errp)
{
struct sockaddr_in sockaddr;
int fd, ret;
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0) {
- perror("socket");
- return -1;
+ error_setg(errp, "Failed to bind socket: %s", strerror(errno));
+ return false;
}
qemu_set_cloexec(fd);
@@ -405,31 +406,32 @@ static int gdbserver_open_port(int port)
return fd;
}
-int gdbserver_start(const char *port_or_path)
+bool gdbserver_start(const char *port_or_path, Error **errp)
{
int port = g_ascii_strtoull(port_or_path, NULL, 10);
int gdb_fd;
if (port > 0) {
- gdb_fd = gdbserver_open_port(port);
+ gdb_fd = gdbserver_open_port(port, errp);
} else {
gdb_fd = gdbserver_open_socket(port_or_path);
}
if (gdb_fd < 0) {
- return -1;
+ return false;
}
if (port > 0 && gdb_accept_tcp(gdb_fd)) {
- return 0;
+ return true;
} else if (gdb_accept_socket(gdb_fd)) {
gdbserver_user_state.socket_path = g_strdup(port_or_path);
- return 0;
+ return true;
}
/* gone wrong */
close(gdb_fd);
- return -1;
+ error_setg(errp, "gdbstub: failed to accept connection");
+ return false;
}
void gdbserver_fork_start(void)
diff --git a/linux-user/main.c b/linux-user/main.c
index b97634a32d..7198fa0986 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1023,11 +1023,7 @@ int main(int argc, char **argv, char **envp)
target_cpu_copy_regs(env, regs);
if (gdbstub) {
- if (gdbserver_start(gdbstub) < 0) {
- fprintf(stderr, "qemu: could not open gdbserver on %s\n",
- gdbstub);
- exit(EXIT_FAILURE);
- }
+ gdbserver_start(gdbstub, &error_fatal);
gdb_handlesig(cpu, 0, NULL, NULL, 0);
}
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 80b2e5ff9f..0aa22e1ae2 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -285,7 +285,7 @@ void hmp_gdbserver(Monitor *mon, const QDict *qdict)
device = "tcp::" DEFAULT_GDBSTUB_PORT;
}
- if (gdbserver_start(device) < 0) {
+ if (!gdbserver_start(device, &error_warn)) {
monitor_printf(mon, "Could not open gdbserver on device '%s'\n",
device);
} else if (strcmp(device, "none") == 0) {
diff --git a/system/vl.c b/system/vl.c
index df59cff865..3c96fc957e 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -811,15 +811,15 @@ static void configure_msg(QemuOpts *opts)
/***********************************************************/
/* USB devices */
-static int usb_parse(const char *cmdline)
+static bool usb_parse(const char *cmdline, Error **errp)
{
g_assert(machine_usb(current_machine));
if (!usbdevice_create(cmdline)) {
- error_report("could not add USB device '%s'", cmdline);
- return -1;
+ error_setg(errp, "could not add USB device '%s'", cmdline);
+ return false;
}
- return 0;
+ return true;
}
/***********************************************************/
@@ -1298,23 +1298,19 @@ static void add_device_config(int type, const char *cmdline)
* @type: device_config type
* @func: device specific config function, returning pass/fail
*
- * Any failure is fatal and we exit with an error message.
+ * @func is called with the &error_fatal handler so device specific
+ * error messages can be reported on failure.
*/
-static void foreach_device_config_or_exit(int type, int (*func)(const char *cmdline))
+static void foreach_device_config_or_exit(int type, bool (*func)(const char *cmdline, Error **errp))
{
struct device_config *conf;
- int rc;
QTAILQ_FOREACH(conf, &device_configs, next) {
if (conf->type != type)
continue;
loc_push_restore(&conf->loc);
- rc = func(conf->cmdline);
+ func(conf->cmdline, &error_fatal);
loc_pop(&conf->loc);
- if (rc) {
- error_setg(&error_fatal, "failed to configure: %s", conf->cmdline);
- exit(1);
- }
}
}
@@ -1445,7 +1441,7 @@ static void qemu_create_default_devices(void)
}
}
-static int serial_parse(const char *devname)
+static bool serial_parse(const char *devname, Error **errp)
{
int index = num_serial_hds;
@@ -1460,13 +1456,13 @@ static int serial_parse(const char *devname)
serial_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL);
if (!serial_hds[index]) {
- error_report("could not connect serial device"
- " to character backend '%s'", devname);
- return -1;
+ error_setg(errp, "could not connect serial device"
+ " to character backend '%s'", devname);
+ return false;
}
}
num_serial_hds++;
- return 0;
+ return true;
}
Chardev *serial_hd(int i)
@@ -1478,44 +1474,44 @@ Chardev *serial_hd(int i)
return NULL;
}
-static int parallel_parse(const char *devname)
+static bool parallel_parse(const char *devname, Error **errp)
{
static int index = 0;
char label[32];
if (strcmp(devname, "none") == 0)
- return 0;
+ return true;
if (index == MAX_PARALLEL_PORTS) {
- error_report("too many parallel ports");
- exit(1);
+ error_setg(errp, "too many parallel ports");
+ return false;
}
snprintf(label, sizeof(label), "parallel%d", index);
parallel_hds[index] = qemu_chr_new_mux_mon(label, devname, NULL);
if (!parallel_hds[index]) {
- error_report("could not connect parallel device"
- " to character backend '%s'", devname);
- return -1;
+ error_setg(errp, "could not connect parallel device"
+ " to character backend '%s'", devname);
+ return false;
}
index++;
- return 0;
+ return true;
}
-static int debugcon_parse(const char *devname)
+static bool debugcon_parse(const char *devname, Error **errp)
{
QemuOpts *opts;
if (!qemu_chr_new_mux_mon("debugcon", devname, NULL)) {
- error_report("invalid character backend '%s'", devname);
- exit(1);
+ error_setg(errp, "invalid character backend '%s'", devname);
+ return false;
}
opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1, NULL);
if (!opts) {
- error_report("already have a debugcon device");
- exit(1);
+ error_setg(errp, "already have a debugcon device");
+ return false;
}
qemu_opt_set(opts, "driver", "isa-debugcon", &error_abort);
qemu_opt_set(opts, "chardev", "debugcon", &error_abort);
- return 0;
+ return true;
}
static gint machine_class_cmp(gconstpointer a, gconstpointer b)
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 11/22] tests/tcg/plugins/insn: remove unused callback parameter
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (9 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups) Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 12/22] contrib/plugins/howvec: ensure we don't regress if this plugin is extended Alex Bennée
` (10 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-2-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/tcg/plugins/insn.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tests/tcg/plugins/insn.c b/tests/tcg/plugins/insn.c
index baf2d07205..0c723cb9ed 100644
--- a/tests/tcg/plugins/insn.c
+++ b/tests/tcg/plugins/insn.c
@@ -150,10 +150,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(
insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1);
} else {
- uint64_t vaddr = qemu_plugin_insn_vaddr(insn);
qemu_plugin_register_vcpu_insn_exec_cb(
- insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS,
- GUINT_TO_POINTER(vaddr));
+ insn, vcpu_insn_exec_before, QEMU_PLUGIN_CB_NO_REGS, NULL);
}
if (do_size) {
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 12/22] contrib/plugins/howvec: ensure we don't regress if this plugin is extended
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (10 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 11/22] tests/tcg/plugins/insn: remove unused callback parameter Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 13/22] tests/tcg/plugins/syscall: fix 32-bit build Alex Bennée
` (9 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-3-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/howvec.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c
index 9be67f7453..2aa9029c3f 100644
--- a/contrib/plugins/howvec.c
+++ b/contrib/plugins/howvec.c
@@ -253,6 +253,8 @@ static struct qemu_plugin_scoreboard *find_counter(
int i;
uint64_t *cnt = NULL;
uint32_t opcode = 0;
+ /* if opcode is greater than 32 bits, we should refactor insn hash table. */
+ G_STATIC_ASSERT(sizeof(opcode) == sizeof(uint32_t));
InsnClassExecCount *class = NULL;
/*
@@ -284,7 +286,7 @@ static struct qemu_plugin_scoreboard *find_counter(
g_mutex_lock(&lock);
icount = (InsnExecCount *) g_hash_table_lookup(insns,
- GUINT_TO_POINTER(opcode));
+ (gpointer)(intptr_t) opcode);
if (!icount) {
icount = g_new0(InsnExecCount, 1);
@@ -295,8 +297,7 @@ static struct qemu_plugin_scoreboard *find_counter(
qemu_plugin_scoreboard_new(sizeof(uint64_t));
icount->count = qemu_plugin_scoreboard_u64(score);
- g_hash_table_insert(insns, GUINT_TO_POINTER(opcode),
- (gpointer) icount);
+ g_hash_table_insert(insns, (gpointer)(intptr_t) opcode, icount);
}
g_mutex_unlock(&lock);
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 13/22] tests/tcg/plugins/syscall: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (11 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 12/22] contrib/plugins/howvec: ensure we don't regress if this plugin is extended Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 14/22] tests/tcg/plugins/mem: " Alex Bennée
` (8 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-4-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/tcg/plugins/syscall.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/tcg/plugins/syscall.c b/tests/tcg/plugins/syscall.c
index ff452178b1..47aad55fc1 100644
--- a/tests/tcg/plugins/syscall.c
+++ b/tests/tcg/plugins/syscall.c
@@ -76,12 +76,12 @@ static int64_t write_sysno = -1;
static SyscallStats *get_or_create_entry(int64_t num)
{
SyscallStats *entry =
- (SyscallStats *) g_hash_table_lookup(statistics, GINT_TO_POINTER(num));
+ (SyscallStats *) g_hash_table_lookup(statistics, &num);
if (!entry) {
entry = g_new0(SyscallStats, 1);
entry->num = num;
- g_hash_table_insert(statistics, GINT_TO_POINTER(num), (gpointer) entry);
+ g_hash_table_insert(statistics, &entry->num, entry);
}
return entry;
@@ -232,7 +232,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
}
if (!do_print) {
- statistics = g_hash_table_new_full(NULL, g_direct_equal, NULL, g_free);
+ statistics = g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, g_free);
}
if (do_log_writes) {
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 14/22] tests/tcg/plugins/mem: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (12 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 13/22] tests/tcg/plugins/syscall: fix 32-bit build Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 15/22] contrib/plugins/stoptrigger: " Alex Bennée
` (7 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-5-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/tcg/plugins/mem.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/tcg/plugins/mem.c b/tests/tcg/plugins/mem.c
index b0fa8a9f27..d87d6628e0 100644
--- a/tests/tcg/plugins/mem.c
+++ b/tests/tcg/plugins/mem.c
@@ -135,14 +135,14 @@ static void update_region_info(uint64_t region, uint64_t offset,
g_assert(offset + size <= region_size);
g_mutex_lock(&lock);
- ri = (RegionInfo *) g_hash_table_lookup(regions, GUINT_TO_POINTER(region));
+ ri = (RegionInfo *) g_hash_table_lookup(regions, ®ion);
if (!ri) {
ri = g_new0(RegionInfo, 1);
ri->region_address = region;
ri->data = g_malloc0(region_size);
ri->seen_all = true;
- g_hash_table_insert(regions, GUINT_TO_POINTER(region), (gpointer) ri);
+ g_hash_table_insert(regions, &ri->region_address, ri);
}
if (is_store) {
@@ -392,7 +392,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
if (do_region_summary) {
region_mask = (region_size - 1);
- regions = g_hash_table_new(NULL, g_direct_equal);
+ regions = g_hash_table_new(g_int64_hash, g_int64_equal);
}
counts = qemu_plugin_scoreboard_new(sizeof(CPUCount));
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 15/22] contrib/plugins/stoptrigger: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (13 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 14/22] tests/tcg/plugins/mem: " Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 16/22] contrib/plugins/cache: " Alex Bennée
` (6 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241217224306.2900490-6-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/stoptrigger.c | 48 ++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/contrib/plugins/stoptrigger.c b/contrib/plugins/stoptrigger.c
index 03ee22f4c6..b3a6ed66a7 100644
--- a/contrib/plugins/stoptrigger.c
+++ b/contrib/plugins/stoptrigger.c
@@ -21,9 +21,11 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
/* Scoreboard to track executed instructions count */
typedef struct {
uint64_t insn_count;
+ uint64_t current_pc;
} InstructionsCount;
static struct qemu_plugin_scoreboard *insn_count_sb;
static qemu_plugin_u64 insn_count;
+static qemu_plugin_u64 current_pc;
static uint64_t icount;
static int icount_exit_code;
@@ -34,6 +36,11 @@ static bool exit_on_address;
/* Map trigger addresses to exit code */
static GHashTable *addrs_ht;
+typedef struct {
+ uint64_t exit_addr;
+ int exit_code;
+} ExitInfo;
+
static void exit_emulation(int return_code, char *message)
{
qemu_plugin_outs(message);
@@ -43,23 +50,18 @@ static void exit_emulation(int return_code, char *message)
static void exit_icount_reached(unsigned int cpu_index, void *udata)
{
- uint64_t insn_vaddr = GPOINTER_TO_UINT(udata);
+ uint64_t insn_vaddr = qemu_plugin_u64_get(current_pc, cpu_index);
char *msg = g_strdup_printf("icount reached at 0x%" PRIx64 ", exiting\n",
insn_vaddr);
-
exit_emulation(icount_exit_code, msg);
}
static void exit_address_reached(unsigned int cpu_index, void *udata)
{
- uint64_t insn_vaddr = GPOINTER_TO_UINT(udata);
- char *msg = g_strdup_printf("0x%" PRIx64 " reached, exiting\n", insn_vaddr);
- int exit_code;
-
- exit_code = GPOINTER_TO_INT(
- g_hash_table_lookup(addrs_ht, GUINT_TO_POINTER(insn_vaddr)));
-
- exit_emulation(exit_code, msg);
+ ExitInfo *ei = udata;
+ g_assert(ei);
+ char *msg = g_strdup_printf("0x%" PRIx64 " reached, exiting\n", ei->exit_addr);
+ exit_emulation(ei->exit_code, msg);
}
static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
@@ -67,23 +69,25 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
size_t tb_n = qemu_plugin_tb_n_insns(tb);
for (size_t i = 0; i < tb_n; i++) {
struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
- gpointer insn_vaddr = GUINT_TO_POINTER(qemu_plugin_insn_vaddr(insn));
+ uint64_t insn_vaddr = qemu_plugin_insn_vaddr(insn);
if (exit_on_icount) {
/* Increment and check scoreboard for each instruction */
qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(
insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_count, 1);
+ qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(
+ insn, QEMU_PLUGIN_INLINE_STORE_U64, current_pc, insn_vaddr);
qemu_plugin_register_vcpu_insn_exec_cond_cb(
insn, exit_icount_reached, QEMU_PLUGIN_CB_NO_REGS,
- QEMU_PLUGIN_COND_EQ, insn_count, icount + 1, insn_vaddr);
+ QEMU_PLUGIN_COND_EQ, insn_count, icount + 1, NULL);
}
if (exit_on_address) {
- if (g_hash_table_contains(addrs_ht, insn_vaddr)) {
+ ExitInfo *ei = g_hash_table_lookup(addrs_ht, &insn_vaddr);
+ if (ei) {
/* Exit triggered by address */
qemu_plugin_register_vcpu_insn_exec_cb(
- insn, exit_address_reached, QEMU_PLUGIN_CB_NO_REGS,
- insn_vaddr);
+ insn, exit_address_reached, QEMU_PLUGIN_CB_NO_REGS, ei);
}
}
}
@@ -99,11 +103,13 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
const qemu_info_t *info, int argc,
char **argv)
{
- addrs_ht = g_hash_table_new(NULL, g_direct_equal);
+ addrs_ht = g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, g_free);
insn_count_sb = qemu_plugin_scoreboard_new(sizeof(InstructionsCount));
insn_count = qemu_plugin_scoreboard_u64_in_struct(
insn_count_sb, InstructionsCount, insn_count);
+ current_pc = qemu_plugin_scoreboard_u64_in_struct(
+ insn_count_sb, InstructionsCount, current_pc);
for (int i = 0; i < argc; i++) {
char *opt = argv[i];
@@ -124,13 +130,13 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
exit_on_icount = true;
} else if (g_strcmp0(tokens[0], "addr") == 0) {
g_auto(GStrv) addr_tokens = g_strsplit(tokens[1], ":", 2);
- uint64_t exit_addr = g_ascii_strtoull(addr_tokens[0], NULL, 0);
- int exit_code = 0;
+ ExitInfo *ei = g_malloc(sizeof(ExitInfo));
+ ei->exit_addr = g_ascii_strtoull(addr_tokens[0], NULL, 0);
+ ei->exit_code = 0;
if (addr_tokens[1]) {
- exit_code = g_ascii_strtoull(addr_tokens[1], NULL, 0);
+ ei->exit_code = g_ascii_strtoull(addr_tokens[1], NULL, 0);
}
- g_hash_table_insert(addrs_ht, GUINT_TO_POINTER(exit_addr),
- GINT_TO_POINTER(exit_code));
+ g_hash_table_insert(addrs_ht, &ei->exit_addr, ei);
exit_on_address = true;
} else {
fprintf(stderr, "option parsing failed: %s\n", opt);
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 16/22] contrib/plugins/cache: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (14 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 15/22] contrib/plugins/stoptrigger: " Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 17/22] contrib/plugins/hotblocks: " Alex Bennée
` (5 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241217224306.2900490-7-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/cache.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
index 512ef6776b..7baff86860 100644
--- a/contrib/plugins/cache.c
+++ b/contrib/plugins/cache.c
@@ -208,7 +208,7 @@ static int fifo_get_first_block(Cache *cache, int set)
static void fifo_update_on_miss(Cache *cache, int set, int blk_idx)
{
GQueue *q = cache->sets[set].fifo_queue;
- g_queue_push_head(q, GINT_TO_POINTER(blk_idx));
+ g_queue_push_head(q, (gpointer)(intptr_t) blk_idx);
}
static void fifo_destroy(Cache *cache)
@@ -471,13 +471,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
n_insns = qemu_plugin_tb_n_insns(tb);
for (i = 0; i < n_insns; i++) {
struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
- uint64_t effective_addr;
-
- if (sys) {
- effective_addr = (uint64_t) qemu_plugin_insn_haddr(insn);
- } else {
- effective_addr = (uint64_t) qemu_plugin_insn_vaddr(insn);
- }
+ uint64_t effective_addr = sys ? (uintptr_t) qemu_plugin_insn_haddr(insn) :
+ qemu_plugin_insn_vaddr(insn);
/*
* Instructions might get translated multiple times, we do not create
@@ -485,14 +480,13 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
* entry from the hash table and register it for the callback again.
*/
g_mutex_lock(&hashtable_lock);
- data = g_hash_table_lookup(miss_ht, GUINT_TO_POINTER(effective_addr));
+ data = g_hash_table_lookup(miss_ht, &effective_addr);
if (data == NULL) {
data = g_new0(InsnData, 1);
data->disas_str = qemu_plugin_insn_disas(insn);
data->symbol = qemu_plugin_insn_symbol(insn);
data->addr = effective_addr;
- g_hash_table_insert(miss_ht, GUINT_TO_POINTER(effective_addr),
- (gpointer) data);
+ g_hash_table_insert(miss_ht, &data->addr, data);
}
g_mutex_unlock(&hashtable_lock);
@@ -853,7 +847,7 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
- miss_ht = g_hash_table_new_full(NULL, g_direct_equal, NULL, insn_free);
+ miss_ht = g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, insn_free);
return 0;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 17/22] contrib/plugins/hotblocks: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (15 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 16/22] contrib/plugins/cache: " Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 18/22] contrib/plugins/cflow: " Alex Bennée
` (4 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241217224306.2900490-8-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/hotblocks.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
index 02bc5078bd..f12bfb7a26 100644
--- a/contrib/plugins/hotblocks.c
+++ b/contrib/plugins/hotblocks.c
@@ -29,7 +29,7 @@ static guint64 limit = 20;
*
* The internals of the TCG are not exposed to plugins so we can only
* get the starting PC for each block. We cheat this slightly by
- * xor'ing the number of instructions to the hash to help
+ * checking the number of instructions as well to help
* differentiate.
*/
typedef struct {
@@ -50,6 +50,20 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b)
return count_a > count_b ? -1 : 1;
}
+static guint exec_count_hash(gconstpointer v)
+{
+ const ExecCount *e = v;
+ return e->start_addr ^ e->insns;
+}
+
+static gboolean exec_count_equal(gconstpointer v1, gconstpointer v2)
+{
+ const ExecCount *ea = v1;
+ const ExecCount *eb = v2;
+ return (ea->start_addr == eb->start_addr) &&
+ (ea->insns == eb->insns);
+}
+
static void exec_count_free(gpointer key, gpointer value, gpointer user_data)
{
ExecCount *cnt = value;
@@ -91,7 +105,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
static void plugin_init(void)
{
- hotblocks = g_hash_table_new(NULL, g_direct_equal);
+ hotblocks = g_hash_table_new(exec_count_hash, exec_count_equal);
}
static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
@@ -111,10 +125,15 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
ExecCount *cnt;
uint64_t pc = qemu_plugin_tb_vaddr(tb);
size_t insns = qemu_plugin_tb_n_insns(tb);
- uint64_t hash = pc ^ insns;
g_mutex_lock(&lock);
- cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash);
+ {
+ ExecCount e;
+ e.start_addr = pc;
+ e.insns = insns;
+ cnt = (ExecCount *) g_hash_table_lookup(hotblocks, &e);
+ }
+
if (cnt) {
cnt->trans_count++;
} else {
@@ -123,7 +142,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
cnt->trans_count = 1;
cnt->insns = insns;
cnt->exec_count = qemu_plugin_scoreboard_new(sizeof(uint64_t));
- g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt);
+ g_hash_table_insert(hotblocks, cnt, cnt);
}
g_mutex_unlock(&lock);
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 18/22] contrib/plugins/cflow: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (16 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 17/22] contrib/plugins/hotblocks: " Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 19/22] contrib/plugins/hwprofile: " Alex Bennée
` (3 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-9-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/cflow.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/contrib/plugins/cflow.c b/contrib/plugins/cflow.c
index b39974d1cf..930ecb46fc 100644
--- a/contrib/plugins/cflow.c
+++ b/contrib/plugins/cflow.c
@@ -76,6 +76,8 @@ typedef struct {
/* We use this to track the current execution state */
typedef struct {
+ /* address of current translated block */
+ uint64_t tb_pc;
/* address of end of block */
uint64_t end_block;
/* next pc after end of block */
@@ -85,6 +87,7 @@ typedef struct {
} VCPUScoreBoard;
/* descriptors for accessing the above scoreboard */
+static qemu_plugin_u64 tb_pc;
static qemu_plugin_u64 end_block;
static qemu_plugin_u64 pc_after_block;
static qemu_plugin_u64 last_pc;
@@ -189,10 +192,11 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
static void plugin_init(void)
{
g_mutex_init(&node_lock);
- nodes = g_hash_table_new(NULL, g_direct_equal);
+ nodes = g_hash_table_new(g_int64_hash, g_int64_equal);
state = qemu_plugin_scoreboard_new(sizeof(VCPUScoreBoard));
/* score board declarations */
+ tb_pc = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard, tb_pc);
end_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard,
end_block);
pc_after_block = qemu_plugin_scoreboard_u64_in_struct(state, VCPUScoreBoard,
@@ -215,10 +219,10 @@ static NodeData *fetch_node(uint64_t addr, bool create_if_not_found)
NodeData *node = NULL;
g_mutex_lock(&node_lock);
- node = (NodeData *) g_hash_table_lookup(nodes, (gconstpointer) addr);
+ node = (NodeData *) g_hash_table_lookup(nodes, &addr);
if (!node && create_if_not_found) {
node = create_node(addr);
- g_hash_table_insert(nodes, (gpointer) addr, (gpointer) node);
+ g_hash_table_insert(nodes, &node->addr, node);
}
g_mutex_unlock(&node_lock);
return node;
@@ -234,7 +238,7 @@ static void vcpu_tb_branched_exec(unsigned int cpu_index, void *udata)
uint64_t lpc = qemu_plugin_u64_get(last_pc, cpu_index);
uint64_t ebpc = qemu_plugin_u64_get(end_block, cpu_index);
uint64_t npc = qemu_plugin_u64_get(pc_after_block, cpu_index);
- uint64_t pc = GPOINTER_TO_UINT(udata);
+ uint64_t pc = qemu_plugin_u64_get(tb_pc, cpu_index);
/* return early for address 0 */
if (!lpc) {
@@ -305,10 +309,11 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
* handle both early block exits and normal branches in the
* callback if we hit it.
*/
- gpointer udata = GUINT_TO_POINTER(pc);
+ qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(
+ tb, QEMU_PLUGIN_INLINE_STORE_U64, tb_pc, pc);
qemu_plugin_register_vcpu_tb_exec_cond_cb(
tb, vcpu_tb_branched_exec, QEMU_PLUGIN_CB_NO_REGS,
- QEMU_PLUGIN_COND_NE, pc_after_block, pc, udata);
+ QEMU_PLUGIN_COND_NE, pc_after_block, pc, NULL);
/*
* Now we can set start/end for this block so the next block can
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 19/22] contrib/plugins/hwprofile: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (17 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 18/22] contrib/plugins/cflow: " Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 20/22] contrib/plugins/hotpages: " Alex Bennée
` (2 subsequent siblings)
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-10-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/hwprofile.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/contrib/plugins/hwprofile.c b/contrib/plugins/hwprofile.c
index 739ac0c66b..2a4cbc47d4 100644
--- a/contrib/plugins/hwprofile.c
+++ b/contrib/plugins/hwprofile.c
@@ -43,6 +43,8 @@ typedef struct {
static GMutex lock;
static GHashTable *devices;
+static struct qemu_plugin_scoreboard *source_pc_scoreboard;
+static qemu_plugin_u64 source_pc;
/* track the access pattern to a piece of HW */
static bool pattern;
@@ -159,7 +161,7 @@ static DeviceCounts *new_count(const char *name, uint64_t base)
count->name = name;
count->base = base;
if (pattern || source) {
- count->detail = g_hash_table_new(NULL, NULL);
+ count->detail = g_hash_table_new(g_int64_hash, g_int64_equal);
}
g_hash_table_insert(devices, (gpointer) name, count);
return count;
@@ -169,7 +171,7 @@ static IOLocationCounts *new_location(GHashTable *table, uint64_t off_or_pc)
{
IOLocationCounts *loc = g_new0(IOLocationCounts, 1);
loc->off_or_pc = off_or_pc;
- g_hash_table_insert(table, (gpointer) off_or_pc, loc);
+ g_hash_table_insert(table, &loc->off_or_pc, loc);
return loc;
}
@@ -224,12 +226,12 @@ static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
/* either track offsets or source of access */
if (source) {
- off = (uint64_t) udata;
+ off = qemu_plugin_u64_get(source_pc, cpu_index);
}
if (pattern || source) {
IOLocationCounts *io_count = g_hash_table_lookup(counts->detail,
- (gpointer) off);
+ &off);
if (!io_count) {
io_count = new_location(counts->detail, off);
}
@@ -247,10 +249,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
for (i = 0; i < n; i++) {
struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
- gpointer udata = (gpointer) (source ? qemu_plugin_insn_vaddr(insn) : 0);
+ if (source) {
+ uint64_t pc = qemu_plugin_insn_vaddr(insn);
+ qemu_plugin_register_vcpu_mem_inline_per_vcpu(
+ insn, rw, QEMU_PLUGIN_INLINE_STORE_U64,
+ source_pc, pc);
+ }
qemu_plugin_register_vcpu_mem_cb(insn, vcpu_haddr,
- QEMU_PLUGIN_CB_NO_REGS,
- rw, udata);
+ QEMU_PLUGIN_CB_NO_REGS, rw, NULL);
}
}
@@ -306,10 +312,9 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
return -1;
}
- /* Just warn about overflow */
- if (info->system.smp_vcpus > 64 ||
- info->system.max_vcpus > 64) {
- fprintf(stderr, "hwprofile: can only track up to 64 CPUs\n");
+ if (source) {
+ source_pc_scoreboard = qemu_plugin_scoreboard_new(sizeof(uint64_t));
+ source_pc = qemu_plugin_scoreboard_u64(source_pc_scoreboard);
}
plugin_init();
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 20/22] contrib/plugins/hotpages: fix 32-bit build
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (18 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 19/22] contrib/plugins/hwprofile: " Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 21/22] configure: reenable plugins by default for 32-bit hosts Alex Bennée
2025-01-09 17:06 ` [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile Alex Bennée
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-11-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
contrib/plugins/hotpages.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/contrib/plugins/hotpages.c b/contrib/plugins/hotpages.c
index 8316ae50c7..c6e6493719 100644
--- a/contrib/plugins/hotpages.c
+++ b/contrib/plugins/hotpages.c
@@ -103,7 +103,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
static void plugin_init(void)
{
page_mask = (page_size - 1);
- pages = g_hash_table_new(NULL, g_direct_equal);
+ pages = g_hash_table_new(g_int64_hash, g_int64_equal);
}
static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
@@ -130,12 +130,12 @@ static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
page &= ~page_mask;
g_mutex_lock(&lock);
- count = (PageCounters *) g_hash_table_lookup(pages, GUINT_TO_POINTER(page));
+ count = (PageCounters *) g_hash_table_lookup(pages, &page);
if (!count) {
count = g_new0(PageCounters, 1);
count->page_address = page;
- g_hash_table_insert(pages, GUINT_TO_POINTER(page), (gpointer) count);
+ g_hash_table_insert(pages, &count->page_address, count);
}
if (qemu_plugin_mem_is_store(meminfo)) {
count->writes++;
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 21/22] configure: reenable plugins by default for 32-bit hosts
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (19 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 20/22] contrib/plugins/hotpages: " Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 17:06 ` [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile Alex Bennée
21 siblings, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20241217224306.2900490-12-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
configure | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/configure b/configure
index 18336376bf..02f1dd2311 100755
--- a/configure
+++ b/configure
@@ -528,25 +528,6 @@ case "$cpu" in
;;
esac
-# Now we have our CPU_CFLAGS we can check if we are targeting a 32 or
-# 64 bit host.
-
-check_64bit_host() {
-cat > $TMPC <<EOF
-#if __SIZEOF_POINTER__ != 8
-#error not 64 bit system
-#endif
-int main(void) { return 0; }
-EOF
- compile_object "$1"
-}
-
-if check_64bit_host "$CPU_CFLAGS"; then
- host_bits=64
-else
- host_bits=32
-fi
-
if test -n "$host_arch" && {
! test -d "$source_path/linux-user/include/host/$host_arch" ||
! test -d "$source_path/common-user/host/$host_arch"; }; then
@@ -1072,7 +1053,7 @@ if test "$static" = "yes" ; then
fi
plugins="no"
fi
-if test "$plugins" != "no" && test $host_bits -eq 64; then
+if test "$plugins" != "no"; then
if has_meson_option "-Dtcg_interpreter=true"; then
plugins="no"
else
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
` (20 preceding siblings ...)
2025-01-09 17:06 ` [PATCH 21/22] configure: reenable plugins by default for 32-bit hosts Alex Bennée
@ 2025-01-09 17:06 ` Alex Bennée
2025-01-09 18:48 ` Pierrick Bouvier
` (2 more replies)
21 siblings, 3 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 17:06 UTC (permalink / raw)
To: qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Alex Bennée, Julian Ganz
While it would be technically correct to allow an IRQ to happen (as
the offending instruction never really completed) it messes up
instrumentation. We already take care to only use memory
instrumentation on the block, we should also suppress IRQs.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Julian Ganz <neither@nut.email>
---
accel/tcg/translate-all.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 453eb20ec9..d56ca13cdd 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -633,9 +633,10 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
* Exit the loop and potentially generate a new TB executing the
* just the I/O insns. We also limit instrumentation to memory
* operations only (which execute after completion) so we don't
- * double instrument the instruction.
+ * double instrument the instruction. Also don't let an IRQ sneak
+ * in before we execute it.
*/
- cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n;
+ cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | CF_NOIRQ | n;
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
vaddr pc = cpu->cc->get_pc(cpu);
--
2.39.5
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH 09/22] system: squash usb_parse into a single function
2025-01-09 17:06 ` [PATCH 09/22] system: squash usb_parse into a single function Alex Bennée
@ 2025-01-09 17:30 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-09 17:30 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier, Thomas Huth,
Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier
On 9/1/25 18:06, Alex Bennée wrote:
> We don't need to wrap usb_device_add as usb_parse is already gated
> with an if (machine_usb(current_machine)) check. Instead just assert
> and directly fail if usbdevice_create returns NULL.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> system/vl.c | 22 ++++------------------
> 1 file changed, 4 insertions(+), 18 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile
2025-01-09 17:06 ` [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile Alex Bennée
@ 2025-01-09 18:48 ` Pierrick Bouvier
2025-01-10 15:02 ` Richard Henderson
2025-01-11 15:09 ` Julian Ganz
2 siblings, 0 replies; 36+ messages in thread
From: Pierrick Bouvier @ 2025-01-09 18:48 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Philippe Mathieu-Daudé, Thomas Huth,
Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier, Julian Ganz
On 1/9/25 09:06, Alex Bennée wrote:
> While it would be technically correct to allow an IRQ to happen (as
> the offending instruction never really completed) it messes up
> instrumentation. We already take care to only use memory
> instrumentation on the block, we should also suppress IRQs.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Julian Ganz <neither@nut.email>
> ---
> accel/tcg/translate-all.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index 453eb20ec9..d56ca13cdd 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -633,9 +633,10 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
> * Exit the loop and potentially generate a new TB executing the
> * just the I/O insns. We also limit instrumentation to memory
> * operations only (which execute after completion) so we don't
> - * double instrument the instruction.
> + * double instrument the instruction. Also don't let an IRQ sneak
> + * in before we execute it.
> */
> - cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n;
> + cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | CF_NOIRQ | n;
>
> if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
> vaddr pc = cpu->cc->get_pc(cpu);
Thanks for the fix Alex, I confirm it solved the issue observed with
discon plugin with aarch64 guest.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/22] semihosting: add guest_error logging for failed opens
2025-01-09 17:05 ` [PATCH 01/22] semihosting: add guest_error logging for failed opens Alex Bennée
@ 2025-01-09 18:48 ` Pierrick Bouvier
0 siblings, 0 replies; 36+ messages in thread
From: Pierrick Bouvier @ 2025-01-09 18:48 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Philippe Mathieu-Daudé, Thomas Huth,
Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier
On 1/9/25 09:05, Alex Bennée wrote:
> This usually indicates the semihosting call was expecting to find
> something but didn't.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> semihosting/syscalls.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c
> index c40348f996..f6451d9bb0 100644
> --- a/semihosting/syscalls.c
> +++ b/semihosting/syscalls.c
> @@ -7,6 +7,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/log.h"
> #include "cpu.h"
> #include "gdbstub/syscalls.h"
> #include "semihosting/guestfd.h"
> @@ -287,6 +288,7 @@ static void host_open(CPUState *cs, gdb_syscall_complete_cb complete,
>
> ret = open(p, host_flags, mode);
> if (ret < 0) {
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to open %s\n", __func__, p);
> complete(cs, -1, errno);
> } else {
> int guestfd = alloc_guestfd();
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 08/22] system/vl: more error exit into config enumeration code
2025-01-09 17:06 ` [PATCH 08/22] system/vl: more error exit into config enumeration code Alex Bennée
@ 2025-01-09 18:49 ` Pierrick Bouvier
2025-01-10 7:34 ` Philippe Mathieu-Daudé
2025-01-10 15:03 ` Richard Henderson
2 siblings, 0 replies; 36+ messages in thread
From: Pierrick Bouvier @ 2025-01-09 18:49 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Philippe Mathieu-Daudé, Thomas Huth,
Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier
On 1/9/25 09:06, Alex Bennée wrote:
> All of the failures to configure devices will result in QEMU exiting
> with an error code. In preparation for passing Error * down the chain
> re-name the iterator to foreach_device_config_or_exit and exit using
> &error_fatal instead of returning a failure indication.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> system/vl.c | 31 ++++++++++++++++---------------
> 1 file changed, 16 insertions(+), 15 deletions(-)
>
> diff --git a/system/vl.c b/system/vl.c
> index 0843b7ab49..25d9968ccc 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -1307,7 +1307,14 @@ static void add_device_config(int type, const char *cmdline)
> QTAILQ_INSERT_TAIL(&device_configs, conf, next);
> }
>
> -static int foreach_device_config(int type, int (*func)(const char *cmdline))
> +/**
> + * foreach_device_config_or_exit(): process per-device configs
> + * @type: device_config type
> + * @func: device specific config function, returning pass/fail
> + *
> + * Any failure is fatal and we exit with an error message.
> + */
> +static void foreach_device_config_or_exit(int type, int (*func)(const char *cmdline))
> {
> struct device_config *conf;
> int rc;
> @@ -1319,10 +1326,10 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline))
> rc = func(conf->cmdline);
> loc_pop(&conf->loc);
> if (rc) {
> - return rc;
> + error_setg(&error_fatal, "failed to configure: %s", conf->cmdline);
> + exit(1);
> }
> }
> - return 0;
> }
>
> static void qemu_disable_default_devices(void)
> @@ -2044,12 +2051,9 @@ static void qemu_create_late_backends(void)
> qemu_opts_foreach(qemu_find_opts("mon"),
> mon_init_func, NULL, &error_fatal);
>
> - if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
> - exit(1);
> - if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
> - exit(1);
> - if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
> - exit(1);
> + foreach_device_config_or_exit(DEV_SERIAL, serial_parse);
> + foreach_device_config_or_exit(DEV_PARALLEL, parallel_parse);
> + foreach_device_config_or_exit(DEV_DEBUGCON, debugcon_parse);
>
> /* now chardevs have been created we may have semihosting to connect */
> qemu_semihosting_chardev_init();
> @@ -2670,8 +2674,7 @@ static void qemu_create_cli_devices(void)
>
> /* init USB devices */
> if (machine_usb(current_machine)) {
> - if (foreach_device_config(DEV_USB, usb_parse) < 0)
> - exit(1);
> + foreach_device_config_or_exit(DEV_USB, usb_parse);
> }
>
> /* init generic devices */
> @@ -2718,10 +2721,8 @@ static bool qemu_machine_creation_done(Error **errp)
> exit(1);
> }
>
> - if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
> - error_setg(errp, "could not start gdbserver");
> - return false;
> - }
> + foreach_device_config_or_exit(DEV_GDB, gdbserver_start);
> +
> if (!vga_interface_created && !default_vga &&
> vga_interface_type != VGA_NONE) {
> warn_report("A -vga option was passed but this machine "
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups)
2025-01-09 17:06 ` [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups) Alex Bennée
@ 2025-01-09 18:55 ` Pierrick Bouvier
2025-01-09 19:45 ` Alex Bennée
0 siblings, 1 reply; 36+ messages in thread
From: Pierrick Bouvier @ 2025-01-09 18:55 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Philippe Mathieu-Daudé, Thomas Huth,
Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier, Ilya Leoshkevich
On 1/9/25 09:06, Alex Bennée wrote:
> This started as a clean-up to properly pass a Error handler to the
> gdbserver_start so we could do the right thing for command line and
> HMP invocations.
>
> Now that we have cleaned up foreach_device_config_or_exit() in earlier
> patches we can further simplify by it by passing &error_fatal instead
> of checking the return value. Having a return value is still useful
> for HMP though so tweak the return to use a simple bool instead.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
>
<snip>
> -static int gdbserver_open_port(int port)
> +static int gdbserver_open_port(int port, Error **errp)
Did you mean:
static bool gdbserver_open_port...?
With that,
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups)
2025-01-09 18:55 ` Pierrick Bouvier
@ 2025-01-09 19:45 ` Alex Bennée
2025-01-09 22:27 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 36+ messages in thread
From: Alex Bennée @ 2025-01-09 19:45 UTC (permalink / raw)
To: Pierrick Bouvier
Cc: qemu-devel, Dr. David Alan Gilbert, Philippe Mathieu-Daudé,
Thomas Huth, Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier, Ilya Leoshkevich
Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> On 1/9/25 09:06, Alex Bennée wrote:
>> This started as a clean-up to properly pass a Error handler to the
>> gdbserver_start so we could do the right thing for command line and
>> HMP invocations.
>> Now that we have cleaned up foreach_device_config_or_exit() in
>> earlier
>> patches we can further simplify by it by passing &error_fatal instead
>> of checking the return value. Having a return value is still useful
>> for HMP though so tweak the return to use a simple bool instead.
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
>>
>
> <snip>
>
>> -static int gdbserver_open_port(int port)
>> +static int gdbserver_open_port(int port, Error **errp)
>
> Did you mean:
> static bool gdbserver_open_port...?
yes, yes I did. Will fix.
>
> With that,
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups)
2025-01-09 19:45 ` Alex Bennée
@ 2025-01-09 22:27 ` Philippe Mathieu-Daudé
2025-01-10 11:54 ` Alex Bennée
2025-01-10 21:05 ` Pierrick Bouvier
0 siblings, 2 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-09 22:27 UTC (permalink / raw)
To: Alex Bennée, Pierrick Bouvier
Cc: qemu-devel, Dr. David Alan Gilbert, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Ilya Leoshkevich
On 9/1/25 20:45, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>
>> On 1/9/25 09:06, Alex Bennée wrote:
>>> This started as a clean-up to properly pass a Error handler to the
>>> gdbserver_start so we could do the right thing for command line and
>>> HMP invocations.
>>> Now that we have cleaned up foreach_device_config_or_exit() in
>>> earlier
>>> patches we can further simplify by it by passing &error_fatal instead
>>> of checking the return value. Having a return value is still useful
>>> for HMP though so tweak the return to use a simple bool instead.
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
>>>
>>
>> <snip>
>>
>>> -static int gdbserver_open_port(int port)
>>> +static int gdbserver_open_port(int port, Error **errp)
>>
>> Did you mean:
>> static bool gdbserver_open_port...?
>
> yes, yes I did. Will fix.
This is returning a socket file descriptor, why bool?
>
>>
>> With that,
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 08/22] system/vl: more error exit into config enumeration code
2025-01-09 17:06 ` [PATCH 08/22] system/vl: more error exit into config enumeration code Alex Bennée
2025-01-09 18:49 ` Pierrick Bouvier
@ 2025-01-10 7:34 ` Philippe Mathieu-Daudé
2025-01-10 15:03 ` Richard Henderson
2 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-10 7:34 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier, Thomas Huth,
Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier
On 9/1/25 18:06, Alex Bennée wrote:
> All of the failures to configure devices will result in QEMU exiting
> with an error code. In preparation for passing Error * down the chain
> re-name the iterator to foreach_device_config_or_exit and exit using
> &error_fatal instead of returning a failure indication.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> system/vl.c | 31 ++++++++++++++++---------------
> 1 file changed, 16 insertions(+), 15 deletions(-)
Yay, simpler.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups)
2025-01-09 22:27 ` Philippe Mathieu-Daudé
@ 2025-01-10 11:54 ` Alex Bennée
2025-01-10 21:05 ` Pierrick Bouvier
1 sibling, 0 replies; 36+ messages in thread
From: Alex Bennée @ 2025-01-10 11:54 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Pierrick Bouvier, qemu-devel, Dr. David Alan Gilbert, Thomas Huth,
Mahmoud Mandour, Alexandre Iooss, Richard Henderson,
Paolo Bonzini, Laurent Vivier, Ilya Leoshkevich
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> On 9/1/25 20:45, Alex Bennée wrote:
>> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>>
>>> On 1/9/25 09:06, Alex Bennée wrote:
>>>> This started as a clean-up to properly pass a Error handler to the
>>>> gdbserver_start so we could do the right thing for command line and
>>>> HMP invocations.
>>>> Now that we have cleaned up foreach_device_config_or_exit() in
>>>> earlier
>>>> patches we can further simplify by it by passing &error_fatal instead
>>>> of checking the return value. Having a return value is still useful
>>>> for HMP though so tweak the return to use a simple bool instead.
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
>>>>
>>>
>>> <snip>
>>>
>>>> -static int gdbserver_open_port(int port)
>>>> +static int gdbserver_open_port(int port, Error **errp)
>>>
>>> Did you mean:
>>> static bool gdbserver_open_port...?
>> yes, yes I did. Will fix.
>
> This is returning a socket file descriptor, why bool?
Doh - misread - I thought this was gdbserver_start... let me check.
>
>>
>>>
>>> With that,
>>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile
2025-01-09 17:06 ` [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile Alex Bennée
2025-01-09 18:48 ` Pierrick Bouvier
@ 2025-01-10 15:02 ` Richard Henderson
2025-01-11 15:09 ` Julian Ganz
2 siblings, 0 replies; 36+ messages in thread
From: Richard Henderson @ 2025-01-10 15:02 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Paolo Bonzini, Laurent Vivier, Julian Ganz
On 1/9/25 09:06, Alex Bennée wrote:
> While it would be technically correct to allow an IRQ to happen (as
> the offending instruction never really completed) it messes up
> instrumentation. We already take care to only use memory
> instrumentation on the block, we should also suppress IRQs.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Julian Ganz <neither@nut.email>
> ---
> accel/tcg/translate-all.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
>
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index 453eb20ec9..d56ca13cdd 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -633,9 +633,10 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
> * Exit the loop and potentially generate a new TB executing the
> * just the I/O insns. We also limit instrumentation to memory
> * operations only (which execute after completion) so we don't
> - * double instrument the instruction.
> + * double instrument the instruction. Also don't let an IRQ sneak
> + * in before we execute it.
> */
> - cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n;
> + cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | CF_NOIRQ | n;
>
> if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
> vaddr pc = cpu->cc->get_pc(cpu);
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 08/22] system/vl: more error exit into config enumeration code
2025-01-09 17:06 ` [PATCH 08/22] system/vl: more error exit into config enumeration code Alex Bennée
2025-01-09 18:49 ` Pierrick Bouvier
2025-01-10 7:34 ` Philippe Mathieu-Daudé
@ 2025-01-10 15:03 ` Richard Henderson
2 siblings, 0 replies; 36+ messages in thread
From: Richard Henderson @ 2025-01-10 15:03 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Paolo Bonzini, Laurent Vivier
On 1/9/25 09:06, Alex Bennée wrote:
> All of the failures to configure devices will result in QEMU exiting
> with an error code. In preparation for passing Error * down the chain
> re-name the iterator to foreach_device_config_or_exit and exit using
> &error_fatal instead of returning a failure indication.
>
> Signed-off-by: Alex Bennée<alex.bennee@linaro.org>
> ---
> system/vl.c | 31 ++++++++++++++++---------------
> 1 file changed, 16 insertions(+), 15 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups)
2025-01-09 22:27 ` Philippe Mathieu-Daudé
2025-01-10 11:54 ` Alex Bennée
@ 2025-01-10 21:05 ` Pierrick Bouvier
1 sibling, 0 replies; 36+ messages in thread
From: Pierrick Bouvier @ 2025-01-10 21:05 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Alex Bennée
Cc: qemu-devel, Dr. David Alan Gilbert, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini, Laurent Vivier,
Ilya Leoshkevich
On 1/9/25 14:27, Philippe Mathieu-Daudé wrote:
> On 9/1/25 20:45, Alex Bennée wrote:
>> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>>
>>> On 1/9/25 09:06, Alex Bennée wrote:
>>>> This started as a clean-up to properly pass a Error handler to the
>>>> gdbserver_start so we could do the right thing for command line and
>>>> HMP invocations.
>>>> Now that we have cleaned up foreach_device_config_or_exit() in
>>>> earlier
>>>> patches we can further simplify by it by passing &error_fatal instead
>>>> of checking the return value. Having a return value is still useful
>>>> for HMP though so tweak the return to use a simple bool instead.
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
>>>>
>>>
>>> <snip>
>>>
>>>> -static int gdbserver_open_port(int port)
>>>> +static int gdbserver_open_port(int port, Error **errp)
>>>
>>> Did you mean:
>>> static bool gdbserver_open_port...?
>>
>> yes, yes I did. Will fix.
>
> This is returning a socket file descriptor, why bool?
>
Oops, yes my comment was wrong.
We should return -1, as it was the case before.
>>
>>>
>>> With that,
>>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile
2025-01-09 17:06 ` [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile Alex Bennée
2025-01-09 18:48 ` Pierrick Bouvier
2025-01-10 15:02 ` Richard Henderson
@ 2025-01-11 15:09 ` Julian Ganz
2 siblings, 0 replies; 36+ messages in thread
From: Julian Ganz @ 2025-01-11 15:09 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Dr. David Alan Gilbert, Pierrick Bouvier,
Philippe Mathieu-Daudé, Thomas Huth, Mahmoud Mandour,
Alexandre Iooss, Richard Henderson, Paolo Bonzini,
Laurent Vivier, Alex Bennée
Hi Alex,
January 9, 2025 at 6:06 PM, "Alex Bennée" wrote:
> While it would be technically correct to allow an IRQ to happen (as
> the offending instruction never really completed) it messes up
> instrumentation. We already take care to only use memory
> instrumentation on the block, we should also suppress IRQs.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Julian Ganz <neither@nut.email>
> ---
> accel/tcg/translate-all.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index 453eb20ec9..d56ca13cdd 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -633,9 +633,10 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
> * Exit the loop and potentially generate a new TB executing the
> * just the I/O insns. We also limit instrumentation to memory
> * operations only (which execute after completion) so we don't
> - * double instrument the instruction.
> + * double instrument the instruction. Also don't let an IRQ sneak
> + * in before we execute it.
> */
> - cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n;
> + cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | CF_NOIRQ | n;
>
> if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
> vaddr pc = cpu->cc->get_pc(cpu);
> --
> 2.39.5
Reviewed-by: Julian Ganz <neither@nut.email>
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2025-01-11 15:10 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 17:05 [PATCH 00/22] maintainer updates for jan '25 (semihosting, gdb, plugins) Alex Bennée
2025-01-09 17:05 ` [PATCH 01/22] semihosting: add guest_error logging for failed opens Alex Bennée
2025-01-09 18:48 ` Pierrick Bouvier
2025-01-09 17:05 ` [PATCH 02/22] semihosting/uaccess: Briefly document returned values Alex Bennée
2025-01-09 17:06 ` [PATCH 03/22] semihosting/syscalls: Include missing 'exec/cpu-defs.h' header Alex Bennée
2025-01-09 17:06 ` [PATCH 04/22] semihosting/uaccess: Include missing 'exec/cpu-all.h' header Alex Bennée
2025-01-09 17:06 ` [PATCH 05/22] semihosting/arm-compat: Include missing 'cpu.h' header Alex Bennée
2025-01-09 17:06 ` [PATCH 06/22] semihosting/console: Avoid including 'cpu.h' Alex Bennée
2025-01-09 17:06 ` [PATCH 07/22] semihosting/meson: Build config.o and console.o once Alex Bennée
2025-01-09 17:06 ` [PATCH 08/22] system/vl: more error exit into config enumeration code Alex Bennée
2025-01-09 18:49 ` Pierrick Bouvier
2025-01-10 7:34 ` Philippe Mathieu-Daudé
2025-01-10 15:03 ` Richard Henderson
2025-01-09 17:06 ` [PATCH 09/22] system: squash usb_parse into a single function Alex Bennée
2025-01-09 17:30 ` Philippe Mathieu-Daudé
2025-01-09 17:06 ` [PATCH 10/22] system: propagate Error to gdbserver_start (and other device setups) Alex Bennée
2025-01-09 18:55 ` Pierrick Bouvier
2025-01-09 19:45 ` Alex Bennée
2025-01-09 22:27 ` Philippe Mathieu-Daudé
2025-01-10 11:54 ` Alex Bennée
2025-01-10 21:05 ` Pierrick Bouvier
2025-01-09 17:06 ` [PATCH 11/22] tests/tcg/plugins/insn: remove unused callback parameter Alex Bennée
2025-01-09 17:06 ` [PATCH 12/22] contrib/plugins/howvec: ensure we don't regress if this plugin is extended Alex Bennée
2025-01-09 17:06 ` [PATCH 13/22] tests/tcg/plugins/syscall: fix 32-bit build Alex Bennée
2025-01-09 17:06 ` [PATCH 14/22] tests/tcg/plugins/mem: " Alex Bennée
2025-01-09 17:06 ` [PATCH 15/22] contrib/plugins/stoptrigger: " Alex Bennée
2025-01-09 17:06 ` [PATCH 16/22] contrib/plugins/cache: " Alex Bennée
2025-01-09 17:06 ` [PATCH 17/22] contrib/plugins/hotblocks: " Alex Bennée
2025-01-09 17:06 ` [PATCH 18/22] contrib/plugins/cflow: " Alex Bennée
2025-01-09 17:06 ` [PATCH 19/22] contrib/plugins/hwprofile: " Alex Bennée
2025-01-09 17:06 ` [PATCH 20/22] contrib/plugins/hotpages: " Alex Bennée
2025-01-09 17:06 ` [PATCH 21/22] configure: reenable plugins by default for 32-bit hosts Alex Bennée
2025-01-09 17:06 ` [PATCH 22/22] accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile Alex Bennée
2025-01-09 18:48 ` Pierrick Bouvier
2025-01-10 15:02 ` Richard Henderson
2025-01-11 15:09 ` Julian Ganz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.