lkml.org 
[lkml]   [2023]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v6 1/2] KVM: x86/cpuid: generalize kvm_update_kvm_cpuid_base() and also capture limit
    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.

    \
     
     \ /
      Last update: 2023-03-26 23:29    [W:5.977 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site