On Tue, Jul 21, 2020 at 11:46:12AM +0100, Peter Maydell wrote: > > + if (!probed) { > > + probed = true; > > + if (kvm_check_extension(kvm_state, KVM_CAP_VCPU_ATTRIBUTES)) { > > + if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, NULL)) { > > + error_report("Failed to create scratch VCPU"); > > + abort(); > > + } > > + > > + has_steal_time = kvm_device_check_attr(fdarray[2], > > + > > KVM_ARM_VCPU_PVTIME_CTRL, > > + > > KVM_ARM_VCPU_PVTIME_IPA); > > + > > + kvm_arm_destroy_scratch_host_vcpu(fdarray); > > I was a bit surprised that we create a scratch VCPU here, but > it looks like we've opted for "create scratch VCPU, check specific > detail, destroy VCPU" as the usual coding pattern rather than trying > to coalesce into a single "create scratch VCPU once, cache all > the info we might need for later". I guess if somebody (a) cares > about startup performance and (b) finds through profiling that > creation-and-destruction of the scratch VMs/VCPUs is a significant > contributor they can write the refactoring themselves :-)
There's still a chance I'll be changing this to a KVM CAP if the KVM maintainers accept the patch I proposed to add one. > > > + } > > + } > > + > > + if (cpu->kvm_steal_time == ON_OFF_AUTO_AUTO) { > > + if (!has_steal_time || !arm_feature(&cpu->env, > > ARM_FEATURE_AARCH64)) { > > + cpu->kvm_steal_time = ON_OFF_AUTO_OFF; > > + } else { > > + cpu->kvm_steal_time = ON_OFF_AUTO_ON; > > + } > > + } else if (cpu->kvm_steal_time == ON_OFF_AUTO_ON) { > > + if (!has_steal_time) { > > + error_setg(errp, "'kvm-steal-time' cannot be enabled " > > + "on this host"); > > + return; > > + } else if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { > > + error_setg(errp, "'kvm-steal-time' cannot be enabled " > > + "for AArch32 guests"); > > Why not? Unlike aarch32-host KVM, aarch32-guest KVM is > still supported. What's the missing piece for kvm-steal-time > to work in that setup? The specification. DEN0057A chapter 2 says "This specification only covers systems in which the Execution state of the hypervisor as well as EL1 of virtual machines is AArch64.". And, to ensure that the smc/hvc calls are only specified as smc64/hvc64. I find that a bit disappointing, since there's nothing about steal-time that should be 64-bit specific, but that's how this cookie is crumbling... I'll add a comment to explain this error for v2. > > > + return; > > + } > > + } > > +} > > + > > bool kvm_arm_aarch32_supported(void) > > { > > return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL1_32BIT); > > > static inline void kvm_arm_add_vcpu_properties(Object *obj) {} > > +static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) > > {} > > Does this stub need to report an error to the caller via errp, > or is it a "never called but needs to exist to avoid linker errors" ? The second one, as we can't have kvm_enabled() and !defined(CONFIG_KVM). Hmm, these types of stubs would be more robust to refactoring if we put build bugs in them. I can try to analyze all the stubs in this #else to see which ones should be returning false/error/nothing vs. build bugging. Thanks, drew