Skip to contentSkip to conversation

Accelerators patches for 2025-07-04

GIT PULL Applied Philippe Mathieu-Daudé 8 participants 52 messages Jul 4, 2025 – Jan 15 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

The following changes since commit c77283dd5d79149f4e7e9edd00f65416c648ee59:

Merge tag 'pull-request-2025-07-02' of https://gitlab.com/thuth/qemu into staging (2025-07-03 06:01:41 -0400)

are available in the Git repository at:

https://github.com/philmd/qemu.git tags/accel-20250704

for you to fetch changes up to d7fffb0c8a498cd0a184832e4e2c24251dbff7c0:

hmp-cmds-target.c: add CPU_DUMP_VPU in hmp_info_registers() (2025-07-04 12:08:44 +0200)

----------------------------------------------------------------
Accelerators patches

- Generic API consolidation, cleanups (dead code removal, documentation added)
- Remove monitor TCG 'info opcount' and @x-query-opcount
- Have HVF / NVMM / WHPX use generic CPUState::vcpu_dirty field
- Expose nvmm_enabled() and whpx_enabled() to common code
- Have hmp_info_registers() dump vector registers

----------------------------------------------------------------

Daniel Henrique Barboza (1):
hmp-cmds-target.c: add CPU_DUMP_VPU in hmp_info_registers()

Philippe Mathieu-Daudé (30):
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/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: Expose and register generic_handle_interrupt()
accel: Keep reference to AccelOpsClass in AccelClass
accel: Propagate AccelState to AccelClass::init_machine() accel/tcg: Prefer local AccelState over global current_accel() accel/kvm: Prefer local AccelState over global MachineState::accel accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()
accel: Directly pass AccelState argument to AccelClass::has_memory()
accel: Remove unused MachineState argument of AccelClass::setup_post()
accel: Pass AccelState argument to gdbstub_supported_sstep_flags()
MAINTAINERS: Add me as reviewer of overall accelerators section

 MAINTAINERS                       |   4 +
 qapi/machine.json                 |  18 --
 accel/dummy-cpus.h                |  14 ++
 accel/tcg/internal-common.h       |   2 +
 include/hw/core/cpu.h             |   3 +-
 include/qemu/accel.h              |  11 +-
 include/system/accel-ops.h        |  22 ++-
 include/system/cpus.h             |   5 -
 include/system/hvf.h              |  38 ----
 include/system/hvf_int.h          |  35 +++-
 include/system/hw_accel.h         |  21 +-
 include/system/kvm.h              |   8 -
 include/system/nvmm.h             |  23 +--
 include/system/whpx.h             |  27 +--
 accel/accel-common.c              |   2 +-
 accel/accel-system.c              |   7 +-
 accel/dummy-cpus.c                |   1 +
 accel/hvf/hvf-accel-ops.c         | 314 ++++--------------------------
 accel/hvf/hvf-all.c               | 277 ++++++++++++++++++++++++--
 accel/kvm/kvm-accel-ops.c         |   1 +
 accel/kvm/kvm-all.c               |  27 +--
 accel/qtest/qtest.c               |   4 +-
 accel/stubs/kvm-stub.c            |   9 -
 accel/stubs/nvmm-stub.c           |  12 ++
 accel/stubs/whpx-stub.c           |  12 ++
 accel/tcg/monitor.c               |  57 ++----
 accel/tcg/tcg-accel-ops.c         |   6 +-
 accel/tcg/tcg-all.c               |   6 +-
 accel/xen/xen-all.c               |   6 +-
 bsd-user/main.c                   |   2 +-
 linux-user/main.c                 |   2 +-
 monitor/hmp-cmds-target.c         |   4 +-
 system/cpus.c                     |  12 +-
 system/memory.c                   |   2 +-
 target/arm/hvf/hvf.c              |   4 +-
 target/i386/hvf/hvf.c             |   4 +-
 target/i386/hvf/x86hvf.c          |   2 +-
 target/i386/nvmm/nvmm-accel-ops.c |   1 +
 target/i386/nvmm/nvmm-all.c       |  31 ++-
 target/i386/whpx/whpx-accel-ops.c |   1 +
 target/i386/whpx/whpx-all.c       |  32 ++-
 tests/qtest/qmp-cmd-test.c        |   1 -
 accel/stubs/meson.build           |   2 +
 hmp-commands-info.hx              |  14 --
 44 files changed, 551 insertions(+), 535 deletions(-)
 create mode 100644 accel/dummy-cpus.h
 create mode 100644 accel/stubs/nvmm-stub.c
 create mode 100644 accel/stubs/whpx-stub.c
Signature · 1 line
2.49.0
#1 lore raw

[PULL 03/31] accel/kvm: Reduce kvm_create_vcpu() declaration scope

kvm_create_vcpu() is only used within the same file unit.

Message-Id: <[email protected]>

---
 include/system/kvm.h | 8 --------
 accel/kvm/kvm-all.c  | 8 +++++++-
 2 files changed, 7 insertions(+), 9 deletions(-)
include/system/kvm.h +0 -8
index 7cc60d26f24..e943df2c09d 100644
@@ -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.
accel/kvm/kvm-all.c +7 -1
index d095d1b98f8..17235f26464 100644
@@ -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;
Signature · 1 line
2.49.0
#2 lore raw

[PULL 11/31] cpus: Document CPUState::vcpu_dirty field

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 include/hw/core/cpu.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/hw/core/cpu.h +2 -1
index 162a56a5daa..5eaf41a566f 100644
@@ -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
Signature · 1 line
2.49.0
#3 lore raw

[PULL 05/31] accel/tcg: Remove profiler leftover

In reply to Philippe Mathieu-Daudé

TCG profiler was removed in commit 1b65b4f54c7.

Fixes 1b65b4f54c7 ("accel/tcg: remove CONFIG_PROFILER")

Message-Id: <[email protected]>

---
 accel/tcg/monitor.c | 6 ------
 1 file changed, 6 deletions(-)
accel/tcg/monitor.c +0 -6
index 7c686226b21..344ec500473 100644
@@ -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)
Signature · 1 line
2.49.0
#4 lore raw

[PULL 01/31] system/cpus: Assert interrupt handling is done with BQL locked

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 accel/tcg/tcg-accel-ops.c | 2 --
 system/cpus.c             | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
