[PATCH v2 7/9] KVM: x86/pmu: Add fixed counter enumeration for pmu v5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 arch/x86/kvm/cpuid.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

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;
 	}
-- 
2.34.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux