On Tue, May 30, 2023 at 04:46:13PM -0300, Daniel Henrique Barboza wrote: > Certain validations, such as the validations done for the machine IDs > (mvendorid/marchid/mimpid), are done before starting the CPU. > Non-dynamic (named) CPUs tries to match user input with a preset > default. As it is today we can't prefetch a KVM default for these cases > because we're only able to read/write KVM regs after the vcpu is > spinning. > > Our target/arm friends use a concept called "scratch CPU", which > consists of creating a vcpu for doing queries and validations and so on, > which is discarded shortly after use [1]. This is a suitable solution > for what we need so let's implement it in target/riscv as well. > > kvm_riscv_init_machine_ids() will be used to do any pre-launch setup for > KVM CPUs, via riscv_cpu_add_user_properties(). The function will create > a KVM scratch CPU, fetch KVM regs that work as default values for user > properties, and then discard the scratch CPU afterwards. > > We're starting by initializing 'mvendorid'. This concept will be used to > init other KVM specific properties in the next patches as well. > > [1] target/arm/kvm.c, kvm_arm_create_scratch_host_vcpu() > > Suggested-by: Andrew Jones <ajo...@ventanamicro.com> > Signed-off-by: Daniel Henrique Barboza <dbarb...@ventanamicro.com> > --- > target/riscv/cpu.c | 4 ++ > target/riscv/kvm.c | 85 ++++++++++++++++++++++++++++++++++++++++ > target/riscv/kvm_riscv.h | 1 + > 3 files changed, 90 insertions(+) >
Reviewed-by: Andrew Jones <ajo...@ventanamicro.com>