Skip to contentSkip to conversation

vpmu: separate architecture specific PMU initialisation

PATCH New Dietmar Hahn 1 participant 1 message Jan 19, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vpmu: separate architecture specific PMU initialisation

 xen/arch/x86/hvm/svm/vpmu.c       |  26 ++++++++++++++++++++++
 xen/arch/x86/hvm/vmx/vpmu_core2.c |  31 ++++++++++++++++++++++++++
 xen/arch/x86/hvm/vpmu.c           |  45 ++++---------------------------------
 xen/include/asm-x86/hvm/vpmu.h    |   6 +++-
 4 files changed, 67 insertions(+), 41 deletions(-)

This patch moves the architecture specific initialisation of the PMU into the archicture specific directory. Further the boot variable opt_vpmu_enabled gets global accessible for using in other files.

xen/arch/x86/hvm/svm/vpmu.c +26 -0
diff -r 5b2676ac1321 xen/arch/x86/hvm/svm/vpmu.c
@@ -362,3 +362,29 @@ struct arch_vpmu_ops amd_vpmu_ops = {
     .arch_vpmu_save = amd_vpmu_save,
     .arch_vpmu_load = amd_vpmu_restore
 };
+
+int svm_vpmu_initialize(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+    __u8 family = current_cpu_data.x86;
+
+    if ( !opt_vpmu_enabled )
+        return -EINVAL;
+
+    switch ( family )
+    {
+    case 0x10:
+    case 0x12:
+    case 0x14:
+    case 0x15:
+        vpmu->arch_vpmu_ops = &amd_vpmu_ops;
+        break;
+    default:
+        printk("VPMU: Initialization failed. "
+               "AMD processor family %d has not "
+               "been supported\n", family);
+        return -EINVAL;
+    }
+    return 0;
+}
+
xen/arch/x86/hvm/vmx/vpmu_core2.c +31 -0
diff -r 5b2676ac1321 xen/arch/x86/hvm/vmx/vpmu_core2.c
@@ -607,3 +607,34 @@ struct arch_vpmu_ops core2_vpmu_ops = {
     .arch_vpmu_save = core2_vpmu_save,
     .arch_vpmu_load = core2_vpmu_load
 };
+
+int vmx_vpmu_initialize(struct vcpu *v)
+{
+    struct vpmu_struct *vpmu = vcpu_vpmu(v);
+    __u8 family = current_cpu_data.x86;
+    __u8 cpu_model = current_cpu_data.x86_model;
+
+    if ( !opt_vpmu_enabled )
+        return -EINVAL;
+
+    if ( family == 6 )
+    {
+        switch ( cpu_model )
+        {
+        case 15:
+        case 23:
+        case 26:
+        case 29:
+        case 42:
+        case 46:
+        case 47:
+            vpmu->arch_vpmu_ops = &core2_vpmu_ops;
+            return 0;
+        }
+    }
+    printk("VPMU: Initialization failed. "
+           "Intel processor family %d model %d has not "
+           "been supported\n", family, cpu_model);
+    return -EINVAL;
+}
+
xen/arch/x86/hvm/vpmu.c +6 -39

71 lines not on this page · raw message

xen/include/asm-x86/hvm/vpmu.h +4 -2
diff -r 5b2676ac1321 xen/include/asm-x86/hvm/vpmu.h
@@ -28,6 +28,8 @@
                                           arch.hvm_vcpu.vpmu))
 #define vpmu_domain(vpmu) (vpmu_vcpu(vpmu)->domain)
 
+extern bool_t opt_vpmu_enabled;
+
 #define MSR_TYPE_COUNTER            0
 #define MSR_TYPE_CTRL               1
 #define MSR_TYPE_GLOBAL             2
@@ -56,8 +58,8 @@ struct arch_vpmu_ops {
     void (*arch_vpmu_load)(struct vcpu *v);
 };
 
-extern struct arch_vpmu_ops core2_vpmu_ops;
-extern struct arch_vpmu_ops amd_vpmu_ops;
+int vmx_vpmu_initialize(struct vcpu *v);
+int svm_vpmu_initialize(struct vcpu *v);
 
 struct vpmu_struct {
     u32 flags;
Signature · 1 line
Company details: http://ts.fujitsu.com/imprint.html