accel/tcg/tcg-accel-ops.c +0 -2
index b24d6a75625..6116644d1c0 100644
@@ -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;
 
     /*
system/cpus.c +2 -0
index d16b0dff989..a43e0e4e796 100644
@@ -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 {
Signature · 1 line
2.49.0
#5 lore raw

[PULL 04/31] accel/tcg: Remove 'info opcount' and @x-query-opcount

In reply to Philippe Mathieu-Daudé

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.

Message-Id: <[email protected]>

---
 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(-)
qapi/machine.json +0 -18
index 0650b8de71a..f712e7da6d6 100644
@@ -1761,24 +1761,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:
 #
accel/tcg/monitor.c +0 -21
index 1c182b6bfb5..7c686226b21 100644
@@ -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);
tests/qtest/qmp-cmd-test.c +0 -1
index 040d042810b..cf718761861 100644
@@ -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 }
     };
hmp-commands-info.hx +0 -14
index 639a450ee51..d7979222752 100644
@@ -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?",
Signature · 1 line
2.49.0
#6 lore raw

[PULL 25/31] accel/kvm: Prefer local AccelState over global MachineState::accel

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 accel/kvm/kvm-all.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
accel/kvm/kvm-all.c +1 -3
index 264f288dc64..72fba12d9fa 100644
@@ -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,
Signature · 1 line
2.49.0
#7 lore raw

[PULL 18/31] accel/nvmm: Expose nvmm_enabled() to common code

In reply to Philippe Mathieu-Daudé

Currently nvmm_enabled() is restricted to target-specific code. By defining CONFIG_NVMM_IS_POSSIBLE we allow its use anywhere.

Message-Id: <[email protected]>

---
 MAINTAINERS                 |  1 +
 include/system/nvmm.h       | 23 ++++++++++++-----------
 accel/stubs/nvmm-stub.c     | 12 ++++++++++++
 target/i386/nvmm/nvmm-all.c |  8 +-------
 accel/stubs/meson.build     |  1 +
 5 files changed, 27 insertions(+), 18 deletions(-)
 create mode 100644 accel/stubs/nvmm-stub.c
MAINTAINERS +1 -0
index b1cbfe115bc..c73468b2422 100644
@@ -586,6 +586,7 @@ NetBSD Virtual Machine Monitor (NVMM) CPU support
 M: Reinoud Zandijk <[email protected]>
 S: Maintained
 F: include/system/nvmm.h
+F: accel/stubs/nvmm-stub.c
 F: target/i386/nvmm/
 
 Hosts
include/system/nvmm.h +12 -11
index 6971ddb3a5a..7390def9adb 100644
@@ -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 */
accel/stubs/nvmm-stub.c new file +12 -0
new file mode 100644
index 00000000000..ec14837501a
@@ -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/nvmm.h"
+
+bool nvmm_allowed;
target/i386/nvmm/nvmm-all.c +1 -7
index aea61a6fd2a..2df49d7eeb4 100644
@@ -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)
 {
accel/stubs/meson.build +1 -0
index 8ca1a4529e2..4c34287215f 100644
@@ -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)
Signature · 1 line
2.49.0
#8 lore raw

[PULL 09/31] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c

In reply to Philippe Mathieu-Daudé

hvf-all.c aims to contain the generic accel methods (TYPE_ACCEL), while hvf-accel-ops.c the per-vcpu methods (TYPE_ACCEL_OPS).

Message-Id: <[email protected]>

---
 accel/hvf/hvf-accel-ops.c | 30 ++++++++++++++++++++++++++++++
 accel/hvf/hvf-all.c       | 28 ----------------------------
 2 files changed, 30 insertions(+), 28 deletions(-)
accel/hvf/hvf-accel-ops.c +30 -0
index b38977207d2..3752334688b 100644
@@ -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"
@@ -482,6 +484,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;
accel/hvf/hvf-all.c +0 -28
index 8c387fda24d..1c72c43ddb4 100644
@@ -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;
-}
Signature · 1 line
2.49.0
#9 lore raw

[PULL 26/31] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm()

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 accel/kvm/kvm-all.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
accel/kvm/kvm-all.c +2 -5
index 72fba12d9fa..007f82a50de 100644
@@ -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;
     }
Signature · 1 line
2.49.0
#10 lore raw

[PULL 24/31] accel/tcg: Prefer local AccelState over global current_accel()

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 accel/tcg/tcg-all.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/tcg-all.c +1 -1
index d68fbb23773..c674d5bcf78 100644
@@ -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
Signature · 1 line
2.49.0
#11 lore raw

[PULL 28/31] accel: Remove unused MachineState argument of AccelClass::setup_post()

In reply to Philippe Mathieu-Daudé

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.

Message-Id: <[email protected]>

---
 include/qemu/accel.h | 2 +-
 accel/accel-system.c | 2 +-
 accel/xen/xen-all.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/qemu/accel.h +1 -1
index f327a71282c..a6a95ff0bcd 100644
@@ -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);
 
accel/accel-system.c +1 -1
index 913b7155d77..af713cc9024 100644
@@ -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);
     }
 }
 
accel/xen/xen-all.c +1 -1
index 8279746f115..bd0ff64befc 100644
@@ -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;
 
Signature · 1 line
2.49.0
#12 lore raw

[PULL 10/31] accel/hvf: Move generic method declarations to hvf-all.c

In reply to Philippe Mathieu-Daudé

hvf-all.c aims to contain the generic accel methods (TYPE_ACCEL), while hvf-accel-ops.c the per-vcpu methods (TYPE_ACCEL_OPS).

Message-Id: <[email protected]>

---
 accel/hvf/hvf-accel-ops.c | 273 +-------------------------------------
 accel/hvf/hvf-all.c       | 267 +++++++++++++++++++++++++++++++++++++
 2 files changed, 271 insertions(+), 269 deletions(-)
accel/hvf/hvf-accel-ops.c +4 -269
index 3752334688b..2c0715a17f7 100644
@@ -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,147 +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->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 +372,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);
accel/hvf/hvf-all.c +267 -0

279 lines not on this page · raw message

Signature · 1 line
2.49.0
#13 lore raw

[PULL 27/31] accel: Directly pass AccelState argument to AccelClass::has_memory()

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 include/qemu/accel.h | 2 +-
 accel/kvm/kvm-all.c  | 4 ++--
 system/memory.c      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
