Skip to content

Commit

Permalink
KVM: x86: Remove the unnecessary loop on CPUID 0x7 sub-leafs
Browse files Browse the repository at this point in the history
Explicitly handle CPUID 0x7 sub-leaf 1.  The kernel is currently aware
of exactly one feature in CPUID 0x7.1,  which means there is room for
another 127 features before CPUID 0x7.2 will see the light of day, i.e.
the looping is likely to be dead code for years to come.

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Mar 16, 2020
1 parent 09f628a commit bcf600c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions arch/x86/kvm/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
if (boot_cpu_has(X86_FEATURE_AMD_SSBD))
cpuid_entry_set(entry, X86_FEATURE_SPEC_CTRL_SSBD);

for (i = 1, max_idx = entry->eax; i <= max_idx; i++) {
if (WARN_ON_ONCE(i > 1))
break;

entry = do_host_cpuid(array, function, i);
/* KVM only supports 0x7.0 and 0x7.1, capped above via min(). */
if (entry->eax == 1) {
entry = do_host_cpuid(array, function, 1);
if (!entry)
goto out;

Expand Down

0 comments on commit bcf600c

Please sign in to comment.