From ced736bf180ffb22d42bdd0c82ce60eb8816ef4c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 13 May 2010 08:55:06 +0100 Subject: [PATCH] VPMU: Migrate vpmu files into public folders Signed-off-by: Wei Wang --- xen/arch/x86/hvm/Makefile | 1 + xen/arch/x86/hvm/vmx/Makefile | 1 - xen/arch/x86/hvm/vmx/vpmu_core2.c | 2 +- xen/arch/x86/hvm/vpmu.c | 119 +++++++++++++++++++++++ xen/arch/x86/oprofile/op_model_ppro.c | 2 +- xen/include/asm-x86/hvm/vmx/vmcs.h | 2 +- xen/include/asm-x86/hvm/{vmx => }/vpmu.h | 0 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 xen/arch/x86/hvm/vpmu.c rename xen/include/asm-x86/hvm/{vmx => }/vpmu.h (100%) diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile index f61d1240e1..44a8b1b62a 100644 --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -21,3 +21,4 @@ obj-y += vlapic.o obj-y += vmsi.o obj-y += vpic.o obj-y += vpt.o +obj-y += vpmu.o \ No newline at end of file diff --git a/xen/arch/x86/hvm/vmx/Makefile b/xen/arch/x86/hvm/vmx/Makefile index 77e0bac3d4..f63aeacc22 100644 --- a/xen/arch/x86/hvm/vmx/Makefile +++ b/xen/arch/x86/hvm/vmx/Makefile @@ -3,5 +3,4 @@ obj-y += intr.o obj-y += realmode.o obj-y += vmcs.o obj-y += vmx.o -obj-y += vpmu.o obj-y += vpmu_core2.o diff --git a/xen/arch/x86/hvm/vmx/vpmu_core2.c b/xen/arch/x86/hvm/vmx/vpmu_core2.c index 31ca46e7b5..e8c19332ca 100644 --- a/xen/arch/x86/hvm/vmx/vpmu_core2.c +++ b/xen/arch/x86/hvm/vmx/vpmu_core2.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include u32 core2_counters_msr[] = { diff --git a/xen/arch/x86/hvm/vpmu.c b/xen/arch/x86/hvm/vpmu.c new file mode 100644 index 0000000000..ac2129106f --- /dev/null +++ b/xen/arch/x86/hvm/vpmu.c @@ -0,0 +1,119 @@ +/* + * vpmu.c: PMU virtualization for HVM domain. + * + * Copyright (c) 2007, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307 USA. + * + * Author: Haitao Shan + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int __read_mostly opt_vpmu_enabled; +boolean_param("vpmu", opt_vpmu_enabled); + +int vpmu_do_wrmsr(struct cpu_user_regs *regs) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(current); + + if ( vpmu->arch_vpmu_ops ) + return vpmu->arch_vpmu_ops->do_wrmsr(regs); + return 0; +} + +int vpmu_do_rdmsr(struct cpu_user_regs *regs) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(current); + + if ( vpmu->arch_vpmu_ops ) + return vpmu->arch_vpmu_ops->do_rdmsr(regs); + return 0; +} + +int vpmu_do_interrupt(struct cpu_user_regs *regs) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(current); + + if ( vpmu->arch_vpmu_ops ) + return vpmu->arch_vpmu_ops->do_interrupt(regs); + return 0; +} + +void vpmu_save(struct vcpu *v) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(v); + + if ( vpmu->arch_vpmu_ops ) + vpmu->arch_vpmu_ops->arch_vpmu_save(v); +} + +void vpmu_load(struct vcpu *v) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(v); + + if ( vpmu->arch_vpmu_ops ) + vpmu->arch_vpmu_ops->arch_vpmu_load(v); +} + +extern struct arch_vpmu_ops core2_vpmu_ops; +void vpmu_initialise(struct vcpu *v) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(v); + + if ( !opt_vpmu_enabled ) + return; + + if ( vpmu->flags & VPMU_CONTEXT_ALLOCATED ) + vpmu_destroy(v); + + if ( current_cpu_data.x86 == 6 ) + { + switch ( current_cpu_data.x86_model ) + { + case 15: + case 23: + case 26: + case 29: + vpmu->arch_vpmu_ops = &core2_vpmu_ops; + break; + } + } + + if ( vpmu->arch_vpmu_ops != NULL ) + { + vpmu->flags = 0; + vpmu->context = NULL; + vpmu->arch_vpmu_ops->arch_vpmu_initialise(v); + } +} + +void vpmu_destroy(struct vcpu *v) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(v); + + if ( vpmu->arch_vpmu_ops ) + vpmu->arch_vpmu_ops->arch_vpmu_destroy(v); +} + diff --git a/xen/arch/x86/oprofile/op_model_ppro.c b/xen/arch/x86/oprofile/op_model_ppro.c index 112824c14c..598b9e47aa 100644 --- a/xen/arch/x86/oprofile/op_model_ppro.c +++ b/xen/arch/x86/oprofile/op_model_ppro.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include "op_x86_model.h" diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h index a30c05ab41..e8bd776641 100644 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h @@ -21,7 +21,7 @@ #include #include -#include +#include extern void start_vmx(void); extern void vmcs_dump_vcpu(struct vcpu *v); diff --git a/xen/include/asm-x86/hvm/vmx/vpmu.h b/xen/include/asm-x86/hvm/vpmu.h similarity index 100% rename from xen/include/asm-x86/hvm/vmx/vpmu.h rename to xen/include/asm-x86/hvm/vpmu.h -- 2.39.5