[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v9 19/20] target/riscv/kvm.c: add kvmconfig_get_cfg_addr() he
From: |
Alistair Francis |
Subject: |
Re: [PATCH v9 19/20] target/riscv/kvm.c: add kvmconfig_get_cfg_addr() helper |
Date: |
Mon, 10 Jul 2023 12:33:08 +1000 |
On Thu, Jul 6, 2023 at 8:19 PM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> There are 2 places in which we need to get a pointer to a certain
> property of the cpu->cfg struct based on property offset. Next patch
> will add a couple more.
>
> Create a helper to avoid repeating this code over and over.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> target/riscv/kvm.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
> index ba940e570e..cfeab5a4c0 100644
> --- a/target/riscv/kvm.c
> +++ b/target/riscv/kvm.c
> @@ -215,11 +215,15 @@ static KVMCPUConfig kvm_multi_ext_cfgs[] = {
> KVM_EXT_CFG("svpbmt", ext_svpbmt, KVM_RISCV_ISA_EXT_SVPBMT),
> };
>
> +static void *kvmconfig_get_cfg_addr(RISCVCPU *cpu, KVMCPUConfig *kvmcfg)
> +{
> + return (void *)&cpu->cfg + kvmcfg->offset;
> +}
> +
> static void kvm_cpu_cfg_set(RISCVCPU *cpu, KVMCPUConfig *multi_ext,
> uint32_t val)
> {
> - int cpu_cfg_offset = multi_ext->offset;
> - bool *ext_enabled = (void *)&cpu->cfg + cpu_cfg_offset;
> + bool *ext_enabled = kvmconfig_get_cfg_addr(cpu, multi_ext);
>
> *ext_enabled = val;
> }
> @@ -227,8 +231,7 @@ static void kvm_cpu_cfg_set(RISCVCPU *cpu, KVMCPUConfig
> *multi_ext,
> static uint32_t kvm_cpu_cfg_get(RISCVCPU *cpu,
> KVMCPUConfig *multi_ext)
> {
> - int cpu_cfg_offset = multi_ext->offset;
> - bool *ext_enabled = (void *)&cpu->cfg + cpu_cfg_offset;
> + bool *ext_enabled = kvmconfig_get_cfg_addr(cpu, multi_ext);
>
> return *ext_enabled;
> }
> --
> 2.41.0
>
>
- Re: [PATCH v9 14/20] target/riscv/kvm.c: add multi-letter extension KVM properties, (continued)
- [PATCH v9 15/20] target/riscv/cpu.c: add satp_mode properties earlier, Daniel Henrique Barboza, 2023/07/06
- [PATCH v9 16/20] target/riscv/cpu.c: remove priv_ver check from riscv_isa_string_ext(), Daniel Henrique Barboza, 2023/07/06
- [PATCH v9 17/20] target/riscv/cpu.c: create KVM mock properties, Daniel Henrique Barboza, 2023/07/06
- [PATCH v9 18/20] target/riscv: update multi-letter extension KVM properties, Daniel Henrique Barboza, 2023/07/06
- [PATCH v9 19/20] target/riscv/kvm.c: add kvmconfig_get_cfg_addr() helper, Daniel Henrique Barboza, 2023/07/06
- Re: [PATCH v9 19/20] target/riscv/kvm.c: add kvmconfig_get_cfg_addr() helper,
Alistair Francis <=
- [PATCH v9 20/20] target/riscv/kvm.c: read/write (cbom|cboz)_blocksize in KVM, Daniel Henrique Barboza, 2023/07/06
- Re: [PATCH v9 00/20] target/riscv, KVM: fixes and enhancements, Alistair Francis, 2023/07/09