[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 37/39] accel: Declare AccelClass::[un]realize_cpu() handlers
From: |
Richard Henderson |
Subject: |
[PATCH v3 37/39] accel: Declare AccelClass::[un]realize_cpu() handlers |
Date: |
Sat, 16 Sep 2023 14:41:21 -0700 |
From: Philippe Mathieu-Daudé <philmd@linaro.org>
Currently accel_cpu_realize() only performs target-specific
realization. Introduce the [un]realize_cpu fields in the
base AccelClass to be able to perform target-agnostic
[un]realization of vCPUs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230915190009.68404-4-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/accel.h | 2 ++
accel/accel-target.c | 21 +++++++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 7b02cb40e5..0b6031bd82 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -43,6 +43,8 @@ typedef struct AccelClass {
bool (*has_memory)(MachineState *ms, AddressSpace *as,
hwaddr start_addr, hwaddr size);
#endif
+ bool (*realize_cpu)(CPUState *cpu, Error **errp);
+ void (*unrealize_cpu)(CPUState *cpu);
/* gdbstub related hooks */
int (*gdbstub_supported_sstep_flags)(void);
diff --git a/accel/accel-target.c b/accel/accel-target.c
index cc3a45e663..6d427f2b9d 100644
--- a/accel/accel-target.c
+++ b/accel/accel-target.c
@@ -122,15 +122,32 @@ void accel_cpu_instance_init(CPUState *cpu)
bool accel_cpu_realize(CPUState *cpu, Error **errp)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
- if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn) {
- return cc->accel_cpu->cpu_realizefn(cpu, errp);
+ /* target specific realization */
+ if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn
+ && !cc->accel_cpu->cpu_realizefn(cpu, errp)) {
+ return false;
}
+
+ /* generic realization */
+ if (acc->realize_cpu && !acc->realize_cpu(cpu, errp)) {
+ return false;
+ }
+
return true;
}
void accel_cpu_unrealize(CPUState *cpu)
{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+
+ /* generic unrealization */
+ if (acc->unrealize_cpu) {
+ acc->unrealize_cpu(cpu);
+ }
}
int accel_supported_gdbstub_sstep_flags(void)
--
2.34.1
- [PATCH v3 32/39] accel/tcg: Make monitor.c a target-agnostic unit, (continued)
- [PATCH v3 32/39] accel/tcg: Make monitor.c a target-agnostic unit, Richard Henderson, 2023/09/16
- [PATCH v3 35/39] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize(), Richard Henderson, 2023/09/16
- [PATCH v3 34/39] accel/tcg: Make cpu-exec-common.c a target agnostic unit, Richard Henderson, 2023/09/16
- [PATCH v3 20/39] accel/tcg: Use CPUState in atomicity helpers, Richard Henderson, 2023/09/16
- [PATCH v3 27/39] accel: Make accel-blocker.o target agnostic, Richard Henderson, 2023/09/16
- [PATCH v3 31/39] accel/tcg: Rename target-specific 'internal.h' -> 'internal-target.h', Richard Henderson, 2023/09/16
- [PATCH v3 36/39] accel: Introduce accel_cpu_unrealize() stub, Richard Henderson, 2023/09/16
- [PATCH v3 22/39] accel/tcg: Unify user and softmmu do_[st|ld]*_mmu(), Richard Henderson, 2023/09/16
- [PATCH v3 23/39] accel/tcg: move ld/st helpers to ldst_common.c.inc, Richard Henderson, 2023/09/16
- [PATCH v3 25/39] exec: Move cpu_loop_foo() target agnostic functions to 'cpu-common.h', Richard Henderson, 2023/09/16
- [PATCH v3 37/39] accel: Declare AccelClass::[un]realize_cpu() handlers,
Richard Henderson <=
- [PATCH v3 39/39] accel/tcg: Restrict tcg_exec_[un]realizefn() to TCG, Richard Henderson, 2023/09/16