[PATCH v7 099/120] KVM: x86: Use standard CPUID(0x80000022) types
"Ahmed S. Darwish" <[email protected]> Thu, 28 May 2026 17:39:01 +0200
| Newsgroups | dev.linux.lists.x86-cpuid,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Use standard CPUID(0x80000022) types from x86-cpuid-db instead of relying on custom perf types. The latter are in process of getting removed from the kernel. Signed-off-by: Ahmed S. Darwish <[email protected]> --- arch/x86/kvm/cpuid.c | 7 ++++--- arch/x86/kvm/svm/pmu.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 706903ad6628..040e15ff87c5 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -1871,7 +1871,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) break; /* AMD Extended Performance Monitoring and Debug */ case 0x80000022: { - union cpuid_0x80000022_ebx ebx = { }; + struct leaf_0x80000022_0 leaf = { }; + struct cpuid_regs *regs = (struct cpuid_regs *)&leaf; entry->ecx = entry->edx = 0; if (!enable_pmu || !kvm_cpu_cap_has(X86_FEATURE_PERFMON_V2)) { @@ -1881,8 +1882,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) cpuid_entry_override(entry, CPUID_8000_0022_EAX); - ebx.split.num_core_pmc = kvm_pmu_cap.num_counters_gp; - entry->ebx = ebx.full; + leaf.n_pmc_core = kvm_pmu_cap.num_counters_gp; + entry->ebx = regs->ebx; break; } /*Add support for Centaur's CPUID instruction*/ diff --git a/arch/x86/kvm/svm/pmu.c b/arch/x86/kvm/svm/pmu.c index 7aa298eeb072..7c89b330fb73 100644 --- a/arch/x86/kvm/svm/pmu.c +++ b/arch/x86/kvm/svm/pmu.c @@ -179,7 +179,8 @@ static int amd_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) static void amd_pmu_refresh(struct kvm_vcpu *vcpu) { struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); - union cpuid_0x80000022_ebx ebx; + struct leaf_0x80000022_0 leaf = { }; + struct cpuid_regs *regs = (struct cpuid_regs *)&leaf; pmu->version = 1; if (guest_cpu_cap_has(vcpu, X86_FEATURE_PERFMON_V2)) { @@ -190,8 +191,8 @@ static void amd_pmu_refresh(struct kvm_vcpu *vcpu) */ BUILD_BUG_ON(x86_feature_cpuid(X86_FEATURE_PERFMON_V2).function != 0x80000022 || x86_feature_cpuid(X86_FEATURE_PERFMON_V2).index); - ebx.full = kvm_find_cpuid_entry_index(vcpu, 0x80000022, 0)->ebx; - pmu->nr_arch_gp_counters = ebx.split.num_core_pmc; + regs->ebx = kvm_find_cpuid_entry_index(vcpu, 0x80000022, 0)->ebx; + pmu->nr_arch_gp_counters = leaf.n_pmc_core; } else if (guest_cpu_cap_has(vcpu, X86_FEATURE_PERFCTR_CORE)) { pmu->nr_arch_gp_counters = AMD64_NUM_COUNTERS_CORE; } else { -- 2.54.0