[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/16] target/riscv: move 'elen' to riscv_cpu_properties[]
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 09/16] target/riscv: move 'elen' to riscv_cpu_properties[] |
Date: |
Thu, 21 Dec 2023 14:51:30 -0300 |
Do the same thing we did with 'vlen' in the previous patch with 'elen'.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/cpu.c | 52 ++++++++++++++++++++++++++++++++++++--
target/riscv/tcg/tcg-cpu.c | 5 ----
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index b75d9dee3c..aec1968cad 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1723,9 +1723,54 @@ const PropertyInfo prop_vlen = {
.set_default_value = qdev_propinfo_set_default_value_uint,
};
-Property riscv_cpu_options[] = {
- DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64),
+static void prop_elen_set(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ RISCVCPU *cpu = RISCV_CPU(obj);
+ uint16_t value;
+
+ if (!visit_type_uint16(v, name, &value, errp)) {
+ return;
+ }
+
+ if (!is_power_of_2(value)) {
+ error_setg(errp, "Vector extension ELEN must be power of 2");
+ return;
+ }
+
+ /* Always allow setting a default value */
+ if (cpu->cfg.elen == 0) {
+ cpu->cfg.elen = value;
+ return;
+ }
+
+ if (value != cpu->cfg.elen && riscv_cpu_is_vendor(obj)) {
+ cpu_set_prop_err(cpu, name, errp);
+ error_append_hint(errp, "Current '%s' val: %u\n",
+ name, cpu->cfg.elen);
+ return;
+ }
+
+ cpu_option_add_user_setting(name, value);
+ cpu->cfg.elen = value;
+}
+
+static void prop_elen_get(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ uint16_t value = RISCV_CPU(obj)->cfg.elen;
+ visit_type_uint16(v, name, &value, errp);
+}
+
+const PropertyInfo prop_elen = {
+ .name = "elen",
+ .get = prop_elen_get,
+ .set = prop_elen_set,
+ .set_default_value = qdev_propinfo_set_default_value_uint,
+};
+
+Property riscv_cpu_options[] = {
DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64),
DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64),
@@ -1748,6 +1793,9 @@ static Property riscv_cpu_properties[] = {
{.name = "vlen", .info = &prop_vlen,
.set_default = true, .defval.u = 128},
+ {.name = "elen", .info = &prop_elen,
+ .set_default = true, .defval.u = 64},
+
#ifndef CONFIG_USER_ONLY
DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC),
#endif
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 8ec858e096..84064ef7e0 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -185,11 +185,6 @@ static void riscv_cpu_validate_v(CPURISCVState *env,
RISCVCPUConfig *cfg,
return;
}
- if (!is_power_of_2(cfg->elen)) {
- error_setg(errp, "Vector extension ELEN must be power of 2");
- return;
- }
-
if (cfg->elen > 64 || cfg->elen < 8) {
error_setg(errp,
"Vector extension implementation only supports ELEN "
--
2.43.0
- [PATCH 00/16] target/riscv: deprecate riscv_cpu_options[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 01/16] target/riscv/cpu_cfg.h: remove user_spec and bext_spec, Daniel Henrique Barboza, 2023/12/21
- [PATCH 02/16] target/riscv: move 'pmu-mask' and 'pmu-num' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 04/16] target/riscv: move 'mmu' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 03/16] target/riscv: make riscv_cpu_is_generic() public, Daniel Henrique Barboza, 2023/12/21
- [PATCH 05/16] target/riscv: move 'pmp' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 06/16] target/riscv: rework 'priv_spec', Daniel Henrique Barboza, 2023/12/21
- [PATCH 08/16] target/riscv: move 'vlen' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 07/16] target/riscv: rework 'vext_spec', Daniel Henrique Barboza, 2023/12/21
- [PATCH 09/16] target/riscv: move 'elen' to riscv_cpu_properties[],
Daniel Henrique Barboza <=
- [PATCH 10/16] target/riscv: create finalize_features() for KVM, Daniel Henrique Barboza, 2023/12/21
- [PATCH 11/16] target/riscv: move 'cbom_blocksize' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 12/16] target/riscv: move 'cboz_blocksize' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 13/16] target/riscv: remove riscv_cpu_options[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 15/16] target/riscv/cpu.c: move 'mimpid' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 14/16] target/riscv/cpu.c: move 'mvendorid' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21
- [PATCH 16/16] target/riscv/cpu.c: move 'marchid' to riscv_cpu_properties[], Daniel Henrique Barboza, 2023/12/21