ia64/xen-unstable

changeset 18754:303b1014f91e

Cpufreq: Enhance hypervisor px sanity check

This patch enhances hypervisor px sanity check in 2 level:
Firstly, move per-cpu-level px sanity check from each cpufreq driver
to common point (@ hypercall path). Secondly, add per-domain-level px
sanity check to common point (@ cpufreq_add_cpu).

Signed-off-by: Jinsong Liu <jinsong.liu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Nov 03 10:24:17 2008 +0000 (2008-11-03)
parents 91a2b9309a72
children 540483d2a98f
files xen/arch/ia64/xen/cpufreq/cpufreq.c xen/arch/x86/acpi/cpufreq/cpufreq.c xen/drivers/cpufreq/cpufreq.c
line diff
     1.1 --- a/xen/arch/ia64/xen/cpufreq/cpufreq.c	Mon Nov 03 10:23:09 2008 +0000
     1.2 +++ b/xen/arch/ia64/xen/cpufreq/cpufreq.c	Mon Nov 03 10:24:17 2008 +0000
     1.3 @@ -209,21 +209,6 @@ acpi_cpufreq_cpu_init (struct cpufreq_po
     1.4  
     1.5  	data->acpi_data = &processor_pminfo[cpu]->perf;
     1.6  
     1.7 -	/* capability check */
     1.8 -	if (data->acpi_data->state_count <= 1) {
     1.9 -		printk(KERN_WARNING "P-States\n");
    1.10 -		result = -ENODEV;
    1.11 -		goto err_unreg;
    1.12 -	}
    1.13 -
    1.14 -	if ((data->acpi_data->control_register.space_id !=
    1.15 -				ACPI_ADR_SPACE_FIXED_HARDWARE) ||
    1.16 -			(data->acpi_data->status_register.space_id !=
    1.17 -			 ACPI_ADR_SPACE_FIXED_HARDWARE)) {
    1.18 -		result = -ENODEV;
    1.19 -		goto err_unreg;
    1.20 -	}
    1.21 -
    1.22  	data->freq_table = xmalloc_array(struct cpufreq_frequency_table,
    1.23  			(data->acpi_data->state_count + 1));
    1.24  	if (!data->freq_table) {
     2.1 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c	Mon Nov 03 10:23:09 2008 +0000
     2.2 +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c	Mon Nov 03 10:24:17 2008 +0000
     2.3 @@ -447,18 +447,6 @@ acpi_cpufreq_cpu_init(struct cpufreq_pol
     2.4      perf = data->acpi_data;
     2.5      policy->shared_type = perf->shared_type;
     2.6  
     2.7 -    /* capability check */
     2.8 -    if (perf->state_count <= 1) {
     2.9 -        printk("No P-States\n");
    2.10 -        result = -ENODEV;
    2.11 -        goto err_unreg;
    2.12 -    }
    2.13 -
    2.14 -    if (perf->control_register.space_id != perf->status_register.space_id) {
    2.15 -        result = -ENODEV;
    2.16 -        goto err_unreg;
    2.17 -    }
    2.18 -
    2.19      switch (perf->control_register.space_id) {
    2.20      case ACPI_ADR_SPACE_SYSTEM_IO:
    2.21          printk("xen_pminfo: @acpi_cpufreq_cpu_init,"
     3.1 --- a/xen/drivers/cpufreq/cpufreq.c	Mon Nov 03 10:23:09 2008 +0000
     3.2 +++ b/xen/drivers/cpufreq/cpufreq.c	Mon Nov 03 10:24:17 2008 +0000
     3.3 @@ -117,6 +117,15 @@ int cpufreq_add_cpu(unsigned int cpu)
     3.4          cpu_set(cpu, cpufreq_dom->map);
     3.5          cpu_set(cpu, policy->cpus);
     3.6  
     3.7 +        /* domain coordination sanity check */
     3.8 +        if ((perf->domain_info.coord_type !=
     3.9 +             processor_pminfo[firstcpu]->perf.domain_info.coord_type) ||
    3.10 +            (perf->domain_info.num_processors !=
    3.11 +             processor_pminfo[firstcpu]->perf.domain_info.num_processors)) {
    3.12 +            ret = -EINVAL;
    3.13 +            goto err2;
    3.14 +        }
    3.15 +
    3.16          printk(KERN_EMERG"adding CPU %u\n", cpu);
    3.17      } else {
    3.18          cpufreq_dom = xmalloc(struct cpufreq_dom);
    3.19 @@ -303,6 +312,24 @@ int set_px_pminfo(uint32_t acpi_id, stru
    3.20  
    3.21      if ( dom0_px_info->flags & XEN_PX_PCT )
    3.22      {
    3.23 +        /* space_id check */
    3.24 +        if (dom0_px_info->control_register.space_id != 
    3.25 +            dom0_px_info->status_register.space_id)
    3.26 +        {
    3.27 +            ret = -EINVAL;
    3.28 +            goto out;
    3.29 +        }
    3.30 +
    3.31 +#ifdef CONFIG_IA64
    3.32 +        /* for IA64, currently it only supports FFH */
    3.33 +        if (dom0_px_info->control_register.space_id !=
    3.34 +            ACPI_ADR_SPACE_FIXED_HARDWARE)
    3.35 +        {
    3.36 +            ret = -EINVAL;
    3.37 +            goto out;
    3.38 +        }
    3.39 +#endif
    3.40 +
    3.41          memcpy ((void *)&pxpt->control_register,
    3.42                  (void *)&dom0_px_info->control_register,
    3.43                  sizeof(struct xen_pct_register));
    3.44 @@ -312,8 +339,16 @@ int set_px_pminfo(uint32_t acpi_id, stru
    3.45          print_PCT(&pxpt->control_register);
    3.46          print_PCT(&pxpt->status_register);
    3.47      }
    3.48 +
    3.49      if ( dom0_px_info->flags & XEN_PX_PSS ) 
    3.50      {
    3.51 +        /* capability check */
    3.52 +        if (dom0_px_info->state_count <= 1)
    3.53 +        {
    3.54 +            ret = -EINVAL;
    3.55 +            goto out;
    3.56 +        }
    3.57 +
    3.58          if ( !(pxpt->states = xmalloc_array(struct xen_processor_px,
    3.59                          dom0_px_info->state_count)) )
    3.60          {
    3.61 @@ -325,14 +360,28 @@ int set_px_pminfo(uint32_t acpi_id, stru
    3.62          pxpt->state_count = dom0_px_info->state_count;
    3.63          print_PSS(pxpt->states,pxpt->state_count);
    3.64      }
    3.65 +
    3.66      if ( dom0_px_info->flags & XEN_PX_PSD )
    3.67      {
    3.68 +#ifdef CONFIG_X86
    3.69 +        /* for X86, check domain coordination */
    3.70 +        /* for IA64, _PSD is optional for current IA64 cpufreq algorithm */
    3.71 +        if (dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_ALL &&
    3.72 +            dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_ANY &&
    3.73 +            dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_HW)
    3.74 +        {
    3.75 +            ret = -EINVAL;
    3.76 +            goto out;
    3.77 +        }
    3.78 +#endif
    3.79 +
    3.80          pxpt->shared_type = dom0_px_info->shared_type;
    3.81          memcpy ((void *)&pxpt->domain_info,
    3.82                  (void *)&dom0_px_info->domain_info,
    3.83                  sizeof(struct xen_psd_package));
    3.84          print_PSD(&pxpt->domain_info);
    3.85      }
    3.86 +
    3.87      if ( dom0_px_info->flags & XEN_PX_PPC )
    3.88      {
    3.89          pxpt->platform_limit = dom0_px_info->platform_limit;
    3.90 @@ -340,7 +389,6 @@ int set_px_pminfo(uint32_t acpi_id, stru
    3.91  
    3.92          if ( pxpt->init == XEN_PX_INIT )
    3.93          {
    3.94 -
    3.95              ret = cpufreq_limit_change(cpuid); 
    3.96              goto out;
    3.97          }