* [PATCH v4 00/65] accel: Preparatory cleanups for split-accel
@ 2025-07-02 18:52 Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 01/65] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
` (65 more replies)
0 siblings, 66 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Missing review: 22-23, 57-59, 63
Since v3:
- Addressed Richard's review comments
Few changes needed before being able to add the
split acceleration:
- few method docstring added
- remove pointless stubs
- propagate soon required AccelState argument
- try to reduce current_accel() uses
- move declarations AccelClass <-> AccelOpsClass
- display model name in 'info cpus'
- add 'info accel' command to QMP/HMP
- make accel_create_vcpu_thread() more generic
- introduce hwaccel_enabled()
I plan to send a PR once fully reviewed.
Regards,
Phil.
Philippe Mathieu-Daudé (65):
system/runstate: Document qemu_add_vm_change_state_handler()
system/cpus: Defer memory layout changes until vCPUs are realized
system/cpus: Assert interrupt handling is done with BQL locked
accel: Keep reference to AccelOpsClass in AccelClass
accel: Introduce AccelOpsClass::cpu_target_realize() hook
accel/hvf: Add hvf_arch_cpu_realize() stubs
accel/kvm: Remove kvm_init_cpu_signals() stub
accel/kvm: Reduce kvm_create_vcpu() declaration scope
accel: Propagate AccelState to AccelClass::init_machine()
accel/kvm: Prefer local AccelState over global MachineState::accel
accel/hvf: Re-use QOM allocated state
accel/tcg: Prefer local AccelState over global current_accel()
accel: Directly pass AccelState argument to AccelClass::has_memory()
accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()
accel: Remove unused MachineState argument of AccelClass::setup_post()
accel: Pass AccelState argument to gdbstub_supported_sstep_flags()
accel: Move supports_guest_debug() declaration to AccelClass
accel: Move cpus_are_resettable() declaration to AccelClass
accel: Move cpu_common_[un]realize() declarations to AccelOpsClass
accel/system: Convert pre_resume() from AccelOpsClass to AccelClass
hw/core/machine: Display CPU model name in 'info cpus' command
qapi: Move definitions related to accelerators in their own file
accel/system: Introduce @x-accel-stats QMP command
accel/system: Add 'info accel' on human monitor
accel/tcg: Factor tcg_dump_flush_info() out
accel/tcg: Implement get_[vcpu]_stats()
accel/hvf: Implement get_vcpu_stats()
accel/hvf: Report missing com.apple.security.hypervisor entitlement
accel/hvf: Restrict internal declarations
accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c
accel/hvf: Move generic method declarations to hvf-all.c
cpus: Document CPUState::vcpu_dirty field
accel/hvf: Replace @dirty field by generic CPUState::vcpu_dirty field
accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field
accel/whpx: Replace @dirty field by generic CPUState::vcpu_dirty field
accel/kvm: Remove kvm_cpu_synchronize_state() stub
accel/system: Document cpu_synchronize_state()
accel/system: Document cpu_synchronize_state_post_init/reset()
accel/nvmm: Expose nvmm_enabled() to common code
accel/whpx: Expose whpx_enabled() to common code
accel/system: Introduce hwaccel_enabled() helper
target/arm: Use generic hwaccel_enabled() to check 'host' cpu type
accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'
accel/dummy: Factor dummy_thread_precreate() out
accel/tcg: Factor tcg_vcpu_thread_precreate() out
accel: Factor accel_create_vcpu_thread() out
accel: Introduce AccelOpsClass::cpu_thread_routine handler
accel/dummy: Convert to AccelOpsClass::cpu_thread_routine
accel/tcg: Convert to AccelOpsClass::cpu_thread_routine
accel/hvf: Convert to AccelOpsClass::cpu_thread_routine
accel/kvm: Convert to AccelOpsClass::cpu_thread_routine
accel/nvmm: Convert to AccelOpsClass::cpu_thread_routine
accel/whpx: Convert to AccelOpsClass::cpu_thread_routine
accel: Factor accel_cpu_realize() out
accel: Pass old/new interrupt mask to handle_interrupt() handler
accel: Expose and register generic_handle_interrupt()
accel: Always register AccelOpsClass::kick_vcpu_thread() handler
accel: Always register AccelOpsClass::get_elapsed_ticks() handler
accel: Always register AccelOpsClass::get_virtual_clock() handler
system/memory: Restrict eventfd dispatch_write() to emulators
accel/tcg: Factor tcg_vcpu_init() out for re-use
accel/tcg: Factor mttcg_cpu_exec() out for re-use
accel/tcg: Factor rr_cpu_exec() out
accel/tcg: Clear exit_request once in tcg_cpu_exec()
accel/tcg: Unregister the RCU before exiting RR thread
MAINTAINERS | 1 +
qapi/accelerator.json | 92 ++++++++
qapi/machine.json | 68 +-----
qapi/qapi-schema.json | 1 +
accel/accel-internal.h | 2 +
accel/dummy-cpus.h | 15 ++
accel/kvm/kvm-cpus.h | 1 -
accel/tcg/internal-common.h | 2 +
accel/tcg/tcg-accel-ops-icount.h | 2 +-
accel/tcg/tcg-accel-ops-mttcg.h | 4 +-
accel/tcg/tcg-accel-ops.h | 5 +-
include/hw/core/cpu.h | 3 +-
include/qemu/accel.h | 22 +-
include/system/accel-ops.h | 42 +++-
include/system/cpus.h | 5 -
include/system/hvf.h | 38 ----
include/system/hvf_int.h | 37 +++-
include/system/hw_accel.h | 34 ++-
include/system/kvm.h | 8 -
include/system/nvmm.h | 23 +-
include/system/runstate.h | 10 +
include/system/whpx.h | 27 +--
target/i386/whpx/whpx-accel-ops.h | 1 -
accel/accel-common.c | 55 ++++-
accel/accel-qmp.c | 34 +++
accel/accel-system.c | 35 ++-
accel/dummy-cpus.c | 11 +-
accel/hvf/hvf-accel-ops.c | 341 +++++-------------------------
accel/hvf/hvf-all.c | 281 ++++++++++++++++++++++--
accel/kvm/kvm-accel-ops.c | 25 +--
accel/kvm/kvm-all.c | 38 ++--
accel/qtest/qtest.c | 10 +-
accel/stubs/kvm-stub.c | 9 -
accel/stubs/nvmm-stub.c | 12 ++
accel/stubs/whpx-stub.c | 12 ++
accel/tcg/monitor.c | 29 ++-
accel/tcg/tcg-accel-ops-icount.c | 8 +-
accel/tcg/tcg-accel-ops-mttcg.c | 28 +--
accel/tcg/tcg-accel-ops-rr.c | 40 ++--
accel/tcg/tcg-accel-ops.c | 44 ++--
accel/tcg/tcg-all.c | 20 +-
accel/xen/xen-all.c | 13 +-
bsd-user/main.c | 2 +-
gdbstub/system.c | 7 +-
hw/core/machine-hmp-cmds.c | 4 +-
hw/core/machine-qmp-cmds.c | 2 +
linux-user/main.c | 2 +-
system/cpus.c | 55 ++---
system/memory.c | 11 +-
system/physmem.c | 8 +
target/arm/arm-qmp-cmds.c | 5 +-
target/arm/cpu.c | 5 +-
target/arm/hvf/hvf.c | 11 +-
target/i386/hvf/hvf.c | 11 +-
target/i386/hvf/x86hvf.c | 2 +-
target/i386/nvmm/nvmm-accel-ops.c | 17 +-
target/i386/nvmm/nvmm-all.c | 29 +--
target/i386/whpx/whpx-accel-ops.c | 18 +-
target/i386/whpx/whpx-all.c | 33 ++-
accel/meson.build | 2 +-
accel/stubs/meson.build | 2 +
hmp-commands-info.hx | 12 ++
qapi/meson.build | 1 +
63 files changed, 1013 insertions(+), 714 deletions(-)
create mode 100644 qapi/accelerator.json
create mode 100644 accel/dummy-cpus.h
create mode 100644 accel/accel-qmp.c
create mode 100644 accel/stubs/nvmm-stub.c
create mode 100644 accel/stubs/whpx-stub.c
--
2.49.0
^ permalink raw reply [flat|nested] 108+ messages in thread
* [PATCH v4 01/65] system/runstate: Document qemu_add_vm_change_state_handler()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-03 7:03 ` Alex Bennée
2025-07-02 18:52 ` [PATCH v4 02/65] system/cpus: Defer memory layout changes until vCPUs are realized Philippe Mathieu-Daudé
` (64 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/runstate.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/system/runstate.h b/include/system/runstate.h
index fdd5c4a5172..b6e8d6beab7 100644
--- a/include/system/runstate.h
+++ b/include/system/runstate.h
@@ -14,6 +14,16 @@ void runstate_replay_enable(void);
typedef void VMChangeStateHandler(void *opaque, bool running, RunState state);
typedef int VMChangeStateHandlerWithRet(void *opaque, bool running, RunState state);
+/**
+ * qemu_add_vm_change_state_handler:
+ * @cb: the callback to invoke
+ * @opaque: user data passed to the callback
+ *
+ * Register a callback function that is invoked when the vm starts or stops
+ * running.
+ *
+ * Returns: an entry to be freed using qemu_del_vm_change_state_handler()
+ */
VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
void *opaque);
VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 02/65] system/cpus: Defer memory layout changes until vCPUs are realized
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 01/65] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-03 16:37 ` Alex Bennée
2025-07-02 18:52 ` [PATCH v4 03/65] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
` (63 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Peter Xu,
David Hildenbrand
vCPUs are not really usable until fully realized. Do not attempt
to commit memory changes in the middle of vCPU realization. Defer
until realization is completed and vCPU fully operational.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
system/physmem.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/system/physmem.c b/system/physmem.c
index ff0ca40222d..8b2be31fa7e 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -2792,6 +2792,14 @@ static void tcg_commit(MemoryListener *listener)
cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
cpu = cpuas->cpu;
+ if (!qdev_is_realized(DEVICE(cpu))) {
+ /*
+ * The listener is also called during realize, before
+ * all of the tcg machinery for run-on is initialized.
+ */
+ return;
+ }
+
/*
* Defer changes to as->memory_dispatch until the cpu is quiescent.
* Otherwise we race between (1) other cpu threads and (2) ongoing
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 03/65] system/cpus: Assert interrupt handling is done with BQL locked
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 01/65] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 02/65] system/cpus: Defer memory layout changes until vCPUs are realized Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 04/65] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
` (62 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops.c | 2 --
system/cpus.c | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index b24d6a75625..6116644d1c0 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -93,8 +93,6 @@ static void tcg_cpu_reset_hold(CPUState *cpu)
/* mask must never be zero, except for A20 change call */
void tcg_handle_interrupt(CPUState *cpu, int mask)
{
- g_assert(bql_locked());
-
cpu->interrupt_request |= mask;
/*
diff --git a/system/cpus.c b/system/cpus.c
index d16b0dff989..a43e0e4e796 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -265,6 +265,8 @@ static void generic_handle_interrupt(CPUState *cpu, int mask)
void cpu_interrupt(CPUState *cpu, int mask)
{
+ g_assert(bql_locked());
+
if (cpus_accel->handle_interrupt) {
cpus_accel->handle_interrupt(cpu, mask);
} else {
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 04/65] accel: Keep reference to AccelOpsClass in AccelClass
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 03/65] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 05/65] accel: Introduce AccelOpsClass::cpu_target_realize() hook Philippe Mathieu-Daudé
` (61 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Allow dereferencing AccelOpsClass outside of accel/accel-system.c.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---
include/qemu/accel.h | 3 +++
include/system/accel-ops.h | 3 ++-
accel/accel-common.c | 1 +
accel/accel-system.c | 3 ++-
accel/tcg/tcg-accel-ops.c | 4 +++-
5 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index fbd3d897fef..9dea3145429 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -37,6 +37,9 @@ typedef struct AccelClass {
/*< public >*/
const char *name;
+ /* Cached by accel_init_ops_interfaces() when created */
+ AccelOpsClass *ops;
+
int (*init_machine)(MachineState *ms);
bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
void (*cpu_common_unrealize)(CPUState *cpu);
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 4c99d25aeff..44b37592d02 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -10,6 +10,7 @@
#ifndef ACCEL_OPS_H
#define ACCEL_OPS_H
+#include "qemu/accel.h"
#include "exec/vaddr.h"
#include "qom/object.h"
@@ -31,7 +32,7 @@ struct AccelOpsClass {
/*< public >*/
/* initialization function called when accel is chosen */
- void (*ops_init)(AccelOpsClass *ops);
+ void (*ops_init)(AccelClass *ac);
bool (*cpus_are_resettable)(void);
void (*cpu_reset_hold)(CPUState *cpu);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 4894b98d64a..56d88940f92 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
#include "qemu/target-info.h"
+#include "system/accel-ops.h"
#include "accel/accel-cpu.h"
#include "accel-internal.h"
diff --git a/accel/accel-system.c b/accel/accel-system.c
index a0f562ae9ff..64bc991b1ce 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -85,8 +85,9 @@ void accel_init_ops_interfaces(AccelClass *ac)
* non-NULL create_vcpu_thread operation.
*/
ops = ACCEL_OPS_CLASS(oc);
+ ac->ops = ops;
if (ops->ops_init) {
- ops->ops_init(ops);
+ ops->ops_init(ac);
}
cpus_register_accel(ops);
}
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 6116644d1c0..37b4b21f882 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -196,8 +196,10 @@ static inline void tcg_remove_all_breakpoints(CPUState *cpu)
cpu_watchpoint_remove_all(cpu, BP_GDB);
}
-static void tcg_accel_ops_init(AccelOpsClass *ops)
+static void tcg_accel_ops_init(AccelClass *ac)
{
+ AccelOpsClass *ops = ac->ops;
+
if (qemu_tcg_mttcg_enabled()) {
ops->create_vcpu_thread = mttcg_start_vcpu_thread;
ops->kick_vcpu_thread = mttcg_kick_vcpu_thread;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 05/65] accel: Introduce AccelOpsClass::cpu_target_realize() hook
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 04/65] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 06/65] accel/hvf: Add hvf_arch_cpu_realize() stubs Philippe Mathieu-Daudé
` (60 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Allow accelerators to set vCPU properties before its realization.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/accel-ops.h | 1 +
accel/accel-common.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 44b37592d02..a863fe59388 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -35,6 +35,7 @@ struct AccelOpsClass {
void (*ops_init)(AccelClass *ac);
bool (*cpus_are_resettable)(void);
+ bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
void (*cpu_reset_hold)(CPUState *cpu);
void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 56d88940f92..55d21b63a48 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -105,6 +105,9 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
return false;
}
+ if (acc->ops->cpu_target_realize && !acc->ops->cpu_target_realize(cpu, errp)) {
+ return false;
+ }
return true;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 06/65] accel/hvf: Add hvf_arch_cpu_realize() stubs
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 05/65] accel: Introduce AccelOpsClass::cpu_target_realize() hook Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 07/65] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
` (59 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal, Alexander Graf,
Peter Maydell, qemu-arm
Implement HVF AccelOpsClass::cpu_target_realize() hook as
empty stubs. Target implementations will come separately.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/hvf.h | 3 +++
accel/hvf/hvf-accel-ops.c | 2 ++
target/arm/hvf/hvf.c | 5 +++++
target/i386/hvf/hvf.c | 5 +++++
4 files changed, 15 insertions(+)
diff --git a/include/system/hvf.h b/include/system/hvf.h
index a9a502f0c8f..8c4409a13f1 100644
--- a/include/system/hvf.h
+++ b/include/system/hvf.h
@@ -72,6 +72,9 @@ void hvf_arch_update_guest_debug(CPUState *cpu);
* Return whether the guest supports debugging.
*/
bool hvf_arch_supports_guest_debug(void);
+
+bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp);
+
#endif /* COMPILING_PER_TARGET */
#endif
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index b38977207d2..b9511103a75 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -588,6 +588,8 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
+ ops->cpu_target_realize = hvf_arch_cpu_realize;
+
ops->create_vcpu_thread = hvf_start_vcpu_thread;
ops->kick_vcpu_thread = hvf_kick_vcpu_thread;
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 7b6d291e79c..4c4d21e38cd 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -1081,6 +1081,11 @@ int hvf_arch_init_vcpu(CPUState *cpu)
return 0;
}
+bool hvf_arch_cpu_realize(CPUState *cs, Error **errp)
+{
+ return true;
+}
+
void hvf_kick_vcpu_thread(CPUState *cpu)
{
cpus_kick_thread(cpu);
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 99e37a33e50..28484496710 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -367,6 +367,11 @@ int hvf_arch_init_vcpu(CPUState *cpu)
return 0;
}
+bool hvf_arch_cpu_realize(CPUState *cs, Error **errp)
+{
+ return true;
+}
+
static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_info)
{
X86CPU *x86_cpu = X86_CPU(cpu);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 07/65] accel/kvm: Remove kvm_init_cpu_signals() stub
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 06/65] accel/hvf: Add hvf_arch_cpu_realize() stubs Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 08/65] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
` (58 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, kvm
Since commit 57038a92bb0 ("cpus: extract out kvm-specific code
to accel/kvm") the kvm_init_cpu_signals() stub is not necessary.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/stubs/kvm-stub.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
index ecfd7636f5f..b9b4427c919 100644
--- a/accel/stubs/kvm-stub.c
+++ b/accel/stubs/kvm-stub.c
@@ -105,11 +105,6 @@ unsigned int kvm_get_free_memslots(void)
return 0;
}
-void kvm_init_cpu_signals(CPUState *cpu)
-{
- abort();
-}
-
bool kvm_arm_supports_user_irq(void)
{
return false;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 08/65] accel/kvm: Reduce kvm_create_vcpu() declaration scope
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 07/65] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 09/65] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
` (57 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, kvm
kvm_create_vcpu() is only used within the same file unit.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/kvm.h | 8 --------
accel/kvm/kvm-all.c | 8 +++++++-
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/include/system/kvm.h b/include/system/kvm.h
index 7cc60d26f24..e943df2c09d 100644
--- a/include/system/kvm.h
+++ b/include/system/kvm.h
@@ -316,14 +316,6 @@ int kvm_create_device(KVMState *s, uint64_t type, bool test);
*/
bool kvm_device_supported(int vmfd, uint64_t type);
-/**
- * kvm_create_vcpu - Gets a parked KVM vCPU or creates a KVM vCPU
- * @cpu: QOM CPUState object for which KVM vCPU has to be fetched/created.
- *
- * @returns: 0 when success, errno (<0) when failed.
- */
-int kvm_create_vcpu(CPUState *cpu);
-
/**
* kvm_park_vcpu - Park QEMU KVM vCPU context
* @cpu: QOM CPUState object for which QEMU KVM vCPU context has to be parked.
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index d095d1b98f8..17235f26464 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -453,7 +453,13 @@ static void kvm_reset_parked_vcpus(KVMState *s)
}
}
-int kvm_create_vcpu(CPUState *cpu)
+/**
+ * kvm_create_vcpu - Gets a parked KVM vCPU or creates a KVM vCPU
+ * @cpu: QOM CPUState object for which KVM vCPU has to be fetched/created.
+ *
+ * @returns: 0 when success, errno (<0) when failed.
+ */
+static int kvm_create_vcpu(CPUState *cpu)
{
unsigned long vcpu_id = kvm_arch_vcpu_id(cpu);
KVMState *s = kvm_state;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 09/65] accel: Propagate AccelState to AccelClass::init_machine()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 08/65] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 10/65] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
` (56 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Warner Losh, Kyle Evans, Reinoud Zandijk,
Sunil Muthuswamy, kvm, xen-devel
In order to avoid init_machine() to call current_accel(),
pass AccelState along.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---
include/qemu/accel.h | 2 +-
accel/accel-system.c | 2 +-
accel/hvf/hvf-accel-ops.c | 2 +-
accel/kvm/kvm-all.c | 2 +-
accel/qtest/qtest.c | 2 +-
accel/tcg/tcg-all.c | 2 +-
accel/xen/xen-all.c | 2 +-
bsd-user/main.c | 2 +-
linux-user/main.c | 2 +-
target/i386/nvmm/nvmm-all.c | 2 +-
target/i386/whpx/whpx-all.c | 2 +-
11 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 9dea3145429..b9a9b3593d8 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -40,7 +40,7 @@ typedef struct AccelClass {
/* Cached by accel_init_ops_interfaces() when created */
AccelOpsClass *ops;
- int (*init_machine)(MachineState *ms);
+ int (*init_machine)(AccelState *as, MachineState *ms);
bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
void (*cpu_common_unrealize)(CPUState *cpu);
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 64bc991b1ce..913b7155d77 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -37,7 +37,7 @@ int accel_init_machine(AccelState *accel, MachineState *ms)
int ret;
ms->accelerator = accel;
*(acc->allowed) = true;
- ret = acc->init_machine(ms);
+ ret = acc->init_machine(accel, ms);
if (ret < 0) {
ms->accelerator = NULL;
*(acc->allowed) = false;
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index b9511103a75..6af849450e1 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -321,7 +321,7 @@ static void dummy_signal(int sig)
bool hvf_allowed;
-static int hvf_accel_init(MachineState *ms)
+static int hvf_accel_init(AccelState *as, MachineState *ms)
{
int x;
hv_return_t ret;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 17235f26464..264f288dc64 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2573,7 +2573,7 @@ static int kvm_setup_dirty_ring(KVMState *s)
return 0;
}
-static int kvm_init(MachineState *ms)
+static int kvm_init(AccelState *as, MachineState *ms)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
static const char upgrade_note[] =
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 92bed9264ce..8b109d4c03b 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -37,7 +37,7 @@ static void qtest_set_virtual_clock(int64_t count)
qatomic_set_i64(&qtest_clock_counter, count);
}
-static int qtest_init_accel(MachineState *ms)
+static int qtest_init_accel(AccelState *as, MachineState *ms)
{
return 0;
}
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 6e5dc333d59..d68fbb23773 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -80,7 +80,7 @@ static void tcg_accel_instance_init(Object *obj)
bool one_insn_per_tb;
-static int tcg_init_machine(MachineState *ms)
+static int tcg_init_machine(AccelState *as, MachineState *ms)
{
TCGState *s = TCG_STATE(current_accel());
unsigned max_threads = 1;
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index de52a8f882a..1117f52bef0 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -76,7 +76,7 @@ static void xen_setup_post(MachineState *ms, AccelState *accel)
}
}
-static int xen_init(MachineState *ms)
+static int xen_init(AccelState *as, MachineState *ms)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 7c0a059c3ba..d0cc8e0088f 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -474,7 +474,7 @@ int main(int argc, char **argv)
opt_one_insn_per_tb, &error_abort);
object_property_set_int(OBJECT(accel), "tb-size",
opt_tb_size, &error_abort);
- ac->init_machine(NULL);
+ ac->init_machine(accel, NULL);
}
/*
diff --git a/linux-user/main.c b/linux-user/main.c
index 5ac5b55dc65..a9142ee7268 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -820,7 +820,7 @@ int main(int argc, char **argv, char **envp)
opt_one_insn_per_tb, &error_abort);
object_property_set_int(OBJECT(accel), "tb-size",
opt_tb_size, &error_abort);
- ac->init_machine(NULL);
+ ac->init_machine(accel, NULL);
}
/*
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index f1c6120ccf1..eaae175aa5d 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -1153,7 +1153,7 @@ static struct RAMBlockNotifier nvmm_ram_notifier = {
/* -------------------------------------------------------------------------- */
static int
-nvmm_accel_init(MachineState *ms)
+nvmm_accel_init(AccelState *as, MachineState *ms)
{
int ret, err;
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index cf6d3e4cdd4..f0be840b7db 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2505,7 +2505,7 @@ static void whpx_set_kernel_irqchip(Object *obj, Visitor *v,
* Partition support
*/
-static int whpx_accel_init(MachineState *ms)
+static int whpx_accel_init(AccelState *as, MachineState *ms)
{
struct whpx_state *whpx;
int ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 10/65] accel/kvm: Prefer local AccelState over global MachineState::accel
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 09/65] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 11/65] accel/hvf: Re-use QOM allocated state Philippe Mathieu-Daudé
` (55 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, kvm
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/kvm/kvm-all.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 264f288dc64..72fba12d9fa 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2588,15 +2588,13 @@ static int kvm_init(AccelState *as, MachineState *ms)
{ /* end of list */ }
}, *nc = num_cpus;
int soft_vcpus_limit, hard_vcpus_limit;
- KVMState *s;
+ KVMState *s = KVM_STATE(as);
const KVMCapabilityInfo *missing_cap;
int ret;
int type;
qemu_mutex_init(&kml_slots_lock);
- s = KVM_STATE(ms->accelerator);
-
/*
* On systems where the kernel can support different base page
* sizes, host page size may be different from TARGET_PAGE_SIZE,
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 11/65] accel/hvf: Re-use QOM allocated state
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 10/65] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 12/65] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
` (54 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/hvf/hvf-accel-ops.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 6af849450e1..c256cdceffb 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -325,7 +325,7 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
{
int x;
hv_return_t ret;
- HVFState *s;
+ HVFState *s = HVF_STATE(as);
int pa_range = 36;
MachineClass *mc = MACHINE_GET_CLASS(ms);
@@ -339,8 +339,6 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
ret = hvf_arch_vm_create(ms, (uint32_t)pa_range);
assert_hvf_ok(ret);
- s = g_new0(HVFState, 1);
-
s->num_slots = ARRAY_SIZE(s->slots);
for (x = 0; x < s->num_slots; ++x) {
s->slots[x].size = 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 12/65] accel/tcg: Prefer local AccelState over global current_accel()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 11/65] accel/hvf: Re-use QOM allocated state Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 13/65] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
` (53 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-all.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index d68fbb23773..c674d5bcf78 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -82,7 +82,7 @@ bool one_insn_per_tb;
static int tcg_init_machine(AccelState *as, MachineState *ms)
{
- TCGState *s = TCG_STATE(current_accel());
+ TCGState *s = TCG_STATE(as);
unsigned max_threads = 1;
#ifndef CONFIG_USER_ONLY
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 13/65] accel: Directly pass AccelState argument to AccelClass::has_memory()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 12/65] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 14/65] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
` (52 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Peter Xu,
David Hildenbrand, kvm
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/accel.h | 2 +-
accel/kvm/kvm-all.c | 4 ++--
system/memory.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index b9a9b3593d8..f327a71282c 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -46,7 +46,7 @@ typedef struct AccelClass {
/* system related hooks */
void (*setup_post)(MachineState *ms, AccelState *accel);
- bool (*has_memory)(MachineState *ms, AddressSpace *as,
+ bool (*has_memory)(AccelState *accel, AddressSpace *as,
hwaddr start_addr, hwaddr size);
/* gdbstub related hooks */
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 72fba12d9fa..f641de34646 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3789,10 +3789,10 @@ int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target)
return r;
}
-static bool kvm_accel_has_memory(MachineState *ms, AddressSpace *as,
+static bool kvm_accel_has_memory(AccelState *accel, AddressSpace *as,
hwaddr start_addr, hwaddr size)
{
- KVMState *kvm = KVM_STATE(ms->accelerator);
+ KVMState *kvm = KVM_STATE(accel);
int i;
for (i = 0; i < kvm->nr_as; ++i) {
diff --git a/system/memory.c b/system/memory.c
index 76b44b8220f..e8d9b15b28f 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -3501,7 +3501,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
if (fvi->ac) {
for (i = 0; i < fv_address_spaces->len; ++i) {
as = g_array_index(fv_address_spaces, AddressSpace*, i);
- if (fvi->ac->has_memory(current_machine, as,
+ if (fvi->ac->has_memory(current_machine->accelerator, as,
int128_get64(range->addr.start),
MR_SIZE(range->addr.size) + 1)) {
qemu_printf(" %s", fvi->ac->name);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 14/65] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 13/65] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 15/65] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
` (51 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, kvm
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/kvm/kvm-all.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index f641de34646..6f6f9ef69ba 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2470,13 +2470,10 @@ uint32_t kvm_dirty_ring_size(void)
return kvm_state->kvm_dirty_ring_size;
}
-static int do_kvm_create_vm(MachineState *ms, int type)
+static int do_kvm_create_vm(KVMState *s, int type)
{
- KVMState *s;
int ret;
- s = KVM_STATE(ms->accelerator);
-
do {
ret = kvm_ioctl(s, KVM_CREATE_VM, type);
} while (ret == -EINTR);
@@ -2646,7 +2643,7 @@ static int kvm_init(AccelState *as, MachineState *ms)
goto err;
}
- ret = do_kvm_create_vm(ms, type);
+ ret = do_kvm_create_vm(s, type);
if (ret < 0) {
goto err;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 15/65] accel: Remove unused MachineState argument of AccelClass::setup_post()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 14/65] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 16/65] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
` (50 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Stefano Stabellini,
Anthony PERARD, Paul Durrant, Edgar E. Iglesias, xen-devel
This method only accesses xen_domid/xen_domid_restrict, which are both
related to the 'accelerator', not the machine. Besides, xen_domid aims
to be in Xen AccelState and xen_domid_restrict a xen_domid_restrict
QOM property.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/accel.h | 2 +-
accel/accel-system.c | 2 +-
accel/xen/xen-all.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index f327a71282c..a6a95ff0bcd 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -45,7 +45,7 @@ typedef struct AccelClass {
void (*cpu_common_unrealize)(CPUState *cpu);
/* system related hooks */
- void (*setup_post)(MachineState *ms, AccelState *accel);
+ void (*setup_post)(AccelState *as);
bool (*has_memory)(AccelState *accel, AddressSpace *as,
hwaddr start_addr, hwaddr size);
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 913b7155d77..af713cc9024 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -58,7 +58,7 @@ void accel_setup_post(MachineState *ms)
AccelState *accel = ms->accelerator;
AccelClass *acc = ACCEL_GET_CLASS(accel);
if (acc->setup_post) {
- acc->setup_post(ms, accel);
+ acc->setup_post(accel);
}
}
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 1117f52bef0..ba752bbe5de 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -63,7 +63,7 @@ static void xen_set_igd_gfx_passthru(Object *obj, bool value, Error **errp)
xen_igd_gfx_pt_set(value, errp);
}
-static void xen_setup_post(MachineState *ms, AccelState *accel)
+static void xen_setup_post(AccelState *as)
{
int rc;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 16/65] accel: Pass AccelState argument to gdbstub_supported_sstep_flags()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 15/65] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 17/65] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
` (49 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal, kvm
In order to have AccelClass methods instrospect their state,
we need to pass AccelState by argument.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/accel.h | 2 +-
accel/accel-common.c | 2 +-
accel/hvf/hvf-accel-ops.c | 2 +-
accel/kvm/kvm-all.c | 2 +-
accel/tcg/tcg-all.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index a6a95ff0bcd..1c097ac4dfb 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -50,7 +50,7 @@ typedef struct AccelClass {
hwaddr start_addr, hwaddr size);
/* gdbstub related hooks */
- int (*gdbstub_supported_sstep_flags)(void);
+ int (*gdbstub_supported_sstep_flags)(AccelState *as);
bool *allowed;
/*
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 55d21b63a48..1d04610f55e 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -128,7 +128,7 @@ int accel_supported_gdbstub_sstep_flags(void)
AccelState *accel = current_accel();
AccelClass *acc = ACCEL_GET_CLASS(accel);
if (acc->gdbstub_supported_sstep_flags) {
- return acc->gdbstub_supported_sstep_flags();
+ return acc->gdbstub_supported_sstep_flags(accel);
}
return 0;
}
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index c256cdceffb..640f41faa43 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -353,7 +353,7 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
return hvf_arch_init();
}
-static inline int hvf_gdbstub_sstep_flags(void)
+static inline int hvf_gdbstub_sstep_flags(AccelState *as)
{
return SSTEP_ENABLE | SSTEP_NOIRQ;
}
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 6f6f9ef69ba..45579f80fa5 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3980,7 +3980,7 @@ static void kvm_accel_instance_init(Object *obj)
* Returns: SSTEP_* flags that KVM supports for guest debug. The
* support is probed during kvm_init()
*/
-static int kvm_gdbstub_sstep_flags(void)
+static int kvm_gdbstub_sstep_flags(AccelState *as)
{
return kvm_sstep_flags;
}
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index c674d5bcf78..5904582a68d 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -219,7 +219,7 @@ static void tcg_set_one_insn_per_tb(Object *obj, bool value, Error **errp)
qatomic_set(&one_insn_per_tb, value);
}
-static int tcg_gdbstub_supported_sstep_flags(void)
+static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
{
/*
* In replay mode all events will come from the log and can't be
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 17/65] accel: Move supports_guest_debug() declaration to AccelClass
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 16/65] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 18/65] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
` (48 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal, Alexander Graf,
Peter Maydell, kvm, qemu-arm
AccelOpsClass is for methods dealing with vCPUs.
When only dealing with AccelState, AccelClass is sufficient.
In order to have AccelClass methods instrospect their state,
we need to pass AccelState by argument.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/kvm/kvm-cpus.h | 1 -
include/qemu/accel.h | 1 +
include/system/accel-ops.h | 1 -
include/system/hvf.h | 2 +-
accel/hvf/hvf-accel-ops.c | 2 +-
accel/kvm/kvm-accel-ops.c | 1 -
accel/kvm/kvm-all.c | 5 ++++-
accel/tcg/tcg-accel-ops.c | 6 ------
accel/tcg/tcg-all.c | 6 ++++++
gdbstub/system.c | 7 ++++---
target/arm/hvf/hvf.c | 2 +-
target/i386/hvf/hvf.c | 2 +-
12 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/accel/kvm/kvm-cpus.h b/accel/kvm/kvm-cpus.h
index 688511151c8..3185659562d 100644
--- a/accel/kvm/kvm-cpus.h
+++ b/accel/kvm/kvm-cpus.h
@@ -16,7 +16,6 @@ void kvm_destroy_vcpu(CPUState *cpu);
void kvm_cpu_synchronize_post_reset(CPUState *cpu);
void kvm_cpu_synchronize_post_init(CPUState *cpu);
void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu);
-bool kvm_supports_guest_debug(void);
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
void kvm_remove_all_breakpoints(CPUState *cpu);
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 1c097ac4dfb..c6fe8dc3913 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -50,6 +50,7 @@ typedef struct AccelClass {
hwaddr start_addr, hwaddr size);
/* gdbstub related hooks */
+ bool (*supports_guest_debug)(AccelState *as);
int (*gdbstub_supported_sstep_flags)(AccelState *as);
bool *allowed;
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index a863fe59388..51faf47ac69 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -65,7 +65,6 @@ struct AccelOpsClass {
int64_t (*get_elapsed_ticks)(void);
/* gdbstub hooks */
- bool (*supports_guest_debug)(void);
int (*update_guest_debug)(CPUState *cpu);
int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
diff --git a/include/system/hvf.h b/include/system/hvf.h
index 8c4409a13f1..7b9384d816c 100644
--- a/include/system/hvf.h
+++ b/include/system/hvf.h
@@ -71,7 +71,7 @@ void hvf_arch_update_guest_debug(CPUState *cpu);
/*
* Return whether the guest supports debugging.
*/
-bool hvf_arch_supports_guest_debug(void);
+bool hvf_arch_supports_guest_debug(AccelState *as);
bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp);
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 640f41faa43..e7f40888c26 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -364,6 +364,7 @@ static void hvf_accel_class_init(ObjectClass *oc, const void *data)
ac->name = "HVF";
ac->init_machine = hvf_accel_init;
ac->allowed = &hvf_allowed;
+ ac->supports_guest_debug = hvf_arch_supports_guest_debug;
ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;
}
@@ -600,7 +601,6 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->remove_breakpoint = hvf_remove_breakpoint;
ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
ops->update_guest_debug = hvf_update_guest_debug;
- ops->supports_guest_debug = hvf_arch_supports_guest_debug;
};
static const TypeInfo hvf_accel_ops_type = {
.name = ACCEL_OPS_NAME("hvf"),
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index e5c15449aa6..96606090889 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -104,7 +104,6 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
ops->update_guest_debug = kvm_update_guest_debug_ops;
- ops->supports_guest_debug = kvm_supports_guest_debug;
ops->insert_breakpoint = kvm_insert_breakpoint;
ops->remove_breakpoint = kvm_remove_breakpoint;
ops->remove_all_breakpoints = kvm_remove_all_breakpoints;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 45579f80fa5..a9d917f1ea6 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3528,7 +3528,7 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
return data.err;
}
-bool kvm_supports_guest_debug(void)
+static bool kvm_supports_guest_debug(AccelState *as)
{
/* probed during kvm_init() */
return kvm_has_guest_debug;
@@ -3993,6 +3993,9 @@ static void kvm_accel_class_init(ObjectClass *oc, const void *data)
ac->has_memory = kvm_accel_has_memory;
ac->allowed = &kvm_allowed;
ac->gdbstub_supported_sstep_flags = kvm_gdbstub_sstep_flags;
+#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
+ ac->supports_guest_debug = kvm_supports_guest_debug;
+#endif
object_class_property_add(oc, "kernel-irqchip", "on|off|split",
NULL, kvm_set_kernel_irqchip,
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 37b4b21f882..07b1ec4ea50 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -106,11 +106,6 @@ void tcg_handle_interrupt(CPUState *cpu, int mask)
}
}
-static bool tcg_supports_guest_debug(void)
-{
- return true;
-}
-
/* Translate GDB watchpoint type to a flags value for cpu_watchpoint_* */
static inline int xlat_gdb_type(CPUState *cpu, int gdbtype)
{
@@ -218,7 +213,6 @@ static void tcg_accel_ops_init(AccelClass *ac)
}
ops->cpu_reset_hold = tcg_cpu_reset_hold;
- ops->supports_guest_debug = tcg_supports_guest_debug;
ops->insert_breakpoint = tcg_insert_breakpoint;
ops->remove_breakpoint = tcg_remove_breakpoint;
ops->remove_all_breakpoints = tcg_remove_all_breakpoints;
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 5904582a68d..93972bc0919 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -219,6 +219,11 @@ static void tcg_set_one_insn_per_tb(Object *obj, bool value, Error **errp)
qatomic_set(&one_insn_per_tb, value);
}
+static bool tcg_supports_guest_debug(AccelState *as)
+{
+ return true;
+}
+
static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
{
/*
@@ -242,6 +247,7 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
ac->cpu_common_realize = tcg_exec_realizefn;
ac->cpu_common_unrealize = tcg_exec_unrealizefn;
ac->allowed = &tcg_allowed;
+ ac->supports_guest_debug = tcg_supports_guest_debug;
ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
object_class_property_add_str(oc, "thread",
diff --git a/gdbstub/system.c b/gdbstub/system.c
index 8a32d8e1a1d..bced226fd94 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -634,9 +634,10 @@ int gdb_signal_to_target(int sig)
bool gdb_supports_guest_debug(void)
{
- const AccelOpsClass *ops = cpus_get_accel();
- if (ops->supports_guest_debug) {
- return ops->supports_guest_debug();
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ if (acc->supports_guest_debug) {
+ return acc->supports_guest_debug(accel);
}
return false;
}
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 4c4d21e38cd..bd19a9f475d 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2357,7 +2357,7 @@ void hvf_arch_update_guest_debug(CPUState *cpu)
hvf_arch_set_traps(cpu);
}
-bool hvf_arch_supports_guest_debug(void)
+bool hvf_arch_supports_guest_debug(AccelState *as)
{
return true;
}
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 28484496710..bcf30662bec 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -1024,7 +1024,7 @@ void hvf_arch_update_guest_debug(CPUState *cpu)
{
}
-bool hvf_arch_supports_guest_debug(void)
+bool hvf_arch_supports_guest_debug(AccelState *as)
{
return false;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 18/65] accel: Move cpus_are_resettable() declaration to AccelClass
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 17/65] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 19/65] accel: Move cpu_common_[un]realize() declarations to AccelOpsClass Philippe Mathieu-Daudé
` (47 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, kvm
AccelOpsClass is for methods dealing with vCPUs.
When only dealing with AccelState, AccelClass is sufficient.
Move cpus_are_resettable() declaration to accel/accel-system.c.
In order to have AccelClass methods instrospect their state,
we need to pass AccelState by argument.
Adapt KVM handler.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/accel.h | 1 +
include/system/accel-ops.h | 1 -
accel/accel-system.c | 10 ++++++++++
accel/kvm/kvm-accel-ops.c | 6 ------
accel/kvm/kvm-all.c | 6 ++++++
system/cpus.c | 8 --------
6 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index c6fe8dc3913..3c6350d6d63 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -48,6 +48,7 @@ typedef struct AccelClass {
void (*setup_post)(AccelState *as);
bool (*has_memory)(AccelState *accel, AddressSpace *as,
hwaddr start_addr, hwaddr size);
+ bool (*cpus_are_resettable)(AccelState *as);
/* gdbstub related hooks */
bool (*supports_guest_debug)(AccelState *as);
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 51faf47ac69..d854b84a66a 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -34,7 +34,6 @@ struct AccelOpsClass {
/* initialization function called when accel is chosen */
void (*ops_init)(AccelClass *ac);
- bool (*cpus_are_resettable)(void);
bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
void (*cpu_reset_hold)(CPUState *cpu);
diff --git a/accel/accel-system.c b/accel/accel-system.c
index af713cc9024..637e2390f35 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -62,6 +62,16 @@ void accel_setup_post(MachineState *ms)
}
}
+bool cpus_are_resettable(void)
+{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ if (acc->cpus_are_resettable) {
+ return acc->cpus_are_resettable(accel);
+ }
+ return true;
+}
+
/* initialize the arch-independent accel operation interfaces */
void accel_init_ops_interfaces(AccelClass *ac)
{
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 96606090889..99f61044da5 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -78,11 +78,6 @@ static bool kvm_vcpu_thread_is_idle(CPUState *cpu)
return !kvm_halt_in_kernel();
}
-static bool kvm_cpus_are_resettable(void)
-{
- return !kvm_enabled() || !kvm_state->guest_state_protected;
-}
-
#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
static int kvm_update_guest_debug_ops(CPUState *cpu)
{
@@ -96,7 +91,6 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->create_vcpu_thread = kvm_start_vcpu_thread;
ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle;
- ops->cpus_are_resettable = kvm_cpus_are_resettable;
ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;
ops->synchronize_post_init = kvm_cpu_synchronize_post_init;
ops->synchronize_state = kvm_cpu_synchronize_state;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index a9d917f1ea6..9d1dc56d7e8 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3974,6 +3974,11 @@ static void kvm_accel_instance_init(Object *obj)
s->msr_energy.enable = false;
}
+static bool kvm_cpus_are_resettable(AccelState *as)
+{
+ return !kvm_enabled() || !kvm_state->guest_state_protected;
+}
+
/**
* kvm_gdbstub_sstep_flags():
*
@@ -3992,6 +3997,7 @@ static void kvm_accel_class_init(ObjectClass *oc, const void *data)
ac->init_machine = kvm_init;
ac->has_memory = kvm_accel_has_memory;
ac->allowed = &kvm_allowed;
+ ac->cpus_are_resettable = kvm_cpus_are_resettable;
ac->gdbstub_supported_sstep_flags = kvm_gdbstub_sstep_flags;
#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
ac->supports_guest_debug = kvm_supports_guest_debug;
diff --git a/system/cpus.c b/system/cpus.c
index a43e0e4e796..4fb764ac880 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -195,14 +195,6 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu)
}
}
-bool cpus_are_resettable(void)
-{
- if (cpus_accel->cpus_are_resettable) {
- return cpus_accel->cpus_are_resettable();
- }
- return true;
-}
-
void cpu_exec_reset_hold(CPUState *cpu)
{
if (cpus_accel->cpu_reset_hold) {
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 19/65] accel: Move cpu_common_[un]realize() declarations to AccelOpsClass
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 18/65] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 20/65] accel/system: Convert pre_resume() from AccelOpsClass to AccelClass Philippe Mathieu-Daudé
` (46 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
AccelClass is for methods dealing with AccelState.
When dealing with vCPUs, we want AccelOpsClass.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/accel.h | 2 --
include/system/accel-ops.h | 2 ++
accel/accel-common.c | 10 ++++++----
accel/tcg/tcg-accel-ops.c | 3 +++
accel/tcg/tcg-all.c | 2 --
5 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 3c6350d6d63..518c99ab643 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -41,8 +41,6 @@ typedef struct AccelClass {
AccelOpsClass *ops;
int (*init_machine)(AccelState *as, MachineState *ms);
- bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
- void (*cpu_common_unrealize)(CPUState *cpu);
/* system related hooks */
void (*setup_post)(AccelState *as);
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index d854b84a66a..fb199dc78f0 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -34,6 +34,8 @@ struct AccelOpsClass {
/* initialization function called when accel is chosen */
void (*ops_init)(AccelClass *ac);
+ bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
+ void (*cpu_common_unrealize)(CPUState *cpu);
bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
void (*cpu_reset_hold)(CPUState *cpu);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 1d04610f55e..d1a5f3ca3df 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -102,10 +102,12 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
}
/* generic realization */
- if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
+ if (acc->ops->cpu_common_realize
+ && !acc->ops->cpu_common_realize(cpu, errp)) {
return false;
}
- if (acc->ops->cpu_target_realize && !acc->ops->cpu_target_realize(cpu, errp)) {
+ if (acc->ops->cpu_target_realize
+ && !acc->ops->cpu_target_realize(cpu, errp)) {
return false;
}
@@ -118,8 +120,8 @@ void accel_cpu_common_unrealize(CPUState *cpu)
AccelClass *acc = ACCEL_GET_CLASS(accel);
/* generic unrealization */
- if (acc->cpu_common_unrealize) {
- acc->cpu_common_unrealize(cpu);
+ if (acc->ops->cpu_common_unrealize) {
+ acc->ops->cpu_common_unrealize(cpu);
}
}
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 07b1ec4ea50..95ff451c148 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -46,6 +46,7 @@
#include "tcg-accel-ops-mttcg.h"
#include "tcg-accel-ops-rr.h"
#include "tcg-accel-ops-icount.h"
+#include "internal-common.h"
/* common functionality among all TCG variants */
@@ -212,6 +213,8 @@ static void tcg_accel_ops_init(AccelClass *ac)
}
}
+ ops->cpu_common_realize = tcg_exec_realizefn;
+ ops->cpu_common_unrealize = tcg_exec_unrealizefn;
ops->cpu_reset_hold = tcg_cpu_reset_hold;
ops->insert_breakpoint = tcg_insert_breakpoint;
ops->remove_breakpoint = tcg_remove_breakpoint;
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 93972bc0919..ae83ca0bd10 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -244,8 +244,6 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "tcg";
ac->init_machine = tcg_init_machine;
- ac->cpu_common_realize = tcg_exec_realizefn;
- ac->cpu_common_unrealize = tcg_exec_unrealizefn;
ac->allowed = &tcg_allowed;
ac->supports_guest_debug = tcg_supports_guest_debug;
ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 20/65] accel/system: Convert pre_resume() from AccelOpsClass to AccelClass
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 19/65] accel: Move cpu_common_[un]realize() declarations to AccelOpsClass Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 21/65] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
` (45 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Sunil Muthuswamy
Accelerators call pre_resume() once. Since it isn't a method to
call for each vCPU, move it from AccelOpsClass to AccelClass.
Adapt WHPX.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/accel.h | 3 +++
include/system/accel-ops.h | 1 -
target/i386/whpx/whpx-accel-ops.h | 1 -
accel/accel-system.c | 9 +++++++++
system/cpus.c | 4 +---
target/i386/whpx/whpx-accel-ops.c | 1 -
target/i386/whpx/whpx-all.c | 3 ++-
7 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 518c99ab643..065de80a87b 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -47,6 +47,7 @@ typedef struct AccelClass {
bool (*has_memory)(AccelState *accel, AddressSpace *as,
hwaddr start_addr, hwaddr size);
bool (*cpus_are_resettable)(AccelState *as);
+ void (*pre_resume_vm)(AccelState *as, bool step_pending);
/* gdbstub related hooks */
bool (*supports_guest_debug)(AccelState *as);
@@ -86,6 +87,8 @@ int accel_init_machine(AccelState *accel, MachineState *ms);
/* Called just before os_setup_post (ie just before drop OS privs) */
void accel_setup_post(MachineState *ms);
+void accel_pre_resume(MachineState *ms, bool step_pending);
+
/**
* accel_cpu_instance_init:
* @cpu: The CPU that needs to do accel-specific object initializations.
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index fb199dc78f0..af54302409c 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -47,7 +47,6 @@ struct AccelOpsClass {
void (*synchronize_post_init)(CPUState *cpu);
void (*synchronize_state)(CPUState *cpu);
void (*synchronize_pre_loadvm)(CPUState *cpu);
- void (*synchronize_pre_resume)(bool step_pending);
void (*handle_interrupt)(CPUState *cpu, int mask);
diff --git a/target/i386/whpx/whpx-accel-ops.h b/target/i386/whpx/whpx-accel-ops.h
index e6cf15511d4..54cfc25a147 100644
--- a/target/i386/whpx/whpx-accel-ops.h
+++ b/target/i386/whpx/whpx-accel-ops.h
@@ -21,7 +21,6 @@ void whpx_cpu_synchronize_state(CPUState *cpu);
void whpx_cpu_synchronize_post_reset(CPUState *cpu);
void whpx_cpu_synchronize_post_init(CPUState *cpu);
void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu);
-void whpx_cpu_synchronize_pre_resume(bool step_pending);
/* state subset only touched by the VCPU itself during runtime */
#define WHPX_SET_RUNTIME_STATE 1
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 637e2390f35..11ba8e24d60 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -62,6 +62,15 @@ void accel_setup_post(MachineState *ms)
}
}
+void accel_pre_resume(MachineState *ms, bool step_pending)
+{
+ AccelState *accel = ms->accelerator;
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ if (acc->pre_resume_vm) {
+ acc->pre_resume_vm(accel, step_pending);
+ }
+}
+
bool cpus_are_resettable(void)
{
AccelState *accel = current_accel();
diff --git a/system/cpus.c b/system/cpus.c
index 4fb764ac880..2c3759ea9be 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -762,9 +762,7 @@ int vm_prepare_start(bool step_pending)
* WHPX accelerator needs to know whether we are going to step
* any CPUs, before starting the first one.
*/
- if (cpus_accel->synchronize_pre_resume) {
- cpus_accel->synchronize_pre_resume(step_pending);
- }
+ accel_pre_resume(MACHINE(qdev_get_machine()), step_pending);
/* We are sending this now, but the CPUs will be resumed shortly later */
qapi_event_send_resume();
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index b8bebe403c9..011810b5e50 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -95,7 +95,6 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
ops->synchronize_state = whpx_cpu_synchronize_state;
ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm;
- ops->synchronize_pre_resume = whpx_cpu_synchronize_pre_resume;
}
static const TypeInfo whpx_accel_ops_type = {
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index f0be840b7db..821167a2a77 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2106,7 +2106,7 @@ void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu)
run_on_cpu(cpu, do_whpx_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL);
}
-void whpx_cpu_synchronize_pre_resume(bool step_pending)
+static void whpx_pre_resume_vm(AccelState *as, bool step_pending)
{
whpx_global.step_pending = step_pending;
}
@@ -2703,6 +2703,7 @@ static void whpx_accel_class_init(ObjectClass *oc, const void *data)
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "WHPX";
ac->init_machine = whpx_accel_init;
+ ac->pre_resume_vm = whpx_pre_resume_vm;
ac->allowed = &whpx_allowed;
object_class_property_add(oc, "kernel-irqchip", "on|off|split",
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 21/65] hw/core/machine: Display CPU model name in 'info cpus' command
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 20/65] accel/system: Convert pre_resume() from AccelOpsClass to AccelClass Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-03 7:23 ` Zhao Liu
2025-07-02 18:52 ` [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file Philippe Mathieu-Daudé
` (44 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, Zhao Liu, Eric Blake,
Markus Armbruster
Display the CPU model in 'info cpus'. Example before:
$ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
QEMU 10.0.0 monitor - type 'help' for more information
(qemu) info cpus
* CPU #0: thread_id=42924
CPU #1: thread_id=42924
CPU #2: thread_id=42924
CPU #3: thread_id=42924
(qemu) q
and after:
$ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
QEMU 10.0.50 monitor - type 'help' for more information
(qemu) info cpus
* CPU #0: thread_id=42916 (cortex-a72)
CPU #1: thread_id=42916 (cortex-a72)
CPU #2: thread_id=42916 (cortex-r5f)
CPU #3: thread_id=42916 (cortex-r5f)
(qemu)
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
qapi/machine.json | 3 +++
hw/core/machine-hmp-cmds.c | 3 ++-
hw/core/machine-qmp-cmds.c | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/qapi/machine.json b/qapi/machine.json
index 0650b8de71a..d5bbb5e367e 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -80,6 +80,8 @@
#
# @thread-id: ID of the underlying host thread
#
+# @model: CPU model name (since 10.1)
+#
# @props: properties associated with a virtual CPU, e.g. the socket id
#
# @target: the QEMU system emulation target, which determines which
@@ -91,6 +93,7 @@
'base' : { 'cpu-index' : 'int',
'qom-path' : 'str',
'thread-id' : 'int',
+ 'model' : 'str',
'*props' : 'CpuInstanceProperties',
'target' : 'SysEmuTarget' },
'discriminator' : 'target',
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index c6325cdcaaa..65eeb5e9cc2 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -40,7 +40,8 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "%c CPU #%" PRId64 ":", active,
cpu->value->cpu_index);
- monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
+ monitor_printf(mon, " thread_id=%" PRId64 " (%s)\n",
+ cpu->value->thread_id, cpu->value->model);
}
qapi_free_CpuInfoFastList(cpu_list);
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index d82043e1c68..ab4fd1ec08a 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -47,6 +47,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
value->cpu_index = cpu->cpu_index;
value->qom_path = object_get_canonical_path(OBJECT(cpu));
value->thread_id = cpu->thread_id;
+ value->model = cpu_model_from_type(object_get_typename(OBJECT(cpu)));
if (mc->cpu_index_to_instance_props) {
CpuInstanceProperties *props;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 21/65] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 20:26 ` Pierrick Bouvier
` (2 more replies)
2025-07-02 18:52 ` [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
` (43 subsequent siblings)
65 siblings, 3 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, Zhao Liu, Eric Blake,
Markus Armbruster, Michael Roth
Extract TCG and KVM definitions from machine.json to accelerator.json.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 1 +
qapi/accelerator.json | 75 ++++++++++++++++++++++++++++++++++++++
qapi/machine.json | 65 ---------------------------------
qapi/qapi-schema.json | 1 +
accel/tcg/monitor.c | 2 +-
hw/core/machine-hmp-cmds.c | 1 +
hw/core/machine-qmp-cmds.c | 1 +
qapi/meson.build | 1 +
8 files changed, 81 insertions(+), 66 deletions(-)
create mode 100644 qapi/accelerator.json
diff --git a/MAINTAINERS b/MAINTAINERS
index 7128e0bc98e..5d6b337cef6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -507,6 +507,7 @@ F: accel/Makefile.objs
F: accel/stubs/Makefile.objs
F: cpu-common.c
F: cpu-target.c
+F: qapi/accelerator.json
F: system/cpus.c
Apple Silicon HVF CPUs
diff --git a/qapi/accelerator.json b/qapi/accelerator.json
new file mode 100644
index 00000000000..1d2a83f1b22
--- /dev/null
+++ b/qapi/accelerator.json
@@ -0,0 +1,75 @@
+# -*- Mode: Python -*-
+# vim: filetype=python
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+##
+# = Accelerators
+##
+
+{ 'include': 'common.json' }
+
+##
+# @KvmInfo:
+#
+# Information about support for KVM acceleration
+#
+# @enabled: true if KVM acceleration is active
+#
+# @present: true if KVM acceleration is built into this executable
+#
+# Since: 0.14
+##
+{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
+
+##
+# @query-kvm:
+#
+# Return information about KVM acceleration
+#
+# Returns: @KvmInfo
+#
+# Since: 0.14
+#
+# .. qmp-example::
+#
+# -> { "execute": "query-kvm" }
+# <- { "return": { "enabled": true, "present": true } }
+##
+{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
+
+##
+# @x-query-jit:
+#
+# Query TCG compiler statistics
+#
+# Features:
+#
+# @unstable: This command is meant for debugging.
+#
+# Returns: TCG compiler statistics
+#
+# Since: 6.2
+##
+{ 'command': 'x-query-jit',
+ 'returns': 'HumanReadableText',
+ 'if': 'CONFIG_TCG',
+ 'features': [ 'unstable' ] }
+
+##
+# @x-query-opcount:
+#
+# Query TCG opcode counters
+#
+# Features:
+#
+# @unstable: This command is meant for debugging.
+#
+# Returns: TCG opcode counters
+#
+# Since: 6.2
+##
+{ 'command': 'x-query-opcount',
+ 'returns': 'HumanReadableText',
+ 'if': 'CONFIG_TCG',
+ 'features': [ 'unstable' ] }
diff --git a/qapi/machine.json b/qapi/machine.json
index d5bbb5e367e..e4713c405e8 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -454,35 +454,6 @@
##
{ 'command': 'inject-nmi' }
-##
-# @KvmInfo:
-#
-# Information about support for KVM acceleration
-#
-# @enabled: true if KVM acceleration is active
-#
-# @present: true if KVM acceleration is built into this executable
-#
-# Since: 0.14
-##
-{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
-
-##
-# @query-kvm:
-#
-# Return information about KVM acceleration
-#
-# Returns: @KvmInfo
-#
-# Since: 0.14
-#
-# .. qmp-example::
-#
-# -> { "execute": "query-kvm" }
-# <- { "return": { "enabled": true, "present": true } }
-##
-{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
-
##
# @NumaOptionsType:
#
@@ -1729,24 +1700,6 @@
'returns': 'HumanReadableText',
'features': [ 'unstable' ] }
-##
-# @x-query-jit:
-#
-# Query TCG compiler statistics
-#
-# Features:
-#
-# @unstable: This command is meant for debugging.
-#
-# Returns: TCG compiler statistics
-#
-# Since: 6.2
-##
-{ 'command': 'x-query-jit',
- 'returns': 'HumanReadableText',
- 'if': 'CONFIG_TCG',
- 'features': [ 'unstable' ] }
-
##
# @x-query-numa:
#
@@ -1764,24 +1717,6 @@
'returns': 'HumanReadableText',
'features': [ 'unstable' ] }
-##
-# @x-query-opcount:
-#
-# Query TCG opcode counters
-#
-# Features:
-#
-# @unstable: This command is meant for debugging.
-#
-# Returns: TCG opcode counters
-#
-# Since: 6.2
-##
-{ 'command': 'x-query-opcount',
- 'returns': 'HumanReadableText',
- 'if': 'CONFIG_TCG',
- 'features': [ 'unstable' ] }
-
##
# @x-query-ramblock:
#
diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
index a8f66163cb7..0477696ff02 100644
--- a/qapi/qapi-schema.json
+++ b/qapi/qapi-schema.json
@@ -37,6 +37,7 @@
{ 'include': 'run-state.json' }
{ 'include': 'crypto.json' }
{ 'include': 'job.json' }
+{ 'include': 'accelerator.json' }
{ 'include': 'block.json' }
{ 'include': 'block-export.json' }
{ 'include': 'char.json' }
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index 1c182b6bfb5..5bdd837006c 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -11,7 +11,7 @@
#include "qemu/qht.h"
#include "qapi/error.h"
#include "qapi/type-helpers.h"
-#include "qapi/qapi-commands-machine.h"
+#include "qapi/qapi-commands-accelerator.h"
#include "monitor/monitor.h"
#include "system/cpu-timers.h"
#include "exec/icount.h"
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index 65eeb5e9cc2..15ae5864d16 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -18,6 +18,7 @@
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-builtin-visit.h"
+#include "qapi/qapi-commands-accelerator.h"
#include "qapi/qapi-commands-machine.h"
#include "qobject/qdict.h"
#include "qapi/string-output-visitor.h"
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index ab4fd1ec08a..f37fd220c2d 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -14,6 +14,7 @@
#include "hw/mem/memory-device.h"
#include "qapi/error.h"
#include "qapi/qapi-builtin-visit.h"
+#include "qapi/qapi-commands-accelerator.h"
#include "qapi/qapi-commands-machine.h"
#include "qobject/qobject.h"
#include "qapi/qobject-input-visitor.h"
diff --git a/qapi/meson.build b/qapi/meson.build
index 3b035aea339..ca6b61a608d 100644
--- a/qapi/meson.build
+++ b/qapi/meson.build
@@ -57,6 +57,7 @@ qapi_all_modules = [
]
if have_system
qapi_all_modules += [
+ 'accelerator',
'acpi',
'audio',
'cryptodev',
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 20:27 ` Pierrick Bouvier
` (2 more replies)
2025-07-02 18:52 ` [PATCH v4 24/65] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (42 subsequent siblings)
65 siblings, 3 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Eric Blake,
Markus Armbruster
Unstable QMP 'x-accel-stats' dispatches to the
AccelOpsClass::get_stats() and get_vcpu_stats() handlers.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
qapi/accelerator.json | 17 +++++++++++++++++
include/qemu/accel.h | 2 ++
include/system/accel-ops.h | 3 +++
accel/accel-qmp.c | 34 ++++++++++++++++++++++++++++++++++
accel/accel-system.c | 1 +
accel/meson.build | 2 +-
6 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 accel/accel-qmp.c
diff --git a/qapi/accelerator.json b/qapi/accelerator.json
index 1d2a83f1b22..88b536e5274 100644
--- a/qapi/accelerator.json
+++ b/qapi/accelerator.json
@@ -73,3 +73,20 @@
'returns': 'HumanReadableText',
'if': 'CONFIG_TCG',
'features': [ 'unstable' ] }
+
+##
+# @x-accel-stats:
+#
+# Query accelerator statistics
+#
+# Features:
+#
+# @unstable: This command is meant for debugging.
+#
+# Returns: accelerator statistics
+#
+# Since: 10.1
+##
+{ 'command': 'x-accel-stats',
+ 'returns': 'HumanReadableText',
+ 'features': [ 'unstable' ] }
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 065de80a87b..598796bdca9 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -41,6 +41,8 @@ typedef struct AccelClass {
AccelOpsClass *ops;
int (*init_machine)(AccelState *as, MachineState *ms);
+ /* get_stats: Append statistics to @buf */
+ void (*get_stats)(AccelState *as, GString *buf);
/* system related hooks */
void (*setup_post)(AccelState *as);
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index af54302409c..2a89641aa81 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -50,6 +50,9 @@ struct AccelOpsClass {
void (*handle_interrupt)(CPUState *cpu, int mask);
+ /* get_vcpu_stats: Append statistics of this @cpu to @buf */
+ void (*get_vcpu_stats)(CPUState *cpu, GString *buf);
+
/**
* @get_virtual_clock: fetch virtual clock
* @set_virtual_clock: set virtual clock
diff --git a/accel/accel-qmp.c b/accel/accel-qmp.c
new file mode 100644
index 00000000000..318629665b3
--- /dev/null
+++ b/accel/accel-qmp.c
@@ -0,0 +1,34 @@
+/*
+ * QMP commands related to accelerators
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/accel.h"
+#include "qapi/type-helpers.h"
+#include "qapi/qapi-commands-accelerator.h"
+#include "system/accel-ops.h"
+#include "hw/core/cpu.h"
+
+HumanReadableText *qmp_x_accel_stats(Error **errp)
+{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ g_autoptr(GString) buf = g_string_new("");
+
+ if (acc->get_stats) {
+ acc->get_stats(accel, buf);
+ }
+ if (acc->ops->get_vcpu_stats) {
+ CPUState *cpu;
+
+ CPU_FOREACH(cpu) {
+ acc->ops->get_vcpu_stats(cpu, buf);
+ }
+ }
+
+ return human_readable_text_from_str(buf);
+}
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 11ba8e24d60..246ea55425f 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -26,6 +26,7 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
#include "hw/boards.h"
+#include "hw/core/cpu.h"
#include "system/accel-ops.h"
#include "system/cpus.h"
#include "qemu/error-report.h"
diff --git a/accel/meson.build b/accel/meson.build
index 52909314bfa..25b0f100b51 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -1,6 +1,6 @@
common_ss.add(files('accel-common.c'))
specific_ss.add(files('accel-target.c'))
-system_ss.add(files('accel-system.c', 'accel-blocker.c'))
+system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c'))
user_ss.add(files('accel-user.c'))
subdir('tcg')
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 24/65] accel/system: Add 'info accel' on human monitor
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 20:27 ` Pierrick Bouvier
2025-07-02 18:52 ` [PATCH v4 25/65] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
` (41 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé,
Dr. David Alan Gilbert
'info accel' dispatches to the AccelOpsClass::get_stats()
and get_vcpu_stats() handlers.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/accel-system.c | 8 ++++++++
hmp-commands-info.hx | 12 ++++++++++++
2 files changed, 20 insertions(+)
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 246ea55425f..6cdfe485c29 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -25,6 +25,8 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
+#include "qapi/qapi-commands-accelerator.h"
+#include "monitor/monitor.h"
#include "hw/boards.h"
#include "hw/core/cpu.h"
#include "system/accel-ops.h"
@@ -112,11 +114,17 @@ void accel_init_ops_interfaces(AccelClass *ac)
cpus_register_accel(ops);
}
+static void accel_ops_class_init(ObjectClass *oc, const void *data)
+{
+ monitor_register_hmp_info_hrt("accel", qmp_x_accel_stats);
+}
+
static const TypeInfo accel_ops_type_info = {
.name = TYPE_ACCEL_OPS,
.parent = TYPE_OBJECT,
.abstract = true,
.class_size = sizeof(AccelOpsClass),
+ .class_init = accel_ops_class_init,
};
static void accel_system_register_types(void)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 639a450ee51..0496be6abfb 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -281,6 +281,18 @@ ERST
.cmd = hmp_info_sync_profile,
},
+ {
+ .name = "accel",
+ .args_type = "",
+ .params = "",
+ .help = "show accelerator info",
+ },
+
+SRST
+ ``info accel``
+ Show accelerator info.
+ERST
+
SRST
``info sync-profile [-m|-n]`` [*max*]
Show synchronization profiling info, up to *max* entries (default: 10),
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 25/65] accel/tcg: Factor tcg_dump_flush_info() out
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (23 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 24/65] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
` (40 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/internal-common.h | 2 ++
accel/tcg/monitor.c | 27 +++++++++++++++++----------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index 1dbc45dd955..fb265d0cefa 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -139,4 +139,6 @@ G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr);
void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
+void tcg_dump_flush_info(GString *buf);
+
#endif
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index 5bdd837006c..3d024e250a1 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -146,11 +146,26 @@ static void tcg_dump_info(GString *buf)
g_string_append_printf(buf, "[TCG profiler not compiled]\n");
}
+void tcg_dump_flush_info(GString *buf)
+{
+ size_t flush_full, flush_part, flush_elide;
+
+ g_string_append_printf(buf, "TB flush count %u\n",
+ qatomic_read(&tb_ctx.tb_flush_count));
+ g_string_append_printf(buf, "TB invalidate count %u\n",
+ qatomic_read(&tb_ctx.tb_phys_invalidate_count));
+
+ tlb_flush_counts(&flush_full, &flush_part, &flush_elide);
+ g_string_append_printf(buf, "TLB full flushes %zu\n", flush_full);
+ g_string_append_printf(buf, "TLB partial flushes %zu\n", flush_part);
+ g_string_append_printf(buf, "TLB elided flushes %zu\n", flush_elide);
+}
+
static void dump_exec_info(GString *buf)
{
struct tb_tree_stats tst = {};
struct qht_stats hst;
- size_t nb_tbs, flush_full, flush_part, flush_elide;
+ size_t nb_tbs;
tcg_tb_foreach(tb_tree_stats_iter, &tst);
nb_tbs = tst.nb_tbs;
@@ -187,15 +202,7 @@ static void dump_exec_info(GString *buf)
qht_statistics_destroy(&hst);
g_string_append_printf(buf, "\nStatistics:\n");
- g_string_append_printf(buf, "TB flush count %u\n",
- qatomic_read(&tb_ctx.tb_flush_count));
- g_string_append_printf(buf, "TB invalidate count %u\n",
- qatomic_read(&tb_ctx.tb_phys_invalidate_count));
-
- tlb_flush_counts(&flush_full, &flush_part, &flush_elide);
- g_string_append_printf(buf, "TLB full flushes %zu\n", flush_full);
- g_string_append_printf(buf, "TLB partial flushes %zu\n", flush_part);
- g_string_append_printf(buf, "TLB elided flushes %zu\n", flush_elide);
+ tcg_dump_flush_info(buf);
tcg_dump_info(buf);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (24 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 25/65] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-03 8:40 ` Zhao Liu
2025-07-03 16:55 ` Alex Bennée
2025-07-02 18:52 ` [PATCH v4 27/65] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
` (39 subsequent siblings)
65 siblings, 2 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-all.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index ae83ca0bd10..d49d2b3b0fa 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -239,11 +239,17 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
}
}
+static void tcg_get_stats(AccelState *as, GString *buf)
+{
+ tcg_dump_flush_info(buf);
+}
+
static void tcg_accel_class_init(ObjectClass *oc, const void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "tcg";
ac->init_machine = tcg_init_machine;
+ ac->get_stats = tcg_get_stats;
ac->allowed = &tcg_allowed;
ac->supports_guest_debug = tcg_supports_guest_debug;
ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 27/65] accel/hvf: Implement get_vcpu_stats()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (25 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-04 12:05 ` Mads Ynddal
2025-07-02 18:52 ` [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
` (38 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/hvf/hvf-accel-ops.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index e7f40888c26..c07ebf8a652 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -358,6 +358,12 @@ static inline int hvf_gdbstub_sstep_flags(AccelState *as)
return SSTEP_ENABLE | SSTEP_NOIRQ;
}
+static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
+{
+ int r = hv_vcpu_get_exec_time(cpu->accel->fd, arg.host_ptr);
+ assert_hvf_ok(r);
+}
+
static void hvf_accel_class_init(ObjectClass *oc, const void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
@@ -583,6 +589,16 @@ static void hvf_remove_all_breakpoints(CPUState *cpu)
}
}
+static void hvf_get_vcpu_stats(CPUState *cpu, GString *buf)
+{
+ uint64_t time_us; /* units of mach_absolute_time() */
+
+ run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_us));
+
+ g_string_append_printf(buf, "HVF cumulative execution time: %llu.%.3llus\n",
+ time_us / 1000000, (time_us % 1000000) / 1000);
+}
+
static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -601,7 +617,10 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->remove_breakpoint = hvf_remove_breakpoint;
ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
ops->update_guest_debug = hvf_update_guest_debug;
+
+ ops->get_vcpu_stats = hvf_get_vcpu_stats;
};
+
static const TypeInfo hvf_accel_ops_type = {
.name = ACCEL_OPS_NAME("hvf"),
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (26 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 27/65] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 21:06 ` Pierrick Bouvier
2025-07-04 9:20 ` Mads Ynddal
2025-07-02 18:52 ` [PATCH v4 29/65] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
` (37 subsequent siblings)
65 siblings, 2 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Shatyuka,
Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Mads Ynddal
We need the QEMU binary signed to be able to use HVF.
Improve the following:
$ ./qemu-system-aarch64-unsigned -M virt -accel hvf
qemu-system-aarch64-unsigned: -accel hvf: Error: ret = HV_DENIED (0xfae94007, at ../../accel/hvf/hvf-accel-ops.c:339)
Abort trap: 6
to:
$ ./qemu-system-aarch64-unsigned -M virt -accel hvf
qemu-system-aarch64-unsigned: -accel hvf: Could not access HVF. Is the executable signed with com.apple.security.hypervisor entitlement?
Suggested-by: Shatyuka <shatyuka@qq.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2800
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/hvf/hvf-accel-ops.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index c07ebf8a652..ada2a3357eb 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -337,6 +337,11 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
}
ret = hvf_arch_vm_create(ms, (uint32_t)pa_range);
+ if (ret == HV_DENIED) {
+ error_report("Could not access HVF. Is the executable signed"
+ " with com.apple.security.hypervisor entitlement?");
+ exit(1);
+ }
assert_hvf_ok(ret);
s->num_slots = ARRAY_SIZE(s->slots);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 29/65] accel/hvf: Restrict internal declarations
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (27 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 30/65] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
` (36 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal
Common code only needs to know whether HVF is enabled and
the QOM type. Move the rest to "hvf_int.h", removing the
need for COMPILING_PER_TARGET #ifdef'ry.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/hvf.h | 41 ----------------------------------------
include/system/hvf_int.h | 36 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 41 deletions(-)
diff --git a/include/system/hvf.h b/include/system/hvf.h
index 7b9384d816c..d3dcf088b3f 100644
--- a/include/system/hvf.h
+++ b/include/system/hvf.h
@@ -14,10 +14,6 @@
#define HVF_H
#include "qemu/accel.h"
-#include "qemu/queue.h"
-#include "exec/vaddr.h"
-#include "qom/object.h"
-#include "exec/vaddr.h"
#ifdef COMPILING_PER_TARGET
# ifdef CONFIG_HVF
@@ -40,41 +36,4 @@ typedef struct HVFState HVFState;
DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE,
TYPE_HVF_ACCEL)
-#ifdef COMPILING_PER_TARGET
-struct hvf_sw_breakpoint {
- vaddr pc;
- vaddr saved_insn;
- int use_count;
- QTAILQ_ENTRY(hvf_sw_breakpoint) entry;
-};
-
-struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu,
- vaddr pc);
-int hvf_sw_breakpoints_active(CPUState *cpu);
-
-int hvf_arch_insert_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
-int hvf_arch_remove_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
-int hvf_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type);
-int hvf_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type);
-void hvf_arch_remove_all_hw_breakpoints(void);
-
-/*
- * hvf_update_guest_debug:
- * @cs: CPUState for the CPU to update
- *
- * Update guest to enable or disable debugging. Per-arch specifics will be
- * handled by calling down to hvf_arch_update_guest_debug.
- */
-int hvf_update_guest_debug(CPUState *cpu);
-void hvf_arch_update_guest_debug(CPUState *cpu);
-
-/*
- * Return whether the guest supports debugging.
- */
-bool hvf_arch_supports_guest_debug(AccelState *as);
-
-bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp);
-
-#endif /* COMPILING_PER_TARGET */
-
#endif
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index d774e58df91..ea6730f255d 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -12,6 +12,8 @@
#define HVF_INT_H
#include "qemu/queue.h"
+#include "exec/vaddr.h"
+#include "qom/object.h"
#ifdef __aarch64__
#include <Hypervisor/Hypervisor.h>
@@ -77,4 +79,38 @@ int hvf_put_registers(CPUState *);
int hvf_get_registers(CPUState *);
void hvf_kick_vcpu_thread(CPUState *cpu);
+struct hvf_sw_breakpoint {
+ vaddr pc;
+ vaddr saved_insn;
+ int use_count;
+ QTAILQ_ENTRY(hvf_sw_breakpoint) entry;
+};
+
+struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu,
+ vaddr pc);
+int hvf_sw_breakpoints_active(CPUState *cpu);
+
+int hvf_arch_insert_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
+int hvf_arch_remove_sw_breakpoint(CPUState *cpu, struct hvf_sw_breakpoint *bp);
+int hvf_arch_insert_hw_breakpoint(vaddr addr, vaddr len, int type);
+int hvf_arch_remove_hw_breakpoint(vaddr addr, vaddr len, int type);
+void hvf_arch_remove_all_hw_breakpoints(void);
+
+/*
+ * hvf_update_guest_debug:
+ * @cs: CPUState for the CPU to update
+ *
+ * Update guest to enable or disable debugging. Per-arch specifics will be
+ * handled by calling down to hvf_arch_update_guest_debug.
+ */
+int hvf_update_guest_debug(CPUState *cpu);
+void hvf_arch_update_guest_debug(CPUState *cpu);
+
+/*
+ * Return whether the guest supports debugging.
+ */
+bool hvf_arch_supports_guest_debug(AccelState *as);
+
+bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp);
+
#endif
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 30/65] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (28 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 29/65] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 31/65] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
` (35 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal
hvf-all.c aims to contain the generic accel methods (TYPE_ACCEL),
while hvf-accel-ops.c the per-vcpu methods (TYPE_ACCEL_OPS).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/hvf/hvf-accel-ops.c | 29 +++++++++++++++++++++++++++++
accel/hvf/hvf-all.c | 29 -----------------------------
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index ada2a3357eb..be044b9ceaa 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -50,6 +50,7 @@
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
+#include "qemu/queue.h"
#include "system/address-spaces.h"
#include "gdbstub/enums.h"
#include "hw/boards.h"
@@ -492,6 +493,34 @@ static void hvf_start_vcpu_thread(CPUState *cpu)
cpu, QEMU_THREAD_JOINABLE);
}
+struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, vaddr pc)
+{
+ struct hvf_sw_breakpoint *bp;
+
+ QTAILQ_FOREACH(bp, &hvf_state->hvf_sw_breakpoints, entry) {
+ if (bp->pc == pc) {
+ return bp;
+ }
+ }
+ return NULL;
+}
+
+int hvf_sw_breakpoints_active(CPUState *cpu)
+{
+ return !QTAILQ_EMPTY(&hvf_state->hvf_sw_breakpoints);
+}
+
+static void do_hvf_update_guest_debug(CPUState *cpu, run_on_cpu_data arg)
+{
+ hvf_arch_update_guest_debug(cpu);
+}
+
+int hvf_update_guest_debug(CPUState *cpu)
+{
+ run_on_cpu(cpu, do_hvf_update_guest_debug, RUN_ON_CPU_NULL);
+ return 0;
+}
+
static int hvf_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
{
struct hvf_sw_breakpoint *bp;
diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index 8c387fda24d..481d7dece57 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -12,7 +12,6 @@
#include "qemu/error-report.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
-#include "hw/core/cpu.h"
const char *hvf_return_string(hv_return_t ret)
{
@@ -41,31 +40,3 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
abort();
}
-
-struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, vaddr pc)
-{
- struct hvf_sw_breakpoint *bp;
-
- QTAILQ_FOREACH(bp, &hvf_state->hvf_sw_breakpoints, entry) {
- if (bp->pc == pc) {
- return bp;
- }
- }
- return NULL;
-}
-
-int hvf_sw_breakpoints_active(CPUState *cpu)
-{
- return !QTAILQ_EMPTY(&hvf_state->hvf_sw_breakpoints);
-}
-
-static void do_hvf_update_guest_debug(CPUState *cpu, run_on_cpu_data arg)
-{
- hvf_arch_update_guest_debug(cpu);
-}
-
-int hvf_update_guest_debug(CPUState *cpu)
-{
- run_on_cpu(cpu, do_hvf_update_guest_debug, RUN_ON_CPU_NULL);
- return 0;
-}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 31/65] accel/hvf: Move generic method declarations to hvf-all.c
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (29 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 30/65] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 32/65] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
` (34 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal
hvf-all.c aims to contain the generic accel methods (TYPE_ACCEL),
while hvf-accel-ops.c the per-vcpu methods (TYPE_ACCEL_OPS).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/hvf/hvf-accel-ops.c | 278 +-------------------------------------
accel/hvf/hvf-all.c | 272 +++++++++++++++++++++++++++++++++++++
2 files changed, 277 insertions(+), 273 deletions(-)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index be044b9ceaa..319c30f703c 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -48,19 +48,16 @@
*/
#include "qemu/osdep.h"
-#include "qemu/error-report.h"
+#include "qemu/guest-random.h"
#include "qemu/main-loop.h"
#include "qemu/queue.h"
-#include "system/address-spaces.h"
#include "gdbstub/enums.h"
-#include "hw/boards.h"
+#include "exec/cpu-common.h"
#include "system/accel-ops.h"
#include "system/cpus.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
-#include "system/runstate.h"
-#include "qemu/guest-random.h"
-#include "trace.h"
+#include "hw/core/cpu.h"
HVFState *hvf_state;
@@ -80,132 +77,6 @@ hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
return NULL;
}
-struct mac_slot {
- int present;
- uint64_t size;
- uint64_t gpa_start;
- uint64_t gva;
-};
-
-struct mac_slot mac_slots[32];
-
-static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags)
-{
- struct mac_slot *macslot;
- hv_return_t ret;
-
- macslot = &mac_slots[slot->slot_id];
-
- if (macslot->present) {
- if (macslot->size != slot->size) {
- macslot->present = 0;
- trace_hvf_vm_unmap(macslot->gpa_start, macslot->size);
- ret = hv_vm_unmap(macslot->gpa_start, macslot->size);
- assert_hvf_ok(ret);
- }
- }
-
- if (!slot->size) {
- return 0;
- }
-
- macslot->present = 1;
- macslot->gpa_start = slot->start;
- macslot->size = slot->size;
- trace_hvf_vm_map(slot->start, slot->size, slot->mem, flags,
- flags & HV_MEMORY_READ ? 'R' : '-',
- flags & HV_MEMORY_WRITE ? 'W' : '-',
- flags & HV_MEMORY_EXEC ? 'E' : '-');
- ret = hv_vm_map(slot->mem, slot->start, slot->size, flags);
- assert_hvf_ok(ret);
- return 0;
-}
-
-static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
-{
- hvf_slot *mem;
- MemoryRegion *area = section->mr;
- bool writable = !area->readonly && !area->rom_device;
- hv_memory_flags_t flags;
- uint64_t page_size = qemu_real_host_page_size();
-
- if (!memory_region_is_ram(area)) {
- if (writable) {
- return;
- } else if (!memory_region_is_romd(area)) {
- /*
- * If the memory device is not in romd_mode, then we actually want
- * to remove the hvf memory slot so all accesses will trap.
- */
- add = false;
- }
- }
-
- if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
- !QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
- /* Not page aligned, so we can not map as RAM */
- add = false;
- }
-
- mem = hvf_find_overlap_slot(
- section->offset_within_address_space,
- int128_get64(section->size));
-
- if (mem && add) {
- if (mem->size == int128_get64(section->size) &&
- mem->start == section->offset_within_address_space &&
- mem->mem == (memory_region_get_ram_ptr(area) +
- section->offset_within_region)) {
- return; /* Same region was attempted to register, go away. */
- }
- }
-
- /* Region needs to be reset. set the size to 0 and remap it. */
- if (mem) {
- mem->size = 0;
- if (do_hvf_set_memory(mem, 0)) {
- error_report("Failed to reset overlapping slot");
- abort();
- }
- }
-
- if (!add) {
- return;
- }
-
- if (area->readonly ||
- (!memory_region_is_ram(area) && memory_region_is_romd(area))) {
- flags = HV_MEMORY_READ | HV_MEMORY_EXEC;
- } else {
- flags = HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC;
- }
-
- /* Now make a new slot. */
- int x;
-
- for (x = 0; x < hvf_state->num_slots; ++x) {
- mem = &hvf_state->slots[x];
- if (!mem->size) {
- break;
- }
- }
-
- if (x == hvf_state->num_slots) {
- error_report("No free slots");
- abort();
- }
-
- mem->size = int128_get64(section->size);
- mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region;
- mem->start = section->offset_within_address_space;
- mem->region = area;
-
- if (do_hvf_set_memory(mem, flags)) {
- error_report("Error registering new memory slot");
- abort();
- }
-}
-
static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
if (!cpu->accel->dirty) {
@@ -243,157 +114,16 @@ static void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu)
run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL);
}
-static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on)
-{
- hvf_slot *slot;
-
- slot = hvf_find_overlap_slot(
- section->offset_within_address_space,
- int128_get64(section->size));
-
- /* protect region against writes; begin tracking it */
- if (on) {
- slot->flags |= HVF_SLOT_LOG;
- hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size,
- HV_MEMORY_READ | HV_MEMORY_EXEC);
- /* stop tracking region*/
- } else {
- slot->flags &= ~HVF_SLOT_LOG;
- hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size,
- HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC);
- }
-}
-
-static void hvf_log_start(MemoryListener *listener,
- MemoryRegionSection *section, int old, int new)
-{
- if (old != 0) {
- return;
- }
-
- hvf_set_dirty_tracking(section, 1);
-}
-
-static void hvf_log_stop(MemoryListener *listener,
- MemoryRegionSection *section, int old, int new)
-{
- if (new != 0) {
- return;
- }
-
- hvf_set_dirty_tracking(section, 0);
-}
-
-static void hvf_log_sync(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- /*
- * sync of dirty pages is handled elsewhere; just make sure we keep
- * tracking the region.
- */
- hvf_set_dirty_tracking(section, 1);
-}
-
-static void hvf_region_add(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- hvf_set_phys_mem(section, true);
-}
-
-static void hvf_region_del(MemoryListener *listener,
- MemoryRegionSection *section)
-{
- hvf_set_phys_mem(section, false);
-}
-
-static MemoryListener hvf_memory_listener = {
- .name = "hvf",
- .priority = MEMORY_LISTENER_PRIORITY_ACCEL,
- .region_add = hvf_region_add,
- .region_del = hvf_region_del,
- .log_start = hvf_log_start,
- .log_stop = hvf_log_stop,
- .log_sync = hvf_log_sync,
-};
-
static void dummy_signal(int sig)
{
}
-bool hvf_allowed;
-
-static int hvf_accel_init(AccelState *as, MachineState *ms)
-{
- int x;
- hv_return_t ret;
- HVFState *s = HVF_STATE(as);
- int pa_range = 36;
- MachineClass *mc = MACHINE_GET_CLASS(ms);
-
- if (mc->hvf_get_physical_address_range) {
- pa_range = mc->hvf_get_physical_address_range(ms);
- if (pa_range < 0) {
- return -EINVAL;
- }
- }
-
- ret = hvf_arch_vm_create(ms, (uint32_t)pa_range);
- if (ret == HV_DENIED) {
- error_report("Could not access HVF. Is the executable signed"
- " with com.apple.security.hypervisor entitlement?");
- exit(1);
- }
- assert_hvf_ok(ret);
-
- s->num_slots = ARRAY_SIZE(s->slots);
- for (x = 0; x < s->num_slots; ++x) {
- s->slots[x].size = 0;
- s->slots[x].slot_id = x;
- }
-
- QTAILQ_INIT(&s->hvf_sw_breakpoints);
-
- hvf_state = s;
- memory_listener_register(&hvf_memory_listener, &address_space_memory);
-
- return hvf_arch_init();
-}
-
-static inline int hvf_gdbstub_sstep_flags(AccelState *as)
-{
- return SSTEP_ENABLE | SSTEP_NOIRQ;
-}
-
static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
{
int r = hv_vcpu_get_exec_time(cpu->accel->fd, arg.host_ptr);
assert_hvf_ok(r);
}
-static void hvf_accel_class_init(ObjectClass *oc, const void *data)
-{
- AccelClass *ac = ACCEL_CLASS(oc);
- ac->name = "HVF";
- ac->init_machine = hvf_accel_init;
- ac->allowed = &hvf_allowed;
- ac->supports_guest_debug = hvf_arch_supports_guest_debug;
- ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;
-}
-
-static const TypeInfo hvf_accel_type = {
- .name = TYPE_HVF_ACCEL,
- .parent = TYPE_ACCEL,
- .instance_size = sizeof(HVFState),
- .class_init = hvf_accel_class_init,
-};
-
-static void hvf_type_init(void)
-{
- type_register_static(&hvf_accel_type);
-}
-
-type_init(hvf_type_init);
-
static void hvf_vcpu_destroy(CPUState *cpu)
{
hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd);
@@ -662,8 +392,10 @@ static const TypeInfo hvf_accel_ops_type = {
.class_init = hvf_accel_ops_class_init,
.abstract = true,
};
+
static void hvf_accel_ops_register_types(void)
{
type_register_static(&hvf_accel_ops_type);
}
+
type_init(hvf_accel_ops_register_types);
diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index 481d7dece57..f498e32a23f 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -10,8 +10,24 @@
#include "qemu/osdep.h"
#include "qemu/error-report.h"
+#include "system/address-spaces.h"
+#include "system/memory.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
+#include "hw/core/cpu.h"
+#include "hw/boards.h"
+#include "trace.h"
+
+bool hvf_allowed;
+
+struct mac_slot {
+ int present;
+ uint64_t size;
+ uint64_t gpa_start;
+ uint64_t gva;
+};
+
+struct mac_slot mac_slots[32];
const char *hvf_return_string(hv_return_t ret)
{
@@ -40,3 +56,259 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
abort();
}
+
+static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags)
+{
+ struct mac_slot *macslot;
+ hv_return_t ret;
+
+ macslot = &mac_slots[slot->slot_id];
+
+ if (macslot->present) {
+ if (macslot->size != slot->size) {
+ macslot->present = 0;
+ trace_hvf_vm_unmap(macslot->gpa_start, macslot->size);
+ ret = hv_vm_unmap(macslot->gpa_start, macslot->size);
+ assert_hvf_ok(ret);
+ }
+ }
+
+ if (!slot->size) {
+ return 0;
+ }
+
+ macslot->present = 1;
+ macslot->gpa_start = slot->start;
+ macslot->size = slot->size;
+ trace_hvf_vm_map(slot->start, slot->size, slot->mem, flags,
+ flags & HV_MEMORY_READ ? 'R' : '-',
+ flags & HV_MEMORY_WRITE ? 'W' : '-',
+ flags & HV_MEMORY_EXEC ? 'E' : '-');
+ ret = hv_vm_map(slot->mem, slot->start, slot->size, flags);
+ assert_hvf_ok(ret);
+ return 0;
+}
+
+static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
+{
+ hvf_slot *mem;
+ MemoryRegion *area = section->mr;
+ bool writable = !area->readonly && !area->rom_device;
+ hv_memory_flags_t flags;
+ uint64_t page_size = qemu_real_host_page_size();
+
+ if (!memory_region_is_ram(area)) {
+ if (writable) {
+ return;
+ } else if (!memory_region_is_romd(area)) {
+ /*
+ * If the memory device is not in romd_mode, then we actually want
+ * to remove the hvf memory slot so all accesses will trap.
+ */
+ add = false;
+ }
+ }
+
+ if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
+ !QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
+ /* Not page aligned, so we can not map as RAM */
+ add = false;
+ }
+
+ mem = hvf_find_overlap_slot(
+ section->offset_within_address_space,
+ int128_get64(section->size));
+
+ if (mem && add) {
+ if (mem->size == int128_get64(section->size) &&
+ mem->start == section->offset_within_address_space &&
+ mem->mem == (memory_region_get_ram_ptr(area) +
+ section->offset_within_region)) {
+ return; /* Same region was attempted to register, go away. */
+ }
+ }
+
+ /* Region needs to be reset. set the size to 0 and remap it. */
+ if (mem) {
+ mem->size = 0;
+ if (do_hvf_set_memory(mem, 0)) {
+ error_report("Failed to reset overlapping slot");
+ abort();
+ }
+ }
+
+ if (!add) {
+ return;
+ }
+
+ if (area->readonly ||
+ (!memory_region_is_ram(area) && memory_region_is_romd(area))) {
+ flags = HV_MEMORY_READ | HV_MEMORY_EXEC;
+ } else {
+ flags = HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC;
+ }
+
+ /* Now make a new slot. */
+ int x;
+
+ for (x = 0; x < hvf_state->num_slots; ++x) {
+ mem = &hvf_state->slots[x];
+ if (!mem->size) {
+ break;
+ }
+ }
+
+ if (x == hvf_state->num_slots) {
+ error_report("No free slots");
+ abort();
+ }
+
+ mem->size = int128_get64(section->size);
+ mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region;
+ mem->start = section->offset_within_address_space;
+ mem->region = area;
+
+ if (do_hvf_set_memory(mem, flags)) {
+ error_report("Error registering new memory slot");
+ abort();
+ }
+}
+
+static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on)
+{
+ hvf_slot *slot;
+
+ slot = hvf_find_overlap_slot(
+ section->offset_within_address_space,
+ int128_get64(section->size));
+
+ /* protect region against writes; begin tracking it */
+ if (on) {
+ slot->flags |= HVF_SLOT_LOG;
+ hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size,
+ HV_MEMORY_READ | HV_MEMORY_EXEC);
+ /* stop tracking region*/
+ } else {
+ slot->flags &= ~HVF_SLOT_LOG;
+ hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size,
+ HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC);
+ }
+}
+
+static void hvf_log_start(MemoryListener *listener,
+ MemoryRegionSection *section, int old, int new)
+{
+ if (old != 0) {
+ return;
+ }
+
+ hvf_set_dirty_tracking(section, 1);
+}
+
+static void hvf_log_stop(MemoryListener *listener,
+ MemoryRegionSection *section, int old, int new)
+{
+ if (new != 0) {
+ return;
+ }
+
+ hvf_set_dirty_tracking(section, 0);
+}
+
+static void hvf_log_sync(MemoryListener *listener,
+ MemoryRegionSection *section)
+{
+ /*
+ * sync of dirty pages is handled elsewhere; just make sure we keep
+ * tracking the region.
+ */
+ hvf_set_dirty_tracking(section, 1);
+}
+
+static void hvf_region_add(MemoryListener *listener,
+ MemoryRegionSection *section)
+{
+ hvf_set_phys_mem(section, true);
+}
+
+static void hvf_region_del(MemoryListener *listener,
+ MemoryRegionSection *section)
+{
+ hvf_set_phys_mem(section, false);
+}
+
+static MemoryListener hvf_memory_listener = {
+ .name = "hvf",
+ .priority = MEMORY_LISTENER_PRIORITY_ACCEL,
+ .region_add = hvf_region_add,
+ .region_del = hvf_region_del,
+ .log_start = hvf_log_start,
+ .log_stop = hvf_log_stop,
+ .log_sync = hvf_log_sync,
+};
+
+static int hvf_accel_init(AccelState *as, MachineState *ms)
+{
+ int x;
+ hv_return_t ret;
+ HVFState *s = HVF_STATE(as);
+ int pa_range = 36;
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
+
+ if (mc->hvf_get_physical_address_range) {
+ pa_range = mc->hvf_get_physical_address_range(ms);
+ if (pa_range < 0) {
+ return -EINVAL;
+ }
+ }
+
+ ret = hvf_arch_vm_create(ms, (uint32_t)pa_range);
+ if (ret == HV_DENIED) {
+ error_report("Could not access HVF. Is the executable signed"
+ " with com.apple.security.hypervisor entitlement?");
+ exit(1);
+ }
+ assert_hvf_ok(ret);
+
+ s->num_slots = ARRAY_SIZE(s->slots);
+ for (x = 0; x < s->num_slots; ++x) {
+ s->slots[x].size = 0;
+ s->slots[x].slot_id = x;
+ }
+
+ QTAILQ_INIT(&s->hvf_sw_breakpoints);
+
+ hvf_state = s;
+ memory_listener_register(&hvf_memory_listener, &address_space_memory);
+
+ return hvf_arch_init();
+}
+
+static inline int hvf_gdbstub_sstep_flags(AccelState *as)
+{
+ return SSTEP_ENABLE | SSTEP_NOIRQ;
+}
+
+static void hvf_accel_class_init(ObjectClass *oc, const void *data)
+{
+ AccelClass *ac = ACCEL_CLASS(oc);
+ ac->name = "HVF";
+ ac->init_machine = hvf_accel_init;
+ ac->allowed = &hvf_allowed;
+ ac->supports_guest_debug = hvf_arch_supports_guest_debug;
+ ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;
+}
+
+static const TypeInfo hvf_accel_type = {
+ .name = TYPE_HVF_ACCEL,
+ .parent = TYPE_ACCEL,
+ .instance_size = sizeof(HVFState),
+ .class_init = hvf_accel_class_init,
+};
+
+static void hvf_type_init(void)
+{
+ type_register_static(&hvf_accel_type);
+}
+
+type_init(hvf_type_init);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 32/65] cpus: Document CPUState::vcpu_dirty field
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (30 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 31/65] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-03 7:29 ` Zhao Liu
2025-07-02 18:52 ` [PATCH v4 33/65] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
` (33 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, Zhao Liu
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/hw/core/cpu.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 33296a1c080..726427449da 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -441,6 +441,7 @@ struct qemu_work_item;
* @opaque: User data.
* @mem_io_pc: Host Program Counter at which the memory was accessed.
* @accel: Pointer to accelerator specific state.
+ * @vcpu_dirty: Hardware accelerator is not synchronized with QEMU state
* @kvm_fd: vCPU file descriptor for KVM.
* @work_mutex: Lock to prevent multiple access to @work_list.
* @work_list: List of pending asynchronous work.
@@ -537,7 +538,6 @@ struct CPUState {
uint32_t kvm_fetch_index;
uint64_t dirty_pages;
int kvm_vcpu_stats_fd;
- bool vcpu_dirty;
/* Use by accel-block: CPU is executing an ioctl() */
QemuLockCnt in_ioctl_lock;
@@ -553,6 +553,7 @@ struct CPUState {
uint32_t halted;
int32_t exception_index;
+ bool vcpu_dirty;
AccelCPUState *accel;
/* Used to keep track of an outstanding cpu throttle thread for migration
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 33/65] accel/hvf: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (31 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 32/65] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-04 10:40 ` Mads Ynddal
2025-07-02 18:52 ` [PATCH v4 34/65] accel/nvmm: " Philippe Mathieu-Daudé
` (32 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal, Alexander Graf,
Peter Maydell, qemu-arm
No need for accel-specific @dirty field when we have
a generic one in CPUState.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/hvf_int.h | 1 -
accel/hvf/hvf-accel-ops.c | 10 +++++-----
target/arm/hvf/hvf.c | 4 ++--
target/i386/hvf/hvf.c | 4 ++--
target/i386/hvf/x86hvf.c | 2 +-
5 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index ea6730f255d..a8ee7c7dae6 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -62,7 +62,6 @@ struct AccelCPUState {
bool vtimer_masked;
sigset_t unblock_ipi_mask;
bool guest_debug_enabled;
- bool dirty;
};
void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 319c30f703c..c91e18bc3dd 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -79,15 +79,15 @@ hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
- if (!cpu->accel->dirty) {
+ if (!cpu->vcpu_dirty) {
hvf_get_registers(cpu);
- cpu->accel->dirty = true;
+ cpu->vcpu_dirty = true;
}
}
static void hvf_cpu_synchronize_state(CPUState *cpu)
{
- if (!cpu->accel->dirty) {
+ if (!cpu->vcpu_dirty) {
run_on_cpu(cpu, do_hvf_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
@@ -96,7 +96,7 @@ static void do_hvf_cpu_synchronize_set_dirty(CPUState *cpu,
run_on_cpu_data arg)
{
/* QEMU state is the reference, push it to HVF now and on next entry */
- cpu->accel->dirty = true;
+ cpu->vcpu_dirty = true;
}
static void hvf_cpu_synchronize_post_reset(CPUState *cpu)
@@ -156,8 +156,8 @@ static int hvf_init_vcpu(CPUState *cpu)
#else
r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT);
#endif
- cpu->accel->dirty = true;
assert_hvf_ok(r);
+ cpu->vcpu_dirty = true;
cpu->accel->guest_debug_enabled = false;
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index bd19a9f475d..44a831d004f 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -813,9 +813,9 @@ int hvf_put_registers(CPUState *cpu)
static void flush_cpu_state(CPUState *cpu)
{
- if (cpu->accel->dirty) {
+ if (cpu->vcpu_dirty) {
hvf_put_registers(cpu);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
}
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index bcf30662bec..c893aaac1b0 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -738,9 +738,9 @@ int hvf_vcpu_exec(CPUState *cpu)
}
do {
- if (cpu->accel->dirty) {
+ if (cpu->vcpu_dirty) {
hvf_put_registers(cpu);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
if (hvf_inject_interrupts(cpu)) {
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index 2057314892a..17fce1d3cdd 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -427,7 +427,7 @@ int hvf_process_events(CPUState *cs)
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
- if (!cs->accel->dirty) {
+ if (!cs->vcpu_dirty) {
/* light weight sync for CPU_INTERRUPT_HARD and IF_MASK */
env->eflags = rreg(cs->accel->fd, HV_X86_RFLAGS);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 34/65] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (32 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 33/65] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 35/65] accel/whpx: " Philippe Mathieu-Daudé
` (31 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Reinoud Zandijk
No need for accel-specific @dirty field when we have
a generic one in CPUState.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index eaae175aa5d..f521c36dc53 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -30,7 +30,6 @@ struct AccelCPUState {
struct nvmm_vcpu vcpu;
uint8_t tpr;
bool stop;
- bool dirty;
/* Window-exiting for INTs/NMIs. */
bool int_window_exit;
@@ -508,7 +507,7 @@ nvmm_io_callback(struct nvmm_io *io)
}
/* Needed, otherwise infinite loop. */
- current_cpu->accel->dirty = false;
+ current_cpu->vcpu_dirty = false;
}
static void
@@ -517,7 +516,7 @@ nvmm_mem_callback(struct nvmm_mem *mem)
cpu_physical_memory_rw(mem->gpa, mem->data, mem->size, mem->write);
/* Needed, otherwise infinite loop. */
- current_cpu->accel->dirty = false;
+ current_cpu->vcpu_dirty = false;
}
static struct nvmm_assist_callbacks nvmm_callbacks = {
@@ -727,9 +726,9 @@ nvmm_vcpu_loop(CPUState *cpu)
* Inner VCPU loop.
*/
do {
- if (cpu->accel->dirty) {
+ if (cpu->vcpu_dirty) {
nvmm_set_registers(cpu);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
if (qcpu->stop) {
@@ -827,32 +826,32 @@ static void
do_nvmm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
nvmm_get_registers(cpu);
- cpu->accel->dirty = true;
+ cpu->vcpu_dirty = true;
}
static void
do_nvmm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg)
{
nvmm_set_registers(cpu);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
static void
do_nvmm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)
{
nvmm_set_registers(cpu);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
static void
do_nvmm_cpu_synchronize_pre_loadvm(CPUState *cpu, run_on_cpu_data arg)
{
- cpu->accel->dirty = true;
+ cpu->vcpu_dirty = true;
}
void nvmm_cpu_synchronize_state(CPUState *cpu)
{
- if (!cpu->accel->dirty) {
+ if (!cpu->vcpu_dirty) {
run_on_cpu(cpu, do_nvmm_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
@@ -982,7 +981,7 @@ nvmm_init_vcpu(CPUState *cpu)
}
}
- qcpu->dirty = true;
+ qcpu->vcpu_dirty = true;
cpu->accel = qcpu;
return 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 35/65] accel/whpx: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (33 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 34/65] accel/nvmm: " Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 36/65] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
` (30 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Sunil Muthuswamy
No need for accel-specific @dirty field when we have
a generic one in CPUState.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/whpx/whpx-all.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 821167a2a77..525d6a9567b 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -237,7 +237,6 @@ struct AccelCPUState {
uint64_t tpr;
uint64_t apic_base;
bool interruption_pending;
- bool dirty;
/* Must be the last field as it may have a tail */
WHV_RUN_VP_EXIT_CONTEXT exit_ctx;
@@ -836,7 +835,7 @@ static HRESULT CALLBACK whpx_emu_setreg_callback(
* The emulator just successfully wrote the register state. We clear the
* dirty state so we avoid the double write on resume of the VP.
*/
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
return hr;
}
@@ -1391,7 +1390,7 @@ static int whpx_last_vcpu_stopping(CPUState *cpu)
/* Returns the address of the next instruction that is about to be executed. */
static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool exit_context_valid)
{
- if (cpu->accel->dirty) {
+ if (cpu->vcpu_dirty) {
/* The CPU registers have been modified by other parts of QEMU. */
return cpu_env(cpu)->eip;
} else if (exit_context_valid) {
@@ -1704,9 +1703,9 @@ static int whpx_vcpu_run(CPUState *cpu)
}
do {
- if (cpu->accel->dirty) {
+ if (cpu->vcpu_dirty) {
whpx_set_registers(cpu, WHPX_SET_RUNTIME_STATE);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
if (exclusive_step_mode == WHPX_STEP_NONE) {
@@ -2054,9 +2053,9 @@ static int whpx_vcpu_run(CPUState *cpu)
static void do_whpx_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
{
- if (!cpu->accel->dirty) {
+ if (!cpu->vcpu_dirty) {
whpx_get_registers(cpu);
- cpu->accel->dirty = true;
+ cpu->vcpu_dirty = true;
}
}
@@ -2064,20 +2063,20 @@ static void do_whpx_cpu_synchronize_post_reset(CPUState *cpu,
run_on_cpu_data arg)
{
whpx_set_registers(cpu, WHPX_SET_RESET_STATE);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
static void do_whpx_cpu_synchronize_post_init(CPUState *cpu,
run_on_cpu_data arg)
{
whpx_set_registers(cpu, WHPX_SET_FULL_STATE);
- cpu->accel->dirty = false;
+ cpu->vcpu_dirty = false;
}
static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu,
run_on_cpu_data arg)
{
- cpu->accel->dirty = true;
+ cpu->vcpu_dirty = true;
}
/*
@@ -2086,7 +2085,7 @@ static void do_whpx_cpu_synchronize_pre_loadvm(CPUState *cpu,
void whpx_cpu_synchronize_state(CPUState *cpu)
{
- if (!cpu->accel->dirty) {
+ if (!cpu->vcpu_dirty) {
run_on_cpu(cpu, do_whpx_cpu_synchronize_state, RUN_ON_CPU_NULL);
}
}
@@ -2226,7 +2225,7 @@ int whpx_init_vcpu(CPUState *cpu)
}
vcpu->interruptable = true;
- vcpu->dirty = true;
+ cpu->vcpu_dirty = true;
cpu->accel = vcpu;
max_vcpu_index = max(max_vcpu_index, cpu->cpu_index);
qemu_add_vm_change_state_handler(whpx_cpu_update_state, env);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 36/65] accel/kvm: Remove kvm_cpu_synchronize_state() stub
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (34 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 35/65] accel/whpx: " Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 37/65] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
` (29 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, kvm
Since commit 57038a92bb0 ("cpus: extract out kvm-specific code
to accel/kvm") the kvm_cpu_synchronize_state() stub is not
necessary.
Fixes: e0715f6abce ("kvm: remove kvm specific functions from global includes")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/stubs/kvm-stub.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
index b9b4427c919..68cd33ba973 100644
--- a/accel/stubs/kvm-stub.c
+++ b/accel/stubs/kvm-stub.c
@@ -29,10 +29,6 @@ void kvm_flush_coalesced_mmio_buffer(void)
{
}
-void kvm_cpu_synchronize_state(CPUState *cpu)
-{
-}
-
bool kvm_has_sync_mmu(void)
{
return false;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 37/65] accel/system: Document cpu_synchronize_state()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (35 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 36/65] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
@ 2025-07-02 18:52 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 38/65] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
` (28 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:52 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/accel-ops.h | 8 ++++++++
include/system/hw_accel.h | 13 +++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 2a89641aa81..ac0283cffba 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -45,6 +45,14 @@ struct AccelOpsClass {
void (*synchronize_post_reset)(CPUState *cpu);
void (*synchronize_post_init)(CPUState *cpu);
+ /**
+ * synchronize_state:
+ * synchronize_pre_loadvm:
+ * @cpu: The vCPU to synchronize.
+ *
+ * Request to synchronize QEMU vCPU registers from the hardware accelerator
+ * (the hardware accelerator is the reference).
+ */
void (*synchronize_state)(CPUState *cpu);
void (*synchronize_pre_loadvm)(CPUState *cpu);
diff --git a/include/system/hw_accel.h b/include/system/hw_accel.h
index 380e9e640b6..574c9738408 100644
--- a/include/system/hw_accel.h
+++ b/include/system/hw_accel.h
@@ -17,9 +17,18 @@
#include "system/whpx.h"
#include "system/nvmm.h"
+/**
+ * cpu_synchronize_state:
+ * cpu_synchronize_pre_loadvm:
+ * @cpu: The vCPU to synchronize.
+ *
+ * Request to synchronize QEMU vCPU registers from the hardware accelerator
+ * (the hardware accelerator is the reference).
+ */
void cpu_synchronize_state(CPUState *cpu);
-void cpu_synchronize_post_reset(CPUState *cpu);
-void cpu_synchronize_post_init(CPUState *cpu);
void cpu_synchronize_pre_loadvm(CPUState *cpu);
+void cpu_synchronize_post_reset(CPUState *cpu);
+void cpu_synchronize_post_init(CPUState *cpu);
+
#endif /* QEMU_HW_ACCEL_H */
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 38/65] accel/system: Document cpu_synchronize_state_post_init/reset()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (36 preceding siblings ...)
2025-07-02 18:52 ` [PATCH v4 37/65] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 39/65] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
` (27 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/accel-ops.h | 8 ++++++++
include/system/hw_accel.h | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index ac0283cffba..77bd3f586bd 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -43,6 +43,14 @@ struct AccelOpsClass {
void (*kick_vcpu_thread)(CPUState *cpu);
bool (*cpu_thread_is_idle)(CPUState *cpu);
+ /**
+ * synchronize_post_reset:
+ * synchronize_post_init:
+ * @cpu: The vCPU to synchronize.
+ *
+ * Request to synchronize QEMU vCPU registers to the hardware accelerator
+ * (QEMU is the reference).
+ */
void (*synchronize_post_reset)(CPUState *cpu);
void (*synchronize_post_init)(CPUState *cpu);
/**
diff --git a/include/system/hw_accel.h b/include/system/hw_accel.h
index 574c9738408..fa9228d5d2d 100644
--- a/include/system/hw_accel.h
+++ b/include/system/hw_accel.h
@@ -28,6 +28,14 @@
void cpu_synchronize_state(CPUState *cpu);
void cpu_synchronize_pre_loadvm(CPUState *cpu);
+/**
+ * cpu_synchronize_post_reset:
+ * cpu_synchronize_post_init:
+ * @cpu: The vCPU to synchronize.
+ *
+ * Request to synchronize QEMU vCPU registers to the hardware accelerator
+ * (QEMU is the reference).
+ */
void cpu_synchronize_post_reset(CPUState *cpu);
void cpu_synchronize_post_init(CPUState *cpu);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 39/65] accel/nvmm: Expose nvmm_enabled() to common code
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (37 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 38/65] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 40/65] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
` (26 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Reinoud Zandijk
Currently nvmm_enabled() is restricted to target-specific code.
By defining CONFIG_NVMM_IS_POSSIBLE we allow its use anywhere.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/nvmm.h | 23 ++++++++++++-----------
accel/stubs/nvmm-stub.c | 12 ++++++++++++
target/i386/nvmm/nvmm-all.c | 6 ------
accel/stubs/meson.build | 1 +
4 files changed, 25 insertions(+), 17 deletions(-)
create mode 100644 accel/stubs/nvmm-stub.c
diff --git a/include/system/nvmm.h b/include/system/nvmm.h
index 6971ddb3a5a..7390def9adb 100644
--- a/include/system/nvmm.h
+++ b/include/system/nvmm.h
@@ -13,17 +13,18 @@
#define QEMU_NVMM_H
#ifdef COMPILING_PER_TARGET
-
-#ifdef CONFIG_NVMM
-
-int nvmm_enabled(void);
-
-#else /* CONFIG_NVMM */
-
-#define nvmm_enabled() (0)
-
-#endif /* CONFIG_NVMM */
-
+# ifdef CONFIG_NVMM
+# define CONFIG_NVMM_IS_POSSIBLE
+# endif /* !CONFIG_NVMM */
+#else
+# define CONFIG_NVMM_IS_POSSIBLE
#endif /* COMPILING_PER_TARGET */
+#ifdef CONFIG_NVMM_IS_POSSIBLE
+extern bool nvmm_allowed;
+#define nvmm_enabled() (nvmm_allowed)
+#else /* !CONFIG_NVMM_IS_POSSIBLE */
+#define nvmm_enabled() 0
+#endif /* !CONFIG_NVMM_IS_POSSIBLE */
+
#endif /* QEMU_NVMM_H */
diff --git a/accel/stubs/nvmm-stub.c b/accel/stubs/nvmm-stub.c
new file mode 100644
index 00000000000..cc58114ceb3
--- /dev/null
+++ b/accel/stubs/nvmm-stub.c
@@ -0,0 +1,12 @@
+/*
+ * NVMM stubs for QEMU
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "system/hvf.h"
+
+bool nvmm_allowed;
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index f521c36dc53..a392d3fc232 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -1192,12 +1192,6 @@ nvmm_accel_init(AccelState *as, MachineState *ms)
return 0;
}
-int
-nvmm_enabled(void)
-{
- return nvmm_allowed;
-}
-
static void
nvmm_accel_class_init(ObjectClass *oc, const void *data)
{
diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
index 8ca1a4529e2..4c34287215f 100644
--- a/accel/stubs/meson.build
+++ b/accel/stubs/meson.build
@@ -3,5 +3,6 @@ system_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
system_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
system_stubs_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
+system_stubs_ss.add(when: 'CONFIG_NVMM', if_false: files('nvmm-stub.c'))
specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss)
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 40/65] accel/whpx: Expose whpx_enabled() to common code
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (38 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 39/65] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 41/65] accel/system: Introduce hwaccel_enabled() helper Philippe Mathieu-Daudé
` (25 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Sunil Muthuswamy
Currently whpx_enabled() is restricted to target-specific code.
By defining CONFIG_WHPX_IS_POSSIBLE we allow its use anywhere.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/whpx.h | 27 ++++++++++++++-------------
accel/stubs/whpx-stub.c | 12 ++++++++++++
target/i386/whpx/whpx-all.c | 5 -----
accel/stubs/meson.build | 1 +
4 files changed, 27 insertions(+), 18 deletions(-)
create mode 100644 accel/stubs/whpx-stub.c
diff --git a/include/system/whpx.h b/include/system/whpx.h
index 00ff409b682..00f6a3e5236 100644
--- a/include/system/whpx.h
+++ b/include/system/whpx.h
@@ -16,19 +16,20 @@
#define QEMU_WHPX_H
#ifdef COMPILING_PER_TARGET
-
-#ifdef CONFIG_WHPX
-
-int whpx_enabled(void);
-bool whpx_apic_in_platform(void);
-
-#else /* CONFIG_WHPX */
-
-#define whpx_enabled() (0)
-#define whpx_apic_in_platform() (0)
-
-#endif /* CONFIG_WHPX */
-
+# ifdef CONFIG_WHPX
+# define CONFIG_WHPX_IS_POSSIBLE
+# endif /* !CONFIG_WHPX */
+#else
+# define CONFIG_WHPX_IS_POSSIBLE
#endif /* COMPILING_PER_TARGET */
+#ifdef CONFIG_WHPX_IS_POSSIBLE
+extern bool whpx_allowed;
+#define whpx_enabled() (whpx_allowed)
+bool whpx_apic_in_platform(void);
+#else /* !CONFIG_WHPX_IS_POSSIBLE */
+#define whpx_enabled() 0
+#define whpx_apic_in_platform() (0)
+#endif /* !CONFIG_WHPX_IS_POSSIBLE */
+
#endif /* QEMU_WHPX_H */
diff --git a/accel/stubs/whpx-stub.c b/accel/stubs/whpx-stub.c
new file mode 100644
index 00000000000..c564c89fd0b
--- /dev/null
+++ b/accel/stubs/whpx-stub.c
@@ -0,0 +1,12 @@
+/*
+ * WHPX stubs for QEMU
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "system/whpx.h"
+
+bool whpx_allowed;
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 525d6a9567b..1732d108105 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2688,11 +2688,6 @@ error:
return ret;
}
-int whpx_enabled(void)
-{
- return whpx_allowed;
-}
-
bool whpx_apic_in_platform(void) {
return whpx_global.apic_in_platform;
}
diff --git a/accel/stubs/meson.build b/accel/stubs/meson.build
index 4c34287215f..9dfc4f9ddaf 100644
--- a/accel/stubs/meson.build
+++ b/accel/stubs/meson.build
@@ -4,5 +4,6 @@ system_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
system_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))
system_stubs_ss.add(when: 'CONFIG_HVF', if_false: files('hvf-stub.c'))
system_stubs_ss.add(when: 'CONFIG_NVMM', if_false: files('nvmm-stub.c'))
+system_stubs_ss.add(when: 'CONFIG_WHPX', if_false: files('whpx-stub.c'))
specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: system_stubs_ss)
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 41/65] accel/system: Introduce hwaccel_enabled() helper
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (39 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 40/65] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 42/65] target/arm: Use generic hwaccel_enabled() to check 'host' cpu type Philippe Mathieu-Daudé
` (24 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
hwaccel_enabled() return whether any hardware accelerator
is available.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/hw_accel.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/system/hw_accel.h b/include/system/hw_accel.h
index fa9228d5d2d..49556b026e0 100644
--- a/include/system/hw_accel.h
+++ b/include/system/hw_accel.h
@@ -39,4 +39,17 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu);
void cpu_synchronize_post_reset(CPUState *cpu);
void cpu_synchronize_post_init(CPUState *cpu);
+/**
+ * hwaccel_enabled:
+ *
+ * Returns: %true if a hardware accelerator is enabled, %false otherwise.
+ */
+static inline bool hwaccel_enabled(void)
+{
+ return hvf_enabled()
+ || kvm_enabled()
+ || nvmm_enabled()
+ || whpx_enabled();
+}
+
#endif /* QEMU_HW_ACCEL_H */
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 42/65] target/arm: Use generic hwaccel_enabled() to check 'host' cpu type
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (40 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 41/65] accel/system: Introduce hwaccel_enabled() helper Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 43/65] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
` (23 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Peter Maydell,
qemu-arm
We should be able to use the 'host' CPU with any hardware accelerator.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/arm-qmp-cmds.c | 5 +++--
target/arm/cpu.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/target/arm/arm-qmp-cmds.c b/target/arm/arm-qmp-cmds.c
index cefd2352638..ee5eb1bac9f 100644
--- a/target/arm/arm-qmp-cmds.c
+++ b/target/arm/arm-qmp-cmds.c
@@ -30,6 +30,7 @@
#include "qapi/qapi-commands-misc-arm.h"
#include "qobject/qdict.h"
#include "qom/qom-qobject.h"
+#include "system/hw_accel.h"
#include "cpu.h"
static GICCapability *gic_cap_new(int version)
@@ -116,8 +117,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
return NULL;
}
- if (!kvm_enabled() && !strcmp(model->name, "host")) {
- error_setg(errp, "The CPU type '%s' requires KVM", model->name);
+ if (!hwaccel_enabled() && !strcmp(model->name, "host")) {
+ error_setg(errp, "The CPU type 'host' requires hardware accelerator");
return NULL;
}
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index a59a5b57af6..1e782865233 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1978,8 +1978,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
* this is the first point where we can report it.
*/
if (cpu->host_cpu_probe_failed) {
- if (!kvm_enabled() && !hvf_enabled()) {
- error_setg(errp, "The 'host' CPU type can only be used with KVM or HVF");
+ if (!hwaccel_enabled()) {
+ error_setg(errp, "The 'host' CPU type can only be used with "
+ "hardware accelator such KVM/HVF");
} else {
error_setg(errp, "Failed to retrieve host CPU features");
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 43/65] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (41 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 42/65] target/arm: Use generic hwaccel_enabled() to check 'host' cpu type Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 44/65] accel/dummy: Factor dummy_thread_precreate() out Philippe Mathieu-Daudé
` (22 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, xen-devel
'dummy' helpers are specific to accelerator implementations,
no need to expose them via "system/cpus.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/dummy-cpus.h | 14 ++++++++++++++
include/system/cpus.h | 5 -----
accel/dummy-cpus.c | 1 +
accel/qtest/qtest.c | 1 +
accel/xen/xen-all.c | 1 +
5 files changed, 17 insertions(+), 5 deletions(-)
create mode 100644 accel/dummy-cpus.h
diff --git a/accel/dummy-cpus.h b/accel/dummy-cpus.h
new file mode 100644
index 00000000000..d18dd0fdc51
--- /dev/null
+++ b/accel/dummy-cpus.h
@@ -0,0 +1,14 @@
+/*
+ * Dummy cpu thread code
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef ACCEL_DUMMY_CPUS_H
+#define ACCEL_DUMMY_CPUS_H
+
+void dummy_start_vcpu_thread(CPUState *cpu);
+
+#endif
diff --git a/include/system/cpus.h b/include/system/cpus.h
index 3226c765d01..69be6a77a75 100644
--- a/include/system/cpus.h
+++ b/include/system/cpus.h
@@ -7,11 +7,6 @@ void cpus_register_accel(const AccelOpsClass *i);
/* return registers ops */
const AccelOpsClass *cpus_get_accel(void);
-/* accel/dummy-cpus.c */
-
-/* Create a dummy vcpu for AccelOpsClass->create_vcpu_thread */
-void dummy_start_vcpu_thread(CPUState *);
-
/* interface available for cpus accelerator threads */
/* For temporary buffers for forming a name */
diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c
index 867276144fa..03cfc0fa01e 100644
--- a/accel/dummy-cpus.c
+++ b/accel/dummy-cpus.c
@@ -17,6 +17,7 @@
#include "qemu/guest-random.h"
#include "qemu/main-loop.h"
#include "hw/core/cpu.h"
+#include "accel/dummy-cpus.h"
static void *dummy_cpu_thread_fn(void *arg)
{
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 8b109d4c03b..2606fe97b49 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -24,6 +24,7 @@
#include "qemu/guest-random.h"
#include "qemu/main-loop.h"
#include "hw/core/cpu.h"
+#include "accel/dummy-cpus.h"
static int64_t qtest_clock_counter;
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index ba752bbe5de..f412ea346bb 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -18,6 +18,7 @@
#include "hw/xen/xen_igd.h"
#include "chardev/char.h"
#include "qemu/accel.h"
+#include "accel/dummy-cpus.h"
#include "system/accel-ops.h"
#include "system/cpus.h"
#include "system/xen.h"
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 44/65] accel/dummy: Factor dummy_thread_precreate() out
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (42 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 43/65] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 45/65] accel/tcg: Factor tcg_vcpu_thread_precreate() out Philippe Mathieu-Daudé
` (21 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Initialize the semaphore before creating the thread,
factor out as dummy_thread_precreate().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/dummy-cpus.h | 1 +
accel/dummy-cpus.c | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/accel/dummy-cpus.h b/accel/dummy-cpus.h
index d18dd0fdc51..c3af710ee8c 100644
--- a/accel/dummy-cpus.h
+++ b/accel/dummy-cpus.h
@@ -9,6 +9,7 @@
#ifndef ACCEL_DUMMY_CPUS_H
#define ACCEL_DUMMY_CPUS_H
+void dummy_thread_precreate(CPUState *cpu);
void dummy_start_vcpu_thread(CPUState *cpu);
#endif
diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c
index 03cfc0fa01e..2cbc3fecc93 100644
--- a/accel/dummy-cpus.c
+++ b/accel/dummy-cpus.c
@@ -65,15 +65,21 @@ static void *dummy_cpu_thread_fn(void *arg)
return NULL;
}
+void dummy_thread_precreate(CPUState *cpu)
+{
+#ifdef _WIN32
+ qemu_sem_init(&cpu->sem, 0);
+#endif
+}
+
void dummy_start_vcpu_thread(CPUState *cpu)
{
char thread_name[VCPU_THREAD_NAME_SIZE];
+ dummy_thread_precreate(cpu);
+
snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY",
cpu->cpu_index);
qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu,
QEMU_THREAD_JOINABLE);
-#ifdef _WIN32
- qemu_sem_init(&cpu->sem, 0);
-#endif
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 45/65] accel/tcg: Factor tcg_vcpu_thread_precreate() out
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (43 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 44/65] accel/dummy: Factor dummy_thread_precreate() out Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 46/65] accel: Factor accel_create_vcpu_thread() out Philippe Mathieu-Daudé
` (20 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Factor tcg_vcpu_thread_precreate() out for re-use.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops.h | 1 +
accel/tcg/tcg-accel-ops-mttcg.c | 3 +--
accel/tcg/tcg-accel-ops-rr.c | 3 +--
accel/tcg/tcg-accel-ops.c | 7 +++++++
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h
index 6feeb3f3e9b..129af89c3e7 100644
--- a/accel/tcg/tcg-accel-ops.h
+++ b/accel/tcg/tcg-accel-ops.h
@@ -14,6 +14,7 @@
#include "system/cpus.h"
+void tcg_vcpu_thread_precreate(CPUState *cpu);
void tcg_cpu_destroy(CPUState *cpu);
int tcg_cpu_exec(CPUState *cpu);
void tcg_handle_interrupt(CPUState *cpu, int mask);
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index dfcee30947e..462be7596b9 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -133,8 +133,7 @@ void mttcg_start_vcpu_thread(CPUState *cpu)
{
char thread_name[VCPU_THREAD_NAME_SIZE];
- g_assert(tcg_enabled());
- tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1);
+ tcg_vcpu_thread_precreate(cpu);
/* create a thread per vCPU with TCG (MTTCG) */
snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG",
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index 6eec5c9eee9..fc33a13e4e8 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -311,8 +311,7 @@ void rr_start_vcpu_thread(CPUState *cpu)
static QemuCond *single_tcg_halt_cond;
static QemuThread *single_tcg_cpu_thread;
- g_assert(tcg_enabled());
- tcg_cpu_init_cflags(cpu, false);
+ tcg_vcpu_thread_precreate(cpu);
if (!single_tcg_cpu_thread) {
single_tcg_halt_cond = cpu->halt_cond;
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 95ff451c148..861996649b7 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -41,6 +41,7 @@
#include "gdbstub/enums.h"
#include "hw/core/cpu.h"
+#include "hw/boards.h"
#include "tcg-accel-ops.h"
#include "tcg-accel-ops-mttcg.h"
@@ -69,6 +70,12 @@ void tcg_cpu_init_cflags(CPUState *cpu, bool parallel)
tcg_cflags_set(cpu, cflags);
}
+void tcg_vcpu_thread_precreate(CPUState *cpu)
+{
+ g_assert(tcg_enabled());
+ tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1);
+}
+
void tcg_cpu_destroy(CPUState *cpu)
{
cpu_thread_signal_destroyed(cpu);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 46/65] accel: Factor accel_create_vcpu_thread() out
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (44 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 45/65] accel/tcg: Factor tcg_vcpu_thread_precreate() out Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 47/65] accel: Introduce AccelOpsClass::cpu_thread_routine handler Philippe Mathieu-Daudé
` (19 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Factor accel_create_vcpu_thread() out of system/cpus.c
to be able to access accel/ internal definitions.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/accel.h | 2 ++
accel/accel-common.c | 19 +++++++++++++++++++
system/cpus.c | 4 +---
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 598796bdca9..17cf103e445 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -97,6 +97,8 @@ void accel_pre_resume(MachineState *ms, bool step_pending);
*/
void accel_cpu_instance_init(CPUState *cpu);
+void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu);
+
/**
* accel_cpu_common_realize:
* @cpu: The CPU that needs to call accel-specific cpu realization.
diff --git a/accel/accel-common.c b/accel/accel-common.c
index d1a5f3ca3df..d719917063e 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -89,6 +89,25 @@ void accel_cpu_instance_init(CPUState *cpu)
}
}
+void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu)
+{
+ AccelClass *ac;
+
+ if (!accel) {
+ accel = current_accel();
+ }
+ ac = ACCEL_GET_CLASS(accel);
+
+ /* accelerators all implement the AccelOpsClass */
+ g_assert(ac->ops);
+
+ if (ac->ops->create_vcpu_thread != NULL) {
+ ac->ops->create_vcpu_thread(cpu);
+ } else {
+ g_assert_not_reached();
+ }
+}
+
bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
{
AccelState *accel = current_accel();
diff --git a/system/cpus.c b/system/cpus.c
index 2c3759ea9be..6055f7c1c5f 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -698,9 +698,7 @@ void qemu_init_vcpu(CPUState *cpu)
cpu_address_space_init(cpu, 0, "cpu-memory", cpu->memory);
}
- /* accelerators all implement the AccelOpsClass */
- g_assert(cpus_accel != NULL && cpus_accel->create_vcpu_thread != NULL);
- cpus_accel->create_vcpu_thread(cpu);
+ accel_create_vcpu_thread(NULL, cpu);
while (!cpu->created) {
qemu_cond_wait(&qemu_cpu_cond, &bql);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 47/65] accel: Introduce AccelOpsClass::cpu_thread_routine handler
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (45 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 46/65] accel: Factor accel_create_vcpu_thread() out Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-04 9:12 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 48/65] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine Philippe Mathieu-Daudé
` (18 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
In order to have a generic function creating threads,
introduce the thread_precreate() and cpu_thread_routine()
handlers.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/system/accel-ops.h | 5 ++++-
accel/accel-common.c | 16 +++++++++++++++-
system/cpus.c | 2 +-
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 77bd3f586bd..d4bd9c02d14 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -39,7 +39,10 @@ struct AccelOpsClass {
bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
void (*cpu_reset_hold)(CPUState *cpu);
- void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
+ /* Either cpu_thread_routine() or create_vcpu_thread() is mandatory */
+ void *(*cpu_thread_routine)(void *);
+ void (*thread_precreate)(CPUState *cpu);
+ void (*create_vcpu_thread)(CPUState *cpu);
void (*kick_vcpu_thread)(CPUState *cpu);
bool (*cpu_thread_is_idle)(CPUState *cpu);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index d719917063e..24038acf4aa 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -11,6 +11,7 @@
#include "qemu/accel.h"
#include "qemu/target-info.h"
#include "system/accel-ops.h"
+#include "system/cpus.h"
#include "accel/accel-cpu.h"
#include "accel-internal.h"
@@ -104,7 +105,20 @@ void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu)
if (ac->ops->create_vcpu_thread != NULL) {
ac->ops->create_vcpu_thread(cpu);
} else {
- g_assert_not_reached();
+ char thread_name[VCPU_THREAD_NAME_SIZE];
+
+ assert(ac->name);
+ assert(ac->ops->cpu_thread_routine);
+
+ if (ac->ops->thread_precreate) {
+ ac->ops->thread_precreate(cpu);
+ }
+
+ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/%s",
+ cpu->cpu_index, ac->name);
+ qemu_thread_create(cpu->thread, thread_name,
+ ac->ops->cpu_thread_routine,
+ cpu, QEMU_THREAD_JOINABLE);
}
}
diff --git a/system/cpus.c b/system/cpus.c
index 6055f7c1c5f..c2ad640980c 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -671,7 +671,7 @@ void cpu_remove_sync(CPUState *cpu)
void cpus_register_accel(const AccelOpsClass *ops)
{
assert(ops != NULL);
- assert(ops->create_vcpu_thread != NULL); /* mandatory */
+ assert(ops->create_vcpu_thread || ops->cpu_thread_routine);
cpus_accel = ops;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 48/65] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (46 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 47/65] accel: Introduce AccelOpsClass::cpu_thread_routine handler Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 20:09 ` Fabiano Rosas
2025-07-02 18:53 ` [PATCH v4 49/65] accel/tcg: " Philippe Mathieu-Daudé
` (17 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, xen-devel
By converting to AccelOpsClass::cpu_thread_routine we can
let the common accel_create_vcpu_thread() create the thread.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/dummy-cpus.h | 2 +-
accel/dummy-cpus.c | 14 +-------------
accel/qtest/qtest.c | 3 ++-
accel/xen/xen-all.c | 3 ++-
4 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/accel/dummy-cpus.h b/accel/dummy-cpus.h
index c3af710ee8c..c2f9fee164c 100644
--- a/accel/dummy-cpus.h
+++ b/accel/dummy-cpus.h
@@ -10,6 +10,6 @@
#define ACCEL_DUMMY_CPUS_H
void dummy_thread_precreate(CPUState *cpu);
-void dummy_start_vcpu_thread(CPUState *cpu);
+void *dummy_cpu_thread_routine(void *arg);
#endif
diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c
index 2cbc3fecc93..f637ab05e32 100644
--- a/accel/dummy-cpus.c
+++ b/accel/dummy-cpus.c
@@ -19,7 +19,7 @@
#include "hw/core/cpu.h"
#include "accel/dummy-cpus.h"
-static void *dummy_cpu_thread_fn(void *arg)
+void *dummy_cpu_thread_routine(void *arg)
{
CPUState *cpu = arg;
@@ -71,15 +71,3 @@ void dummy_thread_precreate(CPUState *cpu)
qemu_sem_init(&cpu->sem, 0);
#endif
}
-
-void dummy_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- dummy_thread_precreate(cpu);
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu,
- QEMU_THREAD_JOINABLE);
-}
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 2606fe97b49..9f30098d133 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -64,7 +64,8 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
- ops->create_vcpu_thread = dummy_start_vcpu_thread;
+ ops->thread_precreate = dummy_thread_precreate;
+ ops->cpu_thread_routine = dummy_cpu_thread_routine;
ops->get_virtual_clock = qtest_get_virtual_clock;
ops->set_virtual_clock = qtest_set_virtual_clock;
};
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index f412ea346bb..e2ad42c0d18 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -152,7 +152,8 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
- ops->create_vcpu_thread = dummy_start_vcpu_thread;
+ ops->thread_precreate = dummy_thread_precreate;
+ ops->cpu_thread_routine = dummy_cpu_thread_routine;
}
static const TypeInfo xen_accel_ops_type = {
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 49/65] accel/tcg: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (47 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 48/65] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 50/65] accel/hvf: " Philippe Mathieu-Daudé
` (16 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
By converting to AccelOpsClass::cpu_thread_routine we can
let the common accel_create_vcpu_thread() create the thread.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops-mttcg.h | 3 +--
accel/tcg/tcg-accel-ops-mttcg.c | 16 +---------------
accel/tcg/tcg-accel-ops.c | 3 ++-
3 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops-mttcg.h b/accel/tcg/tcg-accel-ops-mttcg.h
index 8ffa7a9a9fe..8bf2452c886 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.h
+++ b/accel/tcg/tcg-accel-ops-mttcg.h
@@ -13,7 +13,6 @@
/* kick MTTCG vCPU thread */
void mttcg_kick_vcpu_thread(CPUState *cpu);
-/* start an mttcg vCPU thread */
-void mttcg_start_vcpu_thread(CPUState *cpu);
+void *mttcg_cpu_thread_routine(void *arg);
#endif /* TCG_ACCEL_OPS_MTTCG_H */
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index 462be7596b9..96ce065eb59 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -61,7 +61,7 @@ static void mttcg_force_rcu(Notifier *notify, void *data)
* current CPUState for a given thread.
*/
-static void *mttcg_cpu_thread_fn(void *arg)
+void *mttcg_cpu_thread_routine(void *arg)
{
MttcgForceRcuNotifier force_rcu;
CPUState *cpu = arg;
@@ -128,17 +128,3 @@ void mttcg_kick_vcpu_thread(CPUState *cpu)
{
cpu_exit(cpu);
}
-
-void mttcg_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- tcg_vcpu_thread_precreate(cpu);
-
- /* create a thread per vCPU with TCG (MTTCG) */
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG",
- cpu->cpu_index);
-
- qemu_thread_create(cpu->thread, thread_name, mttcg_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-}
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 861996649b7..4931e536beb 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -204,7 +204,7 @@ static void tcg_accel_ops_init(AccelClass *ac)
AccelOpsClass *ops = ac->ops;
if (qemu_tcg_mttcg_enabled()) {
- ops->create_vcpu_thread = mttcg_start_vcpu_thread;
+ ops->cpu_thread_routine = mttcg_cpu_thread_routine;
ops->kick_vcpu_thread = mttcg_kick_vcpu_thread;
ops->handle_interrupt = tcg_handle_interrupt;
} else {
@@ -222,6 +222,7 @@ static void tcg_accel_ops_init(AccelClass *ac)
ops->cpu_common_realize = tcg_exec_realizefn;
ops->cpu_common_unrealize = tcg_exec_unrealizefn;
+ ops->thread_precreate = tcg_vcpu_thread_precreate;
ops->cpu_reset_hold = tcg_cpu_reset_hold;
ops->insert_breakpoint = tcg_insert_breakpoint;
ops->remove_breakpoint = tcg_remove_breakpoint;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 50/65] accel/hvf: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (48 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 49/65] accel/tcg: " Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-04 9:12 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 51/65] accel/kvm: " Philippe Mathieu-Daudé
` (15 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal
By converting to AccelOpsClass::cpu_thread_routine we can
let the common accel_create_vcpu_thread() create the thread.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/hvf/hvf-accel-ops.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index c91e18bc3dd..b61f08330f1 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -207,22 +207,6 @@ static void *hvf_cpu_thread_fn(void *arg)
return NULL;
}
-static void hvf_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- /*
- * HVF currently does not support TCG, and only runs in
- * unrestricted-guest mode.
- */
- assert(hvf_enabled());
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HVF",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, hvf_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-}
-
struct hvf_sw_breakpoint *hvf_find_sw_breakpoint(CPUState *cpu, vaddr pc)
{
struct hvf_sw_breakpoint *bp;
@@ -369,7 +353,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->cpu_target_realize = hvf_arch_cpu_realize;
- ops->create_vcpu_thread = hvf_start_vcpu_thread;
+ ops->cpu_thread_routine = hvf_cpu_thread_fn,
ops->kick_vcpu_thread = hvf_kick_vcpu_thread;
ops->synchronize_post_reset = hvf_cpu_synchronize_post_reset;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 51/65] accel/kvm: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (49 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 50/65] accel/hvf: " Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-04 9:15 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 52/65] accel/nvmm: " Philippe Mathieu-Daudé
` (14 subsequent siblings)
65 siblings, 1 reply; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, kvm
By converting to AccelOpsClass::cpu_thread_routine we can
let the common accel_create_vcpu_thread() create the thread.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/kvm/kvm-accel-ops.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 99f61044da5..841024148e1 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -63,16 +63,6 @@ static void *kvm_vcpu_thread_fn(void *arg)
return NULL;
}
-static void kvm_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/KVM",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, kvm_vcpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-}
-
static bool kvm_vcpu_thread_is_idle(CPUState *cpu)
{
return !kvm_halt_in_kernel();
@@ -89,7 +79,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
- ops->create_vcpu_thread = kvm_start_vcpu_thread;
+ ops->cpu_thread_routine = kvm_vcpu_thread_fn;
ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle;
ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;
ops->synchronize_post_init = kvm_cpu_synchronize_post_init;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 52/65] accel/nvmm: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (50 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 51/65] accel/kvm: " Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 53/65] accel/whpx: " Philippe Mathieu-Daudé
` (13 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Reinoud Zandijk
By converting to AccelOpsClass::cpu_thread_routine we can
let the common accel_create_vcpu_thread() create the thread.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/nvmm/nvmm-accel-ops.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c
index 21443078b72..bef6f61b776 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -61,16 +61,6 @@ static void *qemu_nvmm_cpu_thread_fn(void *arg)
return NULL;
}
-static void nvmm_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/NVMM",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, qemu_nvmm_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-}
-
/*
* Abort the call to run the virtual processor by another thread, and to
* return the control to that thread.
@@ -85,7 +75,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
- ops->create_vcpu_thread = nvmm_start_vcpu_thread;
+ ops->cpu_thread_routine = qemu_nvmm_cpu_thread_fn;
ops->kick_vcpu_thread = nvmm_kick_vcpu_thread;
ops->synchronize_post_reset = nvmm_cpu_synchronize_post_reset;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 53/65] accel/whpx: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (51 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 52/65] accel/nvmm: " Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 54/65] accel: Factor accel_cpu_realize() out Philippe Mathieu-Daudé
` (12 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Sunil Muthuswamy
By converting to AccelOpsClass::cpu_thread_routine we can
let the common accel_create_vcpu_thread() create the thread.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/whpx/whpx-accel-ops.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index 011810b5e50..8cbc6f4e2d8 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -61,16 +61,6 @@ static void *whpx_cpu_thread_fn(void *arg)
return NULL;
}
-static void whpx_start_vcpu_thread(CPUState *cpu)
-{
- char thread_name[VCPU_THREAD_NAME_SIZE];
-
- snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/WHPX",
- cpu->cpu_index);
- qemu_thread_create(cpu->thread, thread_name, whpx_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-}
-
static void whpx_kick_vcpu_thread(CPUState *cpu)
{
if (!qemu_cpu_is_self(cpu)) {
@@ -87,7 +77,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
- ops->create_vcpu_thread = whpx_start_vcpu_thread;
+ ops->cpu_thread_routine = whpx_cpu_thread_fn;
ops->kick_vcpu_thread = whpx_kick_vcpu_thread;
ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 54/65] accel: Factor accel_cpu_realize() out
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (52 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 53/65] accel/whpx: " Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 55/65] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
` (11 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Factor accel_cpu_realize() out of accel_cpu_common_realize()
for re-use.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/accel-internal.h | 2 ++
accel/accel-common.c | 8 ++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/accel/accel-internal.h b/accel/accel-internal.h
index d3a4422cbf7..b541377c349 100644
--- a/accel/accel-internal.h
+++ b/accel/accel-internal.h
@@ -14,4 +14,6 @@
void accel_init_ops_interfaces(AccelClass *ac);
+bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp);
+
#endif /* ACCEL_SYSTEM_H */
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 24038acf4aa..de010adb484 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -122,9 +122,8 @@ void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu)
}
}
-bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
+bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp)
{
- AccelState *accel = current_accel();
AccelClass *acc = ACCEL_GET_CLASS(accel);
/* target specific realization */
@@ -147,6 +146,11 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
return true;
}
+bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
+{
+ return accel_cpu_realize(current_accel(), cpu, errp);
+}
+
void accel_cpu_common_unrealize(CPUState *cpu)
{
AccelState *accel = current_accel();
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 55/65] accel: Pass old/new interrupt mask to handle_interrupt() handler
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (53 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 54/65] accel: Factor accel_cpu_realize() out Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
` (10 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Update CPUState::interrupt_request once in cpu_interrupt().
Pass the old and new masks along.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops-icount.h | 2 +-
accel/tcg/tcg-accel-ops.h | 2 +-
include/system/accel-ops.h | 2 +-
accel/tcg/tcg-accel-ops-icount.c | 8 +++-----
accel/tcg/tcg-accel-ops.c | 4 +---
system/cpus.c | 12 +++++++-----
6 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops-icount.h b/accel/tcg/tcg-accel-ops-icount.h
index 16a301b6dc0..1d9d66f0707 100644
--- a/accel/tcg/tcg-accel-ops-icount.h
+++ b/accel/tcg/tcg-accel-ops-icount.h
@@ -15,6 +15,6 @@ void icount_prepare_for_run(CPUState *cpu, int64_t cpu_budget);
int64_t icount_percpu_budget(int cpu_count);
void icount_process_data(CPUState *cpu);
-void icount_handle_interrupt(CPUState *cpu, int mask);
+void icount_handle_interrupt(CPUState *cpu, int old_mask, int new_mask);
#endif /* TCG_ACCEL_OPS_ICOUNT_H */
diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h
index 129af89c3e7..3f8eccb7a7f 100644
--- a/accel/tcg/tcg-accel-ops.h
+++ b/accel/tcg/tcg-accel-ops.h
@@ -17,7 +17,7 @@
void tcg_vcpu_thread_precreate(CPUState *cpu);
void tcg_cpu_destroy(CPUState *cpu);
int tcg_cpu_exec(CPUState *cpu);
-void tcg_handle_interrupt(CPUState *cpu, int mask);
+void tcg_handle_interrupt(CPUState *cpu, int old_mask, int new_mask);
void tcg_cpu_init_cflags(CPUState *cpu, bool parallel);
#endif /* TCG_ACCEL_OPS_H */
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index d4bd9c02d14..6d0791d73a4 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -67,7 +67,7 @@ struct AccelOpsClass {
void (*synchronize_state)(CPUState *cpu);
void (*synchronize_pre_loadvm)(CPUState *cpu);
- void (*handle_interrupt)(CPUState *cpu, int mask);
+ void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask);
/* get_vcpu_stats: Append statistics of this @cpu to @buf */
void (*get_vcpu_stats)(CPUState *cpu, GString *buf);
diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-icount.c
index d0f7b410fab..500b5dd4942 100644
--- a/accel/tcg/tcg-accel-ops-icount.c
+++ b/accel/tcg/tcg-accel-ops-icount.c
@@ -147,14 +147,12 @@ void icount_process_data(CPUState *cpu)
replay_mutex_unlock();
}
-void icount_handle_interrupt(CPUState *cpu, int mask)
+void icount_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
{
- int old_mask = cpu->interrupt_request;
-
- tcg_handle_interrupt(cpu, mask);
+ tcg_handle_interrupt(cpu, old_mask, new_mask);
if (qemu_cpu_is_self(cpu) &&
!cpu->neg.can_do_io
- && (mask & ~old_mask) != 0) {
+ && (new_mask & ~old_mask) != 0) {
cpu_abort(cpu, "Raised interrupt while not in I/O function");
}
}
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 4931e536beb..a8c24cf8a4c 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -99,10 +99,8 @@ static void tcg_cpu_reset_hold(CPUState *cpu)
}
/* mask must never be zero, except for A20 change call */
-void tcg_handle_interrupt(CPUState *cpu, int mask)
+void tcg_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
{
- cpu->interrupt_request |= mask;
-
/*
* If called from iothread context, wake the target cpu in
* case its halted.
diff --git a/system/cpus.c b/system/cpus.c
index c2ad640980c..8c2647f5f19 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -246,10 +246,8 @@ int64_t cpus_get_elapsed_ticks(void)
return cpu_get_ticks();
}
-static void generic_handle_interrupt(CPUState *cpu, int mask)
+static void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
{
- cpu->interrupt_request |= mask;
-
if (!qemu_cpu_is_self(cpu)) {
qemu_cpu_kick(cpu);
}
@@ -257,12 +255,16 @@ static void generic_handle_interrupt(CPUState *cpu, int mask)
void cpu_interrupt(CPUState *cpu, int mask)
{
+ int old_mask = cpu->interrupt_request;
+
g_assert(bql_locked());
+ cpu->interrupt_request |= mask;
+
if (cpus_accel->handle_interrupt) {
- cpus_accel->handle_interrupt(cpu, mask);
+ cpus_accel->handle_interrupt(cpu, old_mask, cpu->interrupt_request);
} else {
- generic_handle_interrupt(cpu, mask);
+ generic_handle_interrupt(cpu, old_mask, cpu->interrupt_request);
}
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (54 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 55/65] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 21:19 ` Pierrick Bouvier
` (2 more replies)
2025-07-02 18:53 ` [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler Philippe Mathieu-Daudé
` (9 subsequent siblings)
65 siblings, 3 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
In order to dispatch over AccelOpsClass::handle_interrupt(),
we need it always defined, not calling a hidden handler under
the hood. Make AccelOpsClass::handle_interrupt() mandatory.
Expose generic_handle_interrupt() prototype and register it
for each accelerator.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/accel-ops.h | 3 +++
accel/hvf/hvf-accel-ops.c | 1 +
accel/kvm/kvm-accel-ops.c | 1 +
accel/qtest/qtest.c | 1 +
accel/xen/xen-all.c | 1 +
system/cpus.c | 9 +++------
target/i386/nvmm/nvmm-accel-ops.c | 1 +
target/i386/whpx/whpx-accel-ops.c | 1 +
8 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 6d0791d73a4..dc8df9ba7dd 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -67,6 +67,7 @@ struct AccelOpsClass {
void (*synchronize_state)(CPUState *cpu);
void (*synchronize_pre_loadvm)(CPUState *cpu);
+ /* handle_interrupt is mandatory. */
void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask);
/* get_vcpu_stats: Append statistics of this @cpu to @buf */
@@ -93,4 +94,6 @@ struct AccelOpsClass {
void (*remove_all_breakpoints)(CPUState *cpu);
};
+void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask);
+
#endif /* ACCEL_OPS_H */
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index b61f08330f1..420630773c8 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -355,6 +355,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->cpu_thread_routine = hvf_cpu_thread_fn,
ops->kick_vcpu_thread = hvf_kick_vcpu_thread;
+ ops->handle_interrupt = generic_handle_interrupt;
ops->synchronize_post_reset = hvf_cpu_synchronize_post_reset;
ops->synchronize_post_init = hvf_cpu_synchronize_post_init;
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 841024148e1..b79c04b6267 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -85,6 +85,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->synchronize_post_init = kvm_cpu_synchronize_post_init;
ops->synchronize_state = kvm_cpu_synchronize_state;
ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
+ ops->handle_interrupt = generic_handle_interrupt;
#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
ops->update_guest_debug = kvm_update_guest_debug_ops;
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 9f30098d133..47fa9e38ce3 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -68,6 +68,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->cpu_thread_routine = dummy_cpu_thread_routine;
ops->get_virtual_clock = qtest_get_virtual_clock;
ops->set_virtual_clock = qtest_set_virtual_clock;
+ ops->handle_interrupt = generic_handle_interrupt;
};
static const TypeInfo qtest_accel_ops_type = {
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index e2ad42c0d18..a51f4c5b2ad 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -154,6 +154,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->thread_precreate = dummy_thread_precreate;
ops->cpu_thread_routine = dummy_cpu_thread_routine;
+ ops->handle_interrupt = generic_handle_interrupt;
}
static const TypeInfo xen_accel_ops_type = {
diff --git a/system/cpus.c b/system/cpus.c
index 8c2647f5f19..efe1a5e211b 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -246,7 +246,7 @@ int64_t cpus_get_elapsed_ticks(void)
return cpu_get_ticks();
}
-static void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
+void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
{
if (!qemu_cpu_is_self(cpu)) {
qemu_cpu_kick(cpu);
@@ -261,11 +261,7 @@ void cpu_interrupt(CPUState *cpu, int mask)
cpu->interrupt_request |= mask;
- if (cpus_accel->handle_interrupt) {
- cpus_accel->handle_interrupt(cpu, old_mask, cpu->interrupt_request);
- } else {
- generic_handle_interrupt(cpu, old_mask, cpu->interrupt_request);
- }
+ cpus_accel->handle_interrupt(cpu, old_mask, cpu->interrupt_request);
}
/*
@@ -674,6 +670,7 @@ void cpus_register_accel(const AccelOpsClass *ops)
{
assert(ops != NULL);
assert(ops->create_vcpu_thread || ops->cpu_thread_routine);
+ assert(ops->handle_interrupt);
cpus_accel = ops;
}
diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c
index bef6f61b776..d568cc737b1 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -77,6 +77,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->cpu_thread_routine = qemu_nvmm_cpu_thread_fn;
ops->kick_vcpu_thread = nvmm_kick_vcpu_thread;
+ ops->handle_interrupt = generic_handle_interrupt;
ops->synchronize_post_reset = nvmm_cpu_synchronize_post_reset;
ops->synchronize_post_init = nvmm_cpu_synchronize_post_init;
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index 8cbc6f4e2d8..fbffd952ac4 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -80,6 +80,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->cpu_thread_routine = whpx_cpu_thread_fn;
ops->kick_vcpu_thread = whpx_kick_vcpu_thread;
ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle;
+ ops->handle_interrupt = generic_handle_interrupt;
ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset;
ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (55 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 21:26 ` Pierrick Bouvier
2025-07-03 8:46 ` Zhao Liu
2025-07-02 18:53 ` [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler Philippe Mathieu-Daudé
` (8 subsequent siblings)
65 siblings, 2 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, kvm, xen-devel
In order to dispatch over AccelOpsClass::kick_vcpu_thread(),
we need it always defined, not calling a hidden handler under
the hood. Make AccelOpsClass::kick_vcpu_thread() mandatory.
Register the default cpus_kick_thread() for each accelerator.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/accel-ops.h | 1 +
accel/kvm/kvm-accel-ops.c | 1 +
accel/qtest/qtest.c | 1 +
accel/xen/xen-all.c | 1 +
system/cpus.c | 7 ++-----
5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index dc8df9ba7dd..e1e6985a27c 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -43,6 +43,7 @@ struct AccelOpsClass {
void *(*cpu_thread_routine)(void *);
void (*thread_precreate)(CPUState *cpu);
void (*create_vcpu_thread)(CPUState *cpu);
+ /* kick_vcpu_thread is mandatory. */
void (*kick_vcpu_thread)(CPUState *cpu);
bool (*cpu_thread_is_idle)(CPUState *cpu);
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index b79c04b6267..a4bcaa87c8d 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -81,6 +81,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->cpu_thread_routine = kvm_vcpu_thread_fn;
ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle;
+ ops->kick_vcpu_thread = cpus_kick_thread;
ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;
ops->synchronize_post_init = kvm_cpu_synchronize_post_init;
ops->synchronize_state = kvm_cpu_synchronize_state;
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 47fa9e38ce3..8e2379d6e37 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -66,6 +66,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->thread_precreate = dummy_thread_precreate;
ops->cpu_thread_routine = dummy_cpu_thread_routine;
+ ops->kick_vcpu_thread = cpus_kick_thread;
ops->get_virtual_clock = qtest_get_virtual_clock;
ops->set_virtual_clock = qtest_set_virtual_clock;
ops->handle_interrupt = generic_handle_interrupt;
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index a51f4c5b2ad..18ae0d82db5 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -154,6 +154,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->thread_precreate = dummy_thread_precreate;
ops->cpu_thread_routine = dummy_cpu_thread_routine;
+ ops->kick_vcpu_thread = cpus_kick_thread;
ops->handle_interrupt = generic_handle_interrupt;
}
diff --git a/system/cpus.c b/system/cpus.c
index efe1a5e211b..6c64ffccbb3 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -486,11 +486,7 @@ void cpus_kick_thread(CPUState *cpu)
void qemu_cpu_kick(CPUState *cpu)
{
qemu_cond_broadcast(cpu->halt_cond);
- if (cpus_accel->kick_vcpu_thread) {
- cpus_accel->kick_vcpu_thread(cpu);
- } else { /* default */
- cpus_kick_thread(cpu);
- }
+ cpus_accel->kick_vcpu_thread(cpu);
}
void qemu_cpu_kick_self(void)
@@ -670,6 +666,7 @@ void cpus_register_accel(const AccelOpsClass *ops)
{
assert(ops != NULL);
assert(ops->create_vcpu_thread || ops->cpu_thread_routine);
+ assert(ops->kick_vcpu_thread);
assert(ops->handle_interrupt);
cpus_accel = ops;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (56 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 21:29 ` Pierrick Bouvier
` (2 more replies)
2025-07-02 18:53 ` [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler Philippe Mathieu-Daudé
` (7 subsequent siblings)
65 siblings, 3 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
In order to dispatch over AccelOpsClass::get_elapsed_ticks(),
we need it always defined, not calling a hidden handler under
the hood. Make AccelOpsClass::get_elapsed_ticks() mandatory.
Register the default cpus_kick_thread() for each accelerator.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/accel-ops.h | 1 +
accel/hvf/hvf-accel-ops.c | 2 ++
accel/kvm/kvm-accel-ops.c | 3 +++
accel/qtest/qtest.c | 2 ++
accel/tcg/tcg-accel-ops.c | 3 +++
accel/xen/xen-all.c | 2 ++
system/cpus.c | 6 ++----
target/i386/nvmm/nvmm-accel-ops.c | 3 +++
target/i386/whpx/whpx-accel-ops.c | 3 +++
9 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index e1e6985a27c..8683cd37716 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -86,6 +86,7 @@ struct AccelOpsClass {
int64_t (*get_virtual_clock)(void);
void (*set_virtual_clock)(int64_t time);
+ /* get_elapsed_ticks is mandatory. */
int64_t (*get_elapsed_ticks)(void);
/* gdbstub hooks */
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 420630773c8..17776e700eb 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -54,6 +54,7 @@
#include "gdbstub/enums.h"
#include "exec/cpu-common.h"
#include "system/accel-ops.h"
+#include "system/cpu-timers.h"
#include "system/cpus.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
@@ -367,6 +368,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
ops->update_guest_debug = hvf_update_guest_debug;
+ ops->get_elapsed_ticks = cpu_get_ticks;
ops->get_vcpu_stats = hvf_get_vcpu_stats;
};
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index a4bcaa87c8d..f27228d4cd9 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -17,6 +17,7 @@
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "system/accel-ops.h"
+#include "system/cpu-timers.h"
#include "system/kvm.h"
#include "system/kvm_int.h"
#include "system/runstate.h"
@@ -94,6 +95,8 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->remove_breakpoint = kvm_remove_breakpoint;
ops->remove_all_breakpoints = kvm_remove_all_breakpoints;
#endif
+
+ ops->get_elapsed_ticks = cpu_get_ticks;
}
static const TypeInfo kvm_accel_ops_type = {
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 8e2379d6e37..b019cf69412 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -20,6 +20,7 @@
#include "qemu/accel.h"
#include "system/accel-ops.h"
#include "system/qtest.h"
+#include "system/cpu-timers.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
#include "qemu/main-loop.h"
@@ -67,6 +68,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->thread_precreate = dummy_thread_precreate;
ops->cpu_thread_routine = dummy_cpu_thread_routine;
ops->kick_vcpu_thread = cpus_kick_thread;
+ ops->get_elapsed_ticks = cpu_get_ticks;
ops->get_virtual_clock = qtest_get_virtual_clock;
ops->set_virtual_clock = qtest_set_virtual_clock;
ops->handle_interrupt = generic_handle_interrupt;
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index a8c24cf8a4c..f22f5d73abe 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -27,6 +27,7 @@
#include "qemu/osdep.h"
#include "system/accel-ops.h"
+#include "system/cpu-timers.h"
#include "system/tcg.h"
#include "system/replay.h"
#include "exec/icount.h"
@@ -205,6 +206,7 @@ static void tcg_accel_ops_init(AccelClass *ac)
ops->cpu_thread_routine = mttcg_cpu_thread_routine;
ops->kick_vcpu_thread = mttcg_kick_vcpu_thread;
ops->handle_interrupt = tcg_handle_interrupt;
+ ops->get_elapsed_ticks = cpu_get_ticks;
} else {
ops->create_vcpu_thread = rr_start_vcpu_thread;
ops->kick_vcpu_thread = rr_kick_vcpu_thread;
@@ -215,6 +217,7 @@ static void tcg_accel_ops_init(AccelClass *ac)
ops->get_elapsed_ticks = icount_get;
} else {
ops->handle_interrupt = tcg_handle_interrupt;
+ ops->get_elapsed_ticks = cpu_get_ticks;
}
}
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 18ae0d82db5..48d458bc4c7 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -20,6 +20,7 @@
#include "qemu/accel.h"
#include "accel/dummy-cpus.h"
#include "system/accel-ops.h"
+#include "system/cpu-timers.h"
#include "system/cpus.h"
#include "system/xen.h"
#include "system/runstate.h"
@@ -156,6 +157,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->cpu_thread_routine = dummy_cpu_thread_routine;
ops->kick_vcpu_thread = cpus_kick_thread;
ops->handle_interrupt = generic_handle_interrupt;
+ ops->get_elapsed_ticks = cpu_get_ticks;
}
static const TypeInfo xen_accel_ops_type = {
diff --git a/system/cpus.c b/system/cpus.c
index 6c64ffccbb3..d32b89ecf7b 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -240,10 +240,7 @@ void cpus_set_virtual_clock(int64_t new_time)
*/
int64_t cpus_get_elapsed_ticks(void)
{
- if (cpus_accel->get_elapsed_ticks) {
- return cpus_accel->get_elapsed_ticks();
- }
- return cpu_get_ticks();
+ return cpus_accel->get_elapsed_ticks();
}
void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
@@ -668,6 +665,7 @@ void cpus_register_accel(const AccelOpsClass *ops)
assert(ops->create_vcpu_thread || ops->cpu_thread_routine);
assert(ops->kick_vcpu_thread);
assert(ops->handle_interrupt);
+ assert(ops->get_elapsed_ticks);
cpus_accel = ops;
}
diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c
index d568cc737b1..4deff57471c 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -11,6 +11,7 @@
#include "system/kvm_int.h"
#include "qemu/main-loop.h"
#include "system/accel-ops.h"
+#include "system/cpu-timers.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
@@ -83,6 +84,8 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->synchronize_post_init = nvmm_cpu_synchronize_post_init;
ops->synchronize_state = nvmm_cpu_synchronize_state;
ops->synchronize_pre_loadvm = nvmm_cpu_synchronize_pre_loadvm;
+
+ ops->get_elapsed_ticks = cpu_get_ticks;
}
static const TypeInfo nvmm_accel_ops_type = {
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index fbffd952ac4..f47033a502c 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -12,6 +12,7 @@
#include "system/kvm_int.h"
#include "qemu/main-loop.h"
#include "system/accel-ops.h"
+#include "system/cpu-timers.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
@@ -86,6 +87,8 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
ops->synchronize_state = whpx_cpu_synchronize_state;
ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm;
+
+ ops->get_elapsed_ticks = cpu_get_ticks;
}
static const TypeInfo whpx_accel_ops_type = {
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (57 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 21:30 ` Pierrick Bouvier
` (3 more replies)
2025-07-02 18:53 ` [PATCH v4 60/65] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
` (6 subsequent siblings)
65 siblings, 4 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Cameron Esfahani,
Roman Bolshakov, Phil Dennis-Jordan, Mads Ynddal,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
In order to dispatch over AccelOpsClass::get_virtual_clock(),
we need it always defined, not calling a hidden handler under
the hood. Make AccelOpsClass::get_virtual_clock() mandatory.
Register the default cpus_kick_thread() for each accelerator.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/accel-ops.h | 2 ++
accel/hvf/hvf-accel-ops.c | 1 +
accel/kvm/kvm-accel-ops.c | 1 +
accel/tcg/tcg-accel-ops.c | 2 ++
accel/xen/xen-all.c | 1 +
system/cpus.c | 7 ++++---
target/i386/nvmm/nvmm-accel-ops.c | 1 +
target/i386/whpx/whpx-accel-ops.c | 1 +
8 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 8683cd37716..d5154acc75a 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -82,6 +82,8 @@ struct AccelOpsClass {
* fetch time. The set function is needed if the accelerator wants
* to track the changes to time as the timer is warped through
* various timer events.
+ *
+ * get_virtual_clock() is mandatory.
*/
int64_t (*get_virtual_clock)(void);
void (*set_virtual_clock)(int64_t time);
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 17776e700eb..cf623a1ea47 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -369,6 +369,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->update_guest_debug = hvf_update_guest_debug;
ops->get_elapsed_ticks = cpu_get_ticks;
+ ops->get_virtual_clock = cpu_get_clock;
ops->get_vcpu_stats = hvf_get_vcpu_stats;
};
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index f27228d4cd9..dde498e0626 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -97,6 +97,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
#endif
ops->get_elapsed_ticks = cpu_get_ticks;
+ ops->get_virtual_clock = cpu_get_clock;
}
static const TypeInfo kvm_accel_ops_type = {
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index f22f5d73abe..780e9debbc4 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -207,6 +207,7 @@ static void tcg_accel_ops_init(AccelClass *ac)
ops->kick_vcpu_thread = mttcg_kick_vcpu_thread;
ops->handle_interrupt = tcg_handle_interrupt;
ops->get_elapsed_ticks = cpu_get_ticks;
+ ops->get_virtual_clock = cpu_get_clock;
} else {
ops->create_vcpu_thread = rr_start_vcpu_thread;
ops->kick_vcpu_thread = rr_kick_vcpu_thread;
@@ -217,6 +218,7 @@ static void tcg_accel_ops_init(AccelClass *ac)
ops->get_elapsed_ticks = icount_get;
} else {
ops->handle_interrupt = tcg_handle_interrupt;
+ ops->get_virtual_clock = cpu_get_clock;
ops->get_elapsed_ticks = cpu_get_ticks;
}
}
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 48d458bc4c7..85fb9d1606c 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -158,6 +158,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->kick_vcpu_thread = cpus_kick_thread;
ops->handle_interrupt = generic_handle_interrupt;
ops->get_elapsed_ticks = cpu_get_ticks;
+ ops->get_virtual_clock = cpu_get_clock;
}
static const TypeInfo xen_accel_ops_type = {
diff --git a/system/cpus.c b/system/cpus.c
index d32b89ecf7b..6c99756346a 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -216,10 +216,10 @@ int64_t cpus_get_virtual_clock(void)
*
* XXX
*/
- if (cpus_accel && cpus_accel->get_virtual_clock) {
- return cpus_accel->get_virtual_clock();
+ if (!cpus_accel) {
+ return cpu_get_clock();
}
- return cpu_get_clock();
+ return cpus_accel->get_virtual_clock();
}
/*
@@ -666,6 +666,7 @@ void cpus_register_accel(const AccelOpsClass *ops)
assert(ops->kick_vcpu_thread);
assert(ops->handle_interrupt);
assert(ops->get_elapsed_ticks);
+ assert(ops->get_virtual_clock);
cpus_accel = ops;
}
diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c
index 4deff57471c..a2e84cb087a 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -86,6 +86,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->synchronize_pre_loadvm = nvmm_cpu_synchronize_pre_loadvm;
ops->get_elapsed_ticks = cpu_get_ticks;
+ ops->get_virtual_clock = cpu_get_clock;
}
static const TypeInfo nvmm_accel_ops_type = {
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index f47033a502c..d27e89dd9c5 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -89,6 +89,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm;
ops->get_elapsed_ticks = cpu_get_ticks;
+ ops->get_virtual_clock = cpu_get_clock;
}
static const TypeInfo whpx_accel_ops_type = {
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 60/65] system/memory: Restrict eventfd dispatch_write() to emulators
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (58 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 61/65] accel/tcg: Factor tcg_vcpu_init() out for re-use Philippe Mathieu-Daudé
` (5 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Peter Xu,
David Hildenbrand
Commit 8c56c1a592b ("memory: emulate ioeventfd") added a !KVM
check because the only accelerator available back then were TCG,
QTest and KVM. Then commit 126e7f78036 ("kvm: require
KVM_CAP_IOEVENTFD and KVM_CAP_IOEVENTFD_ANY_LENGTH") suggested
'!KVM' check should be '(TCG || QTest)'. Later more accelerator
were added. Implement the suggestion as a safety measure, not
dispatching to eventfd when hardware accelerator is used.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
system/memory.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/system/memory.c b/system/memory.c
index e8d9b15b28f..b072a6bef83 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -25,7 +25,7 @@
#include "qom/object.h"
#include "trace.h"
#include "system/ram_addr.h"
-#include "system/kvm.h"
+#include "system/qtest.h"
#include "system/runstate.h"
#include "system/tcg.h"
#include "qemu/accel.h"
@@ -1530,12 +1530,7 @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr,
adjust_endianness(mr, &data, op);
- /*
- * FIXME: it's not clear why under KVM the write would be processed
- * directly, instead of going through eventfd. This probably should
- * test "tcg_enabled() || qtest_enabled()", or should just go away.
- */
- if (!kvm_enabled() &&
+ if ((tcg_enabled() || qtest_enabled()) &&
memory_region_dispatch_write_eventfds(mr, addr, data, size, attrs)) {
return MEMTX_OK;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 61/65] accel/tcg: Factor tcg_vcpu_init() out for re-use
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (59 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 60/65] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 62/65] accel/tcg: Factor mttcg_cpu_exec() " Philippe Mathieu-Daudé
` (4 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops.h | 2 ++
accel/tcg/tcg-accel-ops-mttcg.c | 4 +++-
accel/tcg/tcg-accel-ops-rr.c | 4 +++-
accel/tcg/tcg-accel-ops.c | 7 +++++++
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h
index 3f8eccb7a7f..a95d97fca29 100644
--- a/accel/tcg/tcg-accel-ops.h
+++ b/accel/tcg/tcg-accel-ops.h
@@ -20,4 +20,6 @@ int tcg_cpu_exec(CPUState *cpu);
void tcg_handle_interrupt(CPUState *cpu, int old_mask, int new_mask);
void tcg_cpu_init_cflags(CPUState *cpu, bool parallel);
+int tcg_vcpu_init(CPUState *cpu);
+
#endif /* TCG_ACCEL_OPS_H */
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index 96ce065eb59..4de506a80ca 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -79,8 +79,10 @@ void *mttcg_cpu_thread_routine(void *arg)
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
- cpu->neg.can_do_io = true;
current_cpu = cpu;
+
+ tcg_vcpu_init(cpu);
+
cpu_thread_signal_created(cpu);
qemu_guest_random_seed_thread_part2(cpu->random_seed);
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index fc33a13e4e8..9578bc639cb 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -192,7 +192,9 @@ static void *rr_cpu_thread_fn(void *arg)
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
- cpu->neg.can_do_io = true;
+
+ tcg_vcpu_init(cpu);
+
cpu_thread_signal_created(cpu);
qemu_guest_random_seed_thread_part2(cpu->random_seed);
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 780e9debbc4..6823f31d8ad 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -77,6 +77,13 @@ void tcg_vcpu_thread_precreate(CPUState *cpu)
tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1);
}
+int tcg_vcpu_init(CPUState *cpu)
+{
+ cpu->neg.can_do_io = true;
+
+ return 0;
+}
+
void tcg_cpu_destroy(CPUState *cpu)
{
cpu_thread_signal_destroyed(cpu);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 62/65] accel/tcg: Factor mttcg_cpu_exec() out for re-use
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (60 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 61/65] accel/tcg: Factor tcg_vcpu_init() out for re-use Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out Philippe Mathieu-Daudé
` (3 subsequent siblings)
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops-mttcg.h | 1 +
accel/tcg/tcg-accel-ops-mttcg.c | 16 ++++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops-mttcg.h b/accel/tcg/tcg-accel-ops-mttcg.h
index 8bf2452c886..72eb1a71d61 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.h
+++ b/accel/tcg/tcg-accel-ops-mttcg.h
@@ -14,5 +14,6 @@
void mttcg_kick_vcpu_thread(CPUState *cpu);
void *mttcg_cpu_thread_routine(void *arg);
+int mttcg_cpu_exec(CPUState *cpu);
#endif /* TCG_ACCEL_OPS_MTTCG_H */
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index 4de506a80ca..6f2a992efad 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -91,10 +91,7 @@ void *mttcg_cpu_thread_routine(void *arg)
do {
if (cpu_can_run(cpu)) {
- int r;
- bql_unlock();
- r = tcg_cpu_exec(cpu);
- bql_lock();
+ int r = mttcg_cpu_exec(cpu);
switch (r) {
case EXCP_DEBUG:
cpu_handle_guest_debug(cpu);
@@ -130,3 +127,14 @@ void mttcg_kick_vcpu_thread(CPUState *cpu)
{
cpu_exit(cpu);
}
+
+int mttcg_cpu_exec(CPUState *cpu)
+{
+ int ret;
+
+ bql_unlock();
+ ret = tcg_cpu_exec(cpu);
+ bql_lock();
+
+ return ret;
+}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (61 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 62/65] accel/tcg: Factor mttcg_cpu_exec() " Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 21:07 ` Pierrick Bouvier
2025-07-03 8:50 ` Zhao Liu
2025-07-02 18:53 ` [PATCH v4 64/65] accel/tcg: Clear exit_request once in tcg_cpu_exec() Philippe Mathieu-Daudé
` (2 subsequent siblings)
65 siblings, 2 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Altough we aren't going to re-use rr_cpu_exec(), factor
it out to have RR implementation matches with MTTCG one.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/tcg-accel-ops-rr.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index 9578bc639cb..d976daa7319 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -169,6 +169,25 @@ static int rr_cpu_count(void)
return cpu_count;
}
+static int rr_cpu_exec(CPUState *cpu, int64_t cpu_budget)
+{
+ int ret;
+
+ bql_unlock();
+ if (icount_enabled()) {
+ icount_prepare_for_run(cpu, cpu_budget);
+ }
+
+ ret = tcg_cpu_exec(cpu);
+
+ if (icount_enabled()) {
+ icount_process_data(cpu);
+ }
+ bql_lock();
+
+ return ret;
+}
+
/*
* In the single-threaded case each vCPU is simulated in turn. If
* there is more than a single vCPU we create a simple timer to kick
@@ -254,17 +273,7 @@ static void *rr_cpu_thread_fn(void *arg)
(cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);
if (cpu_can_run(cpu)) {
- int r;
-
- bql_unlock();
- if (icount_enabled()) {
- icount_prepare_for_run(cpu, cpu_budget);
- }
- r = tcg_cpu_exec(cpu);
- if (icount_enabled()) {
- icount_process_data(cpu);
- }
- bql_lock();
+ int r = rr_cpu_exec(cpu, cpu_budget);
if (r == EXCP_DEBUG) {
cpu_handle_guest_debug(cpu);
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 64/65] accel/tcg: Clear exit_request once in tcg_cpu_exec()
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (62 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
2025-07-02 19:08 ` [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops-mttcg.c | 1 -
accel/tcg/tcg-accel-ops.c | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index 6f2a992efad..543c4effa0e 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -112,7 +112,6 @@ void *mttcg_cpu_thread_routine(void *arg)
}
}
- qatomic_set_mb(&cpu->exit_request, 0);
qemu_wait_io_event(cpu);
} while (!cpu->unplug || cpu_can_run(cpu));
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 6823f31d8ad..c5784f420f0 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -96,6 +96,9 @@ int tcg_cpu_exec(CPUState *cpu)
cpu_exec_start(cpu);
ret = cpu_exec(cpu);
cpu_exec_end(cpu);
+
+ qatomic_set_mb(&cpu->exit_request, 0);
+
return ret;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (63 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 64/65] accel/tcg: Clear exit_request once in tcg_cpu_exec() Philippe Mathieu-Daudé
@ 2025-07-02 18:53 ` Philippe Mathieu-Daudé
2025-07-02 21:09 ` Pierrick Bouvier
2025-07-03 8:51 ` Zhao Liu
2025-07-02 19:08 ` [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
65 siblings, 2 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 18:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé
Although unreachable, still unregister the RCU before exiting
the thread, as documented in "qemu/rcu.h":
/*
* Important !
*
* Each thread containing read-side critical sections must be registered
* with rcu_register_thread() before calling rcu_read_lock().
* rcu_unregister_thread() should be called before the thread exits.
*/
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-accel-ops-rr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index d976daa7319..0aa4ba393a4 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -313,6 +313,8 @@ static void *rr_cpu_thread_fn(void *arg)
rr_deal_with_unplugged_cpus();
}
+ rcu_unregister_thread();
+
g_assert_not_reached();
}
--
2.49.0
^ permalink raw reply related [flat|nested] 108+ messages in thread
* Re: [PATCH v4 00/65] accel: Preparatory cleanups for split-accel
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (64 preceding siblings ...)
2025-07-02 18:53 ` [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
@ 2025-07-02 19:08 ` Philippe Mathieu-Daudé
65 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-02 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier
On 2/7/25 20:52, Philippe Mathieu-Daudé wrote:
> Missing review: 22-23, 57-59, 63
and 56!
>
> Since v3:
> - Addressed Richard's review comments
>
> Few changes needed before being able to add the
> split acceleration:
>
> - few method docstring added
> - remove pointless stubs
> - propagate soon required AccelState argument
> - try to reduce current_accel() uses
> - move declarations AccelClass <-> AccelOpsClass
> - display model name in 'info cpus'
> - add 'info accel' command to QMP/HMP
> - make accel_create_vcpu_thread() more generic
> - introduce hwaccel_enabled()
>
> I plan to send a PR once fully reviewed.
>
> Regards,
>
> Phil.
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 48/65] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:53 ` [PATCH v4 48/65] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine Philippe Mathieu-Daudé
@ 2025-07-02 20:09 ` Fabiano Rosas
0 siblings, 0 replies; 108+ messages in thread
From: Fabiano Rosas @ 2025-07-02 20:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Philippe Mathieu-Daudé, Laurent Vivier,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, xen-devel
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> By converting to AccelOpsClass::cpu_thread_routine we can
> let the common accel_create_vcpu_thread() create the thread.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Fabiano Rosas <farosas@suse.de>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file
2025-07-02 18:52 ` [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file Philippe Mathieu-Daudé
@ 2025-07-02 20:26 ` Pierrick Bouvier
2025-07-03 7:26 ` Zhao Liu
2025-07-03 8:31 ` Markus Armbruster
2 siblings, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 20:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Eduardo Habkost, Marcel Apfelbaum, Yanan Wang, Zhao Liu,
Eric Blake, Markus Armbruster, Michael Roth
On 7/2/25 11:52 AM, Philippe Mathieu-Daudé wrote:
> Extract TCG and KVM definitions from machine.json to accelerator.json.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> MAINTAINERS | 1 +
> qapi/accelerator.json | 75 ++++++++++++++++++++++++++++++++++++++
> qapi/machine.json | 65 ---------------------------------
> qapi/qapi-schema.json | 1 +
> accel/tcg/monitor.c | 2 +-
> hw/core/machine-hmp-cmds.c | 1 +
> hw/core/machine-qmp-cmds.c | 1 +
> qapi/meson.build | 1 +
> 8 files changed, 81 insertions(+), 66 deletions(-)
> create mode 100644 qapi/accelerator.json
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7128e0bc98e..5d6b337cef6 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -507,6 +507,7 @@ F: accel/Makefile.objs
> F: accel/stubs/Makefile.objs
> F: cpu-common.c
> F: cpu-target.c
> +F: qapi/accelerator.json
> F: system/cpus.c
>
> Apple Silicon HVF CPUs
> diff --git a/qapi/accelerator.json b/qapi/accelerator.json
> new file mode 100644
> index 00000000000..1d2a83f1b22
> --- /dev/null
> +++ b/qapi/accelerator.json
> @@ -0,0 +1,75 @@
> +# -*- Mode: Python -*-
> +# vim: filetype=python
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +##
> +# = Accelerators
> +##
> +
> +{ 'include': 'common.json' }
> +
> +##
> +# @KvmInfo:
> +#
> +# Information about support for KVM acceleration
> +#
> +# @enabled: true if KVM acceleration is active
> +#
> +# @present: true if KVM acceleration is built into this executable
> +#
> +# Since: 0.14
> +##
> +{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> +
> +##
> +# @query-kvm:
> +#
> +# Return information about KVM acceleration
> +#
> +# Returns: @KvmInfo
> +#
> +# Since: 0.14
> +#
> +# .. qmp-example::
> +#
> +# -> { "execute": "query-kvm" }
> +# <- { "return": { "enabled": true, "present": true } }
> +##
> +{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
> +
> +##
> +# @x-query-jit:
> +#
> +# Query TCG compiler statistics
> +#
> +# Features:
> +#
> +# @unstable: This command is meant for debugging.
> +#
> +# Returns: TCG compiler statistics
> +#
> +# Since: 6.2
> +##
> +{ 'command': 'x-query-jit',
> + 'returns': 'HumanReadableText',
> + 'if': 'CONFIG_TCG',
> + 'features': [ 'unstable' ] }
> +
> +##
> +# @x-query-opcount:
> +#
> +# Query TCG opcode counters
> +#
> +# Features:
> +#
> +# @unstable: This command is meant for debugging.
> +#
> +# Returns: TCG opcode counters
> +#
> +# Since: 6.2
> +##
> +{ 'command': 'x-query-opcount',
> + 'returns': 'HumanReadableText',
> + 'if': 'CONFIG_TCG',
> + 'features': [ 'unstable' ] }
> diff --git a/qapi/machine.json b/qapi/machine.json
> index d5bbb5e367e..e4713c405e8 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -454,35 +454,6 @@
> ##
> { 'command': 'inject-nmi' }
>
> -##
> -# @KvmInfo:
> -#
> -# Information about support for KVM acceleration
> -#
> -# @enabled: true if KVM acceleration is active
> -#
> -# @present: true if KVM acceleration is built into this executable
> -#
> -# Since: 0.14
> -##
> -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> -
> -##
> -# @query-kvm:
> -#
> -# Return information about KVM acceleration
> -#
> -# Returns: @KvmInfo
> -#
> -# Since: 0.14
> -#
> -# .. qmp-example::
> -#
> -# -> { "execute": "query-kvm" }
> -# <- { "return": { "enabled": true, "present": true } }
> -##
> -{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
> -
> ##
> # @NumaOptionsType:
> #
> @@ -1729,24 +1700,6 @@
> 'returns': 'HumanReadableText',
> 'features': [ 'unstable' ] }
>
> -##
> -# @x-query-jit:
> -#
> -# Query TCG compiler statistics
> -#
> -# Features:
> -#
> -# @unstable: This command is meant for debugging.
> -#
> -# Returns: TCG compiler statistics
> -#
> -# Since: 6.2
> -##
> -{ 'command': 'x-query-jit',
> - 'returns': 'HumanReadableText',
> - 'if': 'CONFIG_TCG',
> - 'features': [ 'unstable' ] }
> -
> ##
> # @x-query-numa:
> #
> @@ -1764,24 +1717,6 @@
> 'returns': 'HumanReadableText',
> 'features': [ 'unstable' ] }
>
> -##
> -# @x-query-opcount:
> -#
> -# Query TCG opcode counters
> -#
> -# Features:
> -#
> -# @unstable: This command is meant for debugging.
> -#
> -# Returns: TCG opcode counters
> -#
> -# Since: 6.2
> -##
> -{ 'command': 'x-query-opcount',
> - 'returns': 'HumanReadableText',
> - 'if': 'CONFIG_TCG',
> - 'features': [ 'unstable' ] }
> -
> ##
> # @x-query-ramblock:
> #
> diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
> index a8f66163cb7..0477696ff02 100644
> --- a/qapi/qapi-schema.json
> +++ b/qapi/qapi-schema.json
> @@ -37,6 +37,7 @@
> { 'include': 'run-state.json' }
> { 'include': 'crypto.json' }
> { 'include': 'job.json' }
> +{ 'include': 'accelerator.json' }
> { 'include': 'block.json' }
> { 'include': 'block-export.json' }
> { 'include': 'char.json' }
> diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
> index 1c182b6bfb5..5bdd837006c 100644
> --- a/accel/tcg/monitor.c
> +++ b/accel/tcg/monitor.c
> @@ -11,7 +11,7 @@
> #include "qemu/qht.h"
> #include "qapi/error.h"
> #include "qapi/type-helpers.h"
> -#include "qapi/qapi-commands-machine.h"
> +#include "qapi/qapi-commands-accelerator.h"
> #include "monitor/monitor.h"
> #include "system/cpu-timers.h"
> #include "exec/icount.h"
> diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
> index 65eeb5e9cc2..15ae5864d16 100644
> --- a/hw/core/machine-hmp-cmds.c
> +++ b/hw/core/machine-hmp-cmds.c
> @@ -18,6 +18,7 @@
> #include "monitor/monitor.h"
> #include "qapi/error.h"
> #include "qapi/qapi-builtin-visit.h"
> +#include "qapi/qapi-commands-accelerator.h"
> #include "qapi/qapi-commands-machine.h"
> #include "qobject/qdict.h"
> #include "qapi/string-output-visitor.h"
> diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
> index ab4fd1ec08a..f37fd220c2d 100644
> --- a/hw/core/machine-qmp-cmds.c
> +++ b/hw/core/machine-qmp-cmds.c
> @@ -14,6 +14,7 @@
> #include "hw/mem/memory-device.h"
> #include "qapi/error.h"
> #include "qapi/qapi-builtin-visit.h"
> +#include "qapi/qapi-commands-accelerator.h"
> #include "qapi/qapi-commands-machine.h"
> #include "qobject/qobject.h"
> #include "qapi/qobject-input-visitor.h"
> diff --git a/qapi/meson.build b/qapi/meson.build
> index 3b035aea339..ca6b61a608d 100644
> --- a/qapi/meson.build
> +++ b/qapi/meson.build
> @@ -57,6 +57,7 @@ qapi_all_modules = [
> ]
> if have_system
> qapi_all_modules += [
> + 'accelerator',
> 'acpi',
> 'audio',
> 'cryptodev',
Good for me, in case a lower granularity (kvm, tcg, other) is needed
later, it can always be modified.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command
2025-07-02 18:52 ` [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
@ 2025-07-02 20:27 ` Pierrick Bouvier
2025-07-03 8:35 ` Markus Armbruster
2025-07-03 8:42 ` Zhao Liu
2 siblings, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 20:27 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson, Eric Blake,
Markus Armbruster
On 7/2/25 11:52 AM, Philippe Mathieu-Daudé wrote:
> Unstable QMP 'x-accel-stats' dispatches to the
> AccelOpsClass::get_stats() and get_vcpu_stats() handlers.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> qapi/accelerator.json | 17 +++++++++++++++++
> include/qemu/accel.h | 2 ++
> include/system/accel-ops.h | 3 +++
> accel/accel-qmp.c | 34 ++++++++++++++++++++++++++++++++++
> accel/accel-system.c | 1 +
> accel/meson.build | 2 +-
> 6 files changed, 58 insertions(+), 1 deletion(-)
> create mode 100644 accel/accel-qmp.c
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 24/65] accel/system: Add 'info accel' on human monitor
2025-07-02 18:52 ` [PATCH v4 24/65] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
@ 2025-07-02 20:27 ` Pierrick Bouvier
0 siblings, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 20:27 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Dr. David Alan Gilbert
On 7/2/25 11:52 AM, Philippe Mathieu-Daudé wrote:
> 'info accel' dispatches to the AccelOpsClass::get_stats()
> and get_vcpu_stats() handlers.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/accel-system.c | 8 ++++++++
> hmp-commands-info.hx | 12 ++++++++++++
> 2 files changed, 20 insertions(+)
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement
2025-07-02 18:52 ` [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
@ 2025-07-02 21:06 ` Pierrick Bouvier
2025-07-04 9:20 ` Mads Ynddal
1 sibling, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:06 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson, Shatyuka,
Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Mads Ynddal
On 7/2/25 11:52 AM, Philippe Mathieu-Daudé wrote:
> We need the QEMU binary signed to be able to use HVF.
> Improve the following:
>
> $ ./qemu-system-aarch64-unsigned -M virt -accel hvf
> qemu-system-aarch64-unsigned: -accel hvf: Error: ret = HV_DENIED (0xfae94007, at ../../accel/hvf/hvf-accel-ops.c:339)
> Abort trap: 6
>
> to:
>
> $ ./qemu-system-aarch64-unsigned -M virt -accel hvf
> qemu-system-aarch64-unsigned: -accel hvf: Could not access HVF. Is the executable signed with com.apple.security.hypervisor entitlement?
>
> Suggested-by: Shatyuka <shatyuka@qq.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2800
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/hvf/hvf-accel-ops.c | 5 +++++
> 1 file changed, 5 insertions(+)
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out
2025-07-02 18:53 ` [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out Philippe Mathieu-Daudé
@ 2025-07-02 21:07 ` Pierrick Bouvier
2025-07-03 8:50 ` Zhao Liu
1 sibling, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> Altough we aren't going to re-use rr_cpu_exec(), factor
> it out to have RR implementation matches with MTTCG one.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 31 ++++++++++++++++++++-----------
> 1 file changed, 20 insertions(+), 11 deletions(-)
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread
2025-07-02 18:53 ` [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
@ 2025-07-02 21:09 ` Pierrick Bouvier
2025-07-03 8:51 ` Zhao Liu
1 sibling, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> Although unreachable, still unregister the RCU before exiting
> the thread, as documented in "qemu/rcu.h":
>
> /*
> * Important !
> *
> * Each thread containing read-side critical sections must be registered
> * with rcu_register_thread() before calling rcu_read_lock().
> * rcu_unregister_thread() should be called before the thread exits.
> */
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 2 ++
> 1 file changed, 2 insertions(+)
This is on par with what is done for other accelerators.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt()
2025-07-02 18:53 ` [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
@ 2025-07-02 21:19 ` Pierrick Bouvier
2025-07-03 8:53 ` Zhao Liu
2025-07-04 10:30 ` Mads Ynddal
2 siblings, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Mads Ynddal, Fabiano Rosas, Laurent Vivier, Stefano Stabellini,
Anthony PERARD, Paul Durrant, Edgar E. Iglesias, Reinoud Zandijk,
Sunil Muthuswamy, kvm, xen-devel
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> In order to dispatch over AccelOpsClass::handle_interrupt(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::handle_interrupt() mandatory.
> Expose generic_handle_interrupt() prototype and register it
> for each accelerator.
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 3 +++
> accel/hvf/hvf-accel-ops.c | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/qtest/qtest.c | 1 +
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 9 +++------
> target/i386/nvmm/nvmm-accel-ops.c | 1 +
> target/i386/whpx/whpx-accel-ops.c | 1 +
> 8 files changed, 12 insertions(+), 6 deletions(-)
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler
2025-07-02 18:53 ` [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler Philippe Mathieu-Daudé
@ 2025-07-02 21:26 ` Pierrick Bouvier
2025-07-03 10:45 ` Philippe Mathieu-Daudé
2025-07-03 8:46 ` Zhao Liu
1 sibling, 1 reply; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, kvm, xen-devel
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> In order to dispatch over AccelOpsClass::kick_vcpu_thread(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::kick_vcpu_thread() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/qtest/qtest.c | 1 +
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 7 ++-----
> 5 files changed, 6 insertions(+), 5 deletions(-)
Sounds good.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Unrelated, but I noticed that hvf_kick_vcpu_thread uses hv_vcpus_exit
[1] on x86 and hv_vcpu_interrupt [2] on arm64.
I'm not even sure what's the difference when reading the Apple doc,
except that exit existed before interrupt.
[1] https://developer.apple.com/documentation/hypervisor/hv_vcpus_exit(_:_:)
[2]
https://developer.apple.com/documentation/hypervisor/hv_vcpu_interrupt(_:_:)
It might be worth moving x86 to use interrupt also, in a future series.
Regards,
Pierrick
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler
2025-07-02 18:53 ` [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler Philippe Mathieu-Daudé
@ 2025-07-02 21:29 ` Pierrick Bouvier
2025-07-03 8:48 ` Zhao Liu
2025-07-04 9:34 ` Mads Ynddal
2 siblings, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:29 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Mads Ynddal, Fabiano Rosas, Laurent Vivier, Stefano Stabellini,
Anthony PERARD, Paul Durrant, Edgar E. Iglesias, Reinoud Zandijk,
Sunil Muthuswamy, kvm, xen-devel
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> In order to dispatch over AccelOpsClass::get_elapsed_ticks(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::get_elapsed_ticks() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
Missing a replace when copied from previous description.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 1 +
> accel/hvf/hvf-accel-ops.c | 2 ++
> accel/kvm/kvm-accel-ops.c | 3 +++
> accel/qtest/qtest.c | 2 ++
> accel/tcg/tcg-accel-ops.c | 3 +++
> accel/xen/xen-all.c | 2 ++
> system/cpus.c | 6 ++----
> target/i386/nvmm/nvmm-accel-ops.c | 3 +++
> target/i386/whpx/whpx-accel-ops.c | 3 +++
> 9 files changed, 21 insertions(+), 4 deletions(-)
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler
2025-07-02 18:53 ` [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler Philippe Mathieu-Daudé
@ 2025-07-02 21:30 ` Pierrick Bouvier
2025-07-02 21:35 ` Pierrick Bouvier
` (2 subsequent siblings)
3 siblings, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Mads Ynddal, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> In order to dispatch over AccelOpsClass::get_virtual_clock(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::get_virtual_clock() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
Same same.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 2 ++
> accel/hvf/hvf-accel-ops.c | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/tcg/tcg-accel-ops.c | 2 ++
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 7 ++++---
> target/i386/nvmm/nvmm-accel-ops.c | 1 +
> target/i386/whpx/whpx-accel-ops.c | 1 +
> 8 files changed, 13 insertions(+), 3 deletions(-)
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler
2025-07-02 18:53 ` [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler Philippe Mathieu-Daudé
2025-07-02 21:30 ` Pierrick Bouvier
@ 2025-07-02 21:35 ` Pierrick Bouvier
2025-07-03 8:49 ` Zhao Liu
2025-07-04 9:31 ` Mads Ynddal
3 siblings, 0 replies; 108+ messages in thread
From: Pierrick Bouvier @ 2025-07-02 21:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson,
Cameron Esfahani, Roman Bolshakov, Phil Dennis-Jordan,
Mads Ynddal, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> In order to dispatch over AccelOpsClass::get_virtual_clock(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::get_virtual_clock() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 2 ++
> accel/hvf/hvf-accel-ops.c | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/tcg/tcg-accel-ops.c | 2 ++
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 7 ++++---
> target/i386/nvmm/nvmm-accel-ops.c | 1 +
> target/i386/whpx/whpx-accel-ops.c | 1 +
> 8 files changed, 13 insertions(+), 3 deletions(-)
Seeing the pattern in last 3 commits, I have a question regarding QOM.
Is that possible to get a constructor called for parent type
(TYPE_ACCEL_OPS), where all default values would be set, and so every
child class (specialized accelerator) would just need to override the
field they want with their own method?
It would be more easy than explicitely setting default values in all sub
classes, but maybe QOM design is limited to that.
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 01/65] system/runstate: Document qemu_add_vm_change_state_handler()
2025-07-02 18:52 ` [PATCH v4 01/65] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
@ 2025-07-03 7:03 ` Alex Bennée
0 siblings, 0 replies; 108+ messages in thread
From: Alex Bennée @ 2025-07-03 7:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 21/65] hw/core/machine: Display CPU model name in 'info cpus' command
2025-07-02 18:52 ` [PATCH v4 21/65] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
@ 2025-07-03 7:23 ` Zhao Liu
0 siblings, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 7:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Eduardo Habkost, Marcel Apfelbaum, Yanan Wang,
Eric Blake, Markus Armbruster
On Wed, Jul 02, 2025 at 08:52:43PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:52:43 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 21/65] hw/core/machine: Display CPU model name in 'info
> cpus' command
> X-Mailer: git-send-email 2.49.0
>
> Display the CPU model in 'info cpus'. Example before:
>
> $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
> QEMU 10.0.0 monitor - type 'help' for more information
> (qemu) info cpus
> * CPU #0: thread_id=42924
> CPU #1: thread_id=42924
> CPU #2: thread_id=42924
> CPU #3: thread_id=42924
> (qemu) q
>
> and after:
>
> $ qemu-system-aarch64 -M xlnx-versal-virt -S -monitor stdio
> QEMU 10.0.50 monitor - type 'help' for more information
> (qemu) info cpus
> * CPU #0: thread_id=42916 (cortex-a72)
> CPU #1: thread_id=42916 (cortex-a72)
> CPU #2: thread_id=42916 (cortex-r5f)
> CPU #3: thread_id=42916 (cortex-r5f)
> (qemu)
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> qapi/machine.json | 3 +++
> hw/core/machine-hmp-cmds.c | 3 ++-
> hw/core/machine-qmp-cmds.c | 1 +
> 3 files changed, 6 insertions(+), 1 deletion(-)
It's useful!
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
And tested on x86 platform,
Tested-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file
2025-07-02 18:52 ` [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file Philippe Mathieu-Daudé
2025-07-02 20:26 ` Pierrick Bouvier
@ 2025-07-03 7:26 ` Zhao Liu
2025-07-03 8:31 ` Markus Armbruster
2 siblings, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 7:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Eduardo Habkost, Marcel Apfelbaum, Yanan Wang,
Eric Blake, Markus Armbruster, Michael Roth
On Wed, Jul 02, 2025 at 08:52:44PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:52:44 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 22/65] qapi: Move definitions related to accelerators in
> their own file
> X-Mailer: git-send-email 2.49.0
>
> Extract TCG and KVM definitions from machine.json to accelerator.json.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> MAINTAINERS | 1 +
> qapi/accelerator.json | 75 ++++++++++++++++++++++++++++++++++++++
> qapi/machine.json | 65 ---------------------------------
> qapi/qapi-schema.json | 1 +
> accel/tcg/monitor.c | 2 +-
> hw/core/machine-hmp-cmds.c | 1 +
> hw/core/machine-qmp-cmds.c | 1 +
> qapi/meson.build | 1 +
> 8 files changed, 81 insertions(+), 66 deletions(-)
> create mode 100644 qapi/accelerator.json
Thank you for doing this; then I could refresh the PMU filter series
based on this work.
And,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 32/65] cpus: Document CPUState::vcpu_dirty field
2025-07-02 18:52 ` [PATCH v4 32/65] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
@ 2025-07-03 7:29 ` Zhao Liu
0 siblings, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 7:29 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Eduardo Habkost, Marcel Apfelbaum, Yanan Wang
On Wed, Jul 02, 2025 at 08:52:54PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:52:54 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 32/65] cpus: Document CPUState::vcpu_dirty field
> X-Mailer: git-send-email 2.49.0
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/hw/core/cpu.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file
2025-07-02 18:52 ` [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file Philippe Mathieu-Daudé
2025-07-02 20:26 ` Pierrick Bouvier
2025-07-03 7:26 ` Zhao Liu
@ 2025-07-03 8:31 ` Markus Armbruster
2 siblings, 0 replies; 108+ messages in thread
From: Markus Armbruster @ 2025-07-03 8:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Eduardo Habkost, Marcel Apfelbaum, Yanan Wang,
Zhao Liu, Eric Blake, Michael Roth, John Snow
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Extract TCG and KVM definitions from machine.json to accelerator.json.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> MAINTAINERS | 1 +
> qapi/accelerator.json | 75 ++++++++++++++++++++++++++++++++++++++
> qapi/machine.json | 65 ---------------------------------
> qapi/qapi-schema.json | 1 +
> accel/tcg/monitor.c | 2 +-
> hw/core/machine-hmp-cmds.c | 1 +
> hw/core/machine-qmp-cmds.c | 1 +
> qapi/meson.build | 1 +
> 8 files changed, 81 insertions(+), 66 deletions(-)
> create mode 100644 qapi/accelerator.json
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7128e0bc98e..5d6b337cef6 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -507,6 +507,7 @@ F: accel/Makefile.objs
> F: accel/stubs/Makefile.objs
> F: cpu-common.c
> F: cpu-target.c
> +F: qapi/accelerator.json
> F: system/cpus.c
>
> Apple Silicon HVF CPUs
> diff --git a/qapi/accelerator.json b/qapi/accelerator.json
> new file mode 100644
> index 00000000000..1d2a83f1b22
> --- /dev/null
> +++ b/qapi/accelerator.json
> @@ -0,0 +1,75 @@
> +# -*- Mode: Python -*-
> +# vim: filetype=python
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +##
> +# = Accelerators
> +##
Going to conflict with John Snow's "[PATCH v3 4/5] docs/sphinx: remove
special parsing for freeform sections". Don't worry about it.
> +
> +{ 'include': 'common.json' }
> +
> +##
> +# @KvmInfo:
> +#
> +# Information about support for KVM acceleration
> +#
> +# @enabled: true if KVM acceleration is active
> +#
> +# @present: true if KVM acceleration is built into this executable
> +#
> +# Since: 0.14
> +##
> +{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> +
> +##
> +# @query-kvm:
> +#
> +# Return information about KVM acceleration
> +#
> +# Returns: @KvmInfo
> +#
> +# Since: 0.14
> +#
> +# .. qmp-example::
> +#
> +# -> { "execute": "query-kvm" }
> +# <- { "return": { "enabled": true, "present": true } }
> +##
> +{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
> +
> +##
> +# @x-query-jit:
> +#
> +# Query TCG compiler statistics
> +#
> +# Features:
> +#
> +# @unstable: This command is meant for debugging.
> +#
> +# Returns: TCG compiler statistics
> +#
> +# Since: 6.2
> +##
> +{ 'command': 'x-query-jit',
> + 'returns': 'HumanReadableText',
> + 'if': 'CONFIG_TCG',
> + 'features': [ 'unstable' ] }
> +
> +##
> +# @x-query-opcount:
> +#
> +# Query TCG opcode counters
> +#
> +# Features:
> +#
> +# @unstable: This command is meant for debugging.
> +#
> +# Returns: TCG opcode counters
> +#
> +# Since: 6.2
> +##
> +{ 'command': 'x-query-opcount',
> + 'returns': 'HumanReadableText',
> + 'if': 'CONFIG_TCG',
> + 'features': [ 'unstable' ] }
> diff --git a/qapi/machine.json b/qapi/machine.json
> index d5bbb5e367e..e4713c405e8 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -454,35 +454,6 @@
> ##
> { 'command': 'inject-nmi' }
>
> -##
> -# @KvmInfo:
> -#
> -# Information about support for KVM acceleration
> -#
> -# @enabled: true if KVM acceleration is active
> -#
> -# @present: true if KVM acceleration is built into this executable
> -#
> -# Since: 0.14
> -##
> -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> -
> -##
> -# @query-kvm:
> -#
> -# Return information about KVM acceleration
> -#
> -# Returns: @KvmInfo
> -#
> -# Since: 0.14
> -#
> -# .. qmp-example::
> -#
> -# -> { "execute": "query-kvm" }
> -# <- { "return": { "enabled": true, "present": true } }
> -##
> -{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
> -
> ##
> # @NumaOptionsType:
> #
> @@ -1729,24 +1700,6 @@
> 'returns': 'HumanReadableText',
> 'features': [ 'unstable' ] }
>
> -##
> -# @x-query-jit:
> -#
> -# Query TCG compiler statistics
> -#
> -# Features:
> -#
> -# @unstable: This command is meant for debugging.
> -#
> -# Returns: TCG compiler statistics
> -#
> -# Since: 6.2
> -##
> -{ 'command': 'x-query-jit',
> - 'returns': 'HumanReadableText',
> - 'if': 'CONFIG_TCG',
> - 'features': [ 'unstable' ] }
> -
> ##
> # @x-query-numa:
> #
> @@ -1764,24 +1717,6 @@
> 'returns': 'HumanReadableText',
> 'features': [ 'unstable' ] }
>
> -##
> -# @x-query-opcount:
> -#
> -# Query TCG opcode counters
> -#
> -# Features:
> -#
> -# @unstable: This command is meant for debugging.
> -#
> -# Returns: TCG opcode counters
> -#
> -# Since: 6.2
> -##
> -{ 'command': 'x-query-opcount',
> - 'returns': 'HumanReadableText',
> - 'if': 'CONFIG_TCG',
> - 'features': [ 'unstable' ] }
> -
> ##
> # @x-query-ramblock:
> #
> diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
> index a8f66163cb7..0477696ff02 100644
> --- a/qapi/qapi-schema.json
> +++ b/qapi/qapi-schema.json
> @@ -37,6 +37,7 @@
> { 'include': 'run-state.json' }
> { 'include': 'crypto.json' }
> { 'include': 'job.json' }
> +{ 'include': 'accelerator.json' }
> { 'include': 'block.json' }
> { 'include': 'block-export.json' }
> { 'include': 'char.json' }
This puts the new section "Accelerators" between "Background jobs" and
"Block devices". Feels arbitrary. Much of the existing order does.
Would it fit better next to "Machines"?
> diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
> index 1c182b6bfb5..5bdd837006c 100644
> --- a/accel/tcg/monitor.c
> +++ b/accel/tcg/monitor.c
> @@ -11,7 +11,7 @@
> #include "qemu/qht.h"
> #include "qapi/error.h"
> #include "qapi/type-helpers.h"
> -#include "qapi/qapi-commands-machine.h"
> +#include "qapi/qapi-commands-accelerator.h"
> #include "monitor/monitor.h"
> #include "system/cpu-timers.h"
> #include "exec/icount.h"
> diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
> index 65eeb5e9cc2..15ae5864d16 100644
> --- a/hw/core/machine-hmp-cmds.c
> +++ b/hw/core/machine-hmp-cmds.c
> @@ -18,6 +18,7 @@
> #include "monitor/monitor.h"
> #include "qapi/error.h"
> #include "qapi/qapi-builtin-visit.h"
> +#include "qapi/qapi-commands-accelerator.h"
> #include "qapi/qapi-commands-machine.h"
> #include "qobject/qdict.h"
> #include "qapi/string-output-visitor.h"
> diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
> index ab4fd1ec08a..f37fd220c2d 100644
> --- a/hw/core/machine-qmp-cmds.c
> +++ b/hw/core/machine-qmp-cmds.c
> @@ -14,6 +14,7 @@
> #include "hw/mem/memory-device.h"
> #include "qapi/error.h"
> #include "qapi/qapi-builtin-visit.h"
> +#include "qapi/qapi-commands-accelerator.h"
> #include "qapi/qapi-commands-machine.h"
> #include "qobject/qobject.h"
> #include "qapi/qobject-input-visitor.h"
Have you considered extracting the accelerator command code to
accel/accel-qmp-cmds.c and accel/accel-hmp-cmds.c?
> diff --git a/qapi/meson.build b/qapi/meson.build
> index 3b035aea339..ca6b61a608d 100644
> --- a/qapi/meson.build
> +++ b/qapi/meson.build
> @@ -57,6 +57,7 @@ qapi_all_modules = [
> ]
> if have_system
> qapi_all_modules += [
> + 'accelerator',
> 'acpi',
> 'audio',
> 'cryptodev',
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command
2025-07-02 18:52 ` [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
2025-07-02 20:27 ` Pierrick Bouvier
@ 2025-07-03 8:35 ` Markus Armbruster
2025-07-03 8:42 ` Zhao Liu
2 siblings, 0 replies; 108+ messages in thread
From: Markus Armbruster @ 2025-07-03 8:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Eric Blake
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Unstable QMP 'x-accel-stats' dispatches to the
> AccelOpsClass::get_stats() and get_vcpu_stats() handlers.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats()
2025-07-02 18:52 ` [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
@ 2025-07-03 8:40 ` Zhao Liu
2025-07-03 16:55 ` Alex Bennée
1 sibling, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier
[It seems my previous reply was missing in mail list. If repetitive,
please ignore it. :-) ]
Hi Philippe,
On Wed, Jul 02, 2025 at 08:52:48PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:52:48 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats()
> X-Mailer: git-send-email 2.49.0
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/tcg-all.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
> index ae83ca0bd10..d49d2b3b0fa 100644
> --- a/accel/tcg/tcg-all.c
> +++ b/accel/tcg/tcg-all.c
> @@ -239,11 +239,17 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
> }
> }
>
> +static void tcg_get_stats(AccelState *as, GString *buf)
> +{
> + tcg_dump_flush_info(buf);
> +}
> +
With:
./configure
make -j
I met the error:
/usr/bin/ld: libuser.a.p/accel_tcg_tcg-all.c.o: in function `tcg_get_stats':
/qemu/build/../accel/tcg/tcg-all.c:244: undefined reference to `tcg_dump_flush_info'
It seems tcg_dump_flush_info() needs a stub?
Thanks,
Zhao
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command
2025-07-02 18:52 ` [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
2025-07-02 20:27 ` Pierrick Bouvier
2025-07-03 8:35 ` Markus Armbruster
@ 2025-07-03 8:42 ` Zhao Liu
2 siblings, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Eric Blake, Markus Armbruster
On Wed, Jul 02, 2025 at 08:52:45PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:52:45 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command
> X-Mailer: git-send-email 2.49.0
>
> Unstable QMP 'x-accel-stats' dispatches to the
> AccelOpsClass::get_stats() and get_vcpu_stats() handlers.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> qapi/accelerator.json | 17 +++++++++++++++++
> include/qemu/accel.h | 2 ++
> include/system/accel-ops.h | 3 +++
> accel/accel-qmp.c | 34 ++++++++++++++++++++++++++++++++++
> accel/accel-system.c | 1 +
> accel/meson.build | 2 +-
> 6 files changed, 58 insertions(+), 1 deletion(-)
> create mode 100644 accel/accel-qmp.c
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler
2025-07-02 18:53 ` [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler Philippe Mathieu-Daudé
2025-07-02 21:26 ` Pierrick Bouvier
@ 2025-07-03 8:46 ` Zhao Liu
1 sibling, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Fabiano Rosas, Laurent Vivier,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, kvm, xen-devel
On Wed, Jul 02, 2025 at 08:53:19PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:53:19 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 57/65] accel: Always register
> AccelOpsClass::kick_vcpu_thread() handler
> X-Mailer: git-send-email 2.49.0
>
> In order to dispatch over AccelOpsClass::kick_vcpu_thread(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::kick_vcpu_thread() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/qtest/qtest.c | 1 +
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 7 ++-----
> 5 files changed, 6 insertions(+), 5 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler
2025-07-02 18:53 ` [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler Philippe Mathieu-Daudé
2025-07-02 21:29 ` Pierrick Bouvier
@ 2025-07-03 8:48 ` Zhao Liu
2025-07-04 9:34 ` Mads Ynddal
2 siblings, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:48 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Mads Ynddal, Fabiano Rosas, Laurent Vivier,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
On Wed, Jul 02, 2025 at 08:53:20PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:53:20 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 58/65] accel: Always register
> AccelOpsClass::get_elapsed_ticks() handler
> X-Mailer: git-send-email 2.49.0
>
> In order to dispatch over AccelOpsClass::get_elapsed_ticks(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::get_elapsed_ticks() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 1 +
> accel/hvf/hvf-accel-ops.c | 2 ++
> accel/kvm/kvm-accel-ops.c | 3 +++
> accel/qtest/qtest.c | 2 ++
> accel/tcg/tcg-accel-ops.c | 3 +++
> accel/xen/xen-all.c | 2 ++
> system/cpus.c | 6 ++----
> target/i386/nvmm/nvmm-accel-ops.c | 3 +++
> target/i386/whpx/whpx-accel-ops.c | 3 +++
> 9 files changed, 21 insertions(+), 4 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler
2025-07-02 18:53 ` [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler Philippe Mathieu-Daudé
2025-07-02 21:30 ` Pierrick Bouvier
2025-07-02 21:35 ` Pierrick Bouvier
@ 2025-07-03 8:49 ` Zhao Liu
2025-07-04 9:31 ` Mads Ynddal
3 siblings, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Mads Ynddal, Stefano Stabellini,
Anthony PERARD, Paul Durrant, Edgar E. Iglesias, Reinoud Zandijk,
Sunil Muthuswamy, kvm, xen-devel
On Wed, Jul 02, 2025 at 08:53:21PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:53:21 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 59/65] accel: Always register
> AccelOpsClass::get_virtual_clock() handler
> X-Mailer: git-send-email 2.49.0
>
> In order to dispatch over AccelOpsClass::get_virtual_clock(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::get_virtual_clock() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 2 ++
> accel/hvf/hvf-accel-ops.c | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/tcg/tcg-accel-ops.c | 2 ++
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 7 ++++---
> target/i386/nvmm/nvmm-accel-ops.c | 1 +
> target/i386/whpx/whpx-accel-ops.c | 1 +
> 8 files changed, 13 insertions(+), 3 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out
2025-07-02 18:53 ` [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out Philippe Mathieu-Daudé
2025-07-02 21:07 ` Pierrick Bouvier
@ 2025-07-03 8:50 ` Zhao Liu
1 sibling, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier
On Wed, Jul 02, 2025 at 08:53:25PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:53:25 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out
> X-Mailer: git-send-email 2.49.0
>
> Altough we aren't going to re-use rr_cpu_exec(), factor
> it out to have RR implementation matches with MTTCG one.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 31 ++++++++++++++++++++-----------
> 1 file changed, 20 insertions(+), 11 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread
2025-07-02 18:53 ` [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
2025-07-02 21:09 ` Pierrick Bouvier
@ 2025-07-03 8:51 ` Zhao Liu
1 sibling, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier
On Wed, Jul 02, 2025 at 08:53:27PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:53:27 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR
> thread
> X-Mailer: git-send-email 2.49.0
>
> Although unreachable, still unregister the RCU before exiting
> the thread, as documented in "qemu/rcu.h":
>
> /*
> * Important !
> *
> * Each thread containing read-side critical sections must be registered
> * with rcu_register_thread() before calling rcu_read_lock().
> * rcu_unregister_thread() should be called before the thread exits.
> */
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 2 ++
> 1 file changed, 2 insertions(+)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt()
2025-07-02 18:53 ` [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
2025-07-02 21:19 ` Pierrick Bouvier
@ 2025-07-03 8:53 ` Zhao Liu
2025-07-04 10:30 ` Mads Ynddal
2 siblings, 0 replies; 108+ messages in thread
From: Zhao Liu @ 2025-07-03 8:53 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Mads Ynddal, Fabiano Rosas, Laurent Vivier,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
On Wed, Jul 02, 2025 at 08:53:18PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed, 2 Jul 2025 20:53:18 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 56/65] accel: Expose and register
> generic_handle_interrupt()
> X-Mailer: git-send-email 2.49.0
>
> In order to dispatch over AccelOpsClass::handle_interrupt(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::handle_interrupt() mandatory.
> Expose generic_handle_interrupt() prototype and register it
> for each accelerator.
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 3 +++
> accel/hvf/hvf-accel-ops.c | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/qtest/qtest.c | 1 +
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 9 +++------
> target/i386/nvmm/nvmm-accel-ops.c | 1 +
> target/i386/whpx/whpx-accel-ops.c | 1 +
> 8 files changed, 12 insertions(+), 6 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler
2025-07-02 21:26 ` Pierrick Bouvier
@ 2025-07-03 10:45 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 10:45 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Richard Henderson, Fabiano Rosas,
Laurent Vivier, Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, kvm, xen-devel
On 2/7/25 23:26, Pierrick Bouvier wrote:
> On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
>> In order to dispatch over AccelOpsClass::kick_vcpu_thread(),
>> we need it always defined, not calling a hidden handler under
>> the hood. Make AccelOpsClass::kick_vcpu_thread() mandatory.
>> Register the default cpus_kick_thread() for each accelerator.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> include/system/accel-ops.h | 1 +
>> accel/kvm/kvm-accel-ops.c | 1 +
>> accel/qtest/qtest.c | 1 +
>> accel/xen/xen-all.c | 1 +
>> system/cpus.c | 7 ++-----
>> 5 files changed, 6 insertions(+), 5 deletions(-)
>
> Sounds good.
>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>
> Unrelated, but I noticed that hvf_kick_vcpu_thread uses hv_vcpus_exit
> [1] on x86 and hv_vcpu_interrupt [2] on arm64.
> I'm not even sure what's the difference when reading the Apple doc,
> except that exit existed before interrupt.
> [1] https://developer.apple.com/documentation/hypervisor/
> hv_vcpus_exit(_:_:)
This is the "Apple Silicon" documentation,
> [2] https://developer.apple.com/documentation/hypervisor/
> hv_vcpu_interrupt(_:_:)
and the "Intel-based Mac" one ;)
>
> It might be worth moving x86 to use interrupt also, in a future series.
>
> Regards,
> Pierrick
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 02/65] system/cpus: Defer memory layout changes until vCPUs are realized
2025-07-02 18:52 ` [PATCH v4 02/65] system/cpus: Defer memory layout changes until vCPUs are realized Philippe Mathieu-Daudé
@ 2025-07-03 16:37 ` Alex Bennée
2025-07-03 16:55 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 108+ messages in thread
From: Alex Bennée @ 2025-07-03 16:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Peter Xu, David Hildenbrand
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> vCPUs are not really usable until fully realized. Do not attempt
> to commit memory changes in the middle of vCPU realization. Defer
> until realization is completed and vCPU fully operational.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> system/physmem.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/system/physmem.c b/system/physmem.c
> index ff0ca40222d..8b2be31fa7e 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -2792,6 +2792,14 @@ static void tcg_commit(MemoryListener *listener)
> cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
> cpu = cpuas->cpu;
>
> + if (!qdev_is_realized(DEVICE(cpu))) {
> + /*
> + * The listener is also called during realize, before
> + * all of the tcg machinery for run-on is initialized.
> + */
> + return;
> + }
> +
This is a c&p of the wording bellow:
* That said, the listener is also called during realize, before
* all of the tcg machinery for run-on is initialized: thus halt_cond.
which is now redundant because of the early exit?
> /*
> * Defer changes to as->memory_dispatch until the cpu is quiescent.
> * Otherwise we race between (1) other cpu threads and (2) ongoing
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 02/65] system/cpus: Defer memory layout changes until vCPUs are realized
2025-07-03 16:37 ` Alex Bennée
@ 2025-07-03 16:55 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 16:55 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Peter Xu, David Hildenbrand
On 3/7/25 18:37, Alex Bennée wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
>> vCPUs are not really usable until fully realized. Do not attempt
>> to commit memory changes in the middle of vCPU realization. Defer
>> until realization is completed and vCPU fully operational.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> system/physmem.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/system/physmem.c b/system/physmem.c
>> index ff0ca40222d..8b2be31fa7e 100644
>> --- a/system/physmem.c
>> +++ b/system/physmem.c
>> @@ -2792,6 +2792,14 @@ static void tcg_commit(MemoryListener *listener)
>> cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
>> cpu = cpuas->cpu;
>>
>> + if (!qdev_is_realized(DEVICE(cpu))) {
>> + /*
>> + * The listener is also called during realize, before
>> + * all of the tcg machinery for run-on is initialized.
>> + */
>> + return;
>> + }
>> +
>
> This is a c&p of the wording bellow:
>
> * That said, the listener is also called during realize, before
> * all of the tcg machinery for run-on is initialized: thus halt_cond.
>
> which is now redundant because of the early exit?
Commit 0d58c660689 ("softmmu: Use async_run_on_cpu in tcg_commit") hmmm.
I don't understand enough this area, so I'll drop this patch for now and
keep carrying it for split accel.
Regards,
Phil.
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats()
2025-07-02 18:52 ` [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
2025-07-03 8:40 ` Zhao Liu
@ 2025-07-03 16:55 ` Alex Bennée
2025-07-03 16:57 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 108+ messages in thread
From: Alex Bennée @ 2025-07-03 16:55 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/tcg-all.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
> index ae83ca0bd10..d49d2b3b0fa 100644
> --- a/accel/tcg/tcg-all.c
> +++ b/accel/tcg/tcg-all.c
> @@ -239,11 +239,17 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
> }
> }
>
> +static void tcg_get_stats(AccelState *as, GString *buf)
> +{
> + tcg_dump_flush_info(buf);
This is failing in linux-user because we don't have a monitor:
/usr/bin/ld: libuser.a.p/accel_tcg_tcg-all.c.o: in function `tcg_get_stats':
/home/alex/lsrc/qemu.git/builds/all/../../accel/tcg/tcg-all.c:244:(.text+0x194): undefined reference to `tcg_dump_flush_info'
collect2: error: ld returned 1 exit status
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats()
2025-07-03 16:55 ` Alex Bennée
@ 2025-07-03 16:57 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 16:57 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier
On 3/7/25 18:55, Alex Bennée wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> accel/tcg/tcg-all.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
>> index ae83ca0bd10..d49d2b3b0fa 100644
>> --- a/accel/tcg/tcg-all.c
>> +++ b/accel/tcg/tcg-all.c
>> @@ -239,11 +239,17 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
>> }
>> }
>>
>> +static void tcg_get_stats(AccelState *as, GString *buf)
>> +{
>> + tcg_dump_flush_info(buf);
>
> This is failing in linux-user because we don't have a monitor:
>
> /usr/bin/ld: libuser.a.p/accel_tcg_tcg-all.c.o: in function `tcg_get_stats':
> /home/alex/lsrc/qemu.git/builds/all/../../accel/tcg/tcg-all.c:244:(.text+0x194): undefined reference to `tcg_dump_flush_info'
> collect2: error: ld returned 1 exit status
(reported by Zhao and fixed in v5)
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 50/65] accel/hvf: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:53 ` [PATCH v4 50/65] accel/hvf: " Philippe Mathieu-Daudé
@ 2025-07-04 9:12 ` Mads Ynddal
0 siblings, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 9:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan
> On 2 Jul 2025, at 20.53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> By converting to AccelOpsClass::cpu_thread_routine we can
> let the common accel_create_vcpu_thread() create the thread.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/hvf/hvf-accel-ops.c | 18 +-----------------
> 1 file changed, 1 insertion(+), 17 deletions(-)
>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 47/65] accel: Introduce AccelOpsClass::cpu_thread_routine handler
2025-07-02 18:53 ` [PATCH v4 47/65] accel: Introduce AccelOpsClass::cpu_thread_routine handler Philippe Mathieu-Daudé
@ 2025-07-04 9:12 ` Mads Ynddal
0 siblings, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 9:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier
> On 2 Jul 2025, at 20.53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> In order to have a generic function creating threads,
> introduce the thread_precreate() and cpu_thread_routine()
> handlers.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/system/accel-ops.h | 5 ++++-
> accel/accel-common.c | 16 +++++++++++++++-
> system/cpus.c | 2 +-
> 3 files changed, 20 insertions(+), 3 deletions(-)
>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 51/65] accel/kvm: Convert to AccelOpsClass::cpu_thread_routine
2025-07-02 18:53 ` [PATCH v4 51/65] accel/kvm: " Philippe Mathieu-Daudé
@ 2025-07-04 9:15 ` Mads Ynddal
0 siblings, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 9:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, kvm
> On 2 Jul 2025, at 20.53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> By converting to AccelOpsClass::cpu_thread_routine we can
> let the common accel_create_vcpu_thread() create the thread.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/kvm/kvm-accel-ops.c | 12 +-----------
> 1 file changed, 1 insertion(+), 11 deletions(-)
>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement
2025-07-02 18:52 ` [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
2025-07-02 21:06 ` Pierrick Bouvier
@ 2025-07-04 9:20 ` Mads Ynddal
1 sibling, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 9:20 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Shatyuka, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan
> On 2 Jul 2025, at 20.52, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> We need the QEMU binary signed to be able to use HVF.
> Improve the following:
>
> $ ./qemu-system-aarch64-unsigned -M virt -accel hvf
> qemu-system-aarch64-unsigned: -accel hvf: Error: ret = HV_DENIED (0xfae94007, at ../../accel/hvf/hvf-accel-ops.c:339)
> Abort trap: 6
>
> to:
>
> $ ./qemu-system-aarch64-unsigned -M virt -accel hvf
> qemu-system-aarch64-unsigned: -accel hvf: Could not access HVF. Is the executable signed with com.apple.security.hypervisor entitlement?
>
> Suggested-by: Shatyuka <shatyuka@qq.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2800
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/hvf/hvf-accel-ops.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler
2025-07-02 18:53 ` [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-07-03 8:49 ` Zhao Liu
@ 2025-07-04 9:31 ` Mads Ynddal
3 siblings, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 9:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Stefano Stabellini, Anthony PERARD,
Paul Durrant, Edgar E. Iglesias, Reinoud Zandijk,
Sunil Muthuswamy, kvm, xen-devel
> On 2 Jul 2025, at 20.53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> In order to dispatch over AccelOpsClass::get_virtual_clock(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::get_virtual_clock() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 2 ++
> accel/hvf/hvf-accel-ops.c | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/tcg/tcg-accel-ops.c | 2 ++
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 7 ++++---
> target/i386/nvmm/nvmm-accel-ops.c | 1 +
> target/i386/whpx/whpx-accel-ops.c | 1 +
> 8 files changed, 13 insertions(+), 3 deletions(-)
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler
2025-07-02 18:53 ` [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler Philippe Mathieu-Daudé
2025-07-02 21:29 ` Pierrick Bouvier
2025-07-03 8:48 ` Zhao Liu
@ 2025-07-04 9:34 ` Mads Ynddal
2 siblings, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 9:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Fabiano Rosas, Laurent Vivier,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
> On 2 Jul 2025, at 20.53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> In order to dispatch over AccelOpsClass::get_elapsed_ticks(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::get_elapsed_ticks() mandatory.
> Register the default cpus_kick_thread() for each accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 1 +
> accel/hvf/hvf-accel-ops.c | 2 ++
> accel/kvm/kvm-accel-ops.c | 3 +++
> accel/qtest/qtest.c | 2 ++
> accel/tcg/tcg-accel-ops.c | 3 +++
> accel/xen/xen-all.c | 2 ++
> system/cpus.c | 6 ++----
> target/i386/nvmm/nvmm-accel-ops.c | 3 +++
> target/i386/whpx/whpx-accel-ops.c | 3 +++
> 9 files changed, 21 insertions(+), 4 deletions(-)
>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt()
2025-07-02 18:53 ` [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
2025-07-02 21:19 ` Pierrick Bouvier
2025-07-03 8:53 ` Zhao Liu
@ 2025-07-04 10:30 ` Mads Ynddal
2 siblings, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 10:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Fabiano Rosas, Laurent Vivier,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
> On 2 Jul 2025, at 20.53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> In order to dispatch over AccelOpsClass::handle_interrupt(),
> we need it always defined, not calling a hidden handler under
> the hood. Make AccelOpsClass::handle_interrupt() mandatory.
> Expose generic_handle_interrupt() prototype and register it
> for each accelerator.
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/accel-ops.h | 3 +++
> accel/hvf/hvf-accel-ops.c | 1 +
> accel/kvm/kvm-accel-ops.c | 1 +
> accel/qtest/qtest.c | 1 +
> accel/xen/xen-all.c | 1 +
> system/cpus.c | 9 +++------
> target/i386/nvmm/nvmm-accel-ops.c | 1 +
> target/i386/whpx/whpx-accel-ops.c | 1 +
> 8 files changed, 12 insertions(+), 6 deletions(-)
>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 33/65] accel/hvf: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-02 18:52 ` [PATCH v4 33/65] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
@ 2025-07-04 10:40 ` Mads Ynddal
0 siblings, 0 replies; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 10:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Alexander Graf, Peter Maydell, qemu-arm
> On 2 Jul 2025, at 20.52, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> No need for accel-specific @dirty field when we have
> a generic one in CPUState.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/system/hvf_int.h | 1 -
> accel/hvf/hvf-accel-ops.c | 10 +++++-----
> target/arm/hvf/hvf.c | 4 ++--
> target/i386/hvf/hvf.c | 4 ++--
> target/i386/hvf/x86hvf.c | 2 +-
> 5 files changed, 10 insertions(+), 11 deletions(-)
>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 108+ messages in thread
* Re: [PATCH v4 27/65] accel/hvf: Implement get_vcpu_stats()
2025-07-02 18:52 ` [PATCH v4 27/65] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
@ 2025-07-04 12:05 ` Mads Ynddal
2025-07-04 12:45 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 108+ messages in thread
From: Mads Ynddal @ 2025-07-04 12:05 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan
> On 2 Jul 2025, at 20.52, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/hvf/hvf-accel-ops.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
> index e7f40888c26..c07ebf8a652 100644
> --- a/accel/hvf/hvf-accel-ops.c
> +++ b/accel/hvf/hvf-accel-ops.c
> @@ -358,6 +358,12 @@ static inline int hvf_gdbstub_sstep_flags(AccelState *as)
> return SSTEP_ENABLE | SSTEP_NOIRQ;
> }
>
> +static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
> +{
> + int r = hv_vcpu_get_exec_time(cpu->accel->fd, arg.host_ptr);
> + assert_hvf_ok(r);
> +}
> +
> static void hvf_accel_class_init(ObjectClass *oc, const void *data)
> {
> AccelClass *ac = ACCEL_CLASS(oc);
> @@ -583,6 +589,16 @@ static void hvf_remove_all_breakpoints(CPUState *cpu)
> }
> }
>
> +static void hvf_get_vcpu_stats(CPUState *cpu, GString *buf)
> +{
> + uint64_t time_us; /* units of mach_absolute_time() */
> +
> + run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_us));
> +
> + g_string_append_printf(buf, "HVF cumulative execution time: %llu.%.3llus\n",
> + time_us / 1000000, (time_us % 1000000) / 1000);
> +}
> +
> static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
> {
> AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
> @@ -601,7 +617,10 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
> ops->remove_breakpoint = hvf_remove_breakpoint;
> ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
> ops->update_guest_debug = hvf_update_guest_debug;
> +
> + ops->get_vcpu_stats = hvf_get_vcpu_stats;
> };
> +
> static const TypeInfo hvf_accel_ops_type = {
> .name = ACCEL_OPS_NAME("hvf"),
>
> --
> 2.49.0
>
This doesn't return the right time for me (M3 Pro). If you tested on Intel, it might have a different time scale for mach units?
This is what I needed to change to make it work. Tested with 'yes > /dev/null' in the guest and 'info accel' in monitor.
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index cf623a1ea4..5b3bcd553d 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -59,6 +59,7 @@
#include "system/hvf.h"
#include "system/hvf_int.h"
#include "hw/core/cpu.h"
+#include <mach/mach_time.h>
HVFState *hvf_state;
@@ -340,12 +341,16 @@ static void hvf_remove_all_breakpoints(CPUState *cpu)
static void hvf_get_vcpu_stats(CPUState *cpu, GString *buf)
{
- uint64_t time_us; /* units of mach_absolute_time() */
+ uint64_t time_mach; /* units of mach_absolute_time() */
- run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_us));
+ run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_mach));
+
+ mach_timebase_info_data_t timebase;
+ mach_timebase_info(&timebase);
+ uint64_t time_ns = time_mach * timebase.numer / timebase.denom;
g_string_append_printf(buf, "HVF cumulative execution time: %llu.%.3llus\n",
- time_us / 1000000, (time_us % 1000000) / 1000);
+ time_ns / 1000000000, (time_ns % 1000000000) / 1000000);
}
static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
^ permalink raw reply related [flat|nested] 108+ messages in thread
* Re: [PATCH v4 27/65] accel/hvf: Implement get_vcpu_stats()
2025-07-04 12:05 ` Mads Ynddal
@ 2025-07-04 12:45 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 108+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 12:45 UTC (permalink / raw)
To: Mads Ynddal
Cc: qemu-devel, Alex Bennée, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan
On 4/7/25 14:05, Mads Ynddal wrote:
>
>> On 2 Jul 2025, at 20.52, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> accel/hvf/hvf-accel-ops.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
>> index e7f40888c26..c07ebf8a652 100644
>> --- a/accel/hvf/hvf-accel-ops.c
>> +++ b/accel/hvf/hvf-accel-ops.c
>> @@ -358,6 +358,12 @@ static inline int hvf_gdbstub_sstep_flags(AccelState *as)
>> return SSTEP_ENABLE | SSTEP_NOIRQ;
>> }
>>
>> +static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
>> +{
>> + int r = hv_vcpu_get_exec_time(cpu->accel->fd, arg.host_ptr);
>> + assert_hvf_ok(r);
>> +}
>> +
>> static void hvf_accel_class_init(ObjectClass *oc, const void *data)
>> {
>> AccelClass *ac = ACCEL_CLASS(oc);
>> @@ -583,6 +589,16 @@ static void hvf_remove_all_breakpoints(CPUState *cpu)
>> }
>> }
>>
>> +static void hvf_get_vcpu_stats(CPUState *cpu, GString *buf)
>> +{
>> + uint64_t time_us; /* units of mach_absolute_time() */
>> +
>> + run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_us));
>> +
>> + g_string_append_printf(buf, "HVF cumulative execution time: %llu.%.3llus\n",
>> + time_us / 1000000, (time_us % 1000000) / 1000);
>> +}
>> +
>> static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
>> {
>> AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
>> @@ -601,7 +617,10 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
>> ops->remove_breakpoint = hvf_remove_breakpoint;
>> ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
>> ops->update_guest_debug = hvf_update_guest_debug;
>> +
>> + ops->get_vcpu_stats = hvf_get_vcpu_stats;
>> };
>> +
>> static const TypeInfo hvf_accel_ops_type = {
>> .name = ACCEL_OPS_NAME("hvf"),
>>
>> --
>> 2.49.0
>>
>
> This doesn't return the right time for me (M3 Pro). If you tested on Intel, it might have a different time scale for mach units?
>
> This is what I needed to change to make it work. Tested with 'yes > /dev/null' in the guest and 'info accel' in monitor.
>
>
> diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
> index cf623a1ea4..5b3bcd553d 100644
> --- a/accel/hvf/hvf-accel-ops.c
> +++ b/accel/hvf/hvf-accel-ops.c
> @@ -59,6 +59,7 @@
> #include "system/hvf.h"
> #include "system/hvf_int.h"
> #include "hw/core/cpu.h"
> +#include <mach/mach_time.h>
>
> HVFState *hvf_state;
>
> @@ -340,12 +341,16 @@ static void hvf_remove_all_breakpoints(CPUState *cpu)
>
> static void hvf_get_vcpu_stats(CPUState *cpu, GString *buf)
> {
> - uint64_t time_us; /* units of mach_absolute_time() */
> + uint64_t time_mach; /* units of mach_absolute_time() */
>
> - run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_us));
> + run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_mach));
> +
> + mach_timebase_info_data_t timebase;
> + mach_timebase_info(&timebase);
> + uint64_t time_ns = time_mach * timebase.numer / timebase.denom;
Great, thank you! That works for me :)
>
> g_string_append_printf(buf, "HVF cumulative execution time: %llu.%.3llus\n",
> - time_us / 1000000, (time_us % 1000000) / 1000);
> + time_ns / 1000000000, (time_ns % 1000000000) / 1000000);
> }
>
> static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
>
>
^ permalink raw reply [flat|nested] 108+ messages in thread
end of thread, other threads:[~2025-07-04 12:46 UTC | newest]
Thread overview: 108+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02 18:52 [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 01/65] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
2025-07-03 7:03 ` Alex Bennée
2025-07-02 18:52 ` [PATCH v4 02/65] system/cpus: Defer memory layout changes until vCPUs are realized Philippe Mathieu-Daudé
2025-07-03 16:37 ` Alex Bennée
2025-07-03 16:55 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 03/65] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 04/65] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 05/65] accel: Introduce AccelOpsClass::cpu_target_realize() hook Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 06/65] accel/hvf: Add hvf_arch_cpu_realize() stubs Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 07/65] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 08/65] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 09/65] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 10/65] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 11/65] accel/hvf: Re-use QOM allocated state Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 12/65] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 13/65] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 14/65] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 15/65] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 16/65] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 17/65] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 18/65] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 19/65] accel: Move cpu_common_[un]realize() declarations to AccelOpsClass Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 20/65] accel/system: Convert pre_resume() from AccelOpsClass to AccelClass Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 21/65] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
2025-07-03 7:23 ` Zhao Liu
2025-07-02 18:52 ` [PATCH v4 22/65] qapi: Move definitions related to accelerators in their own file Philippe Mathieu-Daudé
2025-07-02 20:26 ` Pierrick Bouvier
2025-07-03 7:26 ` Zhao Liu
2025-07-03 8:31 ` Markus Armbruster
2025-07-02 18:52 ` [PATCH v4 23/65] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
2025-07-02 20:27 ` Pierrick Bouvier
2025-07-03 8:35 ` Markus Armbruster
2025-07-03 8:42 ` Zhao Liu
2025-07-02 18:52 ` [PATCH v4 24/65] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-02 20:27 ` Pierrick Bouvier
2025-07-02 18:52 ` [PATCH v4 25/65] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 26/65] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
2025-07-03 8:40 ` Zhao Liu
2025-07-03 16:55 ` Alex Bennée
2025-07-03 16:57 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 27/65] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
2025-07-04 12:05 ` Mads Ynddal
2025-07-04 12:45 ` Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 28/65] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
2025-07-02 21:06 ` Pierrick Bouvier
2025-07-04 9:20 ` Mads Ynddal
2025-07-02 18:52 ` [PATCH v4 29/65] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 30/65] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 31/65] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 32/65] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
2025-07-03 7:29 ` Zhao Liu
2025-07-02 18:52 ` [PATCH v4 33/65] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
2025-07-04 10:40 ` Mads Ynddal
2025-07-02 18:52 ` [PATCH v4 34/65] accel/nvmm: " Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 35/65] accel/whpx: " Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 36/65] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
2025-07-02 18:52 ` [PATCH v4 37/65] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 38/65] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 39/65] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 40/65] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 41/65] accel/system: Introduce hwaccel_enabled() helper Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 42/65] target/arm: Use generic hwaccel_enabled() to check 'host' cpu type Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 43/65] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 44/65] accel/dummy: Factor dummy_thread_precreate() out Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 45/65] accel/tcg: Factor tcg_vcpu_thread_precreate() out Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 46/65] accel: Factor accel_create_vcpu_thread() out Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 47/65] accel: Introduce AccelOpsClass::cpu_thread_routine handler Philippe Mathieu-Daudé
2025-07-04 9:12 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 48/65] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine Philippe Mathieu-Daudé
2025-07-02 20:09 ` Fabiano Rosas
2025-07-02 18:53 ` [PATCH v4 49/65] accel/tcg: " Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 50/65] accel/hvf: " Philippe Mathieu-Daudé
2025-07-04 9:12 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 51/65] accel/kvm: " Philippe Mathieu-Daudé
2025-07-04 9:15 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 52/65] accel/nvmm: " Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 53/65] accel/whpx: " Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 54/65] accel: Factor accel_cpu_realize() out Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 55/65] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 56/65] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
2025-07-02 21:19 ` Pierrick Bouvier
2025-07-03 8:53 ` Zhao Liu
2025-07-04 10:30 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 57/65] accel: Always register AccelOpsClass::kick_vcpu_thread() handler Philippe Mathieu-Daudé
2025-07-02 21:26 ` Pierrick Bouvier
2025-07-03 10:45 ` Philippe Mathieu-Daudé
2025-07-03 8:46 ` Zhao Liu
2025-07-02 18:53 ` [PATCH v4 58/65] accel: Always register AccelOpsClass::get_elapsed_ticks() handler Philippe Mathieu-Daudé
2025-07-02 21:29 ` Pierrick Bouvier
2025-07-03 8:48 ` Zhao Liu
2025-07-04 9:34 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 59/65] accel: Always register AccelOpsClass::get_virtual_clock() handler Philippe Mathieu-Daudé
2025-07-02 21:30 ` Pierrick Bouvier
2025-07-02 21:35 ` Pierrick Bouvier
2025-07-03 8:49 ` Zhao Liu
2025-07-04 9:31 ` Mads Ynddal
2025-07-02 18:53 ` [PATCH v4 60/65] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 61/65] accel/tcg: Factor tcg_vcpu_init() out for re-use Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 62/65] accel/tcg: Factor mttcg_cpu_exec() " Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 63/65] accel/tcg: Factor rr_cpu_exec() out Philippe Mathieu-Daudé
2025-07-02 21:07 ` Pierrick Bouvier
2025-07-03 8:50 ` Zhao Liu
2025-07-02 18:53 ` [PATCH v4 64/65] accel/tcg: Clear exit_request once in tcg_cpu_exec() Philippe Mathieu-Daudé
2025-07-02 18:53 ` [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
2025-07-02 21:09 ` Pierrick Bouvier
2025-07-03 8:51 ` Zhao Liu
2025-07-02 19:08 ` [PATCH v4 00/65] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).