include/qemu/accel.h +1 -1
index b9a9b3593d8..f327a71282c 100644
@@ -46,7 +46,7 @@ typedef struct AccelClass {
 
     /* system related hooks */
     void (*setup_post)(MachineState *ms, AccelState *accel);
-    bool (*has_memory)(MachineState *ms, AddressSpace *as,
+    bool (*has_memory)(AccelState *accel, AddressSpace *as,
                        hwaddr start_addr, hwaddr size);
 
     /* gdbstub related hooks */
accel/kvm/kvm-all.c +2 -2
index 007f82a50de..6f6f9ef69ba 100644
@@ -3786,10 +3786,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) {
system/memory.c +1 -1
index 76b44b8220f..e8d9b15b28f 100644
@@ -3501,7 +3501,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
         if (fvi->ac) {
             for (i = 0; i < fv_address_spaces->len; ++i) {
                 as = g_array_index(fv_address_spaces, AddressSpace*, i);
-                if (fvi->ac->has_memory(current_machine, as,
+                if (fvi->ac->has_memory(current_machine->accelerator, as,
                                         int128_get64(range->addr.start),
                                         MR_SIZE(range->addr.size) + 1)) {
                     qemu_printf(" %s", fvi->ac->name);
Signature · 1 line
2.49.0
#14 lore raw

[PULL 06/31] accel/tcg: Factor tcg_dump_flush_info() out

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 accel/tcg/monitor.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
accel/tcg/monitor.c +17 -10
index 344ec500473..6d9cc11d94c 100644
@@ -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)
Signature · 1 line
2.49.0
#15 lore raw

[PULL 29/31] accel: Pass AccelState argument to gdbstub_supported_sstep_flags()

In reply to Philippe Mathieu-Daudé

In order to have AccelClass methods instrospect their state, we need to pass AccelState by argument.

Message-Id: <[email protected]>

---
 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(-)
include/qemu/accel.h +1 -1
index a6a95ff0bcd..1c097ac4dfb 100644
@@ -50,7 +50,7 @@ typedef struct AccelClass {
                        hwaddr start_addr, hwaddr size);
 
     /* gdbstub related hooks */
-    int (*gdbstub_supported_sstep_flags)(void);
+    int (*gdbstub_supported_sstep_flags)(AccelState *as);
 
     bool *allowed;
     /*
accel/accel-common.c +1 -1
index 4894b98d64a..591ff4cbb65 100644
@@ -124,7 +124,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;
 }
accel/hvf/hvf-all.c +1 -1
index 68f1425fae2..b6075c036e2 100644
@@ -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;
 }
accel/kvm/kvm-all.c +1 -1
index 6f6f9ef69ba..45579f80fa5 100644
@@ -3980,7 +3980,7 @@ static void kvm_accel_instance_init(Object *obj)
  * Returns: SSTEP_* flags that KVM supports for guest debug. The
  * support is probed during kvm_init()
  */
-static int kvm_gdbstub_sstep_flags(void)
+static int kvm_gdbstub_sstep_flags(AccelState *as)
 {
     return kvm_sstep_flags;
 }
accel/tcg/tcg-all.c +1 -1
index c674d5bcf78..5904582a68d 100644
@@ -219,7 +219,7 @@ static void tcg_set_one_insn_per_tb(Object *obj, bool value, Error **errp)
     qatomic_set(&one_insn_per_tb, value);
 }
 
-static int tcg_gdbstub_supported_sstep_flags(void)
+static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
 {
     /*
      * In replay mode all events will come from the log and can't be
Signature · 1 line
2.49.0
#16 lore raw

[PULL 22/31] accel: Keep reference to AccelOpsClass in AccelClass

In reply to Philippe Mathieu-Daudé

Allow dereferencing AccelOpsClass outside of accel/accel-system.c.

Message-Id: <[email protected]>

---
 include/qemu/accel.h       | 3 +++
 include/system/accel-ops.h | 3 ++-
 accel/accel-system.c       | 3 ++-
 accel/tcg/tcg-accel-ops.c  | 4 +++-
 4 files changed, 10 insertions(+), 3 deletions(-)
include/qemu/accel.h +3 -0
index fbd3d897fef..9dea3145429 100644
@@ -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);
include/system/accel-ops.h +2 -1
index e775ecc348c..a786c7d478a 100644
@@ -10,6 +10,7 @@
 #ifndef ACCEL_OPS_H
 #define ACCEL_OPS_H
 
+#include "qemu/accel.h"
 #include "exec/vaddr.h"
 #include "qom/object.h"
 
@@ -31,7 +32,7 @@ struct AccelOpsClass {
     /*< public >*/
 
     /* initialization function called when accel is chosen */
-    void (*ops_init)(AccelOpsClass *ops);
+    void (*ops_init)(AccelClass *ac);
 
     bool (*cpus_are_resettable)(void);
     void (*cpu_reset_hold)(CPUState *cpu);
accel/accel-system.c +2 -1
index a0f562ae9ff..64bc991b1ce 100644
@@ -85,8 +85,9 @@ void accel_init_ops_interfaces(AccelClass *ac)
      * non-NULL create_vcpu_thread operation.
      */
     ops = ACCEL_OPS_CLASS(oc);
+    ac->ops = ops;
     if (ops->ops_init) {
-        ops->ops_init(ops);
+        ops->ops_init(ac);
     }
     cpus_register_accel(ops);
 }
accel/tcg/tcg-accel-ops.c +3 -1
index 6116644d1c0..37b4b21f882 100644
@@ -196,8 +196,10 @@ static inline void tcg_remove_all_breakpoints(CPUState *cpu)
     cpu_watchpoint_remove_all(cpu, BP_GDB);
 }
 
-static void tcg_accel_ops_init(AccelOpsClass *ops)
+static void tcg_accel_ops_init(AccelClass *ac)
 {
+    AccelOpsClass *ops = ac->ops;
+
     if (qemu_tcg_mttcg_enabled()) {
         ops->create_vcpu_thread = mttcg_start_vcpu_thread;
         ops->kick_vcpu_thread = mttcg_kick_vcpu_thread;
Signature · 1 line
2.49.0
#17 lore raw

[PULL 07/31] accel/tcg: Factor tcg_dump_stats() out for re-use

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 accel/tcg/internal-common.h |  2 ++
 accel/tcg/monitor.c         | 11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
accel/tcg/internal-common.h +2 -0
index 1dbc45dd955..77a3a0684a5 100644
@@ -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
accel/tcg/monitor.c +8 -3
index 6d9cc11d94c..e7ed7281a4b 100644
@@ -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);
 }
Signature · 1 line
2.49.0
#18 lore raw

[PULL 31/31] hmp-cmds-target.c: add CPU_DUMP_VPU in hmp_info_registers()

In reply to Philippe Mathieu-Daudé

From: Daniel Henrique Barboza <[email protected]>

Commit b84694defb added the CPU_DUMP_VPU to allow vector registers to be logged by log_cpu_exec() in TCG. This flag was then used in commit b227f6a8a7 to print RISC-V vector registers using this flag. Note that this change was done in riscv_cpu_dump_state(), the cpu_dump_state() callback for RISC-V, the same callback used in hmp_info_registers().

Back then we forgot to change hmp_info_registers(), and 'info registers' isn't showing RISC-V vector registers as a result. No other target is impacted since only RISC-V is using CPU_DUMP_VPU.

There's no reason to not show VPU regs in info_registers(), so add CPU_DUMP_VPU to hmp_info_registers(). This will print vector registers for all RISC-V machines and, as said above, has no impact in other archs.

Message-ID: <[email protected]>

---
 monitor/hmp-cmds-target.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
monitor/hmp-cmds-target.c +2 -2
index 8eaf70d9c9a..e9820611466 100644
@@ -102,7 +102,7 @@ void hmp_info_registers(Monitor *mon, const QDict *qdict)
     if (all_cpus) {
         CPU_FOREACH(cs) {
             monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
-            cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
+            cpu_dump_state(cs, NULL, CPU_DUMP_FPU | CPU_DUMP_VPU);
         }
     } else {
         cs = vcpu >= 0 ? qemu_get_cpu(vcpu) : mon_get_cpu(mon);
@@ -117,7 +117,7 @@ void hmp_info_registers(Monitor *mon, const QDict *qdict)
         }
 
         monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index);
-        cpu_dump_state(cs, NULL, CPU_DUMP_FPU);
+        cpu_dump_state(cs, NULL, CPU_DUMP_FPU | CPU_DUMP_VPU);
     }
 }
 
Signature · 1 line
2.49.0
#19 lore raw

[PULL 17/31] accel/system: Document cpu_synchronize_state_post_init/reset()

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 include/system/accel-ops.h | 8 ++++++++
 include/system/hw_accel.h  | 8 ++++++++
 2 files changed, 16 insertions(+)
include/system/accel-ops.h +8 -0
index 55f91cea25d..a4e706b49c9 100644
@@ -40,6 +40,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);
     /**
include/system/hw_accel.h +8 -0
index 574c9738408..fa9228d5d2d 100644
@@ -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);
 
Signature · 1 line
2.49.0
#20 lore raw

[PULL 08/31] accel/hvf: Restrict internal declarations

In reply to Philippe Mathieu-Daudé

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.

Message-Id: <[email protected]>

---
 include/system/hvf.h     | 38 --------------------------------------
 include/system/hvf_int.h | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 38 deletions(-)
include/system/hvf.h +0 -38
index a9a502f0c8f..d3dcf088b3f 100644
@@ -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(void);
-#endif /* COMPILING_PER_TARGET */
-
 #endif
