[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/6] target/riscv/kvm/kvm-cpu.c: add missing property gett
From: |
Alistair Francis |
Subject: |
Re: [PATCH v2 1/6] target/riscv/kvm/kvm-cpu.c: add missing property getters() |
Date: |
Fri, 29 Sep 2023 15:10:30 +1000 |
On Wed, Sep 27, 2023 at 6:10 AM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> We got along without property getters in the KVM driver because we never
> needed them. But the incoming query-cpu-model-expansion API will use
> property getters and setters to retrieve the CPU characteristics.
>
> Add the missing getters for the KVM driver for both MISA and
> multi-letter extension properties. We're also adding an special getter
> for absent multi-letter properties that KVM doesn't implement that
> always return false.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> target/riscv/kvm/kvm-cpu.c | 40 +++++++++++++++++++++++++++++++++++---
> 1 file changed, 37 insertions(+), 3 deletions(-)
>
> diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
> index c6615cb807..b4c231f231 100644
> --- a/target/riscv/kvm/kvm-cpu.c
> +++ b/target/riscv/kvm/kvm-cpu.c
> @@ -140,6 +140,19 @@ static KVMCPUConfig kvm_misa_ext_cfgs[] = {
> KVM_MISA_CFG(RVM, KVM_RISCV_ISA_EXT_M),
> };
>
> +static void kvm_cpu_get_misa_ext_cfg(Object *obj, Visitor *v,
> + const char *name,
> + void *opaque, Error **errp)
> +{
> + KVMCPUConfig *misa_ext_cfg = opaque;
> + target_ulong misa_bit = misa_ext_cfg->offset;
> + RISCVCPU *cpu = RISCV_CPU(obj);
> + CPURISCVState *env = &cpu->env;
> + bool value = env->misa_ext_mask & misa_bit;
> +
> + visit_type_bool(v, name, &value, errp);
> +}
> +
> static void kvm_cpu_set_misa_ext_cfg(Object *obj, Visitor *v,
> const char *name,
> void *opaque, Error **errp)
> @@ -244,6 +257,17 @@ static uint32_t kvm_cpu_cfg_get(RISCVCPU *cpu,
> return *ext_enabled;
> }
>
> +static void kvm_cpu_get_multi_ext_cfg(Object *obj, Visitor *v,
> + const char *name,
> + void *opaque, Error **errp)
> +{
> + KVMCPUConfig *multi_ext_cfg = opaque;
> + RISCVCPU *cpu = RISCV_CPU(obj);
> + bool value = kvm_cpu_cfg_get(cpu, multi_ext_cfg);
> +
> + visit_type_bool(v, name, &value, errp);
> +}
> +
> static void kvm_cpu_set_multi_ext_cfg(Object *obj, Visitor *v,
> const char *name,
> void *opaque, Error **errp)
> @@ -346,6 +370,15 @@ static void kvm_riscv_update_cpu_cfg_isa_ext(RISCVCPU
> *cpu, CPUState *cs)
> }
> }
>
> +static void cpu_get_cfg_unavailable(Object *obj, Visitor *v,
> + const char *name,
> + void *opaque, Error **errp)
> +{
> + bool value = false;
> +
> + visit_type_bool(v, name, &value, errp);
> +}
> +
> static void cpu_set_cfg_unavailable(Object *obj, Visitor *v,
> const char *name,
> void *opaque, Error **errp)
> @@ -376,7 +409,8 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *obj,
> const char *prop_name)
> * to enable any of them.
> */
> object_property_add(obj, prop_name, "bool",
> - NULL, cpu_set_cfg_unavailable,
> + cpu_get_cfg_unavailable,
> + cpu_set_cfg_unavailable,
> NULL, (void *)prop_name);
> }
>
> @@ -406,7 +440,7 @@ static void kvm_riscv_add_cpu_user_properties(Object
> *cpu_obj)
> misa_cfg->description = riscv_get_misa_ext_description(bit);
>
> object_property_add(cpu_obj, misa_cfg->name, "bool",
> - NULL,
> + kvm_cpu_get_misa_ext_cfg,
> kvm_cpu_set_misa_ext_cfg,
> NULL, misa_cfg);
> object_property_set_description(cpu_obj, misa_cfg->name,
> @@ -422,7 +456,7 @@ static void kvm_riscv_add_cpu_user_properties(Object
> *cpu_obj)
> KVMCPUConfig *multi_cfg = &kvm_multi_ext_cfgs[i];
>
> object_property_add(cpu_obj, multi_cfg->name, "bool",
> - NULL,
> + kvm_cpu_get_multi_ext_cfg,
> kvm_cpu_set_multi_ext_cfg,
> NULL, multi_cfg);
> }
> --
> 2.41.0
>
>
- [PATCH v2 0/6] riscv: query-cpu-model-expansion API, Daniel Henrique Barboza, 2023/09/26
- [PATCH v2 1/6] target/riscv/kvm/kvm-cpu.c: add missing property getters(), Daniel Henrique Barboza, 2023/09/26
- Re: [PATCH v2 1/6] target/riscv/kvm/kvm-cpu.c: add missing property getters(),
Alistair Francis <=
- [PATCH v2 2/6] qapi,risc-v: add query-cpu-model-expansion, Daniel Henrique Barboza, 2023/09/26
- [PATCH v2 3/6] target/riscv/tcg: add tcg_cpu_finalize_features(), Daniel Henrique Barboza, 2023/09/26
- [PATCH v2 5/6] target/riscv: add riscv_cpu_accelerator_compatible(), Daniel Henrique Barboza, 2023/09/26
- [PATCH v2 4/6] target/riscv: handle custom props in qmp_query_cpu_model_expansion, Daniel Henrique Barboza, 2023/09/26
- [PATCH v2 6/6] target/riscv/riscv-qmp-cmds.c: check CPU accel in query-cpu-model-expansion, Daniel Henrique Barboza, 2023/09/26