Message ID | 20230921082957.44628-8-xiong.y.zhang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Upgrade intel vPMU version to 5 | expand |
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 0544e30b4946..e10844e2f211 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -1004,7 +1004,15 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) entry->eax = eax.full; entry->ebx = kvm_pmu_cap.events_mask; - entry->ecx = 0; + if (kvm_pmu_cap.version < 5) + entry->ecx = 0; + else + /* + * Todo: When perf driver supports Fixed counter bitmap + * and export it, KVM will get it from perf driver and set + * it into entry->ecx. + */ + entry->ecx = (1ULL << kvm_pmu_cap.num_counters_fixed) - 1; entry->edx = edx.full; break; }
With Arch PMU v5, CPUID.0AH.ECX is a bit mask which enumerates the supported Fixed Counters. If bit 'i' is set, it implies that Fixed Counter 'i' is supported. This commit add CPUID.0AH.ECX emulation for vPMU version 5, KVM support Fixed Counter enumeration starting from 0 by default, user could modify it through SET_CPUID2 ioctl. When perf driver supports fixed counter bitmap and exports it, KVM will get it from perf driver, and set it as KVM supported CPUID.0AH.ECX. Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> --- arch/x86/kvm/cpuid.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)