Re: [PATCH v2 18/49] KVM: x86: Account for max supported CPUID leaf when getting raw host CPUID

From: Yang, Weijiang
Date: Wed Jun 19 2024 - 04:07:34 EST


On 6/19/2024 2:17 PM, Yang, Weijiang wrote:
On 5/18/2024 1:38 AM, Sean Christopherson wrote:

[...]

  /* Mask kvm_cpu_caps for @leaf with the raw CPUID capabilities of this CPU. */
  static __always_inline void __kvm_cpu_cap_mask(unsigned int leaf)
  {
      const struct cpuid_reg cpuid = x86_feature_cpuid(leaf * 32);
-    struct kvm_cpuid_entry2 entry;
        reverse_cpuid_check(leaf);

IIUC, this reverse_cpuid_check() is redundant since it's already enforced in x86_feature_cpuid() via __feature_leaf() as previous patch(17) shows.

Aha, I saw the function is removed in patch(23). Sorry for the noise.

  -    cpuid_count(cpuid.function, cpuid.index,
-            &entry.eax, &entry.ebx, &entry.ecx, &entry.edx);
-
-    kvm_cpu_caps[leaf] &= *__cpuid_entry_get_reg(&entry, cpuid.reg);
+    kvm_cpu_caps[leaf] &= raw_cpuid_get(cpuid);
  }
    static __always_inline