[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Cpufreq: Enhance hypervisor px sanity check



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1225707857 0
# Node ID 303b1014f91e5fa0783a5d7095626a47e82db9d0
# Parent  91a2b9309a723637c31a52caa63dd78ead4f8fd2
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@xxxxxxxxx>
---
 xen/arch/ia64/xen/cpufreq/cpufreq.c |   15 ----------
 xen/arch/x86/acpi/cpufreq/cpufreq.c |   12 --------
 xen/drivers/cpufreq/cpufreq.c       |   50 +++++++++++++++++++++++++++++++++++-
 3 files changed, 49 insertions(+), 28 deletions(-)

diff -r 91a2b9309a72 -r 303b1014f91e xen/arch/ia64/xen/cpufreq/cpufreq.c
--- a/xen/arch/ia64/xen/cpufreq/cpufreq.c       Mon Nov 03 10:23:09 2008 +0000
+++ b/xen/arch/ia64/xen/cpufreq/cpufreq.c       Mon Nov 03 10:24:17 2008 +0000
@@ -209,21 +209,6 @@ acpi_cpufreq_cpu_init (struct cpufreq_po
 
        data->acpi_data = &processor_pminfo[cpu]->perf;
 
-       /* capability check */
-       if (data->acpi_data->state_count <= 1) {
-               printk(KERN_WARNING "P-States\n");
-               result = -ENODEV;
-               goto err_unreg;
-       }
-
-       if ((data->acpi_data->control_register.space_id !=
-                               ACPI_ADR_SPACE_FIXED_HARDWARE) ||
-                       (data->acpi_data->status_register.space_id !=
-                        ACPI_ADR_SPACE_FIXED_HARDWARE)) {
-               result = -ENODEV;
-               goto err_unreg;
-       }
-
        data->freq_table = xmalloc_array(struct cpufreq_frequency_table,
                        (data->acpi_data->state_count + 1));
        if (!data->freq_table) {
diff -r 91a2b9309a72 -r 303b1014f91e xen/arch/x86/acpi/cpufreq/cpufreq.c
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c       Mon Nov 03 10:23:09 2008 +0000
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c       Mon Nov 03 10:24:17 2008 +0000
@@ -447,18 +447,6 @@ acpi_cpufreq_cpu_init(struct cpufreq_pol
     perf = data->acpi_data;
     policy->shared_type = perf->shared_type;
 
-    /* capability check */
-    if (perf->state_count <= 1) {
-        printk("No P-States\n");
-        result = -ENODEV;
-        goto err_unreg;
-    }
-
-    if (perf->control_register.space_id != perf->status_register.space_id) {
-        result = -ENODEV;
-        goto err_unreg;
-    }
-
     switch (perf->control_register.space_id) {
     case ACPI_ADR_SPACE_SYSTEM_IO:
         printk("xen_pminfo: @acpi_cpufreq_cpu_init,"
diff -r 91a2b9309a72 -r 303b1014f91e xen/drivers/cpufreq/cpufreq.c
--- a/xen/drivers/cpufreq/cpufreq.c     Mon Nov 03 10:23:09 2008 +0000
+++ b/xen/drivers/cpufreq/cpufreq.c     Mon Nov 03 10:24:17 2008 +0000
@@ -117,6 +117,15 @@ int cpufreq_add_cpu(unsigned int cpu)
         cpu_set(cpu, cpufreq_dom->map);
         cpu_set(cpu, policy->cpus);
 
+        /* domain coordination sanity check */
+        if ((perf->domain_info.coord_type !=
+             processor_pminfo[firstcpu]->perf.domain_info.coord_type) ||
+            (perf->domain_info.num_processors !=
+             processor_pminfo[firstcpu]->perf.domain_info.num_processors)) {
+            ret = -EINVAL;
+            goto err2;
+        }
+
         printk(KERN_EMERG"adding CPU %u\n", cpu);
     } else {
         cpufreq_dom = xmalloc(struct cpufreq_dom);
@@ -303,6 +312,24 @@ int set_px_pminfo(uint32_t acpi_id, stru
 
     if ( dom0_px_info->flags & XEN_PX_PCT )
     {
+        /* space_id check */
+        if (dom0_px_info->control_register.space_id != 
+            dom0_px_info->status_register.space_id)
+        {
+            ret = -EINVAL;
+            goto out;
+        }
+
+#ifdef CONFIG_IA64
+        /* for IA64, currently it only supports FFH */
+        if (dom0_px_info->control_register.space_id !=
+            ACPI_ADR_SPACE_FIXED_HARDWARE)
+        {
+            ret = -EINVAL;
+            goto out;
+        }
+#endif
+
         memcpy ((void *)&pxpt->control_register,
                 (void *)&dom0_px_info->control_register,
                 sizeof(struct xen_pct_register));
@@ -312,8 +339,16 @@ int set_px_pminfo(uint32_t acpi_id, stru
         print_PCT(&pxpt->control_register);
         print_PCT(&pxpt->status_register);
     }
+
     if ( dom0_px_info->flags & XEN_PX_PSS ) 
     {
+        /* capability check */
+        if (dom0_px_info->state_count <= 1)
+        {
+            ret = -EINVAL;
+            goto out;
+        }
+
         if ( !(pxpt->states = xmalloc_array(struct xen_processor_px,
                         dom0_px_info->state_count)) )
         {
@@ -325,14 +360,28 @@ int set_px_pminfo(uint32_t acpi_id, stru
         pxpt->state_count = dom0_px_info->state_count;
         print_PSS(pxpt->states,pxpt->state_count);
     }
+
     if ( dom0_px_info->flags & XEN_PX_PSD )
     {
+#ifdef CONFIG_X86
+        /* for X86, check domain coordination */
+        /* for IA64, _PSD is optional for current IA64 cpufreq algorithm */
+        if (dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_ALL &&
+            dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_ANY &&
+            dom0_px_info->shared_type != CPUFREQ_SHARED_TYPE_HW)
+        {
+            ret = -EINVAL;
+            goto out;
+        }
+#endif
+
         pxpt->shared_type = dom0_px_info->shared_type;
         memcpy ((void *)&pxpt->domain_info,
                 (void *)&dom0_px_info->domain_info,
                 sizeof(struct xen_psd_package));
         print_PSD(&pxpt->domain_info);
     }
+
     if ( dom0_px_info->flags & XEN_PX_PPC )
     {
         pxpt->platform_limit = dom0_px_info->platform_limit;
@@ -340,7 +389,6 @@ int set_px_pminfo(uint32_t acpi_id, stru
 
         if ( pxpt->init == XEN_PX_INIT )
         {
-
             ret = cpufreq_limit_change(cpuid); 
             goto out;
         }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.