On 23/7/25 17:49, Peter Maydell wrote:
On Wed, 23 Jul 2025 at 14:52, Philippe Mathieu-Daudé <phi...@linaro.org> wrote:
Allow accelerators to set vCPU properties before its realization.
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
---
include/accel/accel-cpu-ops.h | 1 +
accel/accel-common.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/include/accel/accel-cpu-ops.h b/include/accel/accel-cpu-ops.h
index 0674764914f..9c07a903ea0 100644
--- a/include/accel/accel-cpu-ops.h
+++ b/include/accel/accel-cpu-ops.h
@@ -34,6 +34,7 @@ struct AccelOpsClass {
/* initialization function called when accel is chosen */
void (*ops_init)(AccelClass *ac);
+ bool (*cpu_target_realize)(CPUState *cpu, Error **errp);
bool (*cpus_are_resettable)(void);
void (*cpu_reset_hold)(CPUState *cpu);
diff --git a/accel/accel-common.c b/accel/accel-common.c
index 850c5ab4b8e..eecb2a292af 100644
--- a/accel/accel-common.c
+++ b/accel/accel-common.c
@@ -106,6 +106,11 @@ bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
return false;
}
+ if (acc->ops
+ && acc->ops->cpu_target_realize
+ && !acc->ops->cpu_target_realize(cpu, errp)) {
+ return false;
+ }
You don't need to check if acc->ops is NULL here: per the
comment in accel_init_ops_interfaces(), all accelerators
need to define ops, and we would have already crashed if
it was NULL.
Only system-mode registers @ops, so unfortunately we need this check
for user-mode emulation... Richard and myself are aware of this and
plan to work on exposing AccelOpsClass to user code (after v10.1).