* [PATCH v6 00/39] accel: Preparatory cleanups for split-accel
@ 2025-07-03 17:32 Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
` (39 more replies)
0 siblings, 40 replies; 112+ 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é
Missing review: 11, 37-39
Since v5:
- Dropped patches with problems
- Moved system/accel-ops.h -> generic accel/ namespace
- Added R-b tags
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é (39):
hw/core/machine: Display CPU model name in 'info cpus' command
system/memory: Restrict eventfd dispatch_write() to emulators
system/runstate: Document qemu_add_vm_change_state_handler()
system/cpus: Assert interrupt handling is done with BQL locked
accel/kvm: Remove kvm_init_cpu_signals() stub
accel/kvm: Reduce kvm_create_vcpu() declaration scope
accel/tcg: Remove 'info opcount' and @x-query-opcount
accel/tcg: Remove profiler leftover
accel/tcg: Factor tcg_dump_flush_info() out
accel/tcg: Factor tcg_dump_stats() out for re-use
accel/tcg: Extract statistic related code to tcg-stats.c
accel: Move supports_guest_debug() declaration to AccelClass
accel: Move cpus_are_resettable() declaration to AccelClass
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/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'
accel: Pass old/new interrupt mask to handle_interrupt() handler
accel: Expose and register generic_handle_interrupt()
accel: Keep reference to AccelOpsClass in AccelClass
accel: Propagate AccelState to AccelClass::init_machine()
accel/kvm: Prefer local AccelState over global MachineState::accel
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: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h'
accel: Extract AccelClass definition to 'accel/accel-ops.h'
MAINTAINERS: Add me as reviewer of overall accelerators section
MAINTAINERS | 4 +-
qapi/machine.json | 21 +-
accel/dummy-cpus.h | 14 +
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.h | 2 +-
.../accel-ops.h => accel/accel-cpu-ops.h} | 34 +-
include/accel/accel-ops.h | 50 +++
include/hw/core/cpu.h | 3 +-
include/qemu/accel.h | 35 +-
include/system/cpus.h | 5 -
include/system/hvf.h | 38 ---
include/system/hvf_int.h | 38 ++-
include/system/hw_accel.h | 21 +-
include/system/kvm.h | 8 -
include/system/kvm_int.h | 1 +
include/system/nvmm.h | 23 +-
include/system/runstate.h | 10 +
include/system/whpx.h | 27 +-
accel/accel-common.c | 4 +-
accel/accel-system.c | 20 +-
accel/dummy-cpus.c | 1 +
accel/hvf/hvf-accel-ops.c | 317 +++---------------
accel/hvf/hvf-all.c | 279 +++++++++++++--
accel/kvm/kvm-accel-ops.c | 10 +-
accel/kvm/kvm-all.c | 39 ++-
accel/qtest/qtest.c | 7 +-
accel/stubs/kvm-stub.c | 9 -
accel/stubs/nvmm-stub.c | 12 +
accel/stubs/whpx-stub.c | 12 +
accel/tcg/monitor.c | 210 +-----------
accel/tcg/tcg-accel-ops-icount.c | 8 +-
accel/tcg/tcg-accel-ops.c | 19 +-
accel/tcg/tcg-all.c | 13 +-
accel/tcg/tcg-stats.c | 206 ++++++++++++
accel/xen/xen-all.c | 9 +-
bsd-user/main.c | 3 +-
cpu-target.c | 2 +-
gdbstub/system.c | 11 +-
hw/core/machine-hmp-cmds.c | 3 +-
hw/core/machine-qmp-cmds.c | 1 +
linux-user/main.c | 3 +-
system/cpus.c | 28 +-
system/memory.c | 12 +-
target/arm/hvf/hvf.c | 6 +-
target/i386/hvf/hvf.c | 6 +-
target/i386/hvf/x86hvf.c | 2 +-
target/i386/nvmm/nvmm-accel-ops.c | 3 +-
target/i386/nvmm/nvmm-all.c | 32 +-
target/i386/whpx/whpx-accel-ops.c | 3 +-
target/i386/whpx/whpx-all.c | 33 +-
tests/qtest/qmp-cmd-test.c | 1 -
accel/stubs/meson.build | 2 +
accel/tcg/meson.build | 1 +
hmp-commands-info.hx | 14 -
56 files changed, 876 insertions(+), 804 deletions(-)
create mode 100644 accel/dummy-cpus.h
rename include/{system/accel-ops.h => accel/accel-cpu-ops.h} (70%)
create mode 100644 include/accel/accel-ops.h
create mode 100644 accel/stubs/nvmm-stub.c
create mode 100644 accel/stubs/whpx-stub.c
create mode 100644 accel/tcg/tcg-stats.c
--
2.49.0
^ permalink raw reply [flat|nested] 112+ messages in thread
* [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 3:10 ` Xiaoyao Li
2025-07-04 4:59 ` Markus Armbruster
2025-07-03 17:32 ` [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
` (38 subsequent siblings)
39 siblings, 2 replies; 112+ 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é, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, 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>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Tested-by: Zhao Liu <zhao1.liu@intel.com>
---
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] 112+ messages in thread
* [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 3:32 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
` (37 subsequent siblings)
39 siblings, 1 reply; 112+ 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
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 76b44b8220f..4f713889a8e 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] 112+ messages in thread
* [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 3:40 ` Xiaoyao Li
2025-07-04 9:31 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
` (36 subsequent siblings)
39 siblings, 2 replies; 112+ 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é
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/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] 112+ messages in thread
* [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 4:07 ` Xiaoyao Li
2025-07-04 9:32 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
` (35 subsequent siblings)
39 siblings, 2 replies; 112+ 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é
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] 112+ messages in thread
* [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 4:13 ` Xiaoyao Li
2025-07-04 11:49 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
` (34 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (4 preceding siblings ...)
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-04 9:33 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount Philippe Mathieu-Daudé
` (33 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (5 preceding siblings ...)
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 4:23 ` Xiaoyao Li
` (2 more replies)
2025-07-03 17:32 ` [PATCH v6 08/39] accel/tcg: Remove profiler leftover Philippe Mathieu-Daudé
` (32 subsequent siblings)
39 siblings, 3 replies; 112+ 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é,
Dr. David Alan Gilbert, Eduardo Habkost, Marcel Apfelbaum,
Yanan Wang, Eric Blake, Markus Armbruster, Fabiano Rosas,
Laurent Vivier
Since commit 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER",
released with QEMU v8.1.0) we get pointless output:
(qemu) info opcount
[TCG profiler not compiled]
Remove that unstable and unuseful command.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
qapi/machine.json | 18 ------------------
accel/tcg/monitor.c | 21 ---------------------
tests/qtest/qmp-cmd-test.c | 1 -
hmp-commands-info.hx | 14 --------------
4 files changed, 54 deletions(-)
diff --git a/qapi/machine.json b/qapi/machine.json
index d5bbb5e367e..acf6610efa5 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1764,24 +1764,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/accel/tcg/monitor.c b/accel/tcg/monitor.c
index 1c182b6bfb5..7c686226b21 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -215,30 +215,9 @@ HumanReadableText *qmp_x_query_jit(Error **errp)
return human_readable_text_from_str(buf);
}
-static void tcg_dump_op_count(GString *buf)
-{
- g_string_append_printf(buf, "[TCG profiler not compiled]\n");
-}
-
-HumanReadableText *qmp_x_query_opcount(Error **errp)
-{
- g_autoptr(GString) buf = g_string_new("");
-
- if (!tcg_enabled()) {
- error_setg(errp,
- "Opcode count information is only available with accel=tcg");
- return NULL;
- }
-
- tcg_dump_op_count(buf);
-
- return human_readable_text_from_str(buf);
-}
-
static void hmp_tcg_register(void)
{
monitor_register_hmp_info_hrt("jit", qmp_x_query_jit);
- monitor_register_hmp_info_hrt("opcount", qmp_x_query_opcount);
}
type_init(hmp_tcg_register);
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index 040d042810b..cf718761861 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -51,7 +51,6 @@ static int query_error_class(const char *cmd)
{ "x-query-usb", ERROR_CLASS_GENERIC_ERROR },
/* Only valid with accel=tcg */
{ "x-query-jit", ERROR_CLASS_GENERIC_ERROR },
- { "x-query-opcount", ERROR_CLASS_GENERIC_ERROR },
{ "xen-event-list", ERROR_CLASS_GENERIC_ERROR },
{ NULL, -1 }
};
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 639a450ee51..d7979222752 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -256,20 +256,6 @@ SRST
Show dynamic compiler info.
ERST
-#if defined(CONFIG_TCG)
- {
- .name = "opcount",
- .args_type = "",
- .params = "",
- .help = "show dynamic compiler opcode counters",
- },
-#endif
-
-SRST
- ``info opcount``
- Show dynamic compiler opcode counters
-ERST
-
{
.name = "sync-profile",
.args_type = "mean:-m,no_coalesce:-n,max:i?",
--
2.49.0
^ permalink raw reply related [flat|nested] 112+ messages in thread
* [PATCH v6 08/39] accel/tcg: Remove profiler leftover
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 4:24 ` Xiaoyao Li
2025-07-04 9:37 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
` (31 subsequent siblings)
39 siblings, 2 replies; 112+ 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é
TCG profiler was removed in commit 1b65b4f54c7.
Fixes: 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/monitor.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index 7c686226b21..344ec500473 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -141,11 +141,6 @@ static void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide)
*pelide = elide;
}
-static void tcg_dump_info(GString *buf)
-{
- g_string_append_printf(buf, "[TCG profiler not compiled]\n");
-}
-
static void dump_exec_info(GString *buf)
{
struct tb_tree_stats tst = {};
@@ -196,7 +191,6 @@ static void dump_exec_info(GString *buf)
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_info(buf);
}
HumanReadableText *qmp_x_query_jit(Error **errp)
--
2.49.0
^ permalink raw reply related [flat|nested] 112+ messages in thread
* [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 08/39] accel/tcg: Remove profiler leftover Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 4:27 ` Xiaoyao Li
2025-07-04 9:38 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use Philippe Mathieu-Daudé
` (30 subsequent siblings)
39 siblings, 2 replies; 112+ 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é
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/monitor.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index 344ec500473..6d9cc11d94c 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -141,11 +141,26 @@ static void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide)
*pelide = elide;
}
+static 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;
@@ -182,15 +197,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);
}
HumanReadableText *qmp_x_query_jit(Error **errp)
--
2.49.0
^ permalink raw reply related [flat|nested] 112+ messages in thread
* [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 9:39 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 11/39] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
` (29 subsequent siblings)
39 siblings, 1 reply; 112+ 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é
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 | 11 ++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index 1dbc45dd955..77a3a0684a5 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_stats(GString *buf);
+
#endif
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index 6d9cc11d94c..e7ed7281a4b 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -200,6 +200,13 @@ static void dump_exec_info(GString *buf)
tcg_dump_flush_info(buf);
}
+void tcg_dump_stats(GString *buf)
+{
+ dump_accel_info(buf);
+ dump_exec_info(buf);
+ dump_drift_info(buf);
+}
+
HumanReadableText *qmp_x_query_jit(Error **errp)
{
g_autoptr(GString) buf = g_string_new("");
@@ -209,9 +216,7 @@ HumanReadableText *qmp_x_query_jit(Error **errp)
return NULL;
}
- dump_accel_info(buf);
- dump_exec_info(buf);
- dump_drift_info(buf);
+ tcg_dump_stats(buf);
return human_readable_text_from_str(buf);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 112+ messages in thread
* [PATCH v6 11/39] accel/tcg: Extract statistic related code to tcg-stats.c
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 8:44 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
` (28 subsequent siblings)
39 siblings, 1 reply; 112+ 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é
Statistic code is not specific to system emulation (except
cross-page checks) and can be used to analyze user-mode binaries.
Extract statistic related code to its own file: tcg-stats.c,
keeping the original LGPL-2.1-or-later license tag.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/monitor.c | 193 ---------------------------------------
accel/tcg/tcg-stats.c | 206 ++++++++++++++++++++++++++++++++++++++++++
accel/tcg/meson.build | 1 +
3 files changed, 207 insertions(+), 193 deletions(-)
create mode 100644 accel/tcg/tcg-stats.c
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index e7ed7281a4b..adb9de5a1c6 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -7,205 +7,12 @@
*/
#include "qemu/osdep.h"
-#include "qemu/accel.h"
-#include "qemu/qht.h"
#include "qapi/error.h"
#include "qapi/type-helpers.h"
#include "qapi/qapi-commands-machine.h"
#include "monitor/monitor.h"
-#include "system/cpu-timers.h"
-#include "exec/icount.h"
#include "system/tcg.h"
-#include "tcg/tcg.h"
#include "internal-common.h"
-#include "tb-context.h"
-
-
-static void dump_drift_info(GString *buf)
-{
- if (!icount_enabled()) {
- return;
- }
-
- g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
- (cpu_get_clock() - icount_get()) / SCALE_MS);
- if (icount_align_option) {
- g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
- -max_delay / SCALE_MS);
- g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
- max_advance / SCALE_MS);
- } else {
- g_string_append_printf(buf, "Max guest delay NA\n");
- g_string_append_printf(buf, "Max guest advance NA\n");
- }
-}
-
-static void dump_accel_info(GString *buf)
-{
- AccelState *accel = current_accel();
- bool one_insn_per_tb = object_property_get_bool(OBJECT(accel),
- "one-insn-per-tb",
- &error_fatal);
-
- g_string_append_printf(buf, "Accelerator settings:\n");
- g_string_append_printf(buf, "one-insn-per-tb: %s\n\n",
- one_insn_per_tb ? "on" : "off");
-}
-
-static void print_qht_statistics(struct qht_stats hst, GString *buf)
-{
- uint32_t hgram_opts;
- size_t hgram_bins;
- char *hgram;
-
- if (!hst.head_buckets) {
- return;
- }
- g_string_append_printf(buf, "TB hash buckets %zu/%zu "
- "(%0.2f%% head buckets used)\n",
- hst.used_head_buckets, hst.head_buckets,
- (double)hst.used_head_buckets /
- hst.head_buckets * 100);
-
- hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
- hgram_opts |= QDIST_PR_100X | QDIST_PR_PERCENT;
- if (qdist_xmax(&hst.occupancy) - qdist_xmin(&hst.occupancy) == 1) {
- hgram_opts |= QDIST_PR_NODECIMAL;
- }
- hgram = qdist_pr(&hst.occupancy, 10, hgram_opts);
- g_string_append_printf(buf, "TB hash occupancy %0.2f%% avg chain occ. "
- "Histogram: %s\n",
- qdist_avg(&hst.occupancy) * 100, hgram);
- g_free(hgram);
-
- hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
- hgram_bins = qdist_xmax(&hst.chain) - qdist_xmin(&hst.chain);
- if (hgram_bins > 10) {
- hgram_bins = 10;
- } else {
- hgram_bins = 0;
- hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE;
- }
- hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts);
- g_string_append_printf(buf, "TB hash avg chain %0.3f buckets. "
- "Histogram: %s\n",
- qdist_avg(&hst.chain), hgram);
- g_free(hgram);
-}
-
-struct tb_tree_stats {
- size_t nb_tbs;
- size_t host_size;
- size_t target_size;
- size_t max_target_size;
- size_t direct_jmp_count;
- size_t direct_jmp2_count;
- size_t cross_page;
-};
-
-static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data)
-{
- const TranslationBlock *tb = value;
- struct tb_tree_stats *tst = data;
-
- tst->nb_tbs++;
- tst->host_size += tb->tc.size;
- tst->target_size += tb->size;
- if (tb->size > tst->max_target_size) {
- tst->max_target_size = tb->size;
- }
- if (tb->page_addr[1] != -1) {
- tst->cross_page++;
- }
- if (tb->jmp_reset_offset[0] != TB_JMP_OFFSET_INVALID) {
- tst->direct_jmp_count++;
- if (tb->jmp_reset_offset[1] != TB_JMP_OFFSET_INVALID) {
- tst->direct_jmp2_count++;
- }
- }
- return false;
-}
-
-static void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide)
-{
- CPUState *cpu;
- size_t full = 0, part = 0, elide = 0;
-
- CPU_FOREACH(cpu) {
- full += qatomic_read(&cpu->neg.tlb.c.full_flush_count);
- part += qatomic_read(&cpu->neg.tlb.c.part_flush_count);
- elide += qatomic_read(&cpu->neg.tlb.c.elide_flush_count);
- }
- *pfull = full;
- *ppart = part;
- *pelide = elide;
-}
-
-static 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;
-
- tcg_tb_foreach(tb_tree_stats_iter, &tst);
- nb_tbs = tst.nb_tbs;
- /* XXX: avoid using doubles ? */
- g_string_append_printf(buf, "Translation buffer state:\n");
- /*
- * Report total code size including the padding and TB structs;
- * otherwise users might think "-accel tcg,tb-size" is not honoured.
- * For avg host size we use the precise numbers from tb_tree_stats though.
- */
- g_string_append_printf(buf, "gen code size %zu/%zu\n",
- tcg_code_size(), tcg_code_capacity());
- g_string_append_printf(buf, "TB count %zu\n", nb_tbs);
- g_string_append_printf(buf, "TB avg target size %zu max=%zu bytes\n",
- nb_tbs ? tst.target_size / nb_tbs : 0,
- tst.max_target_size);
- g_string_append_printf(buf, "TB avg host size %zu bytes "
- "(expansion ratio: %0.1f)\n",
- nb_tbs ? tst.host_size / nb_tbs : 0,
- tst.target_size ?
- (double)tst.host_size / tst.target_size : 0);
- g_string_append_printf(buf, "cross page TB count %zu (%zu%%)\n",
- tst.cross_page,
- nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0);
- g_string_append_printf(buf, "direct jump count %zu (%zu%%) "
- "(2 jumps=%zu %zu%%)\n",
- tst.direct_jmp_count,
- nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0,
- tst.direct_jmp2_count,
- nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0);
-
- qht_statistics_init(&tb_ctx.htable, &hst);
- print_qht_statistics(hst, buf);
- qht_statistics_destroy(&hst);
-
- g_string_append_printf(buf, "\nStatistics:\n");
- tcg_dump_flush_info(buf);
-}
-
-void tcg_dump_stats(GString *buf)
-{
- dump_accel_info(buf);
- dump_exec_info(buf);
- dump_drift_info(buf);
-}
HumanReadableText *qmp_x_query_jit(Error **errp)
{
diff --git a/accel/tcg/tcg-stats.c b/accel/tcg/tcg-stats.c
new file mode 100644
index 00000000000..284ac435bdb
--- /dev/null
+++ b/accel/tcg/tcg-stats.c
@@ -0,0 +1,206 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * QEMU TCG statistics
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/accel.h"
+#include "qemu/qht.h"
+#include "qapi/error.h"
+#include "system/cpu-timers.h"
+#include "exec/icount.h"
+#include "hw/core/cpu.h"
+#include "tcg/tcg.h"
+#include "internal-common.h"
+#include "tb-context.h"
+
+static void dump_drift_info(GString *buf)
+{
+ if (!icount_enabled()) {
+ return;
+ }
+
+ g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
+ (cpu_get_clock() - icount_get()) / SCALE_MS);
+ if (icount_align_option) {
+ g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
+ -max_delay / SCALE_MS);
+ g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
+ max_advance / SCALE_MS);
+ } else {
+ g_string_append_printf(buf, "Max guest delay NA\n");
+ g_string_append_printf(buf, "Max guest advance NA\n");
+ }
+}
+
+static void dump_accel_info(GString *buf)
+{
+ AccelState *accel = current_accel();
+ bool one_insn_per_tb = object_property_get_bool(OBJECT(accel),
+ "one-insn-per-tb",
+ &error_fatal);
+
+ g_string_append_printf(buf, "Accelerator settings:\n");
+ g_string_append_printf(buf, "one-insn-per-tb: %s\n\n",
+ one_insn_per_tb ? "on" : "off");
+}
+
+static void print_qht_statistics(struct qht_stats hst, GString *buf)
+{
+ uint32_t hgram_opts;
+ size_t hgram_bins;
+ char *hgram;
+
+ if (!hst.head_buckets) {
+ return;
+ }
+ g_string_append_printf(buf, "TB hash buckets %zu/%zu "
+ "(%0.2f%% head buckets used)\n",
+ hst.used_head_buckets, hst.head_buckets,
+ (double)hst.used_head_buckets /
+ hst.head_buckets * 100);
+
+ hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
+ hgram_opts |= QDIST_PR_100X | QDIST_PR_PERCENT;
+ if (qdist_xmax(&hst.occupancy) - qdist_xmin(&hst.occupancy) == 1) {
+ hgram_opts |= QDIST_PR_NODECIMAL;
+ }
+ hgram = qdist_pr(&hst.occupancy, 10, hgram_opts);
+ g_string_append_printf(buf, "TB hash occupancy %0.2f%% avg chain occ. "
+ "Histogram: %s\n",
+ qdist_avg(&hst.occupancy) * 100, hgram);
+ g_free(hgram);
+
+ hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
+ hgram_bins = qdist_xmax(&hst.chain) - qdist_xmin(&hst.chain);
+ if (hgram_bins > 10) {
+ hgram_bins = 10;
+ } else {
+ hgram_bins = 0;
+ hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE;
+ }
+ hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts);
+ g_string_append_printf(buf, "TB hash avg chain %0.3f buckets. "
+ "Histogram: %s\n",
+ qdist_avg(&hst.chain), hgram);
+ g_free(hgram);
+}
+
+struct tb_tree_stats {
+ size_t nb_tbs;
+ size_t host_size;
+ size_t target_size;
+ size_t max_target_size;
+ size_t direct_jmp_count;
+ size_t direct_jmp2_count;
+ size_t cross_page;
+};
+
+static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data)
+{
+ const TranslationBlock *tb = value;
+ struct tb_tree_stats *tst = data;
+
+ tst->nb_tbs++;
+ tst->host_size += tb->tc.size;
+ tst->target_size += tb->size;
+ if (tb->size > tst->max_target_size) {
+ tst->max_target_size = tb->size;
+ }
+#ifndef CONFIG_USER_ONLY
+ if (tb->page_addr[1] != -1) {
+ tst->cross_page++;
+ }
+#endif
+ if (tb->jmp_reset_offset[0] != TB_JMP_OFFSET_INVALID) {
+ tst->direct_jmp_count++;
+ if (tb->jmp_reset_offset[1] != TB_JMP_OFFSET_INVALID) {
+ tst->direct_jmp2_count++;
+ }
+ }
+ return false;
+}
+
+static void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide)
+{
+ CPUState *cpu;
+ size_t full = 0, part = 0, elide = 0;
+
+ CPU_FOREACH(cpu) {
+ full += qatomic_read(&cpu->neg.tlb.c.full_flush_count);
+ part += qatomic_read(&cpu->neg.tlb.c.part_flush_count);
+ elide += qatomic_read(&cpu->neg.tlb.c.elide_flush_count);
+ }
+ *pfull = full;
+ *ppart = part;
+ *pelide = elide;
+}
+
+static 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;
+
+ tcg_tb_foreach(tb_tree_stats_iter, &tst);
+ nb_tbs = tst.nb_tbs;
+ /* XXX: avoid using doubles ? */
+ g_string_append_printf(buf, "Translation buffer state:\n");
+ /*
+ * Report total code size including the padding and TB structs;
+ * otherwise users might think "-accel tcg,tb-size" is not honoured.
+ * For avg host size we use the precise numbers from tb_tree_stats though.
+ */
+ g_string_append_printf(buf, "gen code size %zu/%zu\n",
+ tcg_code_size(), tcg_code_capacity());
+ g_string_append_printf(buf, "TB count %zu\n", nb_tbs);
+ g_string_append_printf(buf, "TB avg target size %zu max=%zu bytes\n",
+ nb_tbs ? tst.target_size / nb_tbs : 0,
+ tst.max_target_size);
+ g_string_append_printf(buf, "TB avg host size %zu bytes "
+ "(expansion ratio: %0.1f)\n",
+ nb_tbs ? tst.host_size / nb_tbs : 0,
+ tst.target_size ?
+ (double)tst.host_size / tst.target_size : 0);
+ g_string_append_printf(buf, "cross page TB count %zu (%zu%%)\n",
+ tst.cross_page,
+ nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0);
+ g_string_append_printf(buf, "direct jump count %zu (%zu%%) "
+ "(2 jumps=%zu %zu%%)\n",
+ tst.direct_jmp_count,
+ nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0,
+ tst.direct_jmp2_count,
+ nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0);
+
+ qht_statistics_init(&tb_ctx.htable, &hst);
+ print_qht_statistics(hst, buf);
+ qht_statistics_destroy(&hst);
+
+ g_string_append_printf(buf, "\nStatistics:\n");
+ tcg_dump_flush_info(buf);
+}
+
+void tcg_dump_stats(GString *buf)
+{
+ dump_accel_info(buf);
+ dump_exec_info(buf);
+ dump_drift_info(buf);
+}
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 575e92bb9e8..002aa8f4588 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -11,6 +11,7 @@ tcg_ss.add(files(
'tcg-runtime-gvec.c',
'tb-maint.c',
'tcg-all.c',
+ 'tcg-stats.c',
'translate-all.c',
'translator.c',
))
--
2.49.0
^ permalink raw reply related [flat|nested] 112+ messages in thread
* [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 11/39] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 5:25 ` Xiaoyao Li
2025-07-04 9:42 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 13/39] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
` (27 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 13/39] accel: Move cpus_are_resettable() declaration to AccelClass
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (11 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-04 9:44 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 14/39] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
` (26 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 14/39] accel/hvf: Restrict internal declarations
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (12 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 5:39 ` Xiaoyao Li
2025-07-04 9:45 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
` (25 subsequent siblings)
39 siblings, 2 replies; 112+ 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
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 | 38 --------------------------------------
include/system/hvf_int.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/include/system/hvf.h b/include/system/hvf.h
index a9fd13d9bba..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,38 +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);
-#endif /* COMPILING_PER_TARGET */
-
#endif
diff --git a/include/system/hvf_int.h b/include/system/hvf_int.h
index d774e58df91..dcf06f53d97 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,36 @@ 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);
+
#endif
--
2.49.0
^ permalink raw reply related [flat|nested] 112+ messages in thread
* [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 14/39] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 9:46 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 16/39] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
` (24 subsequent siblings)
39 siblings, 1 reply; 112+ 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
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 | 30 ++++++++++++++++++++++++++++++
accel/hvf/hvf-all.c | 28 ----------------------------
2 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index aed791a3f3e..646cd240238 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -50,9 +50,11 @@
#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"
+#include "hw/core/cpu.h"
#include "system/accel-ops.h"
#include "system/cpus.h"
#include "system/hvf.h"
@@ -483,6 +485,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..1c72c43ddb4 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -41,31 +41,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] 112+ messages in thread
* [PATCH v6 16/39] accel/hvf: Move generic method declarations to hvf-all.c
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 9:50 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 17/39] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
` (23 subsequent siblings)
39 siblings, 1 reply; 112+ 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
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 | 274 +-------------------------------------
accel/hvf/hvf-all.c | 268 +++++++++++++++++++++++++++++++++++++
2 files changed, 272 insertions(+), 270 deletions(-)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 646cd240238..6b1a256deb5 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -48,20 +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 "hw/core/cpu.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"
HVFState *hvf_state;
@@ -81,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) {
@@ -244,148 +114,10 @@ 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(MachineState *ms)
-{
- int x;
- hv_return_t ret;
- HVFState *s;
- 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);
- 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;
- 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(void)
-{
- 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);
-
static void hvf_vcpu_destroy(CPUState *cpu)
{
hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd);
@@ -639,8 +371,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 1c72c43ddb4..897a02eebe2 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -10,9 +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)
{
@@ -41,3 +56,256 @@ 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(MachineState *ms)
+{
+ int x;
+ hv_return_t ret;
+ HVFState *s;
+ 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);
+ 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;
+ 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 int hvf_gdbstub_sstep_flags(void)
+{
+ 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] 112+ messages in thread
* [PATCH v6 17/39] cpus: Document CPUState::vcpu_dirty field
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 16/39] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 5:52 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
` (22 subsequent siblings)
39 siblings, 1 reply; 112+ 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é, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
---
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 162a56a5daa..5eaf41a566f 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -442,6 +442,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.
@@ -538,7 +539,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;
@@ -554,6 +554,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] 112+ messages in thread
* [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 17/39] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 5:54 ` Xiaoyao Li
2025-07-04 10:07 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 19/39] accel/nvmm: " Philippe Mathieu-Daudé
` (21 subsequent siblings)
39 siblings, 2 replies; 112+ 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, 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 dcf06f53d97..ecc49a309cf 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 6b1a256deb5..2944e350ca9 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)
@@ -150,8 +150,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 995a6a74b06..ac0d6ef8187 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 b25bff0df41..9b8acd5a946 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -733,9 +733,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] 112+ messages in thread
* [PATCH v6 19/39] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 5:55 ` Xiaoyao Li
2025-07-04 10:08 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 20/39] accel/whpx: " Philippe Mathieu-Daudé
` (20 subsequent siblings)
39 siblings, 2 replies; 112+ 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é, 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 f1c6120ccf1..aea61a6fd2a 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] 112+ messages in thread
* [PATCH v6 20/39] accel/whpx: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 19/39] accel/nvmm: " Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 5:55 ` Xiaoyao Li
2025-07-04 10:11 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
` (19 subsequent siblings)
39 siblings, 2 replies; 112+ 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é, 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 cf6d3e4cdd4..5001afad3a7 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] 112+ messages in thread
* [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 20/39] accel/whpx: " Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 6:02 ` Xiaoyao Li
2025-07-04 10:15 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 22/39] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
` (18 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 22/39] accel/system: Document cpu_synchronize_state()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (20 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 10:17 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 23/39] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
` (17 subsequent siblings)
39 siblings, 1 reply; 112+ 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é
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 f19245d0a0e..6eed1a3cfc8 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -41,6 +41,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);
void (*synchronize_pre_resume)(bool step_pending);
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] 112+ messages in thread
* [PATCH v6 23/39] accel/system: Document cpu_synchronize_state_post_init/reset()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 22/39] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 10:19 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
` (16 subsequent siblings)
39 siblings, 1 reply; 112+ 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é
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 6eed1a3cfc8..2075691331c 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -39,6 +39,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] 112+ messages in thread
* [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 23/39] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 8:32 ` Philippe Mathieu-Daudé
2025-07-04 10:26 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
` (15 subsequent siblings)
39 siblings, 2 replies; 112+ 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é, 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 | 8 +-------
accel/stubs/meson.build | 1 +
4 files changed, 26 insertions(+), 18 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 aea61a6fd2a..2df49d7eeb4 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -46,7 +46,7 @@ struct qemu_machine {
/* -------------------------------------------------------------------------- */
-static bool nvmm_allowed;
+bool nvmm_allowed;
static struct qemu_machine qemu_mach;
static struct nvmm_machine *
@@ -1192,12 +1192,6 @@ nvmm_accel_init(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] 112+ messages in thread
* [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() to common code
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (23 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 10:36 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
` (14 subsequent siblings)
39 siblings, 1 reply; 112+ 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é, 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 | 7 +------
accel/stubs/meson.build | 1 +
4 files changed, 28 insertions(+), 19 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 5001afad3a7..94fd5fc7849 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -242,7 +242,7 @@ struct AccelCPUState {
WHV_RUN_VP_EXIT_CONTEXT exit_ctx;
};
-static bool whpx_allowed;
+bool whpx_allowed;
static bool whp_dispatch_initialized;
static HMODULE hWinHvPlatform, hWinHvEmulation;
static uint32_t max_vcpu_index;
@@ -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] 112+ messages in thread
* [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (24 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 6:16 ` Xiaoyao Li
2025-07-04 10:44 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
` (13 subsequent siblings)
39 siblings, 2 replies; 112+ 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é, 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>
---
MAINTAINERS | 1 +
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 +
6 files changed, 18 insertions(+), 5 deletions(-)
create mode 100644 accel/dummy-cpus.h
diff --git a/MAINTAINERS b/MAINTAINERS
index b1cbfe115bc..37d02b2313c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -503,6 +503,7 @@ F: include/system/accel-*.h
F: include/system/cpus.h
F: include/accel/accel-cpu*.h
F: accel/accel-*.?
+F: accel/dummy-cpus.?
F: accel/Makefile.objs
F: accel/stubs/Makefile.objs
F: cpu-common.c
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 92bed9264ce..612cede160b 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 de52a8f882a..c150dd43cab 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] 112+ messages in thread
* [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (25 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 6:32 ` Xiaoyao Li
2025-07-04 10:59 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
` (12 subsequent siblings)
39 siblings, 2 replies; 112+ 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é
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 6feeb3f3e9b..6e7c2aae5a8 100644
--- a/accel/tcg/tcg-accel-ops.h
+++ b/accel/tcg/tcg-accel-ops.h
@@ -16,7 +16,7 @@
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 2075691331c..d84eaa376c2 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -61,7 +61,7 @@ struct AccelOpsClass {
void (*synchronize_pre_loadvm)(CPUState *cpu);
void (*synchronize_pre_resume)(bool step_pending);
- void (*handle_interrupt)(CPUState *cpu, int mask);
+ void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask);
/**
* @get_virtual_clock: fetch virtual clock
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 f579685a611..eb16a6bf6db 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -91,10 +91,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 4fb764ac880..13535a74e6f 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] 112+ messages in thread
* [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (26 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler 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 29/39] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
` (11 subsequent siblings)
39 siblings, 1 reply; 112+ 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] 112+ messages in thread
* [PATCH v6 29/39] accel: Keep reference to AccelOpsClass in AccelClass
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (27 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:01 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
` (10 subsequent siblings)
39 siblings, 1 reply; 112+ 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é
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 f987d16baaa..197badcb705 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 95a0f402cde..17c80887016 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);
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 07b75dae797..b5b368c6a9c 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -95,8 +95,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 eb16a6bf6db..bc809ad5640 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -189,8 +189,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] 112+ messages in thread
* [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (28 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 29/39] accel: Keep reference to AccelOpsClass in AccelClass 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é
` (9 subsequent siblings)
39 siblings, 1 reply; 112+ 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] 112+ messages in thread
* [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (29 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-04 11:33 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
` (8 subsequent siblings)
39 siblings, 1 reply; 112+ 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] 112+ messages in thread
* [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global current_accel()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (30 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-04 11:34 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
` (7 subsequent siblings)
39 siblings, 1 reply; 112+ 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é
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 7ae7d552d9e..969c50c87ea 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] 112+ messages in thread
* [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (31 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 11:35 ` Zhao Liu
2025-07-04 11:46 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
` (6 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (32 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-04 11:37 ` Zhao Liu
2025-07-04 11:46 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 35/39] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
` (5 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 35/39] accel: Remove unused MachineState argument of AccelClass::setup_post()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (33 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-04 11:38 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
` (4 subsequent siblings)
39 siblings, 1 reply; 112+ 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é, 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 44189b77daa..19ccc5ef6a1 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);
bool (*cpus_are_resettable)(AccelState *as);
diff --git a/accel/accel-system.c b/accel/accel-system.c
index fb8abe38594..637e2390f35 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 8279746f115..bd0ff64befc 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -64,7 +64,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] 112+ messages in thread
* [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags()
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (34 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 35/39] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-04 11:42 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h' Philippe Mathieu-Daudé
` (3 subsequent siblings)
39 siblings, 1 reply; 112+ 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] 112+ messages in thread
* [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h'
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (35 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é
` (2 subsequent siblings)
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h'
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (36 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
2025-07-03 17:32 ` [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section Philippe Mathieu-Daudé
2025-07-04 8:50 ` [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
39 siblings, 2 replies; 112+ 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] 112+ messages in thread
* [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (37 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h' Philippe Mathieu-Daudé
@ 2025-07-03 17:32 ` Philippe Mathieu-Daudé
2025-07-03 22:42 ` Philippe Mathieu-Daudé
2025-07-04 3:23 ` Richard Henderson
2025-07-04 8:50 ` [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
39 siblings, 2 replies; 112+ 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é
I'd like to be informed of overall changes of accelerators.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index e3e08d4607f..a8bf3f9ccfa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -495,6 +495,7 @@ Guest CPU Cores (other accelerators)
Overall
M: Richard Henderson <richard.henderson@linaro.org>
R: Paolo Bonzini <pbonzini@redhat.com>
+M: Philippe Mathieu-Daudé <philmd@linaro.org>
S: Maintained
F: include/exec/cpu*.h
F: include/exec/target_long.h
--
2.49.0
^ permalink raw reply related [flat|nested] 112+ messages in thread
* Re: [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section
2025-07-03 17:32 ` [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section Philippe Mathieu-Daudé
@ 2025-07-03 22:42 ` Philippe Mathieu-Daudé
2025-07-04 3:23 ` Richard Henderson
1 sibling, 0 replies; 112+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-03 22:42 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 3/7/25 19:32, Philippe Mathieu-Daudé wrote:
> I'd like to be informed of overall changes of accelerators.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> MAINTAINERS | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e3e08d4607f..a8bf3f9ccfa 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -495,6 +495,7 @@ Guest CPU Cores (other accelerators)
> Overall
> M: Richard Henderson <richard.henderson@linaro.org>
> R: Paolo Bonzini <pbonzini@redhat.com>
> +M: Philippe Mathieu-Daudé <philmd@linaro.org>
Bad copy/paste, I meant s/M/R/ :)
> S: Maintained
> F: include/exec/cpu*.h
> F: include/exec/target_long.h
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command
2025-07-03 17:32 ` [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
@ 2025-07-04 3:10 ` Xiaoyao Li
2025-07-04 4:59 ` Markus Armbruster
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 3:10 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Eduardo Habkost, Marcel Apfelbaum, Yanan Wang,
Eric Blake, Markus Armbruster
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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)
wow, it's really useful to the architectures can run with multiple CPU
cores.
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> Tested-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> 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;
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section
2025-07-03 17:32 ` [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section Philippe Mathieu-Daudé
2025-07-03 22:42 ` Philippe Mathieu-Daudé
@ 2025-07-04 3:23 ` Richard Henderson
1 sibling, 0 replies; 112+ messages in thread
From: Richard Henderson @ 2025-07-04 3:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Pierrick Bouvier, Alex Bennée
On 7/3/25 11:32, Philippe Mathieu-Daudé wrote:
> I'd like to be informed of overall changes of accelerators.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> MAINTAINERS | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e3e08d4607f..a8bf3f9ccfa 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -495,6 +495,7 @@ Guest CPU Cores (other accelerators)
> Overall
> M: Richard Henderson <richard.henderson@linaro.org>
> R: Paolo Bonzini <pbonzini@redhat.com>
> +M: Philippe Mathieu-Daudé <philmd@linaro.org>
> S: Maintained
> F: include/exec/cpu*.h
> F: include/exec/target_long.h
With R:,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators
2025-07-03 17:32 ` [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
@ 2025-07-04 3:32 ` Xiaoyao Li
2025-07-04 11:34 ` Alex Bennée
0 siblings, 1 reply; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 3:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Peter Xu, David Hildenbrand
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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 76b44b8220f..4f713889a8e 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()) &&
The FIXME provides two options:
1. change to "tcg_enabled() || qtest_enabled()"
2. remove !kvm_enabled()
And as the FIXME said, it's not clear why under KVM the write would be
processed directly. Now, the question becomes why under hardware
accelerator is used the write would be processed directly instead of
going through eventfd. I think it needs to answer this question when we
do such change, and it's better to put the answer as the comment in the
code.
> memory_region_dispatch_write_eventfds(mr, addr, data, size, attrs)) {
> return MEMTX_OK;
> }
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler()
2025-07-03 17:32 ` [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
@ 2025-07-04 3:40 ` Xiaoyao Li
2025-07-15 9:02 ` Alex Bennée
2025-07-04 9:31 ` Zhao Liu
1 sibling, 1 reply; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 3:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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/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()
> + */
qemu_add_vm_change_state_handler_prio() and
qemu_add_vm_change_state_handler_prio_full() put the document in the
implementation in system/runstate.c.
Please make them consistent.
> VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
> void *opaque);
> VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked
2025-07-03 17:32 ` [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
@ 2025-07-04 4:07 ` Xiaoyao Li
2025-07-04 9:32 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 4:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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());
The best result is it doesn't break any thing. But it can surely help
catch the case without bql locked and get the case fixed them.
So
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> if (cpus_accel->handle_interrupt) {
> cpus_accel->handle_interrupt(cpu, mask);
> } else {
^ permalink raw reply [flat|nested] 112+ 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é
2025-07-04 11:49 ` Zhao Liu
1 sibling, 1 reply; 112+ 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] 112+ 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
2025-07-04 9:33 ` Zhao Liu
1 sibling, 0 replies; 112+ 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] 112+ messages in thread
* Re: [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount
2025-07-03 17:32 ` [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount Philippe Mathieu-Daudé
@ 2025-07-04 4:23 ` Xiaoyao Li
2025-07-04 4:50 ` Markus Armbruster
2025-07-04 9:36 ` Zhao Liu
2 siblings, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 4:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Dr. David Alan Gilbert, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, Eric Blake, Markus Armbruster,
Fabiano Rosas, Laurent Vivier
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> Since commit 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER",
> released with QEMU v8.1.0) we get pointless output:
>
> (qemu) info opcount
> [TCG profiler not compiled]
>
> Remove that unstable and unuseful command.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Dr. David Alan Gilbert <dave@treblig.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 08/39] accel/tcg: Remove profiler leftover
2025-07-03 17:32 ` [PATCH v6 08/39] accel/tcg: Remove profiler leftover Philippe Mathieu-Daudé
@ 2025-07-04 4:24 ` Xiaoyao Li
2025-07-04 9:37 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 4:24 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> TCG profiler was removed in commit 1b65b4f54c7.
>
> Fixes: 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER")
> 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] 112+ messages in thread
* Re: [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out
2025-07-03 17:32 ` [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
@ 2025-07-04 4:27 ` Xiaoyao Li
2025-07-04 4:33 ` Xiaoyao Li
2025-07-04 9:38 ` Zhao Liu
1 sibling, 1 reply; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 4:27 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> accel/tcg/monitor.c | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
> index 344ec500473..6d9cc11d94c 100644
> --- a/accel/tcg/monitor.c
> +++ b/accel/tcg/monitor.c
> @@ -141,11 +141,26 @@ static void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide)
> *pelide = elide;
> }
>
> +static 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;
> @@ -182,15 +197,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",
side topic,
is the "TB" an typo of "TLB"?
> - 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);
> }
>
> HumanReadableText *qmp_x_query_jit(Error **errp)
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out
2025-07-04 4:27 ` Xiaoyao Li
@ 2025-07-04 4:33 ` Xiaoyao Li
0 siblings, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 4:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 7/4/2025 12:27 PM, Xiaoyao Li wrote:
> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>> 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>
>
>> ---
>> accel/tcg/monitor.c | 27 +++++++++++++++++----------
>> 1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
>> index 344ec500473..6d9cc11d94c 100644
>> --- a/accel/tcg/monitor.c
>> +++ b/accel/tcg/monitor.c
>> @@ -141,11 +141,26 @@ static void tlb_flush_counts(size_t *pfull,
>> size_t *ppart, size_t *pelide)
>> *pelide = elide;
>> }
>> +static 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;
>> @@ -182,15 +197,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",
>
> side topic,
>
> is the "TB" an typo of "TLB"?
Please ignore my silly question. It's TranslationBlock of tcg.
>> - 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);
>> }
>> HumanReadableText *qmp_x_query_jit(Error **errp)
>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount
2025-07-03 17:32 ` [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount Philippe Mathieu-Daudé
2025-07-04 4:23 ` Xiaoyao Li
@ 2025-07-04 4:50 ` Markus Armbruster
2025-07-04 9:36 ` Zhao Liu
2 siblings, 0 replies; 112+ messages in thread
From: Markus Armbruster @ 2025-07-04 4:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Zhao Liu, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Alex Bennée, Dr. David Alan Gilbert,
Eduardo Habkost, Marcel Apfelbaum, Yanan Wang, Eric Blake,
Fabiano Rosas, Laurent Vivier
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Since commit 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER",
> released with QEMU v8.1.0) we get pointless output:
>
> (qemu) info opcount
> [TCG profiler not compiled]
>
> Remove that unstable and unuseful command.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Dr. David Alan Gilbert <dave@treblig.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command
2025-07-03 17:32 ` [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
2025-07-04 3:10 ` Xiaoyao Li
@ 2025-07-04 4:59 ` Markus Armbruster
2025-07-15 8:48 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 112+ messages in thread
From: Markus Armbruster @ 2025-07-04 4:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Zhao Liu, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Alex Bennée, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, Eric Blake
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> 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>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> Tested-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> 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;
Does the conversion from CPU type name to model name lose information?
If yes, should we provide the type name at least in QMP?
Let me also try a different angle... what's the preferred thing for
users of HMP and for users of QMP, CPU model name or CPU type name?
Are there any commands that accept one, but not the other?
Are there other commands that return one, but not the other?
^ permalink raw reply [flat|nested] 112+ 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
2025-07-04 9:42 ` Zhao Liu
1 sibling, 0 replies; 112+ 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] 112+ 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
2025-07-04 9:44 ` Zhao Liu
1 sibling, 0 replies; 112+ 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] 112+ messages in thread
* Re: [PATCH v6 14/39] accel/hvf: Restrict internal declarations
2025-07-03 17:32 ` [PATCH v6 14/39] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
@ 2025-07-04 5:39 ` Xiaoyao Li
2025-07-04 9:45 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 5:39 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
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 17/39] cpus: Document CPUState::vcpu_dirty field
2025-07-03 17:32 ` [PATCH v6 17/39] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
@ 2025-07-04 5:52 ` Xiaoyao Li
0 siblings, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 5:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Eduardo Habkost, Marcel Apfelbaum, Yanan Wang
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
> 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 162a56a5daa..5eaf41a566f 100644
> --- a/include/hw/core/cpu.h
> +++ b/include/hw/core/cpu.h
> @@ -442,6 +442,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.
> @@ -538,7 +539,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;
> @@ -554,6 +554,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
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 ` [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
@ 2025-07-04 5:54 ` Xiaoyao Li
2025-07-04 10:07 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 5:54 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,
qemu-arm
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé 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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 19/39] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 ` [PATCH v6 19/39] accel/nvmm: " Philippe Mathieu-Daudé
@ 2025-07-04 5:55 ` Xiaoyao Li
2025-07-04 10:08 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 5:55 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Reinoud Zandijk
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé 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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 20/39] accel/whpx: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 ` [PATCH v6 20/39] accel/whpx: " Philippe Mathieu-Daudé
@ 2025-07-04 5:55 ` Xiaoyao Li
2025-07-04 10:11 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 5:55 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Sunil Muthuswamy
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé 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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 112+ 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é
2025-07-04 10:15 ` Zhao Liu
1 sibling, 1 reply; 112+ 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] 112+ messages in thread
* Re: [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'
2025-07-03 17:32 ` [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
@ 2025-07-04 6:16 ` Xiaoyao Li
2025-07-04 10:44 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 6:16 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Fabiano Rosas, Laurent Vivier,
Stefano Stabellini, Anthony PERARD, Paul Durrant,
Edgar E. Iglesias, xen-devel
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> '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>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler
2025-07-03 17:32 ` [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
@ 2025-07-04 6:32 ` Xiaoyao Li
2025-07-04 10:59 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-04 6:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
> 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 6feeb3f3e9b..6e7c2aae5a8 100644
> --- a/accel/tcg/tcg-accel-ops.h
> +++ b/accel/tcg/tcg-accel-ops.h
> @@ -16,7 +16,7 @@
>
> 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 2075691331c..d84eaa376c2 100644
> --- a/include/system/accel-ops.h
> +++ b/include/system/accel-ops.h
> @@ -61,7 +61,7 @@ struct AccelOpsClass {
> void (*synchronize_pre_loadvm)(CPUState *cpu);
> void (*synchronize_pre_resume)(bool step_pending);
>
> - void (*handle_interrupt)(CPUState *cpu, int mask);
> + void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask);
>
> /**
> * @get_virtual_clock: fetch virtual clock
> 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) {
This patch changes the behavior,
Assume the @mask is the value passed to cpu_interrupt()
- before this patch:
(mask & ~old_mask) is
(@mask & ~cpu->interrupt_request)
- after this patch:
(new_mask & ~old_mask) is
((@mask | cpu->interrupt_request) & ~cpu->interrupt_request)
^ permalink raw reply [flat|nested] 112+ 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; 112+ 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] 112+ 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; 112+ 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] 112+ 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; 112+ 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] 112+ 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; 112+ 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] 112+ messages in thread
* Re: [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code
2025-07-03 17:32 ` [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
@ 2025-07-04 8:32 ` Philippe Mathieu-Daudé
2025-07-04 10:26 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 8:32 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée, Reinoud Zandijk
On 3/7/25 19:32, Philippe Mathieu-Daudé wrote:
> 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 | 8 +-------
> accel/stubs/meson.build | 1 +
> 4 files changed, 26 insertions(+), 18 deletions(-)
> create mode 100644 accel/stubs/nvmm-stub.c
> 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"
"system/nvmm.h" ;)
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 11/39] accel/tcg: Extract statistic related code to tcg-stats.c
2025-07-03 17:32 ` [PATCH v6 11/39] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
@ 2025-07-04 8:44 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 8:44 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On Thu, Jul 03, 2025 at 07:32:17PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:17 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 11/39] accel/tcg: Extract statistic related code to
> tcg-stats.c
> X-Mailer: git-send-email 2.49.0
>
> Statistic code is not specific to system emulation (except
> cross-page checks) and can be used to analyze user-mode binaries.
> Extract statistic related code to its own file: tcg-stats.c,
> keeping the original LGPL-2.1-or-later license tag.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> accel/tcg/monitor.c | 193 ---------------------------------------
> accel/tcg/tcg-stats.c | 206 ++++++++++++++++++++++++++++++++++++++++++
> accel/tcg/meson.build | 1 +
> 3 files changed, 207 insertions(+), 193 deletions(-)
> create mode 100644 accel/tcg/tcg-stats.c
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 00/39] accel: Preparatory cleanups for split-accel
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
` (38 preceding siblings ...)
2025-07-03 17:32 ` [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section Philippe Mathieu-Daudé
@ 2025-07-04 8:50 ` Philippe Mathieu-Daudé
39 siblings, 0 replies; 112+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 8:50 UTC (permalink / raw)
To: qemu-devel
Cc: Zhao Liu, Paolo Bonzini, Richard Henderson, Pierrick Bouvier,
Alex Bennée
On 3/7/25 19:32, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (39):
> hw/core/machine: Display CPU model name in 'info cpus' command
> system/memory: Restrict eventfd dispatch_write() to emulators
> system/runstate: Document qemu_add_vm_change_state_handler()
> system/cpus: Assert interrupt handling is done with BQL locked
> accel/kvm: Remove kvm_init_cpu_signals() stub
> accel/kvm: Reduce kvm_create_vcpu() declaration scope
> accel/tcg: Remove 'info opcount' and @x-query-opcount
> accel/tcg: Remove profiler leftover
> accel/tcg: Factor tcg_dump_flush_info() out
> accel/tcg: Factor tcg_dump_stats() out for re-use
> accel/tcg: Extract statistic related code to tcg-stats.c
> accel: Move supports_guest_debug() declaration to AccelClass
> accel: Move cpus_are_resettable() declaration to AccelClass
> 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/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'
> accel: Pass old/new interrupt mask to handle_interrupt() handler
> accel: Expose and register generic_handle_interrupt()
> accel: Keep reference to AccelOpsClass in AccelClass
> accel: Propagate AccelState to AccelClass::init_machine()
> accel/kvm: Prefer local AccelState over global MachineState::accel
> 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: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h'
> accel: Extract AccelClass definition to 'accel/accel-ops.h'
> MAINTAINERS: Add me as reviewer of overall accelerators section
Non-controversial patches queued to accel-next, thanks.
^ permalink raw reply [flat|nested] 112+ 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; 112+ 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] 112+ 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; 112+ 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] 112+ messages in thread
* Re: [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler()
2025-07-03 17:32 ` [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
2025-07-04 3:40 ` Xiaoyao Li
@ 2025-07-04 9:31 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:31 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:09PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:09 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 03/39] system/runstate: Document
> qemu_add_vm_change_state_handler()
> 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>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> include/system/runstate.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked
2025-07-03 17:32 ` [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
2025-07-04 4:07 ` Xiaoyao Li
@ 2025-07-04 9:32 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:10PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:10 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 04/39] system/cpus: Assert interrupt handling is done
> with BQL locked
> 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-accel-ops.c | 2 --
> system/cpus.c | 2 ++
> 2 files changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ 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
@ 2025-07-04 9:33 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:12PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:12 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration
> scope
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount
2025-07-03 17:32 ` [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount Philippe Mathieu-Daudé
2025-07-04 4:23 ` Xiaoyao Li
2025-07-04 4:50 ` Markus Armbruster
@ 2025-07-04 9:36 ` Zhao Liu
2 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:13PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:13 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and
> @x-query-opcount
> X-Mailer: git-send-email 2.49.0
>
> Since commit 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER",
> released with QEMU v8.1.0) we get pointless output:
>
> (qemu) info opcount
> [TCG profiler not compiled]
>
> Remove that unstable and unuseful command.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Dr. David Alan Gilbert <dave@treblig.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> qapi/machine.json | 18 ------------------
> accel/tcg/monitor.c | 21 ---------------------
> tests/qtest/qmp-cmd-test.c | 1 -
> hmp-commands-info.hx | 14 --------------
> 4 files changed, 54 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 08/39] accel/tcg: Remove profiler leftover
2025-07-03 17:32 ` [PATCH v6 08/39] accel/tcg: Remove profiler leftover Philippe Mathieu-Daudé
2025-07-04 4:24 ` Xiaoyao Li
@ 2025-07-04 9:37 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:14PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:14 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 08/39] accel/tcg: Remove profiler leftover
> X-Mailer: git-send-email 2.49.0
>
> TCG profiler was removed in commit 1b65b4f54c7.
>
> Fixes: 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/monitor.c | 6 ------
> 1 file changed, 6 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out
2025-07-03 17:32 ` [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
2025-07-04 4:27 ` Xiaoyao Li
@ 2025-07-04 9:38 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:15PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:15 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out
> 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/monitor.c | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use
2025-07-03 17:32 ` [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use Philippe Mathieu-Daudé
@ 2025-07-04 9:39 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:39 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:16PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:16 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use
> 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/internal-common.h | 2 ++
> accel/tcg/monitor.c | 11 ++++++++---
> 2 files changed, 10 insertions(+), 3 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ 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
@ 2025-07-04 9:42 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:18PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:18 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to
> AccelClass
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ 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
@ 2025-07-04 9:44 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:44 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:19PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:19 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 13/39] accel: Move cpus_are_resettable() declaration to
> AccelClass
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 14/39] accel/hvf: Restrict internal declarations
2025-07-03 17:32 ` [PATCH v6 14/39] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
2025-07-04 5:39 ` Xiaoyao Li
@ 2025-07-04 9:45 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:45 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:20PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:20 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 14/39] accel/hvf: Restrict internal declarations
> X-Mailer: git-send-email 2.49.0
>
> 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 | 38 --------------------------------------
> include/system/hvf_int.h | 34 ++++++++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+), 38 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c
2025-07-03 17:32 ` [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
@ 2025-07-04 9:46 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:21PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:21 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to
> hvf-accel-ops.c
> X-Mailer: git-send-email 2.49.0
>
> 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 | 30 ++++++++++++++++++++++++++++++
> accel/hvf/hvf-all.c | 28 ----------------------------
> 2 files changed, 30 insertions(+), 28 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 16/39] accel/hvf: Move generic method declarations to hvf-all.c
2025-07-03 17:32 ` [PATCH v6 16/39] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
@ 2025-07-04 9:50 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 9:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:22PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:22 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 16/39] accel/hvf: Move generic method declarations to
> hvf-all.c
> X-Mailer: git-send-email 2.49.0
>
> 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 | 274 +-------------------------------------
> accel/hvf/hvf-all.c | 268 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 272 insertions(+), 270 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 ` [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
2025-07-04 5:54 ` Xiaoyao Li
@ 2025-07-04 10:07 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:07 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:24PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:24 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic
> CPUState::vcpu_dirty field
> X-Mailer: git-send-email 2.49.0
>
> 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: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 19/39] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 ` [PATCH v6 19/39] accel/nvmm: " Philippe Mathieu-Daudé
2025-07-04 5:55 ` Xiaoyao Li
@ 2025-07-04 10:08 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:08 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:25PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:25 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 19/39] accel/nvmm: Replace @dirty field by generic
> CPUState::vcpu_dirty field
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 20/39] accel/whpx: Replace @dirty field by generic CPUState::vcpu_dirty field
2025-07-03 17:32 ` [PATCH v6 20/39] accel/whpx: " Philippe Mathieu-Daudé
2025-07-04 5:55 ` Xiaoyao Li
@ 2025-07-04 10:11 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:11 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:26PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:26 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 20/39] accel/whpx: Replace @dirty field by generic
> CPUState::vcpu_dirty field
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ 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 10:15 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:27PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:27 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 22/39] accel/system: Document cpu_synchronize_state()
2025-07-03 17:32 ` [PATCH v6 22/39] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
@ 2025-07-04 10:17 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:17 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:28PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:28 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 22/39] accel/system: Document cpu_synchronize_state()
> 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/system/accel-ops.h | 8 ++++++++
> include/system/hw_accel.h | 13 +++++++++++--
> 2 files changed, 19 insertions(+), 2 deletions(-)>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 23/39] accel/system: Document cpu_synchronize_state_post_init/reset()
2025-07-03 17:32 ` [PATCH v6 23/39] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
@ 2025-07-04 10:19 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:29PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:29 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 23/39] accel/system: Document
> cpu_synchronize_state_post_init/reset()
> 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/system/accel-ops.h | 8 ++++++++
> include/system/hw_accel.h | 8 ++++++++
> 2 files changed, 16 insertions(+)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code
2025-07-03 17:32 ` [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
2025-07-04 8:32 ` Philippe Mathieu-Daudé
@ 2025-07-04 10:26 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:30PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:30 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code
> X-Mailer: git-send-email 2.49.0
>
> 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 | 8 +-------
> accel/stubs/meson.build | 1 +
> 4 files changed, 26 insertions(+), 18 deletions(-)
> create mode 100644 accel/stubs/nvmm-stub.c
With header file fixed,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() to common code
2025-07-03 17:32 ` [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
@ 2025-07-04 10:36 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:31PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:31 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() to common code
> X-Mailer: git-send-email 2.49.0
>
> 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 | 7 +------
> accel/stubs/meson.build | 1 +
> 4 files changed, 28 insertions(+), 19 deletions(-)
> create mode 100644 accel/stubs/whpx-stub.c
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'
2025-07-03 17:32 ` [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
2025-07-04 6:16 ` Xiaoyao Li
@ 2025-07-04 10:44 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:44 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:32PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:32 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from
> 'system/cpus.h'
> X-Mailer: git-send-email 2.49.0
>
> '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>
> ---
> MAINTAINERS | 1 +
> 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 +
> 6 files changed, 18 insertions(+), 5 deletions(-)
> create mode 100644 accel/dummy-cpus.h
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler
2025-07-03 17:32 ` [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
2025-07-04 6:32 ` Xiaoyao Li
@ 2025-07-04 10:59 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 10:59 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:33PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:33 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 27/39] accel: Pass old/new interrupt mask to
> handle_interrupt() handler
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 29/39] accel: Keep reference to AccelOpsClass in AccelClass
2025-07-03 17:32 ` [PATCH v6 29/39] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
@ 2025-07-04 11:01 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:01 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:35PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:35 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 29/39] accel: Keep reference to AccelOpsClass in
> AccelClass
> X-Mailer: git-send-email 2.49.0
>
> 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(-)>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ 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; 112+ 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] 112+ messages in thread
* Re: [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel
2025-07-03 17:32 ` [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
@ 2025-07-04 11:33 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:37PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:37 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global
> MachineState::accel
> 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/kvm/kvm-all.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators
2025-07-04 3:32 ` Xiaoyao Li
@ 2025-07-04 11:34 ` Alex Bennée
0 siblings, 0 replies; 112+ messages in thread
From: Alex Bennée @ 2025-07-04 11:34 UTC (permalink / raw)
To: Xiaoyao Li
Cc: Philippe Mathieu-Daudé, qemu-devel, Zhao Liu, Paolo Bonzini,
Richard Henderson, Pierrick Bouvier, Peter Xu, David Hildenbrand
Xiaoyao Li <xiaoyao.li@intel.com> writes:
> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>> 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 76b44b8220f..4f713889a8e 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()) &&
>
> The FIXME provides two options:
> 1. change to "tcg_enabled() || qtest_enabled()"
> 2. remove !kvm_enabled()
>
> And as the FIXME said, it's not clear why under KVM the write would be
> processed directly. Now, the question becomes why under hardware
> accelerator is used the write would be processed directly instead of
> going through eventfd. I think it needs to answer this question when
> we do such change, and it's better to put the answer as the comment in
> the code.
Under KVM the eventfd notifications are sent directly from the kernel to
the relevant fd. There is no reason why under KVM you couldn't inject
the eventfds from QEMU but it would be a weird and sub-optimal setup.
KVM is perfectly capable of trapping the MMIO accesses in kernel.
I don't think eventfd's can be supported for HVF because I don't think
it has such a concept. For vhost-user devices they would then rely on
VHOST_USER_VRING_KICK over the socket instead.
>
>> memory_region_dispatch_write_eventfds(mr, addr, data, size, attrs)) {
>> return MEMTX_OK;
>> }
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global current_accel()
2025-07-03 17:32 ` [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
@ 2025-07-04 11:34 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:38PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:38 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global
> current_accel()
> 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 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory()
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
@ 2025-07-04 11:35 ` Zhao Liu
2025-07-04 11:46 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:39PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:39 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 33/39] accel: Directly pass AccelState argument to
> AccelClass::has_memory()
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()
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-04 11:37 ` Zhao Liu
2025-07-04 11:46 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:40PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:40 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to
> do_kvm_create_vm()
> 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/kvm/kvm-all.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 35/39] accel: Remove unused MachineState argument of AccelClass::setup_post()
2025-07-03 17:32 ` [PATCH v6 35/39] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
@ 2025-07-04 11:38 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:41PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:41 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 35/39] accel: Remove unused MachineState argument of
> AccelClass::setup_post()
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags()
2025-07-03 17:32 ` [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
@ 2025-07-04 11:42 ` Zhao Liu
0 siblings, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:42PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:42 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 36/39] accel: Pass AccelState argument to
> gdbstub_supported_sstep_flags()
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Make sense. I think then MachineClass can also be similarly cleaned up.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory()
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
2025-07-04 11:35 ` Zhao Liu
@ 2025-07-04 11:46 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:39PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:39 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 33/39] accel: Directly pass AccelState argument to
> AccelClass::has_memory()
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()
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-04 11:37 ` Zhao Liu
@ 2025-07-04 11:46 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:40PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:40 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to
> do_kvm_create_vm()
> 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/kvm/kvm-all.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ 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 11:49 ` Zhao Liu
1 sibling, 0 replies; 112+ messages in thread
From: Zhao Liu @ 2025-07-04 11:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, Jul 03, 2025 at 07:32:11PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Thu, 3 Jul 2025 19:32:11 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub
> X-Mailer: git-send-email 2.49.0
>
> 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(-)
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 112+ 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; 112+ 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] 112+ 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; 112+ 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] 112+ messages in thread
* Re: [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command
2025-07-04 4:59 ` Markus Armbruster
@ 2025-07-15 8:48 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 112+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 8:48 UTC (permalink / raw)
To: Markus Armbruster
Cc: qemu-devel, Zhao Liu, Paolo Bonzini, Richard Henderson,
Pierrick Bouvier, Alex Bennée, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang, Eric Blake
On 4/7/25 06:59, Markus Armbruster wrote:
> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>
>> 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>
>> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>> Tested-by: Zhao Liu <zhao1.liu@intel.com>
>> ---
>> 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;
>
> Does the conversion from CPU type name to model name lose information?
Likely.
> If yes, should we provide the type name at least in QMP?
OK.
> Let me also try a different angle... what's the preferred thing for
> users of HMP and for users of QMP, CPU model name or CPU type name?
>
> Are there any commands that accept one, but not the other?
Likely. In particular the CLI expect model names for '-cpu',
except when created as '-device' were the type name is expected...
> Are there other commands that return one, but not the other?
QMP commands usually return the QOM type name, not the model.
IMHO the external interface should be the CPU model name. Keeping it
simple, an example could be "max".
The internal interface (QOM type name) is used to compose the QOM model.
Some types end verbose, such "riscv64-max-tcg". I expect such
information to be more relevant to an experimented QEMU developer or in
a bug report rather than exposed to the users.
Anyway, I'll respin using type name for QMP and model name for HMP.
Thanks,
Phil.
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler()
2025-07-04 3:40 ` Xiaoyao Li
@ 2025-07-15 9:02 ` Alex Bennée
2025-07-15 9:34 ` Xiaoyao Li
0 siblings, 1 reply; 112+ messages in thread
From: Alex Bennée @ 2025-07-15 9:02 UTC (permalink / raw)
To: Xiaoyao Li
Cc: Philippe Mathieu-Daudé, qemu-devel, Zhao Liu, Paolo Bonzini,
Richard Henderson, Pierrick Bouvier
Xiaoyao Li <xiaoyao.li@intel.com> writes:
> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>> 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/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()
>> + */
>
> qemu_add_vm_change_state_handler_prio() and
> qemu_add_vm_change_state_handler_prio_full() put the document in the
> implementation in system/runstate.c.
Generally APIs to the rest of QEMU should be documented in the headers.
Comments on individual functions or internal details are fine to live in
the C files.
>
> Please make them consistent.
>
>> VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
>> void *opaque);
>> VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 112+ messages in thread
* Re: [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler()
2025-07-15 9:02 ` Alex Bennée
@ 2025-07-15 9:34 ` Xiaoyao Li
0 siblings, 0 replies; 112+ messages in thread
From: Xiaoyao Li @ 2025-07-15 9:34 UTC (permalink / raw)
To: Alex Bennée
Cc: Philippe Mathieu-Daudé, qemu-devel, Zhao Liu, Paolo Bonzini,
Richard Henderson, Pierrick Bouvier
On 7/15/2025 5:02 PM, Alex Bennée wrote:
> Xiaoyao Li <xiaoyao.li@intel.com> writes:
>
>> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>>> 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/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()
>>> + */
>>
>> qemu_add_vm_change_state_handler_prio() and
>> qemu_add_vm_change_state_handler_prio_full() put the document in the
>> implementation in system/runstate.c.
>
> Generally APIs to the rest of QEMU should be documented in the headers.
> Comments on individual functions or internal details are fine to live in
> the C files.
I totally understand it.
I was not asking to put the document into C files, but to ...
>>
>> Please make them consistent.
... make them consistent. IOW, I would expect an additional patch to
move the document of qemu_add_vm_change_state_handler_prio() and
qemu_add_vm_change_state_handler_prio_full() from C files to this header
file.
>>> VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
>>> void *opaque);
>>> VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
>
^ permalink raw reply [flat|nested] 112+ messages in thread
end of thread, other threads:[~2025-07-15 9:40 UTC | newest]
Thread overview: 112+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
2025-07-04 3:10 ` Xiaoyao Li
2025-07-04 4:59 ` Markus Armbruster
2025-07-15 8:48 ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
2025-07-04 3:32 ` Xiaoyao Li
2025-07-04 11:34 ` Alex Bennée
2025-07-03 17:32 ` [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
2025-07-04 3:40 ` Xiaoyao Li
2025-07-15 9:02 ` Alex Bennée
2025-07-15 9:34 ` Xiaoyao Li
2025-07-04 9:31 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
2025-07-04 4:07 ` Xiaoyao Li
2025-07-04 9:32 ` Zhao Liu
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-04 11:49 ` Zhao Liu
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-04 9:33 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount Philippe Mathieu-Daudé
2025-07-04 4:23 ` Xiaoyao Li
2025-07-04 4:50 ` Markus Armbruster
2025-07-04 9:36 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 08/39] accel/tcg: Remove profiler leftover Philippe Mathieu-Daudé
2025-07-04 4:24 ` Xiaoyao Li
2025-07-04 9:37 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
2025-07-04 4:27 ` Xiaoyao Li
2025-07-04 4:33 ` Xiaoyao Li
2025-07-04 9:38 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use Philippe Mathieu-Daudé
2025-07-04 9:39 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 11/39] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
2025-07-04 8:44 ` Zhao Liu
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-04 9:42 ` Zhao Liu
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-04 9:44 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 14/39] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
2025-07-04 5:39 ` Xiaoyao Li
2025-07-04 9:45 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
2025-07-04 9:46 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 16/39] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
2025-07-04 9:50 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 17/39] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
2025-07-04 5:52 ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
2025-07-04 5:54 ` Xiaoyao Li
2025-07-04 10:07 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 19/39] accel/nvmm: " Philippe Mathieu-Daudé
2025-07-04 5:55 ` Xiaoyao Li
2025-07-04 10:08 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 20/39] accel/whpx: " Philippe Mathieu-Daudé
2025-07-04 5:55 ` Xiaoyao Li
2025-07-04 10:11 ` Zhao Liu
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-04 10:15 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 22/39] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
2025-07-04 10:17 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 23/39] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
2025-07-04 10:19 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
2025-07-04 8:32 ` Philippe Mathieu-Daudé
2025-07-04 10:26 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
2025-07-04 10:36 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
2025-07-04 6:16 ` Xiaoyao Li
2025-07-04 10:44 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
2025-07-04 6:32 ` Xiaoyao Li
2025-07-04 10:59 ` Zhao Liu
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 29/39] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
2025-07-04 11:01 ` Zhao Liu
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-04 11:33 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
2025-07-04 11:34 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
2025-07-04 11:35 ` Zhao Liu
2025-07-04 11:46 ` Zhao Liu
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-04 11:37 ` Zhao Liu
2025-07-04 11:46 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 35/39] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
2025-07-04 11:38 ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
2025-07-04 11:42 ` Zhao Liu
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
2025-07-03 17:32 ` [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section Philippe Mathieu-Daudé
2025-07-03 22:42 ` Philippe Mathieu-Daudé
2025-07-04 3:23 ` Richard Henderson
2025-07-04 8:50 ` [PATCH v6 00/39] 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).