include/system/hvf_int.h +34 -0
index d774e58df91..4f6db40c34e 100644
@@ -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(void);
+
 #endif
Signature · 1 line
2.49.0
#21 lore raw

[PULL 19/31] accel/whpx: Expose whpx_enabled() to common code

In reply to Philippe Mathieu-Daudé

Currently whpx_enabled() is restricted to target-specific code. By defining CONFIG_WHPX_IS_POSSIBLE we allow its use anywhere.

Message-Id: <[email protected]>

---
 MAINTAINERS                 |  1 +
 include/system/whpx.h       | 27 ++++++++++++++-------------
 accel/stubs/whpx-stub.c     | 12 ++++++++++++
 target/i386/whpx/whpx-all.c |  7 +------
 accel/stubs/meson.build     |  1 +
 5 files changed, 29 insertions(+), 19 deletions(-)
 create mode 100644 accel/stubs/whpx-stub.c
MAINTAINERS +1 -0
index c73468b2422..0fd8b2a4e61 100644
@@ -540,6 +540,7 @@ WHPX CPUs
 M: Sunil Muthuswamy <[email protected]>
 S: Supported
 F: target/i386/whpx/
+F: accel/stubs/whpx-stub.c
 F: include/system/whpx.h
 
 X86 Instruction Emulator
include/system/whpx.h +14 -13
index 00ff409b682..00f6a3e5236 100644
@@ -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 */
accel/stubs/whpx-stub.c new file +12 -0
new file mode 100644
index 00000000000..c564c89fd0b
@@ -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;
target/i386/whpx/whpx-all.c +1 -6
index 5001afad3a7..94fd5fc7849 100644
@@ -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;
 }
accel/stubs/meson.build +1 -0
index 4c34287215f..9dfc4f9ddaf 100644
@@ -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)
Signature · 1 line
2.49.0
#22 lore raw

[PULL 16/31] accel/system: Document cpu_synchronize_state()

In reply to Philippe Mathieu-Daudé

Message-Id: <[email protected]>

---
 include/system/accel-ops.h |  8 ++++++++
 include/system/hw_accel.h  | 13 +++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
include/system/accel-ops.h +8 -0
index 4c99d25aeff..55f91cea25d 100644
@@ -42,6 +42,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);
include/system/hw_accel.h +11 -2
index 380e9e640b6..574c9738408 100644
@@ -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 */
Signature · 1 line
2.49.0
#23 lore raw

[PULL 15/31] accel/kvm: Remove kvm_cpu_synchronize_state() stub

In reply to Philippe Mathieu-Daudé

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")

Message-Id: <[email protected]>

---
 accel/stubs/kvm-stub.c | 4 ----
 1 file changed, 4 deletions(-)
accel/stubs/kvm-stub.c +0 -4
index b9b4427c919..68cd33ba973 100644
@@ -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;
Signature · 1 line
2.49.0
#24 lore raw

[PULL 30/31] MAINTAINERS: Add me as reviewer of overall accelerators section

In reply to Philippe Mathieu-Daudé

I'd like to be informed of overall changes of accelerators.

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index fca98e12195..bfd59f64122 100644
@@ -495,6 +495,7 @@ Guest CPU Cores (other accelerators)
 Overall
 M: Richard Henderson <[email protected]>
 R: Paolo Bonzini <[email protected]>
+R: Philippe Mathieu-Daudé <[email protected]>
 S: Maintained
 F: include/exec/cpu*.h
 F: include/exec/target_long.h
Signature · 1 line
2.49.0
#25 lore raw

[PULL 23/31] accel: Propagate AccelState to AccelClass::init_machine()

In reply to Philippe Mathieu-Daudé

In order to avoid init_machine() to call current_accel(), pass AccelState along.

Message-Id: <[email protected]>

---
 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(-)
include/qemu/accel.h +1 -1
index 9dea3145429..b9a9b3593d8 100644
@@ -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);
 
accel/accel-system.c +1 -1
index 64bc991b1ce..913b7155d77 100644
@@ -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;
accel/hvf/hvf-all.c +1 -1
index ddc77e629f5..68f1425fae2 100644
@@ -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;
accel/kvm/kvm-all.c +1 -1
index 17235f26464..264f288dc64 100644
@@ -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[] =
accel/qtest/qtest.c +1 -1
index 5474ce73135..2b831260201 100644
@@ -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;
 }
accel/tcg/tcg-all.c +1 -1
index 6e5dc333d59..d68fbb23773 100644
@@ -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;
accel/xen/xen-all.c +1 -1
index c12c22de785..8279746f115 100644
@@ -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);
 
bsd-user/main.c +1 -1
index 7c0a059c3ba..d0cc8e0088f 100644
@@ -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);
     }
 
     /*
linux-user/main.c +1 -1
index 5ac5b55dc65..a9142ee7268 100644
@@ -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);
     }
 
     /*
target/i386/nvmm/nvmm-all.c +1 -1
index 2df49d7eeb4..b4a4d50e860 100644
@@ -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;
 
target/i386/whpx/whpx-all.c +1 -1
index 94fd5fc7849..721c4782b9c 100644
@@ -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;
Signature · 1 line
2.49.0
#26 lore raw

[PULL 12/31] accel/hvf: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>

---
 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(-)
include/system/hvf_int.h +0 -1
index 4f6db40c34e..5150c7dd9c9 100644
@@ -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,
accel/hvf/hvf-accel-ops.c +5 -5
index 2c0715a17f7..395b5a8e1c0 100644
@@ -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;
 
target/arm/hvf/hvf.c +2 -2
index 7b6d291e79c..c9cfcdc08bb 100644
@@ -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;
     }
 }
 
target/i386/hvf/hvf.c +2 -2
index 99e37a33e50..818b50419f4 100644
@@ -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)) {
target/i386/hvf/x86hvf.c +1 -1
index 2057314892a..17fce1d3cdd 100644
@@ -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);
     }
Signature · 1 line
2.49.0
#27 lore raw

[PULL 21/31] accel: Expose and register generic_handle_interrupt()

In reply to Philippe Mathieu-Daudé

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.

Message-Id: <[email protected]>

---
 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(-)
include/system/accel-ops.h +3 -0
index a4e706b49c9..e775ecc348c 100644
@@ -62,6 +62,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 mask);
 
     /**
@@ -86,4 +87,6 @@ struct AccelOpsClass {
     void (*remove_all_breakpoints)(CPUState *cpu);
 };
 
+void generic_handle_interrupt(CPUState *cpu, int mask);
+
 #endif /* ACCEL_OPS_H */
accel/hvf/hvf-accel-ops.c +1 -0
index 395b5a8e1c0..be8724ac896 100644
@@ -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;
accel/kvm/kvm-accel-ops.c +1 -0
index e5c15449aa6..0eafc902c3f 100644
@@ -101,6 +101,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;
accel/qtest/qtest.c +1 -0
index 612cede160b..5474ce73135 100644
@@ -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 = {
accel/xen/xen-all.c +1 -0
index c150dd43cab..c12c22de785 100644
@@ -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 = {
system/cpus.c +4 -6
index a43e0e4e796..0d0eec82a2f 100644
@@ -254,7 +254,7 @@ int64_t cpus_get_elapsed_ticks(void)
     return cpu_get_ticks();
 }
 
-static void generic_handle_interrupt(CPUState *cpu, int mask)
+void generic_handle_interrupt(CPUState *cpu, int mask)
 {
     cpu->interrupt_request |= mask;
 
@@ -267,11 +267,7 @@ void cpu_interrupt(CPUState *cpu, int mask)
 {
     g_assert(bql_locked());
 
-    if (cpus_accel->handle_interrupt) {
-        cpus_accel->handle_interrupt(cpu, mask);
-    } else {
-        generic_handle_interrupt(cpu, mask);
-    }
+    cpus_accel->handle_interrupt(cpu, mask);
 }
 
 /*
@@ -680,6 +676,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;
 }
 
target/i386/nvmm/nvmm-accel-ops.c +1 -0
index 21443078b72..a5517b0abf3 100644
@@ -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;
target/i386/whpx/whpx-accel-ops.c +1 -0
index b8bebe403c9..31cf15f0045 100644
@@ -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;
Signature · 1 line
2.49.0
#28 lore raw

[PULL 20/31] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h'

In reply to Philippe Mathieu-Daudé

'dummy' helpers are specific to accelerator implementations, no need to expose them via "system/cpus.h".

Message-Id: <[email protected]>

---
 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
MAINTAINERS +1 -0
index 0fd8b2a4e61..fca98e12195 100644
@@ -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
accel/dummy-cpus.h new file +14 -0
new file mode 100644
index 00000000000..d18dd0fdc51
@@ -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
include/system/cpus.h +0 -5
index 3226c765d01..69be6a77a75 100644
@@ -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 */
accel/dummy-cpus.c +1 -0
index 867276144fa..03cfc0fa01e 100644
@@ -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)
 {
accel/qtest/qtest.c +1 -0
index 92bed9264ce..612cede160b 100644
@@ -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;
 
accel/xen/xen-all.c +1 -0
index de52a8f882a..c150dd43cab 100644
@@ -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"
Signature · 1 line
2.49.0
#29 lore raw

[PULL 02/31] accel/kvm: Remove kvm_init_cpu_signals() stub

In reply to Philippe Mathieu-Daudé

Since commit 57038a92bb0 ("cpus: extract out kvm-specific code to accel/kvm") the kvm_init_cpu_signals() stub is not necessary.

Message-Id: <[email protected]>

---
 accel/stubs/kvm-stub.c | 5 -----
 1 file changed, 5 deletions(-)
accel/stubs/kvm-stub.c +0 -5
index ecfd7636f5f..b9b4427c919 100644
@@ -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;
Signature · 1 line
2.49.0
#30 lore raw

[PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>

---
 target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
target/i386/nvmm/nvmm-all.c +10 -11
index f1c6120ccf1..aea61a6fd2a 100644
@@ -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;
Signature · 1 line
2.49.0
#31 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 16 lines · Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>

---
  target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------
  1 file changed, 10 insertions(+), 11 deletions(-)
target/i386/nvmm/nvmm-all.c +0 -0
index f1c6120ccf1..aea61a6fd2a 100644

...

target/i386/nvmm/nvmm-all.c nvmm_init_vcpu(CPUState *cpu) · line 987

Quoted 9 lines
target/i386/nvmm/nvmm-all.c +1 -1
@@ -982,7 +981,7 @@ nvmm_init_vcpu(CPUState *cpu)
          }
      }
 
-    qcpu->dirty = true;
+    qcpu->vcpu_dirty = true;
      cpu->accel = qcpu;
 
      return 0;

FYI, this does not seem to compile:

../src/target/i386/nvmm/nvmm-all.c: In function 'nvmm_init_vcpu':
../src/target/i386/nvmm/nvmm-all.c:988:9: error: 'AccelCPUState' has no member named 'vcpu_dirty'
988 | qcpu->vcpu_dirty = true;
| ^~

Is anybody checking the netbsd builds at all?
(I'm currently trying to update test/vm/netbsd to version 10.1, that's how I noticed it)

Thomas

#32 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 28 lines · Thomas Huth
Quoted 16 lines · Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>
---
  target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------

  1 file changed, 10 insertions(+), 11 deletions(-)
target/i386/nvmm/nvmm-all.c +0 -0
index f1c6120ccf1..aea61a6fd2a 100644

...

target/i386/nvmm/nvmm-all.c nvmm_init_vcpu(CPUState *cpu) · line 985

Quoted 7 lines
target/i386/nvmm/nvmm-all.c +1 -1
@@ -982,7 +981,7 @@ nvmm_init_vcpu(CPUState *cpu)
           }
       }
-    qcpu->dirty = true;
+    qcpu->vcpu_dirty = true;
       cpu->accel = qcpu;
       return 0;

FYI, this does not seem to compile:

Quoted 4 lines

../src/target/i386/nvmm/nvmm-all.c: In function 'nvmm_init_vcpu':
../src/target/i386/nvmm/nvmm-all.c:988:9: error: 'AccelCPUState' has no member named 'vcpu_dirty'
  988 |     qcpu->vcpu_dirty = true;
      |         ^~

s/qcpu/cpu/

Quoted 2 lines

Is anybody checking the netbsd builds at all?

3 reviewers and 6 months later.

Should we add a policy for bitrotting untested code?

Quoted 4 lines

(I'm currently trying to update test/vm/netbsd to version 10.1, that's how I noticed it)

 Thomas

#33 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Thomas Huth
Quoted 16 lines · Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>
---
  target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------

  1 file changed, 10 insertions(+), 11 deletions(-)
target/i386/nvmm/nvmm-all.c +0 -0
index f1c6120ccf1..aea61a6fd2a 100644

...

target/i386/nvmm/nvmm-all.c nvmm_init_vcpu(CPUState *cpu) · line 985

Quoted 7 lines
target/i386/nvmm/nvmm-all.c +1 -1
@@ -982,7 +981,7 @@ nvmm_init_vcpu(CPUState *cpu)
           }
       }
-    qcpu->dirty = true;
+    qcpu->vcpu_dirty = true;
       cpu->accel = qcpu;
       return 0;

FYI, this does not seem to compile:

Quoted 4 lines

../src/target/i386/nvmm/nvmm-all.c: In function 'nvmm_init_vcpu':
../src/target/i386/nvmm/nvmm-all.c:988:9: error: 'AccelCPUState' has no member named 'vcpu_dirty' 988 |     qcpu->vcpu_dirty = true;
       |         ^~

Quoted 6 lines

s/qcpu/cpu/

Quoted 2 lines

Is anybody checking the netbsd builds at all?

3 reviewers and 6 months later.

and 7 commits on top of this PR :)

