aboutsummaryrefslogtreecommitdiff
path: root/target/riscv/tcg
diff options
context:
space:
mode:
authorDaniel Henrique Barboza <dbarboza@ventanamicro.com>2023-10-18 16:56:37 -0300
committerAlistair Francis <alistair.francis@wdc.com>2023-11-07 11:06:02 +1000
commitef58fad0fdc7aba2c2196f9c35a89889286ef92b (patch)
tree61fbc9111952ddab7da03be4e3bf364b19544055 /target/riscv/tcg
parent1df4f540d6352131cefa7ca48b637ccb774ce9e0 (diff)
downloadqemu-ef58fad0fdc7aba2c2196f9c35a89889286ef92b.zip
qemu-ef58fad0fdc7aba2c2196f9c35a89889286ef92b.tar.gz
qemu-ef58fad0fdc7aba2c2196f9c35a89889286ef92b.tar.bz2
target/riscv: add riscv_cpu_accelerator_compatible()
Add an API to check if a given CPU is compatible with the current accelerator. This will allow query-cpu-model-expansion to work properly in conditions where QEMU supports both accelerators (TCG and KVM), QEMU is then launched using TCG, and the API requests information about a KVM only CPU (e.g. 'host' CPU). KVM doesn't have such restrictions and, at least in theory, all CPUs models should work with KVM. We will revisit this API in case we decide to restrict the amount of KVM CPUs we support. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20231018195638.211151-6-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'target/riscv/tcg')
-rw-r--r--target/riscv/tcg/tcg-cpu.c7
-rw-r--r--target/riscv/tcg/tcg-cpu.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 21a46f2..6771617 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -581,6 +581,11 @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp)
}
}
+bool riscv_cpu_tcg_compatible(RISCVCPU *cpu)
+{
+ return object_dynamic_cast(OBJECT(cpu), TYPE_RISCV_CPU_HOST) == NULL;
+}
+
static bool riscv_cpu_is_generic(Object *cpu_obj)
{
return object_dynamic_cast(cpu_obj, TYPE_RISCV_DYNAMIC_CPU) != NULL;
@@ -598,7 +603,7 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp)
RISCVCPU *cpu = RISCV_CPU(cs);
Error *local_err = NULL;
- if (object_dynamic_cast(OBJECT(cpu), TYPE_RISCV_CPU_HOST)) {
+ if (!riscv_cpu_tcg_compatible(cpu)) {
g_autofree char *name = riscv_cpu_get_name(cpu);
error_setg(errp, "'%s' CPU is not compatible with TCG acceleration",
name);
diff --git a/target/riscv/tcg/tcg-cpu.h b/target/riscv/tcg/tcg-cpu.h
index aa00fbc..f7b3241 100644
--- a/target/riscv/tcg/tcg-cpu.h
+++ b/target/riscv/tcg/tcg-cpu.h
@@ -24,5 +24,6 @@
void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp);
void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp);
+bool riscv_cpu_tcg_compatible(RISCVCPU *cpu);
#endif