ia64/xen-unstable

changeset 19046:f6a455c9f01d

xenoprof: 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 <nitin.a.kamble@intel.com>
Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 15 12:36:29 2009 +0000 (2009-01-15)
parents 5b75d99acf9c
children ecf603780f56
files xen/arch/x86/oprofile/nmi_int.c
line diff
     1.1 --- a/xen/arch/x86/oprofile/nmi_int.c	Thu Jan 15 12:35:09 2009 +0000
     1.2 +++ b/xen/arch/x86/oprofile/nmi_int.c	Thu Jan 15 12:36:29 2009 +0000
     1.3 @@ -38,19 +38,29 @@ static char *cpu_type;
     1.4  extern int is_active(struct domain *d);
     1.5  extern int is_passive(struct domain *d);
     1.6  
     1.7 +static int passive_domain_msr_op_checks(struct cpu_user_regs *regs ,int *typep, int *indexp)
     1.8 +{
     1.9 +	struct vpmu_struct *vpmu = vcpu_vpmu(current);
    1.10 +	if ( model == NULL )
    1.11 +		return 0;
    1.12 +	if ( model->is_arch_pmu_msr == NULL )
    1.13 +		return 0;
    1.14 +	if ( !model->is_arch_pmu_msr((u64)regs->ecx, typep, indexp) )
    1.15 +		return 0;
    1.16 +
    1.17 +	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
    1.18 +		if ( ! model->allocated_msr(current) )
    1.19 +			return 0;
    1.20 +	return 1;
    1.21 +}
    1.22 +
    1.23  int passive_domain_do_rdmsr(struct cpu_user_regs *regs)
    1.24  {
    1.25  	u64 msr_content;
    1.26  	int type, index;
    1.27 -	struct vpmu_struct *vpmu = vcpu_vpmu(current);
    1.28  
    1.29 -	if ( model->is_arch_pmu_msr == NULL )
    1.30 +	if ( !passive_domain_msr_op_checks(regs, &type, &index))
    1.31  		return 0;
    1.32 -	if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) )
    1.33 -		return 0;
    1.34 -	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
    1.35 -		if ( ! model->allocated_msr(current) )
    1.36 -			return 0;
    1.37  
    1.38  	model->load_msr(current, type, index, &msr_content);
    1.39  	regs->eax = msr_content & 0xFFFFFFFF;
    1.40 @@ -58,23 +68,13 @@ int passive_domain_do_rdmsr(struct cpu_u
    1.41  	return 1;
    1.42  }
    1.43  
    1.44 -
    1.45  int passive_domain_do_wrmsr(struct cpu_user_regs *regs)
    1.46  {
    1.47  	u64 msr_content;
    1.48  	int type, index;
    1.49 -	struct vpmu_struct *vpmu = vcpu_vpmu(current);
    1.50  
    1.51 -	if ( model == NULL )
    1.52 -		return 0;
    1.53 -	if ( model->is_arch_pmu_msr == NULL )
    1.54 +	if ( !passive_domain_msr_op_checks(regs, &type, &index))
    1.55  		return 0;
    1.56 -	if ( !model->is_arch_pmu_msr((u64)regs->ecx, &type, &index) )
    1.57 -		return 0;
    1.58 -
    1.59 -	if ( !(vpmu->flags & PASSIVE_DOMAIN_ALLOCATED) )
    1.60 -		if ( ! model->allocated_msr(current) )
    1.61 -			return 0;
    1.62  
    1.63  	msr_content = (u32)regs->eax | ((u64)regs->edx << 32);
    1.64  	model->save_msr(current, type, index, msr_content);