[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 15/22] exec/cpu: Introduce CPUClass::verify_accel_features()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 15/22] exec/cpu: Introduce CPUClass::verify_accel_features() |
Date: |
Mon, 18 Sep 2023 18:02:48 +0200 |
Some CPUs need to check the requested features are compatible
with the requested accelerator. This has to be done *before*
the accelerator realizes a vCPU.
Introduce the verify_accel_features() handler and call it
just before accel_cpu_realizefn().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/core/cpu.h | 4 ++++
cpu.c | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index c90cf3a162..1e940f6bb5 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -103,6 +103,9 @@ struct SysemuCPUOps;
* @class_by_name: Callback to map -cpu command line model name to an
* instantiatable CPU type.
* @parse_features: Callback to parse command line arguments.
+ * @verify_accel_features: Callback to verify if all requested CPU are
+ * compatible with the requested accelerator. Called before the
+ * accelerator realize a vCPU.
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
* @has_work: Callback for checking if there is work to do.
* @memory_rw_debug: Callback for GDB memory access.
@@ -183,6 +186,7 @@ struct CPUClass {
* class data that depends on the accelerator, see accel/accel-common.c.
*/
void (*init_accel_cpu)(struct AccelCPUClass *accel_cpu, CPUClass *cc);
+ bool (*verify_accel_features)(CPUState *cs, Error **errp);
/*
* Keep non-pointer data at the end to minimize holes.
diff --git a/cpu.c b/cpu.c
index 0769b0b153..84b03c09ac 100644
--- a/cpu.c
+++ b/cpu.c
@@ -136,6 +136,11 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
/* cache the cpu class for the hotpath */
cpu->cc = CPU_GET_CLASS(cpu);
+ if (cpu->cc->verify_accel_features
+ && !cpu->cc->verify_accel_features(cpu, errp)) {
+ return false;
+ }
+
if (!accel_cpu_realizefn(cpu, errp)) {
return;
}
--
2.41.0
- [PATCH 07/22] exec/cpu: Introduce the CPU address space destruction function, (continued)
- [PATCH 07/22] exec/cpu: Introduce the CPU address space destruction function, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 05/22] exec/cpu: Call qemu_init_vcpu() once in cpu_common_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [RFC PATCH 04/22] exec/cpu: Never call cpu_reset() before cpu_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 06/22] exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 08/22] exec/cpu: RFC Destroy vCPU address spaces in cpu_common_unrealize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 09/22] target/arm: Create timers *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 10/22] target/hppa: Create timer *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 11/22] target/nios2: Create IRQs *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 12/22] target/mips: Create clock *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 14/22] target/sparc: Init CPU environment *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 15/22] exec/cpu: Introduce CPUClass::verify_accel_features(),
Philippe Mathieu-Daudé <=
- [PATCH 16/22] target/arm: Extract verify_accel_features() from cpu_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 13/22] target/xtensa: Create IRQs *after* accelerator vCPU is realized, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 17/22] target/i386: Extract verify_accel_features() from cpu_realize(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 18/22] target/s390x: Call s390_cpu_realize_sysemu from s390_realize_cpu_model, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 19/22] target/s390x: Have s390_realize_cpu_model() return a boolean, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 20/22] target/s390x: Use s390_realize_cpu_model() as verify_accel_features(), Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 21/22] exec/cpu: Have cpu_exec_realize() return a boolean, Philippe Mathieu-Daudé, 2023/09/18
- [PATCH 22/22] exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize(), Philippe Mathieu-Daudé, 2023/09/18