ia64/xen-unstable

changeset 11482:3f57453d404c

Small fix for xenoprof.

Update list of privileged xenoprof operations which were not in sync
with new added functions.
Since the number of privileged operations is larger than the non
privileged ones, change the logic to list unprivileged ones instead.
Also added a few printk statements on failed xenoprof initialization
to identify the source of the problem.

Signed-off-by: Jose Renato Santos <jsantos@hpl.hp.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 15 11:01:58 2006 +0100 (2006-09-15)
parents e87e5d216c0b
children e26948616552
files xen/arch/x86/oprofile/nmi_int.c xen/arch/x86/oprofile/xenoprof.c
line diff
     1.1 --- a/xen/arch/x86/oprofile/nmi_int.c	Fri Sep 15 10:59:18 2006 +0100
     1.2 +++ b/xen/arch/x86/oprofile/nmi_int.c	Fri Sep 15 11:01:58 2006 +0100
     1.3 @@ -269,8 +269,12 @@ static int __init p4_init(char * cpu_typ
     1.4  { 
     1.5  	__u8 cpu_model = current_cpu_data.x86_model;
     1.6  
     1.7 -	if ((cpu_model > 6) || (cpu_model == 5))
     1.8 +	if ((cpu_model > 6) || (cpu_model == 5)) {
     1.9 +		printk("xenoprof: Initialization failed. "
    1.10 +		       "Intel processor model %d for pentium 4 family is not "
    1.11 +		       "supported\n", cpu_model);
    1.12  		return 0;
    1.13 +	}
    1.14  
    1.15  #ifndef CONFIG_SMP
    1.16  	strncpy (cpu_type, "i386/p4", XENOPROF_CPU_TYPE_SIZE - 1);
    1.17 @@ -301,8 +305,12 @@ static int __init ppro_init(char *cpu_ty
    1.18  {
    1.19  	__u8 cpu_model = current_cpu_data.x86_model;
    1.20  
    1.21 -	if (cpu_model > 0xd)
    1.22 +	if (cpu_model > 0xd) {
    1.23 +		printk("xenoprof: Initialization failed. "
    1.24 +		       "Intel processor model %d for P6 class family is not "
    1.25 +		       "supported\n", cpu_model);
    1.26  		return 0;
    1.27 +	}
    1.28  
    1.29  	if (cpu_model == 9) {
    1.30  		strncpy (cpu_type, "i386/p6_mobile", XENOPROF_CPU_TYPE_SIZE - 1);
    1.31 @@ -324,8 +332,10 @@ int nmi_init(int *num_events, int *is_pr
    1.32  	__u8 family = current_cpu_data.x86;
    1.33  	int prim = 0;
    1.34   
    1.35 -	if (!cpu_has_apic)
    1.36 +	if (!cpu_has_apic) {
    1.37 +		printk("xenoprof: Initialization failed. No apic.\n");
    1.38  		return -ENODEV;
    1.39 +	}
    1.40  
    1.41  	if (primary_profiler == NULL) {
    1.42  		/* For now, only dom0 can be the primary profiler */
    1.43 @@ -344,6 +354,9 @@ int nmi_init(int *num_events, int *is_pr
    1.44  
    1.45  			switch (family) {
    1.46  			default:
    1.47 +				printk("xenoprof: Initialization failed. "
    1.48 +				       "AMD processor family %d is not "
    1.49 +				       "supported\n", family);
    1.50  				return -ENODEV;
    1.51  			case 6:
    1.52  				model = &op_athlon_spec;
    1.53 @@ -375,11 +388,17 @@ int nmi_init(int *num_events, int *is_pr
    1.54  					break;
    1.55  
    1.56  				default:
    1.57 +				printk("xenoprof: Initialization failed. "
    1.58 +				       "Intel processor family %d is not "
    1.59 +				       "supported\n", family);
    1.60  					return -ENODEV;
    1.61  			}
    1.62  			break;
    1.63  
    1.64  		default:
    1.65 +			printk("xenoprof: Initialization failed. "
    1.66 +			       "Unsupported processor. Unknown vendor %d\n",
    1.67 +				vendor);
    1.68  			return -ENODEV;
    1.69  	}
    1.70  
     2.1 --- a/xen/arch/x86/oprofile/xenoprof.c	Fri Sep 15 10:59:18 2006 +0100
     2.2 +++ b/xen/arch/x86/oprofile/xenoprof.c	Fri Sep 15 11:01:58 2006 +0100
     2.3 @@ -492,19 +492,23 @@ int xenoprof_op_get_buffer(XEN_GUEST_HAN
     2.4      return 0;
     2.5  }
     2.6  
     2.7 -#define PRIV_OP(op) ( (op == XENOPROF_set_active)       \
     2.8 -                   || (op == XENOPROF_reserve_counters) \
     2.9 -                   || (op == XENOPROF_setup_events)     \
    2.10 -                   || (op == XENOPROF_start)            \
    2.11 -                   || (op == XENOPROF_stop)             \
    2.12 -                   || (op == XENOPROF_release_counters) \
    2.13 -                   || (op == XENOPROF_shutdown))
    2.14 -
    2.15 +#define NONPRIV_OP(op) ( (op == XENOPROF_init)          \
    2.16 +                      || (op == XENOPROF_enable_virq)   \
    2.17 +                      || (op == XENOPROF_disable_virq)  \
    2.18 +                      || (op == XENOPROF_get_buffer))
    2.19 + 
    2.20  int do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg)
    2.21  {
    2.22      int ret = 0;
    2.23 +    
    2.24 +    if ( (op < 0) || (op>XENOPROF_last_op) )
    2.25 +    {
    2.26 +        printk("xenoprof: invalid operation %d for domain %d\n",
    2.27 +               op, current->domain->domain_id);
    2.28 +        return -EINVAL;
    2.29 +    }
    2.30  
    2.31 -    if ( PRIV_OP(op) && (current->domain != primary_profiler) )
    2.32 +    if ( !NONPRIV_OP(op) && (current->domain != primary_profiler) )
    2.33      {
    2.34          printk("xenoprof: dom %d denied privileged operation %d\n",
    2.35                 current->domain->domain_id, op);