ia64/xen-unstable

changeset 18545:d4a093819310

x86 pmstat: Fix get_pm_info hypercall argument checking.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Sep 25 10:12:17 2008 +0100 (2008-09-25)
parents 50170dc8649c
children 7592da5118ec
files xen/arch/x86/acpi/pmstat.c
line diff
     1.1 --- a/xen/arch/x86/acpi/pmstat.c	Thu Sep 25 10:03:04 2008 +0100
     1.2 +++ b/xen/arch/x86/acpi/pmstat.c	Thu Sep 25 10:12:17 2008 +0100
     1.3 @@ -36,6 +36,7 @@
     1.4  #include <xen/cpumask.h>
     1.5  #include <asm/processor.h>
     1.6  #include <xen/percpu.h>
     1.7 +#include <xen/domain.h>
     1.8  
     1.9  #include <public/sysctl.h>
    1.10  #include <acpi/cpufreq/cpufreq.h>
    1.11 @@ -51,15 +52,26 @@ int do_get_pm_info(struct xen_sysctl_get
    1.12      int ret = 0;
    1.13      const struct processor_pminfo *pmpt = processor_pminfo[op->cpuid];
    1.14  
    1.15 -    /* to protect the case when Px was not controlled by xen */
    1.16 -    if ( (!pmpt || !(pmpt->perf.init & XEN_PX_INIT)) &&
    1.17 -        (op->type & PMSTAT_CATEGORY_MASK) == PMSTAT_PX )
    1.18 +    if ( (op->cpuid >= NR_CPUS) || !cpu_online(op->cpuid) )
    1.19          return -EINVAL;
    1.20  
    1.21 -    if ( op->cpuid >= NR_CPUS || !cpu_online(op->cpuid) )
    1.22 -        return -EINVAL;
    1.23 +    switch ( op->type & PMSTAT_CATEGORY_MASK )
    1.24 +    {
    1.25 +    case PMSTAT_CX:
    1.26 +        if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_CX) )
    1.27 +            return -ENODEV;
    1.28 +        break;
    1.29 +    case PMSTAT_PX:
    1.30 +        if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
    1.31 +            return -ENODEV;
    1.32 +        if ( !pmpt || !(pmpt->perf.init & XEN_PX_INIT) )
    1.33 +            return -EINVAL;
    1.34 +        break;
    1.35 +    default:
    1.36 +        return -ENODEV;
    1.37 +    }
    1.38  
    1.39 -    switch( op->type )
    1.40 +    switch ( op->type )
    1.41      {
    1.42      case PMSTAT_get_max_px:
    1.43      {