Re: [PATCH v6 1/2] KVM: x86/cpuid: generalize kvm_update_kvm_cpuid_base() and also capture limit

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

 



On 05/01/2023 18:09, Sean Christopherson wrote:
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.

I think it's cleaner too, and I already did the typing so I may as well post. I don't think anyone else has expressed any strong opinions on the code either way.

Paul



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux