* [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub
[not found] <20250703173248.44995-1-philmd@linaro.org>
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 4:13 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
` (11 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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] 27+ messages in thread
* [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope
[not found] <20250703173248.44995-1-philmd@linaro.org>
2025-07-03 17:32 ` [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 4:15 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
` (10 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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] 27+ messages in thread
* [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass
[not found] <20250703173248.44995-1-philmd@linaro.org>
2025-07-03 17:32 ` [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 5:25 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 13/39] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
` (9 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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.
Restrict kvm_supports_guest_debug() scope.
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 | 8 +++++---
target/arm/hvf/hvf.c | 2 +-
target/i386/hvf/hvf.c | 2 +-
12 files changed, 20 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 fbd3d897fef..fb176e89bad 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -47,6 +47,7 @@ typedef struct AccelClass {
hwaddr start_addr, hwaddr size);
/* gdbstub related hooks */
+ bool (*supports_guest_debug)(AccelState *as);
int (*gdbstub_supported_sstep_flags)(void);
bool *allowed;
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 4c99d25aeff..700df92ac6d 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -63,7 +63,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 a9a502f0c8f..a9fd13d9bba 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);
#endif /* COMPILING_PER_TARGET */
#endif
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index b38977207d2..aed791a3f3e 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -366,6 +366,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 17235f26464..c8611552d19 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3533,7 +3533,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;
@@ -3998,6 +3998,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 6116644d1c0..f579685a611 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)
{
@@ -216,7 +211,6 @@ static void tcg_accel_ops_init(AccelOpsClass *ops)
}
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 6e5dc333d59..0cff0f8a0f9 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(void)
{
/*
@@ -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..03934deed49 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
+#include "qemu/accel.h"
#include "qemu/cutils.h"
#include "exec/gdbstub.h"
#include "gdbstub/syscalls.h"
@@ -634,9 +635,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 7b6d291e79c..995a6a74b06 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -2352,7 +2352,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 99e37a33e50..b25bff0df41 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -1019,7 +1019,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] 27+ messages in thread
* [PATCH v6 13/39] accel: Move cpus_are_resettable() declaration to AccelClass
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (2 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 5:36 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
` (8 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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 fb176e89bad..f987d16baaa 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -45,6 +45,7 @@ typedef struct AccelClass {
void (*setup_post)(MachineState *ms, AccelState *accel);
bool (*has_memory)(MachineState *ms, 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 700df92ac6d..f19245d0a0e 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -33,7 +33,6 @@ struct AccelOpsClass {
/* initialization function called when accel is chosen */
void (*ops_init)(AccelOpsClass *ops);
- bool (*cpus_are_resettable)(void);
void (*cpu_reset_hold)(CPUState *cpu);
void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
diff --git a/accel/accel-system.c b/accel/accel-system.c
index a0f562ae9ff..07b75dae797 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 c8611552d19..88fb6d36941 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3979,6 +3979,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():
*
@@ -3997,6 +4002,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] 27+ messages in thread
* [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (3 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 13/39] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 6:02 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
` (7 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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] 27+ messages in thread
* [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt()
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (4 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 6:38 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
` (6 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Richard Henderson <richard.henderson@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 | 10 ++++------
target/i386/nvmm/nvmm-accel-ops.c | 1 +
target/i386/whpx/whpx-accel-ops.c | 1 +
8 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index d84eaa376c2..95a0f402cde 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -61,6 +61,7 @@ struct AccelOpsClass {
void (*synchronize_pre_loadvm)(CPUState *cpu);
void (*synchronize_pre_resume)(bool step_pending);
+ /* handle_interrupt is mandatory. */
void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask);
/**
@@ -84,4 +85,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 2944e350ca9..a0248942f3a 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -353,6 +353,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->create_vcpu_thread = hvf_start_vcpu_thread;
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 99f61044da5..2a744092749 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -95,6 +95,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 612cede160b..5474ce73135 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -67,6 +67,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->create_vcpu_thread = dummy_start_vcpu_thread;
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 c150dd43cab..c12c22de785 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -153,6 +153,7 @@ 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->handle_interrupt = generic_handle_interrupt;
}
static const TypeInfo xen_accel_ops_type = {
diff --git a/system/cpus.c b/system/cpus.c
index 13535a74e6f..f90b8be9eee 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,8 @@ void cpus_register_accel(const AccelOpsClass *ops)
{
assert(ops != NULL);
assert(ops->create_vcpu_thread != NULL); /* mandatory */
+ 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 21443078b72..a5517b0abf3 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -87,6 +87,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->create_vcpu_thread = nvmm_start_vcpu_thread;
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 b8bebe403c9..31cf15f0045 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -90,6 +90,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->create_vcpu_thread = whpx_start_vcpu_thread;
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] 27+ messages in thread
* [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine()
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (5 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 11:33 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
` (5 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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-all.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 197badcb705..b040fa104b6 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 b5b368c6a9c..fb8abe38594 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-all.c b/accel/hvf/hvf-all.c
index 897a02eebe2..2cf2b18fd23 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -247,7 +247,7 @@ static MemoryListener hvf_memory_listener = {
.log_sync = hvf_log_sync,
};
-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 88fb6d36941..1b6b7006470 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 5474ce73135..2b831260201 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -38,7 +38,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 0cff0f8a0f9..7ae7d552d9e 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 c12c22de785..8279746f115 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -77,7 +77,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 2df49d7eeb4..b4a4d50e860 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -1152,7 +1152,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 94fd5fc7849..721c4782b9c 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2504,7 +2504,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] 27+ messages in thread
* [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (6 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
` (4 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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 1b6b7006470..a6ea2c7f614 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] 27+ messages in thread
* [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory()
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (7 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
` (3 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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 b040fa104b6..44189b77daa 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);
bool (*cpus_are_resettable)(AccelState *as);
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index a6ea2c7f614..0cd9b2f29ab 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 4f713889a8e..b072a6bef83 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -3496,7 +3496,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] 27+ messages in thread
* [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (8 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
` (2 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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 0cd9b2f29ab..f1c3d4d27c7 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] 27+ messages in thread
* [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags()
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (9 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h' Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h' Philippe Mathieu-Daudé
12 siblings, 0 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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-all.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 19ccc5ef6a1..3c6350d6d63 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -52,7 +52,7 @@ typedef struct AccelClass {
/* gdbstub related hooks */
bool (*supports_guest_debug)(AccelState *as);
- 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 56d88940f92..b3fbe3216aa 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -125,7 +125,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-all.c b/accel/hvf/hvf-all.c
index 2cf2b18fd23..4fae4c79805 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -281,7 +281,7 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
return hvf_arch_init();
}
-static int hvf_gdbstub_sstep_flags(void)
+static 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 f1c3d4d27c7..9d1dc56d7e8 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -3985,7 +3985,7 @@ static bool kvm_cpus_are_resettable(AccelState *as)
* 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 969c50c87ea..93972bc0919 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -224,7 +224,7 @@ static bool tcg_supports_guest_debug(AccelState *as)
return true;
}
-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] 27+ messages in thread
* [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h'
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (10 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 8:52 ` Zhao Liu
2025-07-04 14:01 ` Richard Henderson
2025-07-03 17:32 ` [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h' Philippe Mathieu-Daudé
12 siblings, 2 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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
Unfortunately "system/accel-ops.h" handlers are not only
system-specific. For example, the cpu_reset_hold() hook
is part of the vCPU creation, after it is realized.
Mechanical rename to drop 'system' using:
$ sed -i -e s_system/accel-ops.h_accel/accel-cpu-ops.h_g \
$(git grep -l system/accel-ops.h)
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/{system/accel-ops.h => accel/accel-cpu-ops.h} | 8 ++++----
accel/accel-common.c | 2 +-
accel/accel-system.c | 2 +-
accel/hvf/hvf-accel-ops.c | 2 +-
accel/kvm/kvm-accel-ops.c | 2 +-
accel/qtest/qtest.c | 2 +-
accel/tcg/tcg-accel-ops.c | 2 +-
accel/xen/xen-all.c | 2 +-
cpu-target.c | 2 +-
gdbstub/system.c | 2 +-
system/cpus.c | 2 +-
target/i386/nvmm/nvmm-accel-ops.c | 2 +-
target/i386/whpx/whpx-accel-ops.c | 2 +-
13 files changed, 16 insertions(+), 16 deletions(-)
rename include/{system/accel-ops.h => accel/accel-cpu-ops.h} (96%)
diff --git a/include/system/accel-ops.h b/include/accel/accel-cpu-ops.h
similarity index 96%
rename from include/system/accel-ops.h
rename to include/accel/accel-cpu-ops.h
index 17c80887016..a045d7c5d4a 100644
--- a/include/system/accel-ops.h
+++ b/include/accel/accel-cpu-ops.h
@@ -1,5 +1,5 @@
/*
- * Accelerator OPS, used for cpus.c module
+ * Accelerator per-vCPU handlers
*
* Copyright 2021 SUSE LLC
*
@@ -7,8 +7,8 @@
* See the COPYING file in the top-level directory.
*/
-#ifndef ACCEL_OPS_H
-#define ACCEL_OPS_H
+#ifndef ACCEL_CPU_OPS_H
+#define ACCEL_CPU_OPS_H
#include "qemu/accel.h"
#include "exec/vaddr.h"
@@ -88,4 +88,4 @@ struct AccelOpsClass {
void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask);
-#endif /* ACCEL_OPS_H */
+#endif /* ACCEL_CPU_OPS_H */
diff --git a/accel/accel-common.c b/accel/accel-common.c
index b3fbe3216aa..b490612447b 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
#include "qemu/target-info.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "accel/accel-cpu.h"
#include "accel-internal.h"
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 637e2390f35..451567e1a50 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -26,7 +26,7 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
#include "hw/boards.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "qemu/error-report.h"
#include "accel-internal.h"
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index a0248942f3a..b13937b29e1 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -54,7 +54,7 @@
#include "gdbstub/enums.h"
#include "exec/cpu-common.h"
#include "hw/core/cpu.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index 2a744092749..2c8f4fecb17 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -16,7 +16,7 @@
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/kvm.h"
#include "system/kvm_int.h"
#include "system/runstate.h"
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 2b831260201..a7fc8bee6dd 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -18,7 +18,7 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qemu/accel.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/qtest.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index bc809ad5640..8f071d2cfeb 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -26,7 +26,7 @@
*/
#include "qemu/osdep.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/tcg.h"
#include "system/replay.h"
#include "exec/icount.h"
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index bd0ff64befc..55a60bb42c2 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -19,7 +19,7 @@
#include "chardev/char.h"
#include "qemu/accel.h"
#include "accel/dummy-cpus.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "system/xen.h"
#include "system/runstate.h"
diff --git a/cpu-target.c b/cpu-target.c
index 1c90a307593..2049eb1d0f6 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -19,7 +19,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "exec/cpu-common.h"
#include "exec/tswap.h"
diff --git a/gdbstub/system.c b/gdbstub/system.c
index 03934deed49..1c48915b6a5 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -20,7 +20,7 @@
#include "gdbstub/commands.h"
#include "exec/hwaddr.h"
#include "exec/tb-flush.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "system/runstate.h"
#include "system/replay.h"
diff --git a/system/cpus.c b/system/cpus.c
index f90b8be9eee..dae66a1bc4d 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -31,7 +31,7 @@
#include "qapi/qapi-events-run-state.h"
#include "qapi/qmp/qerror.h"
#include "exec/gdbstub.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/hw_accel.h"
#include "exec/cpu-common.h"
#include "qemu/thread.h"
diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c
index a5517b0abf3..3799260bbde 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
#include "system/kvm_int.h"
#include "qemu/main-loop.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index 31cf15f0045..2b51b35bfa6 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -11,7 +11,7 @@
#include "qemu/osdep.h"
#include "system/kvm_int.h"
#include "qemu/main-loop.h"
-#include "system/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
--
2.49.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h'
[not found] <20250703173248.44995-1-philmd@linaro.org>
` (11 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h' Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 9:02 ` Zhao Liu
2025-07-04 14:03 ` Richard Henderson
12 siblings, 2 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 17:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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, Peter Xu,
David Hildenbrand, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
Only accelerator implementations (and the common accelator
code) need to know about AccelClass internals. Move the
definition out but forward declare AccelState and AccelClass.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 2 +-
include/accel/accel-ops.h | 50 +++++++++++++++++++++++++++++++++++++
include/qemu/accel.h | 40 ++---------------------------
include/system/hvf_int.h | 3 ++-
include/system/kvm_int.h | 1 +
accel/accel-common.c | 1 +
accel/accel-system.c | 1 +
accel/hvf/hvf-all.c | 1 +
accel/kvm/kvm-all.c | 1 +
accel/qtest/qtest.c | 1 +
accel/tcg/tcg-accel-ops.c | 1 +
accel/tcg/tcg-all.c | 1 +
accel/xen/xen-all.c | 1 +
bsd-user/main.c | 1 +
gdbstub/system.c | 1 +
linux-user/main.c | 1 +
system/memory.c | 1 +
target/i386/nvmm/nvmm-all.c | 1 +
target/i386/whpx/whpx-all.c | 1 +
19 files changed, 70 insertions(+), 40 deletions(-)
create mode 100644 include/accel/accel-ops.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 37d02b2313c..e3e08d4607f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -501,7 +501,7 @@ F: include/exec/target_long.h
F: include/qemu/accel.h
F: include/system/accel-*.h
F: include/system/cpus.h
-F: include/accel/accel-cpu*.h
+F: include/accel/accel-*.h
F: accel/accel-*.?
F: accel/dummy-cpus.?
F: accel/Makefile.objs
diff --git a/include/accel/accel-ops.h b/include/accel/accel-ops.h
new file mode 100644
index 00000000000..35e7d4c3b26
--- /dev/null
+++ b/include/accel/accel-ops.h
@@ -0,0 +1,50 @@
+/*
+ * Accelerator handlers
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef ACCEL_OPS_H
+#define ACCEL_OPS_H
+
+#include "exec/hwaddr.h"
+#include "qemu/accel.h"
+#include "qom/object.h"
+
+struct AccelState {
+ Object parent_obj;
+};
+
+struct AccelClass {
+ ObjectClass parent_class;
+
+ const char *name;
+ /* Cached by accel_init_ops_interfaces() when created */
+ 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);
+ 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);
+ int (*gdbstub_supported_sstep_flags)(AccelState *as);
+
+ bool *allowed;
+ /*
+ * Array of global properties that would be applied when specific
+ * accelerator is chosen. It works like MachineClass.compat_props
+ * but it's for accelerators not machines. Accelerator-provided
+ * global properties may be overridden by machine-type
+ * compat_props or user-provided global properties.
+ */
+ GPtrArray *compat_props;
+};
+
+#endif /* ACCEL_OPS_H */
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 3c6350d6d63..71293a3e2a9 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -26,44 +26,8 @@
#include "qom/object.h"
#include "exec/hwaddr.h"
-struct AccelState {
- /*< private >*/
- Object parent_obj;
-};
-
-typedef struct AccelClass {
- /*< private >*/
- ObjectClass parent_class;
- /*< public >*/
-
- const char *name;
- /* Cached by accel_init_ops_interfaces() when created */
- 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);
- 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);
- int (*gdbstub_supported_sstep_flags)(AccelState *as);
-
- bool *allowed;
- /*
- * Array of global properties that would be applied when specific
- * accelerator is chosen. It works like MachineClass.compat_props
- * but it's for accelerators not machines. Accelerator-provided
- * global properties may be overridden by machine-type
- * compat_props or user-provided global properties.
- */
- GPtrArray *compat_props;
-} AccelClass;
+typedef struct AccelState AccelState;
+typedef struct AccelClass AccelClass;
#define TYPE_ACCEL "accel"
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index ecc49a309cf..8a443af3454 100644
--- a/include/system/hvf_int.h
+++ b/include/system/hvf_int.h
@@ -14,6 +14,7 @@
#include "qemu/queue.h"
#include "exec/vaddr.h"
#include "qom/object.h"
+#include "accel/accel-ops.h"
#ifdef __aarch64__
#include <Hypervisor/Hypervisor.h>
@@ -45,7 +46,7 @@ typedef struct hvf_vcpu_caps {
} hvf_vcpu_caps;
struct HVFState {
- AccelState parent;
+ AccelState parent_obj;
hvf_slot slots[32];
int num_slots;
diff --git a/include/system/kvm_int.h b/include/system/kvm_int.h
index 756a3c0a250..9247493b029 100644
--- a/include/system/kvm_int.h
+++ b/include/system/kvm_int.h
@@ -14,6 +14,7 @@
#include "qemu/accel.h"
#include "qemu/queue.h"
#include "system/kvm.h"
+#include "accel/accel-ops.h"
#include "hw/boards.h"
#include "hw/i386/topology.h"
#include "io/channel-socket.h"
diff --git a/accel/accel-common.c b/accel/accel-common.c
index b490612447b..de2504e435e 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 "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "accel/accel-cpu.h"
#include "accel-internal.h"
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 451567e1a50..bce03c9ddeb 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 "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "qemu/error-report.h"
diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index 4fae4c79805..11514533a84 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "qemu/error-report.h"
+#include "accel/accel-ops.h"
#include "system/address-spaces.h"
#include "system/memory.h"
#include "system/hvf.h"
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 9d1dc56d7e8..683116f68ff 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -32,6 +32,7 @@
#include "system/runstate.h"
#include "system/cpus.h"
#include "system/accel-blocker.h"
+#include "accel/accel-ops.h"
#include "qemu/bswap.h"
#include "exec/tswap.h"
#include "system/memory.h"
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index a7fc8bee6dd..1d4337d698e 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -18,6 +18,7 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qemu/accel.h"
+#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "system/qtest.h"
#include "system/cpus.h"
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 8f071d2cfeb..20802e24d46 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -26,6 +26,7 @@
*/
#include "qemu/osdep.h"
+#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "system/tcg.h"
#include "system/replay.h"
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 93972bc0919..829a7293b80 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -39,6 +39,7 @@
#ifndef CONFIG_USER_ONLY
#include "hw/boards.h"
#endif
+#include "accel/accel-ops.h"
#include "accel/tcg/cpu-ops.h"
#include "internal-common.h"
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 55a60bb42c2..97377d67d1c 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -19,6 +19,7 @@
#include "chardev/char.h"
#include "qemu/accel.h"
#include "accel/dummy-cpus.h"
+#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "system/xen.h"
diff --git a/bsd-user/main.c b/bsd-user/main.c
index d0cc8e0088f..7e5d4bbce09 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -38,6 +38,7 @@
#include "qemu/plugin.h"
#include "user/guest-base.h"
#include "user/page-protection.h"
+#include "accel/accel-ops.h"
#include "tcg/startup.h"
#include "qemu/timer.h"
#include "qemu/envlist.h"
diff --git a/gdbstub/system.c b/gdbstub/system.c
index 1c48915b6a5..11870a1585f 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -20,6 +20,7 @@
#include "gdbstub/commands.h"
#include "exec/hwaddr.h"
#include "exec/tb-flush.h"
+#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
#include "system/runstate.h"
diff --git a/linux-user/main.c b/linux-user/main.c
index a9142ee7268..254cf2526a8 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -42,6 +42,7 @@
#include "user/page-protection.h"
#include "exec/gdbstub.h"
#include "gdbstub/user.h"
+#include "accel/accel-ops.h"
#include "tcg/startup.h"
#include "qemu/timer.h"
#include "qemu/envlist.h"
diff --git a/system/memory.c b/system/memory.c
index b072a6bef83..13e833851a6 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -29,6 +29,7 @@
#include "system/runstate.h"
#include "system/tcg.h"
#include "qemu/accel.h"
+#include "accel/accel-ops.h"
#include "hw/boards.h"
#include "migration/vmstate.h"
#include "system/address-spaces.h"
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index b4a4d50e860..aab12d77326 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -12,6 +12,7 @@
#include "system/address-spaces.h"
#include "system/ioport.h"
#include "qemu/accel.h"
+#include "accel/accel-ops.h"
#include "system/nvmm.h"
#include "system/cpus.h"
#include "system/runstate.h"
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 721c4782b9c..2a90cde6d50 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -14,6 +14,7 @@
#include "system/ioport.h"
#include "gdbstub/helpers.h"
#include "qemu/accel.h"
+#include "accel/accel-ops.h"
#include "system/whpx.h"
#include "system/cpus.h"
#include "system/runstate.h"
--
2.49.0
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub
2025-07-03 17:32 ` [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
@ 2025-07-04 4:13 ` Xiaoyao Li
2025-07-04 8:24 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 27+ messages in thread
From: Xiaoyao Li @ 2025-07-04 4:13 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, kvm
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
BTW, it seems we can further move kvm_init_cpu_signals() into
kvm-accel-ops.c and make it internal static function?
> ---
> 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;
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope
2025-07-03 17:32 ` [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
@ 2025-07-04 4:15 ` Xiaoyao Li
0 siblings, 0 replies; 27+ messages in thread
From: Xiaoyao Li @ 2025-07-04 4:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, kvm
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
> 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;
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass
2025-07-03 17:32 ` [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
@ 2025-07-04 5:25 ` Xiaoyao Li
0 siblings, 0 replies; 27+ messages in thread
From: Xiaoyao Li @ 2025-07-04 5:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Cameron Esfahani, Roman Bolshakov,
Phil Dennis-Jordan, Mads Ynddal, Alexander Graf, Peter Maydell,
kvm, qemu-arm
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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.
>
> Restrict kvm_supports_guest_debug() scope.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 13/39] accel: Move cpus_are_resettable() declaration to AccelClass
2025-07-03 17:32 ` [PATCH v6 13/39] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
@ 2025-07-04 5:36 ` Xiaoyao Li
0 siblings, 0 replies; 27+ messages in thread
From: Xiaoyao Li @ 2025-07-04 5:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, kvm
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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.
I don't think this is necessary unless a solid justfication provided.
One straightfroward question against it, is why don't move
gdb_supports_guest_debug() to accel/accel-system.c as well in the patch 12.
> In order to have AccelClass methods instrospect their state,
> we need to pass AccelState by argument.
Is this the essential preparation for split-accel work?
> 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 fb176e89bad..f987d16baaa 100644
> --- a/include/qemu/accel.h
> +++ b/include/qemu/accel.h
> @@ -45,6 +45,7 @@ typedef struct AccelClass {
> void (*setup_post)(MachineState *ms, AccelState *accel);
> bool (*has_memory)(MachineState *ms, 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 700df92ac6d..f19245d0a0e 100644
> --- a/include/system/accel-ops.h
> +++ b/include/system/accel-ops.h
> @@ -33,7 +33,6 @@ struct AccelOpsClass {
> /* initialization function called when accel is chosen */
> void (*ops_init)(AccelOpsClass *ops);
>
> - bool (*cpus_are_resettable)(void);
> void (*cpu_reset_hold)(CPUState *cpu);
>
> void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
> diff --git a/accel/accel-system.c b/accel/accel-system.c
> index a0f562ae9ff..07b75dae797 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 c8611552d19..88fb6d36941 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -3979,6 +3979,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():
> *
> @@ -3997,6 +4002,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) {
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub
2025-07-03 17:32 ` [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
@ 2025-07-04 6:02 ` Xiaoyao Li
2025-07-04 8:21 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 27+ messages in thread
From: Xiaoyao Li @ 2025-07-04 6:02 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, kvm
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
BTW, as what you do for HVF in this series that moving vcpu methods from
hvf-all.c to hvf-accel-ops.c, do you plan to move
kvm_cpu_synchronize_state() from kvm-all.c to kvm-accel-ops.c ?
> ---
> 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;
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt()
2025-07-03 17:32 ` [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
@ 2025-07-04 6:38 ` Xiaoyao Li
2025-07-04 8:27 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 27+ messages in thread
From: Xiaoyao Li @ 2025-07-04 6:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> In order to dispatch over AccelOpsClass::handle_interrupt(),
> we need it always defined,
It seems I can only understand it until I see the code to really require
it to be mandatory.
But anyway, the change itself is correct.
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> not calling a hidden handler under
> the hood. Make AccelOpsClass::handle_interrupt() mandatory.
> Expose generic_handle_interrupt() prototype and register it
> for each accelerator.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub
2025-07-04 6:02 ` Xiaoyao Li
@ 2025-07-04 8:21 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 8:21 UTC (permalink / raw)
To: Xiaoyao Li, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, kvm
On 4/7/25 08:02, Xiaoyao Li wrote:
> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>> 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>
>
> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Thanks!
>
> BTW, as what you do for HVF in this series that moving vcpu methods from
> hvf-all.c to hvf-accel-ops.c, do you plan to move
> kvm_cpu_synchronize_state() from kvm-all.c to kvm-accel-ops.c ?
While it doesn't seem obvious, I'm trying to consolidate the minimum
in order to have split-acceleration. The proof of concept is with
TCG and HVF, so I'll not do non-necessary changes in KVM.
Regards,
Phil.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub
2025-07-04 4:13 ` Xiaoyao Li
@ 2025-07-04 8:24 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 8:24 UTC (permalink / raw)
To: Xiaoyao Li, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, kvm
On 4/7/25 06:13, Xiaoyao Li wrote:
> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>> 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>
>
> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
>
> BTW, it seems we can further move kvm_init_cpu_signals() into
> kvm-accel-ops.c and make it internal static function?
I suppose we can if we move kvm_immediate_exit to KVM's AccelState,
but KVM code isn't really using it. We ought to move KVM specific
fields from CPUState to KVM's AccelState. Not a priority.
>
>> ---
>> accel/stubs/kvm-stub.c | 5 -----
>> 1 file changed, 5 deletions(-)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt()
2025-07-04 6:38 ` Xiaoyao Li
@ 2025-07-04 8:27 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 27+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 8:27 UTC (permalink / raw)
To: Xiaoyao Li, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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 4/7/25 08:38, Xiaoyao Li wrote:
> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>> In order to dispatch over AccelOpsClass::handle_interrupt(),
>> we need it always defined,
>
> It seems I can only understand it until I see the code to really require
> it to be mandatory.
See
https://lore.kernel.org/qemu-devel/acd1d192-f016-48d3-90e1-39d70eac46f5@linaro.org/
>
> But anyway, the change itself is correct.
>
> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Thanks!
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h'
2025-07-03 17:32 ` [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h' Philippe Mathieu-Daudé
@ 2025-07-04 8:52 ` Zhao Liu
2025-07-04 14:01 ` Richard Henderson
1 sibling, 0 replies; 27+ messages in thread
From: Zhao Liu @ 2025-07-04 8:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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 Thu, Jul 03, 2025 at 07:32:43PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:43 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' ->
> 'accel/accel-cpu-ops.h'
> X-Mailer: git-send-email 2.49.0
>
> Unfortunately "system/accel-ops.h" handlers are not only
> system-specific. For example, the cpu_reset_hold() hook
> is part of the vCPU creation, after it is realized.
>
> Mechanical rename to drop 'system' using:
>
> $ sed -i -e s_system/accel-ops.h_accel/accel-cpu-ops.h_g \
> $(git grep -l system/accel-ops.h)
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/{system/accel-ops.h => accel/accel-cpu-ops.h} | 8 ++++----
> accel/accel-common.c | 2 +-
> accel/accel-system.c | 2 +-
> accel/hvf/hvf-accel-ops.c | 2 +-
> accel/kvm/kvm-accel-ops.c | 2 +-
> accel/qtest/qtest.c | 2 +-
> accel/tcg/tcg-accel-ops.c | 2 +-
> accel/xen/xen-all.c | 2 +-
> cpu-target.c | 2 +-
> gdbstub/system.c | 2 +-
> system/cpus.c | 2 +-
> target/i386/nvmm/nvmm-accel-ops.c | 2 +-
> target/i386/whpx/whpx-accel-ops.c | 2 +-
> 13 files changed, 16 insertions(+), 16 deletions(-)
> rename include/{system/accel-ops.h => accel/accel-cpu-ops.h} (96%)
...
> -#ifndef ACCEL_OPS_H
> -#define ACCEL_OPS_H
> +#ifndef ACCEL_CPU_OPS_H
> +#define ACCEL_CPU_OPS_H
Daniel mentioned "QEMU_" prefix is "best practice":
https://lore.kernel.org/qemu-devel/aAdSMExEAy45NIeB@redhat.com/
But I also think there's no need to change anything here for now. If
you agree, we can move in this direction in the future. So
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h'
2025-07-03 17:32 ` [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h' Philippe Mathieu-Daudé
@ 2025-07-04 9:02 ` Zhao Liu
2025-07-04 14:03 ` Richard Henderson
1 sibling, 0 replies; 27+ messages in thread
From: Zhao Liu @ 2025-07-04 9:02 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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, Peter Xu,
David Hildenbrand, Reinoud Zandijk, Sunil Muthuswamy, kvm,
xen-devel
On Thu, Jul 03, 2025 at 07:32:44PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:44 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 38/39] accel: Extract AccelClass definition to
> 'accel/accel-ops.h'
> X-Mailer: git-send-email 2.49.0
>
> Only accelerator implementations (and the common accelator
> code) need to know about AccelClass internals. Move the
> definition out but forward declare AccelState and AccelClass.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> MAINTAINERS | 2 +-
> include/accel/accel-ops.h | 50 +++++++++++++++++++++++++++++++++++++
> include/qemu/accel.h | 40 ++---------------------------
> include/system/hvf_int.h | 3 ++-
> include/system/kvm_int.h | 1 +
> accel/accel-common.c | 1 +
> accel/accel-system.c | 1 +
> accel/hvf/hvf-all.c | 1 +
> accel/kvm/kvm-all.c | 1 +
> accel/qtest/qtest.c | 1 +
> accel/tcg/tcg-accel-ops.c | 1 +
> accel/tcg/tcg-all.c | 1 +
> accel/xen/xen-all.c | 1 +
> bsd-user/main.c | 1 +
> gdbstub/system.c | 1 +
> linux-user/main.c | 1 +
> system/memory.c | 1 +
> target/i386/nvmm/nvmm-all.c | 1 +
> target/i386/whpx/whpx-all.c | 1 +
> 19 files changed, 70 insertions(+), 40 deletions(-)
> create mode 100644 include/accel/accel-ops.h
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine()
2025-07-03 17:32 ` [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
@ 2025-07-04 11:33 ` Zhao Liu
0 siblings, 0 replies; 27+ messages in thread
From: Zhao Liu @ 2025-07-04 11:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, 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
On Thu, Jul 03, 2025 at 07:32:36PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:36 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 30/39] accel: Propagate AccelState to
> AccelClass::init_machine()
> X-Mailer: git-send-email 2.49.0
>
> 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-all.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/accel/accel-system.c b/accel/accel-system.c
> index b5b368c6a9c..fb8abe38594 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);
Now we've already set "ms->accelerator", so that we could get @accel
by ms->accelerator.
But considerring the user emulation, where the @ms is NULL, and for
these cases, it needs to bring current_accel() back in patch 32.
Anyway, this solution is also fine for me, so,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
...But there're still more comments/questions about user emulation:
> --- 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);
Not the issue about this patch though,
it seems user emulation doesn't set acc->allowed. At least TCG enabled
is necessary, I guess?
> }
>
> /*
> 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);
Ditto.
> }
>
> /*
Thanks,
Zhao
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h'
2025-07-03 17:32 ` [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h' Philippe Mathieu-Daudé
2025-07-04 8:52 ` Zhao Liu
@ 2025-07-04 14:01 ` Richard Henderson
1 sibling, 0 replies; 27+ messages in thread
From: Richard Henderson @ 2025-07-04 14:01 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Pierrick Bouvier, Alex Bennée,
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/3/25 11:32, Philippe Mathieu-Daudé wrote:
> Unfortunately "system/accel-ops.h" handlers are not only
> system-specific. For example, the cpu_reset_hold() hook
> is part of the vCPU creation, after it is realized.
>
> Mechanical rename to drop 'system' using:
>
> $ sed -i -e s_system/accel-ops.h_accel/accel-cpu-ops.h_g \
> $(git grep -l system/accel-ops.h)
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> include/{system/accel-ops.h => accel/accel-cpu-ops.h} | 8 ++++----
> accel/accel-common.c | 2 +-
> accel/accel-system.c | 2 +-
> accel/hvf/hvf-accel-ops.c | 2 +-
> accel/kvm/kvm-accel-ops.c | 2 +-
> accel/qtest/qtest.c | 2 +-
> accel/tcg/tcg-accel-ops.c | 2 +-
> accel/xen/xen-all.c | 2 +-
> cpu-target.c | 2 +-
> gdbstub/system.c | 2 +-
> system/cpus.c | 2 +-
> target/i386/nvmm/nvmm-accel-ops.c | 2 +-
> target/i386/whpx/whpx-accel-ops.c | 2 +-
> 13 files changed, 16 insertions(+), 16 deletions(-)
> rename include/{system/accel-ops.h => accel/accel-cpu-ops.h} (96%)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h'
2025-07-03 17:32 ` [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h' Philippe Mathieu-Daudé
2025-07-04 9:02 ` Zhao Liu
@ 2025-07-04 14:03 ` Richard Henderson
1 sibling, 0 replies; 27+ messages in thread
From: Richard Henderson @ 2025-07-04 14:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Pierrick Bouvier, Alex Bennée,
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, Peter Xu, David Hildenbrand, Reinoud Zandijk,
Sunil Muthuswamy, kvm, xen-devel
On 7/3/25 11:32, Philippe Mathieu-Daudé wrote:
> Only accelerator implementations (and the common accelator
> code) need to know about AccelClass internals. Move the
> definition out but forward declare AccelState and AccelClass.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> MAINTAINERS | 2 +-
> include/accel/accel-ops.h | 50 +++++++++++++++++++++++++++++++++++++
> include/qemu/accel.h | 40 ++---------------------------
> include/system/hvf_int.h | 3 ++-
> include/system/kvm_int.h | 1 +
> accel/accel-common.c | 1 +
> accel/accel-system.c | 1 +
> accel/hvf/hvf-all.c | 1 +
> accel/kvm/kvm-all.c | 1 +
> accel/qtest/qtest.c | 1 +
> accel/tcg/tcg-accel-ops.c | 1 +
> accel/tcg/tcg-all.c | 1 +
> accel/xen/xen-all.c | 1 +
> bsd-user/main.c | 1 +
> gdbstub/system.c | 1 +
> linux-user/main.c | 1 +
> system/memory.c | 1 +
> target/i386/nvmm/nvmm-all.c | 1 +
> target/i386/whpx/whpx-all.c | 1 +
> 19 files changed, 70 insertions(+), 40 deletions(-)
> create mode 100644 include/accel/accel-ops.h
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2025-07-04 14:03 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250703173248.44995-1-philmd@linaro.org>
2025-07-03 17:32 ` [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
2025-07-04 4:13 ` Xiaoyao Li
2025-07-04 8:24 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
2025-07-04 4:15 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
2025-07-04 5:25 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 13/39] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
2025-07-04 5:36 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
2025-07-04 6:02 ` Xiaoyao Li
2025-07-04 8:21 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
2025-07-04 6:38 ` Xiaoyao Li
2025-07-04 8:27 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
2025-07-04 11:33 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h' Philippe Mathieu-Daudé
2025-07-04 8:52 ` Zhao Liu
2025-07-04 14:01 ` Richard Henderson
2025-07-03 17:32 ` [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h' Philippe Mathieu-Daudé
2025-07-04 9:02 ` Zhao Liu
2025-07-04 14:03 ` Richard Henderson
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).