exporting patch: # HG changeset patch # User Nitin A Kamble # Date 1231854695 28800 # Branch pmu_bugfix # Node ID 05673257cd479e1bd03f706e738ac8001dcac4a2 # Parent e2f36d066b7b66a538bbe240d46f49bede51d9ed The checks in the function passive_domain_do_rdmsr() were not sufficient. Also the same checks were done in the function passive_domain_do_wrmsr(). So these common checks are moved in a new single function passive_domain_msr_op_checks(). Signed-off-by: Nitin A Kamble Signed-off-by: Jun Nakajima diff -r e2f36d066b7b -r 05673257cd47 xen/arch/x86/oprofile/nmi_int.c --- a/xen/arch/x86/oprofile/nmi_int.c Mon Dec 22 13:48:40 2008 +0000 +++ b/xen/arch/x86/oprofile/nmi_int.c Tue Jan 13 05:51:35 2009 -0800 @@ -38,19 +38,29 @@ extern int is_active(struct domain *d); extern int is_passive(struct domain *d); +static int passive_domain_msr_op_checks(struct cpu_user_regs *regs ,int *typep, int *indexp) +{ + struct vpmu_struct *vpmu = vcpu_vpmu(current); + if ( model == NULL ) + return 0; + if ( model->is_arch_pmu_msr == NULL ) + return 0; + if ( !model->is_arch_pmu_msr((u64)regs->ecx, typep, indexp) ) + return 0; + + if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) ) + if ( ! model->allocated_msr(current) ) + return 0; + return 1; +} + int passive_domain_do_rdmsr(struct cpu_user_regs *regs) { u64 msr_content; int type, index; - struct vpmu_struct *vpmu = vcpu_vpmu(current); - if ( model->is_arch_pmu_msr == NULL ) + if ( !passive_domain_msr_op_checks(regs, &type, &index)) return 0; - if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) ) - return 0; - if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) ) - if ( ! model->allocated_msr(current) ) - return 0; model->load_msr(current, type, index, &msr_content); regs->eax = msr_content & 0xFFFFFFFF; @@ -58,23 +68,13 @@ return 1; } - int passive_domain_do_wrmsr(struct cpu_user_regs *regs) { u64 msr_content; int type, index; - struct vpmu_struct *vpmu = vcpu_vpmu(current); - if ( model == NULL ) + if ( !passive_domain_msr_op_checks(regs, &type, &index)) return 0; - if ( model->is_arch_pmu_msr == NULL ) - return 0; - if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) ) - return 0; - - if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) ) - if ( ! model->allocated_msr(current) ) - return 0; msr_content = (u32)regs->eax | ((u64)regs->edx << 32); model->save_msr(current, type, index, msr_content);