diff mbox series

[RFC,20/22] x86/PMUv5: limit available fixed PMCs and enable support

Message ID bcbf0d561c4d77794c27e58b0248eb4fa75bae4a.1698261255.git.edwin.torok@cloud.com (mailing list archive)
State New, archived
Headers show
Series vPMU bugfixes and support for PMUv5 | expand

Commit Message

Edwin Torok Oct. 25, 2023, 7:29 p.m. UTC
From: Edwin Török <edvin.torok@citrix.com>

AnyThread deprecation means a bit in 0xa edx, which we pass through.
(we could also avoid doing the anythread masking, but we need that
 for version <= 4 support).

Fixed Counter enumeration means we need to limit fixed counters if we
hide any.

Domain separation needs no action from the hypervisor AFAICT.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
---
 xen/arch/x86/cpuid.c            | 3 ++-
 xen/arch/x86/include/asm/vpmu.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 12e768ae87..8900943bcd 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -338,7 +338,8 @@  void guest_cpuid(const struct vcpu *v, uint32_t leaf,
             res->a = u.eax;
 
             /* We only implement 3 fixed function counters */
-            if ( (res->d & 0x1f) > fixed_pmc_cnt )
+            res->c &= ~((1 << fixed_pmc_cnt) - 1);
+            if ( (res->d & 0x1f) > fixed_pmc_cnt)
                 res->d = (res->d & ~0x1f) | fixed_pmc_cnt;
         }
         break;
diff --git a/xen/arch/x86/include/asm/vpmu.h b/xen/arch/x86/include/asm/vpmu.h
index eaededadb5..f066b17e45 100644
--- a/xen/arch/x86/include/asm/vpmu.h
+++ b/xen/arch/x86/include/asm/vpmu.h
@@ -74,7 +74,7 @@  struct vpmu_struct {
 #define VPMU_CPU_HAS_DS                     0x1000 /* Has Debug Store */
 #define VPMU_CPU_HAS_BTS                    0x2000 /* Has Branch Trace Store */
 
-#define VPMU_VERSION_MAX                    0x4
+#define VPMU_VERSION_MAX                    0x5
 #define VPMU_VERSION_MAX_SUPPORTED          0x5
 
 static inline void vpmu_set(struct vpmu_struct *vpmu, const u32 mask)