$ git log --oneline 2098164a6be..master -- target/i386/nvmm/nvmm-all.c
d5e1d2dea11 target/i386: clear CPU_INTERRUPT_SIPI for all accelerators
5699f6a4409 target/i386/nvmm: Inline cpu_physical_memory_rw() in nvmm_mem_callback
9a191d3782d cpus: clear exit_request in qemu_process_cpu_events
f084ff128b6 accel: use atomic accesses for exit_request
ac6c8a390b4 accel: use store_release/load_acquire for cross-thread exit_request
602d5ebba26 treewide: clear bits of cs->interrupt_request with cpu_reset_interrupt()
87511341c30 add cpu_test_interrupt()/cpu_set_interrupt() helpers and use them tree wide
f96b157ebb9 Merge tag 'accel-20250715' of https://github.com/philmd/qemu into staging
f7a7e7dd217 accel: Extract AccelClass definition to 'accel/accel-ops.h'
d93972d88b0 target/i386: nvmm, whpx: add accel/CPU class that sets host vendor
51e18961999 accel: Propagate AccelState to AccelClass::init_machine()
b6637bd5561 accel/nvmm: Expose nvmm_enabled() to common code
Quoted 8 lines

Should we add a policy for bitrotting untested code?

Quoted 4 lines

(I'm currently trying to update test/vm/netbsd to version 10.1, that's how I noticed it)

  Thomas

#34 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Philippe Mathieu-Daudé
Quoted 32 lines · Philippe Mathieu-Daudé
Quoted 18 lines · Thomas Huth
Quoted 16 lines · Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>
---
  target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------

  1 file changed, 10 insertions(+), 11 deletions(-)
target/i386/nvmm/nvmm-all.c +0 -0
index f1c6120ccf1..aea61a6fd2a 100644

...

Quoted 12 lines

target/i386/nvmm/nvmm-all.c nvmm_init_vcpu(CPUState *cpu) · line 985

Quoted 7 lines
target/i386/nvmm/nvmm-all.c +1 -1
@@ -982,7 +981,7 @@ nvmm_init_vcpu(CPUState *cpu)
           }
       }
-    qcpu->dirty = true;
+    qcpu->vcpu_dirty = true;
       cpu->accel = qcpu;
       return 0;

FYI, this does not seem to compile:
../src/target/i386/nvmm/nvmm-all.c: In function 'nvmm_init_vcpu':
../src/target/i386/nvmm/nvmm-all.c:988:9: error: 'AccelCPUState' has no member named 'vcpu_dirty'
  988 |     qcpu->vcpu_dirty = true;
      |         ^~

Quoted 5 lines

s/qcpu/cpu/

Quoted 1 line

Is anybody checking the netbsd builds at all?

3 reviewers and 6 months later.

I have good news! Because this does not compile since 10.1, and we're already in the 11.0 cycle, we can rip it out immediately without doing the deprecation dance.

Quoted 1 line

Should we add a policy for bitrotting untested code?

What policy do you have in mind?

Quoted 3 lines
Quoted 3 lines

(I'm currently trying to update test/vm/netbsd to version 10.1, that's how I noticed it)
 Thomas

#35 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 40 lines · Markus Armbruster
Quoted 32 lines · Philippe Mathieu-Daudé
Quoted 18 lines · Thomas Huth
Quoted 16 lines · Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>
---
  target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------

  1 file changed, 10 insertions(+), 11 deletions(-)
target/i386/nvmm/nvmm-all.c +0 -0
index f1c6120ccf1..aea61a6fd2a 100644

...

Quoted 12 lines

target/i386/nvmm/nvmm-all.c nvmm_init_vcpu(CPUState *cpu) · line 985

Quoted 7 lines
target/i386/nvmm/nvmm-all.c +1 -1
@@ -982,7 +981,7 @@ nvmm_init_vcpu(CPUState *cpu)
           }
       }
-    qcpu->dirty = true;
+    qcpu->vcpu_dirty = true;
       cpu->accel = qcpu;
       return 0;

FYI, this does not seem to compile:
../src/target/i386/nvmm/nvmm-all.c: In function 'nvmm_init_vcpu':
../src/target/i386/nvmm/nvmm-all.c:988:9: error: 'AccelCPUState' has no member named 'vcpu_dirty'
  988 |     qcpu->vcpu_dirty = true;
      |         ^~

Quoted 5 lines

s/qcpu/cpu/

Quoted 1 line

Is anybody checking the netbsd builds at all?

3 reviewers and 6 months later.

Quoted 7 lines

I have good news! Because this does not compile since 10.1, and we're already in the 11.0 cycle, we can rip it out immediately without doing the deprecation dance.

Quoted 1 line

Should we add a policy for bitrotting untested code?

What policy do you have in mind?

Implicitly I consider the policy to effectively be

(1) Platforms untested by GitLab CI are not guaranteed to work at any time, including in formal releases.
(2) No contributors/maintainers are obligated to investigate or fix breakage in untested platforms
(3) Those whom care about the platform are expected to perform manual testing and contribute fixes as required.

This doesn't imply we should automatically rip it out, but if we see no evidence of (3) for a prolonged period of time, and no sign of it being used downstream in any way, it is worth considering the cost / benefit.

In the case of NetBSD something must be working to some extent since it appears that 10.1.0 QEMU is present in the pkg repos:

https://pkgsrc.se/emulators/qemu

so that argues against ripping stuff out even if we notice breakage.

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

(I'm currently trying to update test/vm/netbsd to version 10.1, that's how I noticed it)
 Thomas

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#36 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 11 lines · Daniel P. Berrangé

This doesn't imply we should automatically rip it out, but if we see no evidence of (3) for a prolonged period of time, and no sign of it being used downstream in any way, it is worth considering the cost / benefit.

In the case of NetBSD something must be working to some extent since it appears that 10.1.0 QEMU is present in the pkg repos:

https://pkgsrc.se/emulators/qemu

so that argues against ripping stuff out even if we notice breakage.

And indeed their pkgsrc has the same patch that Philippe has now submitted for inclusion in qemu.git:

https://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/emulators/qemu/patches/patch-target_i386_nvmm_nvmm-all.c.diff?r1=1.10;r2=1.11

---- target/i386/nvmm/nvmm-all.c.orig 2024-11-20 22:48:05.000000000 +0000
+--- target/i386/nvmm/nvmm-all.c.orig 2025-08-26 18:32:38.000000000 +0000
+++ target/i386/nvmm/nvmm-all.c
-@@ -1057,7 +1057,11 @@ nvmm_process_section(MemoryRegionSection +@@ -984,7 +984,7 @@ nvmm_init_vcpu(CPUState *cpu)
+ }
+ }
+

