[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 42/54] target/riscv: add riscv_cpu_get_name()
From: |
Alistair Francis |
Subject: |
[PULL 42/54] target/riscv: add riscv_cpu_get_name() |
Date: |
Thu, 12 Oct 2023 14:10:39 +1000 |
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
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>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230926183109.165878-2-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
target/riscv/cpu.h | 1 +
target/riscv/cpu.c | 11 +++++++++++
target/riscv/tcg/tcg-cpu.c | 4 +++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 7291b84756..8298f8bf63 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/cpu.c b/target/riscv/cpu.c
index a7cc7aa6e2..cdeb24cb5e 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/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index a021ec833d..104e91846a 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -563,7 +563,9 @@ static bool tcg_cpu_realize(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
- [PULL 32/54] target/riscv: remove kvm-stub.c, (continued)
- [PULL 32/54] target/riscv: remove kvm-stub.c, Alistair Francis, 2023/10/12
- [PULL 33/54] target/riscv: introduce KVM AccelCPUClass, Alistair Francis, 2023/10/12
- [PULL 34/54] target/riscv: move KVM only files to kvm subdir, Alistair Francis, 2023/10/12
- [PULL 35/54] target/riscv/kvm: do not use riscv_cpu_add_misa_properties(), Alistair Francis, 2023/10/12
- [PULL 36/54] target/riscv/cpu.c: export set_misa(), Alistair Francis, 2023/10/12
- [PULL 37/54] target/riscv/tcg: introduce tcg_cpu_instance_init(), Alistair Francis, 2023/10/12
- [PULL 38/54] target/riscv/cpu.c: make misa_ext_cfgs[] 'const', Alistair Francis, 2023/10/12
- [PULL 39/54] target/riscv/tcg: move riscv_cpu_add_misa_properties() to tcg-cpu.c, Alistair Francis, 2023/10/12
- [PULL 40/54] target/riscv/cpu.c: export isa_edata_arr[], Alistair Francis, 2023/10/12
- [PULL 41/54] target/riscv/cpu: move priv spec functions to tcg-cpu.c, Alistair Francis, 2023/10/12
- [PULL 42/54] target/riscv: add riscv_cpu_get_name(),
Alistair Francis <=
- [PULL 43/54] target/riscv/tcg-cpu.c: add extension properties for all cpus, Alistair Francis, 2023/10/12
- [PULL 46/54] hw/misc/sifive_test.c: replace exit calls with proper shutdown, Alistair Francis, 2023/10/12
- [PULL 45/54] softmmu: pass the main loop status to gdb "Wxx" packet, Alistair Francis, 2023/10/12
- [PULL 47/54] hw/char: riscv_htif: replace exit calls with proper shutdown, Alistair Francis, 2023/10/12
- [PULL 44/54] softmmu: add means to pass an exit code when requesting a shutdown, Alistair Francis, 2023/10/12
- [PULL 48/54] gdbstub: replace exit calls with proper shutdown for softmmu, Alistair Francis, 2023/10/12
- [PULL 49/54] target/riscv/kvm: improve 'init_multiext_cfg' error msg, Alistair Francis, 2023/10/12
- [PULL 50/54] target/riscv/kvm: support KVM_GET_REG_LIST, Alistair Francis, 2023/10/12
- [PULL 51/54] target/riscv/tcg: remove RVG warning, Alistair Francis, 2023/10/12
- [PULL 52/54] target/riscv: Use env_archcpu for better performance, Alistair Francis, 2023/10/12