On Thu, Jun 22, 2023 at 10:56:53AM -0300, Daniel Henrique Barboza wrote: > Using all TCG user properties in KVM is tricky. First because KVM > supports only a small subset of what TCG provides, so most of the > cpu->cfg flags do nothing for KVM. > > Second, and more important, we don't have a way of telling if any given > value is an user input or not. For TCG this has a small impact since we > just validating everything and error out if needed. But for KVM it would > be good to know if a given value was set by the user or if it's a value > already provided by KVM. Otherwise we don't know how to handle failed > kvm_set_one_regs() when writing the configurations back. > > These characteristics make it overly complicated to use the same user > facing flags for both KVM and TCG. A simpler approach is to create KVM > specific properties that have specialized logic, forking KVM and TCG use > cases for those cases only. Fully separating KVM/TCG properties is > unneeded at this point - in fact we want the user experience to be as > equal as possible, regardless of the acceleration chosen. > > We'll start this fork with the MISA properties, adding the MISA bits > that the KVM driver currently supports. A new KVMCPUConfig type is > introduced. It'll hold general information about an extension. For MISA > extensions we're going to use the newly created misa_ext_infos[] to > populate their name and description. 'offset' holds the MISA bit (RVA, > RVC, ...). We're calling it 'offset' instead of 'misa_bit' because this > same KVMCPUConfig struct will be used to multi-letter extensions later > on. > > This new type also holds a 'user_set' flag. This flag will be set when > the user set an option that's different than what is already configured > in the host, requiring KVM intervention to write the regs back during > kvm_arch_init_vcpu(). Similar mechanics will be implemented for > multi-letter extensions as well. > > There is no need to duplicate more code than necessary, so we're going > to use the existing kvm_riscv_init_user_properties() to add the KVM > specific properties. Any code that is adding a TCG user prop is then > changed slightly to verify first if there's a KVM prop with the same > name already added. > > Signed-off-by: Daniel Henrique Barboza <[email protected]> > Reviewed-by: Andrew Jones <[email protected]> > --- > target/riscv/cpu.c | 10 ++++++ > target/riscv/kvm.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 88 insertions(+) >
Reviewed-by: Andrew Jones <[email protected]>
