xenoprof: The checks in the function passive_domain_do_rdmsr() were
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 15 Jan 2009 12:36:29 +0000 (12:36 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 15 Jan 2009 12:36:29 +0000 (12:36 +0000)
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 <nitin.a.kamble@intel.com>
Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
xen/arch/x86/oprofile/nmi_int.c

index ef5d1227fdfb0cde9c8de6c74cb5848b3d7f78e3..ba58f2116d3fa41a6830f1b2990206b2c01f9840 100644 (file)
@@ -38,19 +38,29 @@ static char *cpu_type;
 extern int is_active(struct domain *d);
 extern int is_passive(struct domain *d);
 
-int passive_domain_do_rdmsr(struct cpu_user_regs *regs)
+static int passive_domain_msr_op_checks(struct cpu_user_regs *regs ,int *typep, int *indexp)
 {
-       u64 msr_content;
-       int type, index;
        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, &type, &index) )
+       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;
+
+       if ( !passive_domain_msr_op_checks(regs, &type, &index))
+               return 0;
 
        model->load_msr(current, type, index, &msr_content);
        regs->eax = msr_content & 0xFFFFFFFF;
@@ -58,23 +68,13 @@ int passive_domain_do_rdmsr(struct cpu_user_regs *regs)
        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);