qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 00/16] target/riscv: deprecate riscv_cpu_options[]


From: Daniel Henrique Barboza
Subject: [PATCH 00/16] target/riscv: deprecate riscv_cpu_options[]
Date: Thu, 21 Dec 2023 14:51:21 -0300

Hi,

Rob reported a few days ago about vendor properties overrides that we're
having with riscv_cpu_options [1]. At that time I was doing changes in
the 'vlen' and 'elen' properties due to (yet to be sent) changes I'm
making in Vector code. I decided to extend the work I was doing and it
resulted in this cleanup.

As Rob mentioned, the defaults in riscv_cpu_options[] properties will
overwrite settings that comes from cpu_init() due to how the
accelerators are adding them during post_init() time. The KVM driver
does validations in init() time, so it needs to overwrite
riscv_cpu_options[] with its own versions. Vendor CPUs can be changed
via these options because the default constructor does not allow for any
customization. Last, but not the least, we have validations for these
options that are being done by the TCG driver, but should be done in the
common code since it also affects KVM.

The first problem is solved by moving all properties from
riscv_cpu_options[] to riscv_cpu_properties[]. They'll be changed into
class properties, their default values will be initialized earlier, and
any changes in cpu_init() will overwrite them.

The second problem requires changes in the KVM driver. We'll need a
finalize() mechanic, like TCG already has, to validate options during
realize() time. This will relieve the driver from having to re-implement
the setters for each option. 

The third and forth problems can be solved by implementing getters and
setters for these class options. We have a precedent for that - the
machine IDs work this way - but we want to center everything in
riscv_cpu_properties[] for simplicity. We have an example of how this is
done in the pmu-* properties, and we'll do the same for every other
class property.

Another noticeable change made in this series is the removal of the
string properties 'priv_spec' and 'vext_spec'. We'll manipulate strings
as needed but won't store them in cpu->cfg. This will also make it
easier to migrate those properties to bools, like we already do with
satp_mode.

Series based on Alistair's riscv-to-apply.next. It can also be retrieved
via:

https://gitlab.com/danielhb/qemu/-/tree/fix_cpu_opts_v1


[1] 
https://lore.kernel.org/qemu-riscv/b815ab5fdf33d9b9000c8165d50d000f387a3463.camel@rivosinc.com/


Daniel Henrique Barboza (16):
  target/riscv/cpu_cfg.h: remove user_spec and bext_spec
  target/riscv: move 'pmu-mask' and 'pmu-num' to riscv_cpu_properties[]
  target/riscv: make riscv_cpu_is_generic() public
  target/riscv: move 'mmu' to riscv_cpu_properties[]
  target/riscv: move 'pmp' to riscv_cpu_properties[]
  target/riscv: rework 'priv_spec'
  target/riscv: rework 'vext_spec'
  target/riscv: move 'vlen' to riscv_cpu_properties[]
  target/riscv: move 'elen' to riscv_cpu_properties[]
  target/riscv: create finalize_features() for KVM
  target/riscv: move 'cbom_blocksize' to riscv_cpu_properties[]
  target/riscv: move 'cboz_blocksize' to riscv_cpu_properties[]
  target/riscv: remove riscv_cpu_options[]
  target/riscv/cpu.c: move 'mvendorid' to riscv_cpu_properties[]
  target/riscv/cpu.c: move 'mimpid' to riscv_cpu_properties[]
  target/riscv/cpu.c: move 'marchid' to riscv_cpu_properties[]

 target/riscv/cpu.c           | 582 ++++++++++++++++++++++++++++++-----
 target/riscv/cpu.h           |   7 +-
 target/riscv/cpu_cfg.h       |   4 -
 target/riscv/kvm/kvm-cpu.c   |  94 +++---
 target/riscv/kvm/kvm_riscv.h |   1 +
 target/riscv/tcg/tcg-cpu.c   |  63 ----
 6 files changed, 560 insertions(+), 191 deletions(-)

-- 
2.43.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]