[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1 of 2] 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. Signed-off-by: Dietmar Hahn <dietmar.hahn@xxxxxxxxxxxxxx> diff -r 5b2676ac1321 xen/arch/x86/hvm/svm/vpmu.c --- a/xen/arch/x86/hvm/svm/vpmu.c Mon Jan 09 16:01:44 2012 +0100 +++ b/xen/arch/x86/hvm/svm/vpmu.c Thu Jan 19 13:14:02 2012 +0100 @@ -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; +} + diff -r 5b2676ac1321 xen/arch/x86/hvm/vmx/vpmu_core2.c --- a/xen/arch/x86/hvm/vmx/vpmu_core2.c Mon Jan 09 16:01:44 2012 +0100 +++ b/xen/arch/x86/hvm/vmx/vpmu_core2.c Thu Jan 19 13:14:02 2012 +0100 @@ -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; +} + diff -r 5b2676ac1321 xen/arch/x86/hvm/vpmu.c --- a/xen/arch/x86/hvm/vpmu.c Mon Jan 09 16:01:44 2012 +0100 +++ b/xen/arch/x86/hvm/vpmu.c Thu Jan 19 13:14:02 2012 +0100 @@ -32,7 +32,7 @@ #include <asm/hvm/svm/svm.h> #include <asm/hvm/svm/vmcb.h> -static bool_t __read_mostly opt_vpmu_enabled; +bool_t __read_mostly opt_vpmu_enabled; boolean_param("vpmu", opt_vpmu_enabled); int vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content) @@ -82,11 +82,6 @@ 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; - - if ( !opt_vpmu_enabled ) - return; if ( vpmu->flags & VPMU_CONTEXT_ALLOCATED ) vpmu_destroy(v); @@ -94,47 +89,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_initialize(v) ) + 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_initialize(v) ) + opt_vpmu_enabled = 0; break; default: printk("VPMU: Initialization failed. " "Unknown CPU vendor %d\n", vendor); + opt_vpmu_enabled = 0; break; } diff -r 5b2676ac1321 xen/include/asm-x86/hvm/vpmu.h --- a/xen/include/asm-x86/hvm/vpmu.h Mon Jan 09 16:01:44 2012 +0100 +++ b/xen/include/asm-x86/hvm/vpmu.h Thu Jan 19 13:14:02 2012 +0100 @@ -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; -- Company details: http://ts.fujitsu.com/imprint.html _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |