KVM: x86: Add dedicated helper to get CPUID entry with significant index
authorSean Christopherson <seanjc@google.com>
Tue, 12 Jul 2022 00:06:45 +0000 (02:06 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Jul 2022 15:38:32 +0000 (11:38 -0400)
commit277ad7d58611b455662f2e3f7bd24ce5bfeb2fdc
tree66308381c107f60655c3ae1035a2f1e77208a90d
parentbdc2d7ad10724de31463a0cdbd88b0ad7353a6de
KVM: x86: Add dedicated helper to get CPUID entry with significant index

Add a second CPUID helper, kvm_find_cpuid_entry_index(), to handle KVM
queries for CPUID leaves whose index _may_ be significant, and drop the
index param from the existing kvm_find_cpuid_entry().  Add a WARN in the
inner helper, cpuid_entry2_find(), to detect attempts to retrieve a CPUID
entry whose index is significant without explicitly providing an index.

Using an explicit magic number and letting callers omit the index avoids
confusion by eliminating the myriad cases where KVM specifies '0' as a
dummy value.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/cpuid.c
arch/x86/kvm/cpuid.h
arch/x86/kvm/hyperv.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/pmu_intel.c
arch/x86/kvm/vmx/sgx.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c