On Thu, Jan 05, 2023, Paul Durrant wrote: > On 04/01/2023 19:34, Sean Christopherson wrote: > > Since the struct is a 64-bit value, what about making this a pure getter that > > returns a copy? > > > > static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcpu, > > const char *sig) > > { > > struct kvm_hypervisor_cpuid cpuid = {}; > > struct kvm_cpuid_entry2 *entry; > > u32 function; > > > > for_each_possible_hypervisor_cpuid_base(cpuid.base) { > > entry = kvm_find_cpuid_entry(vcpu, function); > > > > if (entry) { > > u32 signature[3]; > > > > signature[0] = entry->ebx; > > signature[1] = entry->ecx; > > signature[2] = entry->edx; > > > > if (!memcmp(signature, sig, sizeof(signature))) { > > cpuid.base = function; > > cpuid.limit = entry->eax; > > break; > > } > > } > > } > > > > return cpuid; > > } > > > > > > vcpu->arch.kvm_cpuid = kvm_get_hypervisor_cpuid(vcpu, KVM_SIGNATURE); > > vcpu->arch.xen.cpuid = kvm_get_hypervisor_cpuid(vcpu, XEN_SIGNATURE); > > Yes, if that's preferable then no problem. I like it (obviously), but it's probably worth waiting a few days to see what others think before posting a new version.