[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 24/40] target/riscv: Validate misa_mxl_max only once
From: |
Alex Bennée |
Subject: |
[PATCH 24/40] target/riscv: Validate misa_mxl_max only once |
Date: |
Thu, 21 Dec 2023 10:38:02 +0000 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
misa_mxl_max is now a class member and initialized only once for each
class. This also moves the initialization of gdb_core_xml_file which
will be referenced before realization in the future.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20231213-riscv-v7-4-a760156a337f@daynix.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
target/riscv/cpu.c | 21 +++++++++++++++++++++
target/riscv/tcg/tcg-cpu.c | 23 -----------------------
2 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 2ab61df2217..b799f133604 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1247,6 +1247,26 @@ static const MISAExtInfo misa_ext_info_arr[] = {
MISA_EXT_INFO(RVG, "g", "General purpose (IMAFD_Zicsr_Zifencei)"),
};
+static void riscv_cpu_validate_misa_mxl(RISCVCPUClass *mcc)
+{
+ CPUClass *cc = CPU_CLASS(mcc);
+
+ /* Validate that MISA_MXL is set properly. */
+ switch (mcc->misa_mxl_max) {
+#ifdef TARGET_RISCV64
+ case MXL_RV64:
+ case MXL_RV128:
+ cc->gdb_core_xml_file = "riscv-64bit-cpu.xml";
+ break;
+#endif
+ case MXL_RV32:
+ cc->gdb_core_xml_file = "riscv-32bit-cpu.xml";
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
static int riscv_validate_misa_info_idx(uint32_t bit)
{
int idx;
@@ -1695,6 +1715,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void
*data)
RISCVCPUClass *mcc = RISCV_CPU_CLASS(c);
mcc->misa_mxl_max = (uint32_t)(uintptr_t)data;
+ riscv_cpu_validate_misa_mxl(mcc);
}
static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str,
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 7f6712c81a4..eb243e011ca 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -148,27 +148,6 @@ static void riscv_cpu_validate_misa_priv(CPURISCVState
*env, Error **errp)
}
}
-static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu)
-{
- RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu);
- CPUClass *cc = CPU_CLASS(mcc);
-
- /* Validate that MISA_MXL is set properly. */
- switch (mcc->misa_mxl_max) {
-#ifdef TARGET_RISCV64
- case MXL_RV64:
- case MXL_RV128:
- cc->gdb_core_xml_file = "riscv-64bit-cpu.xml";
- break;
-#endif
- case MXL_RV32:
- cc->gdb_core_xml_file = "riscv-32bit-cpu.xml";
- break;
- default:
- g_assert_not_reached();
- }
-}
-
static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp)
{
CPURISCVState *env = &cpu->env;
@@ -676,8 +655,6 @@ static bool tcg_cpu_realize(CPUState *cs, Error **errp)
return false;
}
- riscv_cpu_validate_misa_mxl(cpu);
-
#ifndef CONFIG_USER_ONLY
CPURISCVState *env = &cpu->env;
Error *local_err = NULL;
--
2.39.2
- [PATCH 37/40] plugins: add an API to read registers, (continued)
- [PATCH 37/40] plugins: add an API to read registers, Alex Bennée, 2023/12/21
- [PATCH 38/40] contrib/plugins: fix imatch, Alex Bennée, 2023/12/21
- [PATCH 40/40] contrib/plugins: optimise the register value tracking, Alex Bennée, 2023/12/21
- [PATCH 22/40] target/riscv: Remove misa_mxl validation, Alex Bennée, 2023/12/21
- [PATCH 23/40] target/riscv: Move misa_mxl_max to class, Alex Bennée, 2023/12/21
- [PATCH 25/40] target/arm: Use GDBFeature for dynamic XML, Alex Bennée, 2023/12/21
- [PATCH 27/40] target/riscv: Use GDBFeature for dynamic XML, Alex Bennée, 2023/12/21
- [PATCH 33/40] hw/core/cpu: Remove gdb_get_dynamic_xml member, Alex Bennée, 2023/12/21
- [PATCH 32/40] gdbstub: Infer number of core registers from XML, Alex Bennée, 2023/12/21
- [PATCH 35/40] plugins: Use different helpers when reading registers, Alex Bennée, 2023/12/21
- [PATCH 24/40] target/riscv: Validate misa_mxl_max only once,
Alex Bennée <=
- [PATCH 31/40] gdbstub: Simplify XML lookup, Alex Bennée, 2023/12/21
- [PATCH 26/40] target/ppc: Use GDBFeature for dynamic XML, Alex Bennée, 2023/12/21
- [PATCH 16/40] tests/qtest: Bump the device-introspect-test timeout to 12 minutes, Alex Bennée, 2023/12/21
- [PATCH 34/40] gdbstub: Add members to identify registers to GDBFeature, Alex Bennée, 2023/12/21
- [PATCH 20/40] mtest2make: stop disabling meson test timeouts, Alex Bennée, 2023/12/21
- [PATCH 17/40] tests/unit: Bump test-aio-multithread test timeout to 2 minutes, Alex Bennée, 2023/12/21
- [PATCH 28/40] gdbstub: Use GDBFeature for gdb_register_coprocessor, Alex Bennée, 2023/12/21
- [PATCH 21/40] hw/riscv: Use misa_mxl instead of misa_mxl_max, Alex Bennée, 2023/12/21
- [PATCH 29/40] gdbstub: Use GDBFeature for GDBRegisterState, Alex Bennée, 2023/12/21
- [PATCH 18/40] tests/unit: Bump test-crypto-block test timeout to 5 minutes, Alex Bennée, 2023/12/21