KVM: x86: disconnect kvm_check_cpuid() from vcpu->arch.cpuid_entries
authorVitaly Kuznetsov <vkuznets@redhat.com>
Thu, 1 Oct 2020 13:05:39 +0000 (15:05 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 21 Oct 2020 21:36:32 +0000 (17:36 -0400)
commitf69858fcc727f8098419f3c595678e671bd2d8b7
treeb4c544ec4287050ace8cd563b5dba21ecffb4c4e
parent3ee6fb4949aad0f2164829299934a77f62b79dcd
KVM: x86: disconnect kvm_check_cpuid() from vcpu->arch.cpuid_entries

As a preparatory step to allocating vcpu->arch.cpuid_entries dynamically
make kvm_check_cpuid() check work with an arbitrary 'struct kvm_cpuid_entry2'
array.

Currently, when kvm_check_cpuid() fails we reset vcpu->arch.cpuid_nent to
0 and this is kind of weird, i.e. one would expect CPUIDs to remain
unchanged when KVM_SET_CPUID[2] call fails.

No functional change intended. It would've been possible to move the updated
kvm_check_cpuid() in kvm_vcpu_ioctl_set_cpuid2() and check the supplied
input before we start updating vcpu->arch.cpuid_entries/nent but we
can't do the same in kvm_vcpu_ioctl_set_cpuid() as we'll have to copy
'struct kvm_cpuid_entry' entries first. The change will be made when
vcpu->arch.cpuid_entries[] array becomes allocated dynamically.

Suggested-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20201001130541.1398392-2-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/cpuid.c