[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4aba7537-7c70-4965-46e2-ac36d389ef0a@xen.org>
Date: Fri, 6 Jan 2023 09:20:00 +0000
From: Paul Durrant <xadimgnik@...il.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Paul Durrant <pdurrant@...zon.com>, x86@...nel.org,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
David Woodhouse <dwmw2@...radead.org>
Subject: Re: [PATCH v6 1/2] KVM: x86/cpuid: generalize
kvm_update_kvm_cpuid_base() and also capture limit
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
Powered by blists - more mailing lists