[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 05/10] target/riscv/tcg: add user flag for profile support
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v2 05/10] target/riscv/tcg: add user flag for profile support |
Date: |
Fri, 6 Oct 2023 10:21:29 -0300 |
The TCG emulation implements all the extensions described in the
RVA22U64 profile, both mandatory and optional. The mandatory extensions
will be enabled via the profile flag. We'll leave the optional
extensions to be enabled by hand.
Given that this is the first profile we're implementing in TCG we'll
need some ground work first:
- all profiles declared in riscv_profiles[] will be exposed to users.
TCG is the main accelerator we're considering when adding profile
support in QEMU, so for now it's safe to assume that all profiles in
riscv_profiles[] will be relevant to TCG;
- the set() callback for the profile user property will set the
'user_set' flag for each profile that users enable/disable in the
command line;
- we'll not support user profile settings for vendor CPUs. The flags
will still be exposed but users won't be able to change them. The idea
is that vendor CPUs in the future can enable profiles internally in
their cpu_init() functions, showing to the external world that the CPU
supports a certain profile. But users won't be able to enable/disable
it.
For now we'll just expose the user flags for all profiles. Next patch
will introduce the 'commit profile' logic.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/tcg/tcg-cpu.c | 46 ++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 731192bafc..a8ea869e6e 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -740,6 +740,50 @@ static void riscv_cpu_add_misa_properties(Object *cpu_obj)
}
}
+static void cpu_set_profile(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ RISCVCPUProfile *profile = opaque;
+ bool value;
+
+ if (object_dynamic_cast(obj, TYPE_RISCV_DYNAMIC_CPU) == NULL) {
+ error_setg(errp, "Profile %s only available for generic CPUs",
+ profile->name);
+ return;
+ }
+
+ if (!visit_type_bool(v, name, &value, errp)) {
+ return;
+ }
+
+ profile->user_set = true;
+ profile->enabled = value;
+}
+
+static void cpu_get_profile(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ RISCVCPUProfile *profile = opaque;
+ bool value = profile->enabled;
+
+ visit_type_bool(v, name, &value, errp);
+}
+
+static void riscv_cpu_add_profiles(Object *cpu_obj)
+{
+ for (int i = 0;; i++) {
+ const RISCVCPUProfile *profile = riscv_profiles[i];
+
+ if (!profile) {
+ break;
+ }
+
+ object_property_add(cpu_obj, profile->name, "bool",
+ cpu_get_profile, cpu_set_profile,
+ NULL, (void *)profile);
+ }
+}
+
static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
@@ -834,6 +878,8 @@ static void riscv_cpu_add_user_properties(Object *obj)
riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_vendor_exts);
riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_experimental_exts);
+ riscv_cpu_add_profiles(obj);
+
for (Property *prop = riscv_cpu_options; prop && prop->name; prop++) {
qdev_property_add_static(DEVICE(obj), prop);
}
--
2.41.0
- [PATCH v2 00/10] riscv: RVA22U64 profile support, Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 01/10] target/riscv/cpu.c: add zicntr extension flag, Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 02/10] target/riscv/cpu.c: add zihpm extension flag, Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 03/10] target/riscv: add rva22u64 profile definition, Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 05/10] target/riscv/tcg: add user flag for profile support,
Daniel Henrique Barboza <=
- [PATCH v2 04/10] target/riscv/kvm: add 'rva22u64' flag as unavailable, Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 07/10] target/riscv/tcg: add MISA user options hash, Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 06/10] target/riscv/tcg: commit profiles during realize(), Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 08/10] target/riscv/tcg: add riscv_cpu_write_misa_bit(), Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 09/10] target/riscv/tcg: handle MISA bits on profile commit, Daniel Henrique Barboza, 2023/10/06
- [PATCH v2 10/10] target/riscv/tcg: add hash table insert helpers, Daniel Henrique Barboza, 2023/10/06
- Re: [PATCH v2 00/10] riscv: RVA22U64 profile support, Alistair Francis, 2023/10/10