+-    qcpu->vcpu_dirty = true;
++    cpu->vcpu_dirty = true;
+     cpu->accel = qcpu;
+
+     return 0;
+@@ -1059,7 +1059,11 @@ nvmm_process_section(MemoryRegionSection
      unsigned int delta;
      uintptr_t hva;
#37 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 24 lines · Paolo Bonzini
Quoted 11 lines · Daniel P. Berrangé

This doesn't imply we should automatically rip it out, but if we see no evidence of (3) for a prolonged period of time, and no sign of it being used downstream in any way, it is worth considering the cost / benefit.

In the case of NetBSD something must be working to some extent since it appears that 10.1.0 QEMU is present in the pkg repos:

https://pkgsrc.se/emulators/qemu

so that argues against ripping stuff out even if we notice breakage.

And indeed their pkgsrc has the same patch that Philippe has now submitted for inclusion in qemu.git:

https://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/emulators/qemu/patches/patch-target_i386_nvmm_nvmm-all.c.diff?r1=1.10;r2=1.11

---- target/i386/nvmm/nvmm-all.c.orig 2024-11-20 22:48:05.000000000 +0000
+--- target/i386/nvmm/nvmm-all.c.orig 2025-08-26 18:32:38.000000000 +0000
+++ target/i386/nvmm/nvmm-all.c
-@@ -1057,7 +1057,11 @@ nvmm_process_section(MemoryRegionSection +@@ -984,7 +984,7 @@ nvmm_init_vcpu(CPUState *cpu)

(quoted diff) +1 -0
+         }

Review

Quoted 10 lines
(quoted diff) +8 -0
+     }
+
+-    qcpu->vcpu_dirty = true;
++    cpu->vcpu_dirty = true;
+     cpu->accel = qcpu;
+
+     return 0;
+@@ -1059,7 +1059,11 @@ nvmm_process_section(MemoryRegionSection
      unsigned int delta;
      uintptr_t hva;

That they didn't immediately post the fix upstream is a bit of a disappointment. Deep in the weeds, I guess.

#38 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 11 lines · Markus Armbruster
Quoted 11 lines

---- target/i386/nvmm/nvmm-all.c.orig 2024-11-20 22:48:05.000000000 +0000
+--- target/i386/nvmm/nvmm-all.c.orig 2025-08-26 18:32:38.000000000 +0000
+++ target/i386/nvmm/nvmm-all.c
-@@ -1057,7 +1057,11 @@ nvmm_process_section(MemoryRegionSection +@@ -984,7 +984,7 @@ nvmm_init_vcpu(CPUState *cpu)

(quoted diff) +6 -0
+         }
+     }
+
+-    qcpu->vcpu_dirty = true;
++    cpu->vcpu_dirty = true;
+     cpu->accel = qcpu;
Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +3 -0
+
+     return 0;
+@@ -1059,7 +1059,11 @@ nvmm_process_section(MemoryRegionSection
       unsigned int delta;
       uintptr_t hva;

That they didn't immediately post the fix upstream is a bit of a disappointment. Deep in the weeds, I guess.

Eh, it happens. :/ For the future, since Ryo and Reinoud are in Cc, it would have been enough to contact anyone on IRC or reply to the release announcement.

Paolo

#39 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 20 lines · Paolo Bonzini
Quoted 10 lines · Markus Armbruster
Quoted 10 lines

---- target/i386/nvmm/nvmm-all.c.orig 2024-11-20 22:48:05.000000000 +0000
+--- target/i386/nvmm/nvmm-all.c.orig 2025-08-26 18:32:38.000000000 +0000
+++ target/i386/nvmm/nvmm-all.c
-@@ -1057,7 +1057,11 @@ nvmm_process_section(MemoryRegionSection +@@ -984,7 +984,7 @@ nvmm_init_vcpu(CPUState *cpu)

(quoted diff) +5 -0
+         }
+     }
+
+-    qcpu->vcpu_dirty = true;
++    cpu->vcpu_dirty = true;
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +4 -0
+     cpu->accel = qcpu;
+
+     return 0;
+@@ -1059,7 +1059,11 @@ nvmm_process_section(MemoryRegionSection
       unsigned int delta;
       uintptr_t hva;

That they didn't immediately post the fix upstream is a bit of a disappointment. Deep in the weeds, I guess.

Quoted 1 line

Eh, it happens. :/ For the future, since Ryo and Reinoud are in Cc, it would have been enough to contact anyone on IRC or reply to the release announcement.

Yes, it happens, especially when you're deep in the weeds.

#40 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Markus Armbruster
Quoted 2 lines · Markus Armbruster

That they didn't immediately post the fix upstream is a bit of a disappointment. Deep in the weeds, I guess.

Sorry to break this but even submitting simple patches and getting them into the qemu source tree hasn't been an easy nor enjoyable experience to me to understate it so once in a while, a new version is pulled into pkgsrc and patches are made on top and if they start to grow or diverge too much a patch round can be made requested on the qemu repo. This is just my experience of course.

With regards,
Reinoud

#41 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

#42 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Reinoud Zandijk
Quoted 7 lines · Reinoud Zandijk
Quoted 2 lines · Markus Armbruster

That they didn't immediately post the fix upstream is a bit of a disappointment. Deep in the weeds, I guess.

Sorry to break this but even submitting simple patches and getting them into the qemu source tree hasn't been an easy nor enjoyable experience to me to understate it

Have you actually tried since 2021 when your last commit was? https://patchew.org/search?q=project%3AQEMU+from%3Areinoud says you didn't but I may be missing something.

In fact your only contribution was a really big one, and I say this not to understate you work but because *almost anything* would be easier than submitting a new accelerator.

Quoted 4 lines

so once in a while, a new version is pulled into pkgsrc and patches are made on top and if they start to grow or diverge too much a patch round can be made requested on the qemu repo. This is just my experience of course.

We're not asking you to keep CI up-to-date (which Thomas is doing now, despite having no specific need that I know of to support NetBSD), just to *report* failure to build from source and tell us "hey, that's how we fixed it". Otherwise we have the false impression that no one even cares about new QEMU on NetBSD.

Thanks,

Paolo

ps: sorry about the previous copy of the message, I somehow fat-fingered the "encrypt message" command...

#43 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 5 lines · Paolo Bonzini
Quoted 3 lines · Reinoud Zandijk

Sorry to break this but even submitting simple patches and getting them into the qemu source tree hasn't been an easy nor enjoyable experience to me to understate it

Quoted 7 lines

Have you actually tried since 2021 when your last commit was?
https://patchew.org/search?q=project%3AQEMU+from%3Areinoud says you didn't but I may be missing something.

In fact your only contribution was a really big one, and I say this not to understate you work but because *almost anything* would be easier than submitting a new accelerator.

I can't claim all the credits :) Most of the low level work was done by maxv, the author of NVMM. IIRC I updated the local patch and modified it to work with the newer build framework and committed it into the tree. I have to admit I haven't contributed more since but I still use Qemu daily, with the NVMM accelerator :) It makes such a big difference.

Quoted 10 lines
Quoted 4 lines

so once in a while, a new version is pulled into pkgsrc and patches are made on top and if they start to grow or diverge too much a patch round can be made requested on the qemu repo. This is just my experience of course.

We're not asking you to keep CI up-to-date (which Thomas is doing now, despite having no specific need that I know of to support NetBSD), just to *report* failure to build from source and tell us "hey, that's how we fixed it". Otherwise we have the false impression that no one even cares about new QEMU on NetBSD.

As pkgsrc normally tracks releases and has a directory with local patches on top of that, build errors only show up when we bump the version. Version 10.2 is now in pkgsrc though I am running 10.1.3 so there is surely interest in keeping it running. I could try to commit some more trivial patches in the repo here to reduce the diffs some more.

Thanks for the feedback,
Reinoud

#44 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 2 lines · Reinoud Zandijk
Quoted 1 line · Paolo Bonzini

