[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/8] target/riscv: add riscv_cpu_get_name()
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 1/8] target/riscv: add riscv_cpu_get_name() |
Date: |
Wed, 20 Sep 2023 18:37:36 -0300 |
We'll introduce generic errors that will output a CPU type name via its
RISCVCPU pointer. Create a helper for that.
Use the helper in tcg_cpu_realizefn() instead of hardcoding the 'host'
CPU name.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/cpu.c | 11 +++++++++++
target/riscv/cpu.h | 1 +
target/riscv/tcg/tcg-cpu.c | 4 +++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index eeeb08a35a..521bb88538 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -643,6 +643,17 @@ static ObjectClass *riscv_cpu_class_by_name(const char
*cpu_model)
return oc;
}
+char *riscv_cpu_get_name(RISCVCPU *cpu)
+{
+ RISCVCPUClass *rcc = RISCV_CPU_GET_CLASS(cpu);
+ const char *typename = object_class_get_name(OBJECT_CLASS(rcc));
+
+ g_assert(g_str_has_suffix(typename, RISCV_CPU_TYPE_SUFFIX));
+
+ return g_strndup(typename,
+ strlen(typename) - strlen(RISCV_CPU_TYPE_SUFFIX));
+}
+
static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
{
RISCVCPU *cpu = RISCV_CPU(cs);
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 219fe2e9b5..3f11e69223 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -730,6 +730,7 @@ typedef struct isa_ext_data {
int ext_enable_offset;
} RISCVIsaExtData;
extern const RISCVIsaExtData isa_edata_arr[];
+char *riscv_cpu_get_name(RISCVCPU *cpu);
void riscv_add_satp_mode_properties(Object *obj);
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 8c052d6fcd..f31aa9bcc4 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -563,7 +563,9 @@ static bool tcg_cpu_realizefn(CPUState *cs, Error **errp)
Error *local_err = NULL;
if (object_dynamic_cast(OBJECT(cpu), TYPE_RISCV_CPU_HOST)) {
- error_setg(errp, "'host' CPU is not compatible with TCG acceleration");
+ g_autofree char *name = riscv_cpu_get_name(cpu);
+ error_setg(errp, "'%s' CPU is not compatible with TCG acceleration",
+ name);
return false;
}
--
2.41.0
- [PATCH 0/8] riscv: query-cpu-model-expansion API, Daniel Henrique Barboza, 2023/09/20
- [PATCH 1/8] target/riscv: add riscv_cpu_get_name(),
Daniel Henrique Barboza <=
- [PATCH 2/8] target/riscv/tcg-cpu.c: add extension properties for all cpus, Daniel Henrique Barboza, 2023/09/20
- [PATCH 3/8] target/riscv/kvm/kvm-cpu.c: add missing property getters(), Daniel Henrique Barboza, 2023/09/20
- [PATCH 4/8] qapi,risc-v: add query-cpu-model-expansion, Daniel Henrique Barboza, 2023/09/20
- [PATCH 5/8] target/riscv/tcg: add tcg_cpu_finalize_features(), Daniel Henrique Barboza, 2023/09/20
- [PATCH 6/8] target/riscv: handle custom props in qmp_query_cpu_model_expansion, Daniel Henrique Barboza, 2023/09/20
- [PATCH 7/8] target/riscv: add riscv_cpu_accelerator_compatible(), Daniel Henrique Barboza, 2023/09/20
- [PATCH 8/8] target/riscv/riscv-qmp-cmds.c: check CPU accel in query-cpu-model-expansion, Daniel Henrique Barboza, 2023/09/20
- Re: [PATCH 0/8] riscv: query-cpu-model-expansion API, Daniel Henrique Barboza, 2023/09/26