aboutsummaryrefslogtreecommitdiffstats
path: root/xen/drivers/cpufreq
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-11-03 10:24:17 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-11-03 10:24:17 +0000
commit7df6b00a5824702c9f539c74b2ede76a3ebf6d47 (patch)
treee3c0fe787ceed995e7c600bdd0c1359898142638 /xen/drivers/cpufreq
parent9cec91aba58722d189ef7f5c7257aed5fc072e8c (diff)
downloadxen-7df6b00a5824702c9f539c74b2ede76a3ebf6d47.tar.gz
xen-7df6b00a5824702c9f539c74b2ede76a3ebf6d47.tar.bz2
xen-7df6b00a5824702c9f539c74b2ede76a3ebf6d47.zip
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>
Diffstat (limited to 'xen/drivers/cpufreq')
-rw-r--r--xen/drivers/cpufreq/cpufreq.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index 26101b8086..8777a8a822 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -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, struct xen_processor_performance *dom0_px_in
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, struct xen_processor_performance *dom0_px_in
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, struct xen_processor_performance *dom0_px_in
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, struct xen_processor_performance *dom0_px_in
if ( pxpt->init == XEN_PX_INIT )
{
-
ret = cpufreq_limit_change(cpuid);
goto out;
}