* [PULL v2 08/36] accel/tcg: Clear exit_request once in tcg_cpu_exec()
2025-07-04 13:24 [PULL v2 00/36] Accelerators patches for 2025-07-04 Philippe Mathieu-Daudé
@ 2025-07-04 13:24 ` Philippe Mathieu-Daudé
2025-07-04 13:24 ` [PULL v2 09/36] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
` (5 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 13:24 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250701144017.43487-62-philmd@linaro.org>
---
accel/tcg/tcg-accel-ops-mttcg.c | 1 -
accel/tcg/tcg-accel-ops.c | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index dfcee30947e..337b993d3da 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -113,7 +113,6 @@ static void *mttcg_cpu_thread_fn(void *arg)
}
}
- qatomic_set_mb(&cpu->exit_request, 0);
qemu_wait_io_event(cpu);
} while (!cpu->unplug || cpu_can_run(cpu));
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 6116644d1c0..71776bc29c0 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -80,6 +80,9 @@ int tcg_cpu_exec(CPUState *cpu)
cpu_exec_start(cpu);
ret = cpu_exec(cpu);
cpu_exec_end(cpu);
+
+ qatomic_set_mb(&cpu->exit_request, 0);
+
return ret;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL v2 09/36] accel/tcg: Unregister the RCU before exiting RR thread
2025-07-04 13:24 [PULL v2 00/36] Accelerators patches for 2025-07-04 Philippe Mathieu-Daudé
2025-07-04 13:24 ` [PULL v2 08/36] accel/tcg: Clear exit_request once in tcg_cpu_exec() Philippe Mathieu-Daudé
@ 2025-07-04 13:24 ` Philippe Mathieu-Daudé
2025-07-10 14:33 ` Peter Maydell
2025-07-04 13:24 ` [PULL v2 13/36] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
` (4 subsequent siblings)
6 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 13:24 UTC (permalink / raw)
To: qemu-devel
Although unreachable, still unregister the RCU before exiting
the thread, as documented in "qemu/rcu.h":
/*
* Important !
*
* Each thread containing read-side critical sections must be registered
* with rcu_register_thread() before calling rcu_read_lock().
* rcu_unregister_thread() should be called before the thread exits.
*/
Unregister the RCU to be on par with what is done for other
accelerators.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20250702185332.43650-66-philmd@linaro.org>
---
accel/tcg/tcg-accel-ops-rr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index 6eec5c9eee9..a578698d071 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -302,6 +302,8 @@ static void *rr_cpu_thread_fn(void *arg)
rr_deal_with_unplugged_cpus();
}
+ rcu_unregister_thread();
+
g_assert_not_reached();
}
--
2.49.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PULL v2 09/36] accel/tcg: Unregister the RCU before exiting RR thread
2025-07-04 13:24 ` [PULL v2 09/36] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
@ 2025-07-10 14:33 ` Peter Maydell
2025-07-11 10:45 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2025-07-10 14:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Fri, 4 Jul 2025 at 14:25, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Although unreachable, still unregister the RCU before exiting
> the thread, as documented in "qemu/rcu.h":
>
> /*
> * Important !
> *
> * Each thread containing read-side critical sections must be registered
> * with rcu_register_thread() before calling rcu_read_lock().
> * rcu_unregister_thread() should be called before the thread exits.
> */
>
> Unregister the RCU to be on par with what is done for other
> accelerators.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> Message-Id: <20250702185332.43650-66-philmd@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
> index 6eec5c9eee9..a578698d071 100644
> --- a/accel/tcg/tcg-accel-ops-rr.c
> +++ b/accel/tcg/tcg-accel-ops-rr.c
> @@ -302,6 +302,8 @@ static void *rr_cpu_thread_fn(void *arg)
> rr_deal_with_unplugged_cpus();
> }
>
> + rcu_unregister_thread();
> +
> g_assert_not_reached();
> }
This has reintroduced CID 1547782 (unreachable code).
We can't get to this point, so why are we trying to call a
function here ? This is not a place where the thread can exit.
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL v2 09/36] accel/tcg: Unregister the RCU before exiting RR thread
2025-07-10 14:33 ` Peter Maydell
@ 2025-07-11 10:45 ` Philippe Mathieu-Daudé
2025-07-11 12:17 ` Peter Maydell
0 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-11 10:45 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
On 10/7/25 16:33, Peter Maydell wrote:
> On Fri, 4 Jul 2025 at 14:25, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Although unreachable, still unregister the RCU before exiting
>> the thread, as documented in "qemu/rcu.h":
>>
>> /*
>> * Important !
>> *
>> * Each thread containing read-side critical sections must be registered
>> * with rcu_register_thread() before calling rcu_read_lock().
>> * rcu_unregister_thread() should be called before the thread exits.
>> */
>>
>> Unregister the RCU to be on par with what is done for other
>> accelerators.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Acked-by: Richard Henderson <richard.henderson@linaro.org>
>> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>> Message-Id: <20250702185332.43650-66-philmd@linaro.org>
>> ---
>> accel/tcg/tcg-accel-ops-rr.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
>> index 6eec5c9eee9..a578698d071 100644
>> --- a/accel/tcg/tcg-accel-ops-rr.c
>> +++ b/accel/tcg/tcg-accel-ops-rr.c
>> @@ -302,6 +302,8 @@ static void *rr_cpu_thread_fn(void *arg)
>> rr_deal_with_unplugged_cpus();
>> }
>>
>> + rcu_unregister_thread();
>> +
>> g_assert_not_reached();
>> }
>
> This has reintroduced CID 1547782 (unreachable code).
>
> We can't get to this point, so why are we trying to call a
> function here ? This is not a place where the thread can exit.
The goal is to unify accelerators vcpu thread logic and
eventually remove AccelOpsClass::create_vcpu_thread(), superseded
by AccelOpsClass::cpu_thread_routine(). I couldn't finish RR for
10.1 but squeezed this patch in. Let's revert it, and I'll
re-commit it later.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL v2 09/36] accel/tcg: Unregister the RCU before exiting RR thread
2025-07-11 10:45 ` Philippe Mathieu-Daudé
@ 2025-07-11 12:17 ` Peter Maydell
0 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2025-07-11 12:17 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Fri, 11 Jul 2025 at 11:45, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> On 10/7/25 16:33, Peter Maydell wrote:
> > This has reintroduced CID 1547782 (unreachable code).
> >
> > We can't get to this point, so why are we trying to call a
> > function here ? This is not a place where the thread can exit.
>
> The goal is to unify accelerators vcpu thread logic and
> eventually remove AccelOpsClass::create_vcpu_thread(), superseded
> by AccelOpsClass::cpu_thread_routine(). I couldn't finish RR for
> 10.1 but squeezed this patch in. Let's revert it, and I'll
> re-commit it later.
When you do have a need for it, note that rcu_unregister_thread()
is probably not the only call you need here -- see commit
da7510b720591. We used to also have an equally unreachable
rcu_remove_force_rcu_notifier() call.
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PULL v2 13/36] accel/hvf: Report missing com.apple.security.hypervisor entitlement
2025-07-04 13:24 [PULL v2 00/36] Accelerators patches for 2025-07-04 Philippe Mathieu-Daudé
2025-07-04 13:24 ` [PULL v2 08/36] accel/tcg: Clear exit_request once in tcg_cpu_exec() Philippe Mathieu-Daudé
2025-07-04 13:24 ` [PULL v2 09/36] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
@ 2025-07-04 13:24 ` Philippe Mathieu-Daudé
2025-07-04 13:24 ` [PULL v2 26/36] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
` (3 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 13:24 UTC (permalink / raw)
To: qemu-devel
We need the QEMU binary signed to be able to use HVF.
Improve the following:
$ ./qemu-system-aarch64-unsigned -M virt -accel hvf
qemu-system-aarch64-unsigned: -accel hvf: Error: ret = HV_DENIED (0xfae94007, at ../../accel/hvf/hvf-accel-ops.c:339)
Abort trap: 6
to:
$ ./qemu-system-aarch64-unsigned -M virt -accel hvf
qemu-system-aarch64-unsigned: -accel hvf: Could not access HVF. Is the executable signed with com.apple.security.hypervisor entitlement?
Suggested-by: Shatyuka <shatyuka@qq.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2800
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mads Ynddal <mads@ynddal.dk>
Message-Id: <20250702185332.43650-29-philmd@linaro.org>
---
accel/hvf/hvf-all.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index ddc77e629f5..09fe3f24152 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -263,6 +263,11 @@ static int hvf_accel_init(MachineState *ms)
}
ret = hvf_arch_vm_create(ms, (uint32_t)pa_range);
+ if (ret == HV_DENIED) {
+ error_report("Could not access HVF. Is the executable signed"
+ " with com.apple.security.hypervisor entitlement?");
+ exit(1);
+ }
assert_hvf_ok(ret);
s = g_new0(HVFState, 1);
--
2.49.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL v2 26/36] accel: Propagate AccelState to AccelClass::init_machine()
2025-07-04 13:24 [PULL v2 00/36] Accelerators patches for 2025-07-04 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-07-04 13:24 ` [PULL v2 13/36] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
@ 2025-07-04 13:24 ` Philippe Mathieu-Daudé
2025-07-04 13:24 ` [PULL v2 27/36] accel/hvf: Re-use QOM allocated state Philippe Mathieu-Daudé
` (2 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 13:24 UTC (permalink / raw)
To: qemu-devel
In order to avoid init_machine() to call current_accel(),
pass AccelState along.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20250703173248.44995-31-philmd@linaro.org>
---
include/qemu/accel.h | 2 +-
accel/accel-system.c | 2 +-
accel/hvf/hvf-all.c | 2 +-
accel/kvm/kvm-all.c | 2 +-
accel/qtest/qtest.c | 2 +-
accel/tcg/tcg-all.c | 2 +-
accel/xen/xen-all.c | 2 +-
bsd-user/main.c | 2 +-
linux-user/main.c | 2 +-
target/i386/nvmm/nvmm-all.c | 2 +-
target/i386/whpx/whpx-all.c | 2 +-
11 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 9dea3145429..b9a9b3593d8 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -40,7 +40,7 @@ typedef struct AccelClass {
/* Cached by accel_init_ops_interfaces() when created */
AccelOpsClass *ops;
- int (*init_machine)(MachineState *ms);
+ int (*init_machine)(AccelState *as, MachineState *ms);
bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
void (*cpu_common_unrealize)(CPUState *cpu);
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 64bc991b1ce..913b7155d77 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -37,7 +37,7 @@ int accel_init_machine(AccelState *accel, MachineState *ms)
int ret;
ms->accelerator = accel;
*(acc->allowed) = true;
- ret = acc->init_machine(ms);
+ ret = acc->init_machine(accel, ms);
if (ret < 0) {
ms->accelerator = NULL;
*(acc->allowed) = false;
diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index 09fe3f24152..9e4012e2d10 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -247,7 +247,7 @@ static MemoryListener hvf_memory_listener = {
.log_sync = hvf_log_sync,
};
-static int hvf_accel_init(MachineState *ms)
+static int hvf_accel_init(AccelState *as, MachineState *ms)
{
int x;
hv_return_t ret;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 17235f26464..264f288dc64 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2573,7 +2573,7 @@ static int kvm_setup_dirty_ring(KVMState *s)
return 0;
}
-static int kvm_init(MachineState *ms)
+static int kvm_init(AccelState *as, MachineState *ms)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
static const char upgrade_note[] =
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 5474ce73135..2b831260201 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -38,7 +38,7 @@ static void qtest_set_virtual_clock(int64_t count)
qatomic_set_i64(&qtest_clock_counter, count);
}
-static int qtest_init_accel(MachineState *ms)
+static int qtest_init_accel(AccelState *as, MachineState *ms)
{
return 0;
}
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 6e5dc333d59..d68fbb23773 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -80,7 +80,7 @@ static void tcg_accel_instance_init(Object *obj)
bool one_insn_per_tb;
-static int tcg_init_machine(MachineState *ms)
+static int tcg_init_machine(AccelState *as, MachineState *ms)
{
TCGState *s = TCG_STATE(current_accel());
unsigned max_threads = 1;
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index c12c22de785..8279746f115 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -77,7 +77,7 @@ static void xen_setup_post(MachineState *ms, AccelState *accel)
}
}
-static int xen_init(MachineState *ms)
+static int xen_init(AccelState *as, MachineState *ms)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 7c0a059c3ba..d0cc8e0088f 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -474,7 +474,7 @@ int main(int argc, char **argv)
opt_one_insn_per_tb, &error_abort);
object_property_set_int(OBJECT(accel), "tb-size",
opt_tb_size, &error_abort);
- ac->init_machine(NULL);
+ ac->init_machine(accel, NULL);
}
/*
diff --git a/linux-user/main.c b/linux-user/main.c
index 5ac5b55dc65..a9142ee7268 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -820,7 +820,7 @@ int main(int argc, char **argv, char **envp)
opt_one_insn_per_tb, &error_abort);
object_property_set_int(OBJECT(accel), "tb-size",
opt_tb_size, &error_abort);
- ac->init_machine(NULL);
+ ac->init_machine(accel, NULL);
}
/*
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index 2df49d7eeb4..b4a4d50e860 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -1152,7 +1152,7 @@ static struct RAMBlockNotifier nvmm_ram_notifier = {
/* -------------------------------------------------------------------------- */
static int
-nvmm_accel_init(MachineState *ms)
+nvmm_accel_init(AccelState *as, MachineState *ms)
{
int ret, err;
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 94fd5fc7849..721c4782b9c 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2504,7 +2504,7 @@ static void whpx_set_kernel_irqchip(Object *obj, Visitor *v,
* Partition support
*/
-static int whpx_accel_init(MachineState *ms)
+static int whpx_accel_init(AccelState *as, MachineState *ms)
{
struct whpx_state *whpx;
int ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL v2 27/36] accel/hvf: Re-use QOM allocated state
2025-07-04 13:24 [PULL v2 00/36] Accelerators patches for 2025-07-04 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-07-04 13:24 ` [PULL v2 26/36] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
@ 2025-07-04 13:24 ` Philippe Mathieu-Daudé
2025-07-04 13:24 ` [PULL v2 34/36] accel/system: Convert pre_resume() from AccelOpsClass to AccelClass Philippe Mathieu-Daudé
2025-07-08 7:25 ` [PULL v2 00/36] Accelerators patches for 2025-07-04 Stefan Hajnoczi
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 13:24 UTC (permalink / raw)
To: qemu-devel
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250606164418.98655-8-philmd@linaro.org>
---
accel/hvf/hvf-all.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
index 9e4012e2d10..df95ba74d6e 100644
--- a/accel/hvf/hvf-all.c
+++ b/accel/hvf/hvf-all.c
@@ -251,7 +251,7 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
{
int x;
hv_return_t ret;
- HVFState *s;
+ HVFState *s = HVF_STATE(as);
int pa_range = 36;
MachineClass *mc = MACHINE_GET_CLASS(ms);
@@ -270,8 +270,6 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
}
assert_hvf_ok(ret);
- s = g_new0(HVFState, 1);
-
s->num_slots = ARRAY_SIZE(s->slots);
for (x = 0; x < s->num_slots; ++x) {
s->slots[x].size = 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL v2 34/36] accel/system: Convert pre_resume() from AccelOpsClass to AccelClass
2025-07-04 13:24 [PULL v2 00/36] Accelerators patches for 2025-07-04 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-07-04 13:24 ` [PULL v2 27/36] accel/hvf: Re-use QOM allocated state Philippe Mathieu-Daudé
@ 2025-07-04 13:24 ` Philippe Mathieu-Daudé
2025-07-08 7:25 ` [PULL v2 00/36] Accelerators patches for 2025-07-04 Stefan Hajnoczi
6 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-04 13:24 UTC (permalink / raw)
To: qemu-devel
Accelerators call pre_resume() once. Since it isn't a method to
call for each vCPU, move it from AccelOpsClass to AccelClass.
Adapt WHPX.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250702185332.43650-21-philmd@linaro.org>
---
include/qemu/accel.h | 3 +++
include/system/accel-ops.h | 1 -
target/i386/whpx/whpx-accel-ops.h | 1 -
accel/accel-system.c | 9 +++++++++
system/cpus.c | 4 +---
target/i386/whpx/whpx-accel-ops.c | 1 -
target/i386/whpx/whpx-all.c | 3 ++-
7 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 1c097ac4dfb..f2bfc02d61e 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -51,6 +51,7 @@ typedef struct AccelClass {
/* gdbstub related hooks */
int (*gdbstub_supported_sstep_flags)(AccelState *as);
+ void (*pre_resume_vm)(AccelState *as, bool step_pending);
bool *allowed;
/*
@@ -86,6 +87,8 @@ int accel_init_machine(AccelState *accel, MachineState *ms);
/* Called just before os_setup_post (ie just before drop OS privs) */
void accel_setup_post(MachineState *ms);
+void accel_pre_resume(MachineState *ms, bool step_pending);
+
/**
* accel_cpu_instance_init:
* @cpu: The CPU that needs to do accel-specific object initializations.
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index a786c7d478a..bf7383511d0 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -61,7 +61,6 @@ struct AccelOpsClass {
*/
void (*synchronize_state)(CPUState *cpu);
void (*synchronize_pre_loadvm)(CPUState *cpu);
- void (*synchronize_pre_resume)(bool step_pending);
/* handle_interrupt is mandatory. */
void (*handle_interrupt)(CPUState *cpu, int mask);
diff --git a/target/i386/whpx/whpx-accel-ops.h b/target/i386/whpx/whpx-accel-ops.h
index e6cf15511d4..54cfc25a147 100644
--- a/target/i386/whpx/whpx-accel-ops.h
+++ b/target/i386/whpx/whpx-accel-ops.h
@@ -21,7 +21,6 @@ void whpx_cpu_synchronize_state(CPUState *cpu);
void whpx_cpu_synchronize_post_reset(CPUState *cpu);
void whpx_cpu_synchronize_post_init(CPUState *cpu);
void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu);
-void whpx_cpu_synchronize_pre_resume(bool step_pending);
/* state subset only touched by the VCPU itself during runtime */
#define WHPX_SET_RUNTIME_STATE 1
diff --git a/accel/accel-system.c b/accel/accel-system.c
index af713cc9024..c54c30f18ba 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -62,6 +62,15 @@ void accel_setup_post(MachineState *ms)
}
}
+void accel_pre_resume(MachineState *ms, bool step_pending)
+{
+ AccelState *accel = ms->accelerator;
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ if (acc->pre_resume_vm) {
+ acc->pre_resume_vm(accel, step_pending);
+ }
+}
+
/* initialize the arch-independent accel operation interfaces */
void accel_init_ops_interfaces(AccelClass *ac)
{
diff --git a/system/cpus.c b/system/cpus.c
index 0d0eec82a2f..8e6da2e0606 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -768,9 +768,7 @@ int vm_prepare_start(bool step_pending)
* WHPX accelerator needs to know whether we are going to step
* any CPUs, before starting the first one.
*/
- if (cpus_accel->synchronize_pre_resume) {
- cpus_accel->synchronize_pre_resume(step_pending);
- }
+ accel_pre_resume(MACHINE(qdev_get_machine()), step_pending);
/* We are sending this now, but the CPUs will be resumed shortly later */
qapi_event_send_resume();
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index 31cf15f0045..5f4841c9fa4 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -96,7 +96,6 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
ops->synchronize_state = whpx_cpu_synchronize_state;
ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm;
- ops->synchronize_pre_resume = whpx_cpu_synchronize_pre_resume;
}
static const TypeInfo whpx_accel_ops_type = {
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 721c4782b9c..faf56e19722 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2105,7 +2105,7 @@ void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu)
run_on_cpu(cpu, do_whpx_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL);
}
-void whpx_cpu_synchronize_pre_resume(bool step_pending)
+static void whpx_pre_resume_vm(AccelState *as, bool step_pending)
{
whpx_global.step_pending = step_pending;
}
@@ -2697,6 +2697,7 @@ static void whpx_accel_class_init(ObjectClass *oc, const void *data)
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "WHPX";
ac->init_machine = whpx_accel_init;
+ ac->pre_resume_vm = whpx_pre_resume_vm;
ac->allowed = &whpx_allowed;
object_class_property_add(oc, "kernel-irqchip", "on|off|split",
--
2.49.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PULL v2 00/36] Accelerators patches for 2025-07-04
2025-07-04 13:24 [PULL v2 00/36] Accelerators patches for 2025-07-04 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-07-04 13:24 ` [PULL v2 34/36] accel/system: Convert pre_resume() from AccelOpsClass to AccelClass Philippe Mathieu-Daudé
@ 2025-07-08 7:25 ` Stefan Hajnoczi
6 siblings, 0 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2025-07-08 7:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.1 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread