diff options
author | Dietmar Hahn <dietmar.hahn@ts.fujitsu.com> | 2012-01-20 10:40:16 +0000 |
---|---|---|
committer | Dietmar Hahn <dietmar.hahn@ts.fujitsu.com> | 2012-01-20 10:40:16 +0000 |
commit | b4960592ac4f1e9c34ae50d6fefd4df92d9601fb (patch) | |
tree | 60c221f9105f967037079f3a571cd3c0055234d7 /xen | |
parent | 3852f2a6da36de3a600a00c432426a3ba967526a (diff) | |
download | xen-b4960592ac4f1e9c34ae50d6fefd4df92d9601fb.tar.gz xen-b4960592ac4f1e9c34ae50d6fefd4df92d9601fb.tar.bz2 xen-b4960592ac4f1e9c34ae50d6fefd4df92d9601fb.zip |
vpmu: separate architecture specific PMU initialisation
This patch moves the architecture specific initialisation of the PMU
into the archicture specific directory.
Signed-off-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Signed-off-by: Keir Fraser <keir@xen.org>
Committed-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen')
-rw-r--r-- | xen/arch/x86/hvm/svm/vpmu.c | 24 | ||||
-rw-r--r-- | xen/arch/x86/hvm/vmx/vpmu_core2.c | 29 | ||||
-rw-r--r-- | xen/arch/x86/hvm/vpmu.c | 42 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vpmu.h | 4 |
4 files changed, 60 insertions, 39 deletions
diff --git a/xen/arch/x86/hvm/svm/vpmu.c b/xen/arch/x86/hvm/svm/vpmu.c index 30288a4fc5..1a69249ca4 100644 --- a/xen/arch/x86/hvm/svm/vpmu.c +++ b/xen/arch/x86/hvm/svm/vpmu.c @@ -296,7 +296,7 @@ static void amd_vpmu_initialise(struct vcpu *v) { struct amd_vpmu_context *ctxt = NULL; struct vpmu_struct *vpmu = vcpu_vpmu(v); - __u8 family = current_cpu_data.x86; + uint8_t family = current_cpu_data.x86; if ( vpmu->flags & VPMU_CONTEXT_ALLOCATED ) return; @@ -362,3 +362,25 @@ struct arch_vpmu_ops amd_vpmu_ops = { .arch_vpmu_save = amd_vpmu_save, .arch_vpmu_load = amd_vpmu_restore }; + +int svm_vpmu_initialise(struct vcpu *v) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(v); + uint8_t family = current_cpu_data.x86; + + switch ( family ) + { + case 0x10: + case 0x12: + case 0x14: + case 0x15: + vpmu->arch_vpmu_ops = &amd_vpmu_ops; + return 0; + } + + printk("VPMU: Initialization failed. " + "AMD processor family %d has not " + "been supported\n", family); + return -EINVAL; +} + diff --git a/xen/arch/x86/hvm/vmx/vpmu_core2.c b/xen/arch/x86/hvm/vmx/vpmu_core2.c index 19ac9cbb04..35ef78a5fd 100644 --- a/xen/arch/x86/hvm/vmx/vpmu_core2.c +++ b/xen/arch/x86/hvm/vmx/vpmu_core2.c @@ -607,3 +607,32 @@ struct arch_vpmu_ops core2_vpmu_ops = { .arch_vpmu_save = core2_vpmu_save, .arch_vpmu_load = core2_vpmu_load }; + +int vmx_vpmu_initialise(struct vcpu *v) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(v); + uint8_t family = current_cpu_data.x86; + uint8_t cpu_model = current_cpu_data.x86_model; + + 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; +} + diff --git a/xen/arch/x86/hvm/vpmu.c b/xen/arch/x86/hvm/vpmu.c index d761fb2c91..bae6eedcf4 100644 --- a/xen/arch/x86/hvm/vpmu.c +++ b/xen/arch/x86/hvm/vpmu.c @@ -81,9 +81,7 @@ void vpmu_load(struct vcpu *v) void vpmu_initialise(struct vcpu *v) { struct vpmu_struct *vpmu = vcpu_vpmu(v); - __u8 vendor = current_cpu_data.x86_vendor; - __u8 family = current_cpu_data.x86; - __u8 cpu_model = current_cpu_data.x86_model; + uint8_t vendor = current_cpu_data.x86_vendor; if ( !opt_vpmu_enabled ) return; @@ -94,47 +92,19 @@ void vpmu_initialise(struct vcpu *v) switch ( vendor ) { case X86_VENDOR_AMD: - 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; - } + if ( svm_vpmu_initialise(v) != 0 ) + opt_vpmu_enabled = 0; break; case X86_VENDOR_INTEL: - 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; - break; - } - } - if ( vpmu->arch_vpmu_ops == NULL ) - printk("VPMU: Initialization failed. " - "Intel processor family %d model %d has not " - "been supported\n", family, cpu_model); + if ( vmx_vpmu_initialise(v) != 0 ) + opt_vpmu_enabled = 0; break; default: printk("VPMU: Initialization failed. " "Unknown CPU vendor %d\n", vendor); + opt_vpmu_enabled = 0; break; } diff --git a/xen/include/asm-x86/hvm/vpmu.h b/xen/include/asm-x86/hvm/vpmu.h index 276333fd80..d08bbc6214 100644 --- a/xen/include/asm-x86/hvm/vpmu.h +++ b/xen/include/asm-x86/hvm/vpmu.h @@ -56,8 +56,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_initialise(struct vcpu *v); +int svm_vpmu_initialise(struct vcpu *v); struct vpmu_struct { u32 flags; |