On 1/14/26 12:28, Reinoud Zandijk wrote:

[...]

Quoted 11 lines
Quoted 5 lines

We're not asking you to keep CI up-to-date (which Thomas is doing now, despite having no specific need that I know of to support NetBSD), just to *report* failure to build from source and tell us "hey, that's how we fixed it". Otherwise we have the false impression that no one even cares about new QEMU on NetBSD.

As pkgsrc normally tracks releases and has a directory with local patches on top of that, build errors only show up when we bump the version. Version 10.2 is now in pkgsrc though I am running 10.1.3 so there is surely interest in keeping it running. I could try to commit some more trivial patches in the repo here to reduce the diffs some more.

Fixing the build long after it broke is less than ideal. What would it take to get NetBSD covered in CI?

#45 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 13 lines · Markus Armbruster
Quoted 2 lines · Reinoud Zandijk
Quoted 1 line · Paolo Bonzini

On 1/14/26 12:28, Reinoud Zandijk wrote:

[...]

Quoted 6 lines
Quoted 5 lines

We're not asking you to keep CI up-to-date (which Thomas is doing now, despite having no specific need that I know of to support NetBSD), just to *report* failure to build from source and tell us "hey, that's how we fixed it". Otherwise we have the false impression that no one even cares about new QEMU on NetBSD.

Quoted 8 lines
Quoted 5 lines

As pkgsrc normally tracks releases and has a directory with local patches on top of that, build errors only show up when we bump the version. Version 10.2 is now in pkgsrc though I am running 10.1.3 so there is surely interest in keeping it running. I could try to commit some more trivial patches in the repo here to reduce the diffs some more.

Fixing the build long after it broke is less than ideal. What would it take to get NetBSD covered in CI?

We have the ability to run tests via the vm-build:

make vm-build-netbsd

however to take full advantage that needs a runner with a reasonable amount of memory and access to KVM so it can run reasonably fast. Does anyone want to host a dedicated x86_64 custom runner?

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#46 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

Quoted 24 lines · Alex Bennée
Quoted 13 lines · Markus Armbruster
Quoted 2 lines · Reinoud Zandijk
Quoted 1 line · Paolo Bonzini

On 1/14/26 12:28, Reinoud Zandijk wrote:

[...]

Quoted 6 lines
Quoted 5 lines

We're not asking you to keep CI up-to-date (which Thomas is doing now, despite having no specific need that I know of to support NetBSD), just to *report* failure to build from source and tell us "hey, that's how we fixed it". Otherwise we have the false impression that no one even cares about new QEMU on NetBSD.

Quoted 8 lines
Quoted 5 lines

As pkgsrc normally tracks releases and has a directory with local patches on top of that, build errors only show up when we bump the version. Version 10.2 is now in pkgsrc though I am running 10.1.3 so there is surely interest in keeping it running. I could try to commit some more trivial patches in the repo here to reduce the diffs some more.

Fixing the build long after it broke is less than ideal. What would it take to get NetBSD covered in CI?

Quoted 7 lines

We have the ability to run tests via the vm-build:

make vm-build-netbsd

however to take full advantage that needs a runner with a reasonable amount of memory and access to KVM so it can run reasonably fast. Does anyone want to host a dedicated x86_64 custom runner?

Pierrick had a clever & simpler way to get that:
https://lore.kernel.org/qemu-devel/[email protected]/

#47 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Reinoud Zandijk
Quoted 6 lines · Reinoud Zandijk
Quoted 2 lines · Markus Armbruster

That they didn't immediately post the fix upstream is a bit of a disappointment. Deep in the weeds, I guess.

Sorry to break this but even submitting simple patches and getting them into the qemu source tree hasn't been an easy nor enjoyable experience to me

Sorry to hear that (and yes, I agree, it can be difficult indeed some times for bigger patch sets), but at least for simple patches like this one-line fix, you can always CC: [email protected] which should help to get those in rather easily, I hope.

HTH,
Thomas

#48 lore raw

Policy regarding platforms / features with out CI coverage (was: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field)

In reply to Daniel P. Berrangé
Quoted 2 lines · Daniel P. Berrangé
Quoted 1 line · Markus Armbruster

Philippe Mathieu-Daudé <[email protected]> writes:

[...]

Quoted 13 lines
Quoted 3 lines
Quoted 1 line

Should we add a policy for bitrotting untested code?

What policy do you have in mind?

Implicitly I consider the policy to effectively be

(1) Platforms untested by GitLab CI are not guaranteed to work at any time, including in formal releases.
(2) No contributors/maintainers are obligated to investigate or fix breakage in untested platforms
(3) Those whom care about the platform are expected to perform manual testing and contribute fixes as required.

Quoted 4 lines

This doesn't imply we should automatically rip it out, but if we see no evidence of (3) for a prolonged period of time, and no sign of it being used downstream in any way, it is worth considering the cost / benefit.

Sounds good to me. Put it in docs/ somewhere?

[...]

#49 lore raw

Re: [PULL 13/31] accel/nvmm: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Philippe Mathieu-Daudé
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Thomas Huth
Quoted 16 lines · Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>
---
  target/i386/nvmm/nvmm-all.c | 21 ++++++++++-----------

  1 file changed, 10 insertions(+), 11 deletions(-)
target/i386/nvmm/nvmm-all.c +0 -0
index f1c6120ccf1..aea61a6fd2a 100644

...

target/i386/nvmm/nvmm-all.c nvmm_init_vcpu(CPUState *cpu) · line 985

Quoted 7 lines
target/i386/nvmm/nvmm-all.c +1 -1
@@ -982,7 +981,7 @@ nvmm_init_vcpu(CPUState *cpu)
           }
       }
-    qcpu->dirty = true;
+    qcpu->vcpu_dirty = true;
       cpu->accel = qcpu;
       return 0;

FYI, this does not seem to compile:

Quoted 5 lines

../src/target/i386/nvmm/nvmm-all.c: In function 'nvmm_init_vcpu':
../src/target/i386/nvmm/nvmm-all.c:988:9: error: 'AccelCPUState' has no member named 'vcpu_dirty'
  988 |     qcpu->vcpu_dirty = true;
      |         ^~

Quoted 8 lines

s/qcpu/cpu/

Quoted 2 lines

Is anybody checking the netbsd builds at all?

3 reviewers and 6 months later.

Should we add a policy for bitrotting untested code?

Since we don't cover netbsd in GitLab CI, all responsibility for keeping it working lies with whomever cares about the distro. No contributors or maintainers in general should feel obligated to fix bugs in untested platforms unless they specifically care about the platform.

Quoted 2 lines
Quoted 2 lines

(I'm currently trying to update test/vm/netbsd to version 10.1, that's how I noticed it)

MAINTAINERS lists no one against test/vm/netbsd.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#50 lore raw

[PULL 14/31] accel/whpx: Replace @dirty field by generic CPUState::vcpu_dirty field

In reply to Philippe Mathieu-Daudé

No need for accel-specific @dirty field when we have a generic one in CPUState.

Message-Id: <[email protected]>

---
 target/i386/whpx/whpx-all.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
target/i386/whpx/whpx-all.c +11 -12
index cf6d3e4cdd4..5001afad3a7 100644
@@ -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);
Signature · 1 line
2.49.0