@@ -9,6 +9,7 @@ obj-y += bootfdt.o
obj-y += cpu.o
obj-y += cpuerrata.o
obj-y += cpufeature.o
+obj-y += cpupool.o
obj-y += decode.o
obj-y += device.o
obj-y += domain.o
new file mode 100644
@@ -0,0 +1,45 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <xen/cpumask.h>
+#include <xen/sched.h>
+#include <xen/sched-if.h>
+
+int arch_cpupool_create(struct cpupool *c)
+{
+ c->info.midr = -1;
+
+ return 0;
+}
+
+int arch_cpupool_cpu_add(struct cpupool *c, unsigned int cpu)
+{
+ if (( c->info.midr == -1 ) || ( cpumask_weight(c->cpu_valid) == 0 ))
+ {
+ c->info.midr = cpu_data[cpu].midr.bits;
+
+ return 0;
+ }
+ else if (( c->info.midr == cpu_data[cpu].midr.bits ))
+ {
+ return 0;
+ }
+ else
+ {
+ return -EINVAL;
+ }
+}
+
+bool_t arch_domain_cpupool_compatible(struct domain *d, struct cpupool *c)
+{
+ return true;
+}
@@ -4,6 +4,7 @@ subdir-y += mtrr
obj-y += amd.o
obj-y += centaur.o
obj-y += common.o
+obj-y += cpupool.o
obj-y += intel.o
obj-y += intel_cacheinfo.o
obj-y += mwait-idle.o
new file mode 100644
@@ -0,0 +1,30 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <xen/cpumask.h>
+#include <xen/sched.h>
+#include <xen/sched-if.h>
+
+int arch_cpupool_create(struct cpupool *c)
+{
+ return 0;
+}
+
+int arch_cpupool_cpu_add(struct cpupool *c, unsigned int cpu)
+{
+ return 0;
+}
+
+bool_t arch_domain_cpupool_compatible(struct domain *d, struct cpupool *c)
+{
+ return true;
+}
@@ -134,11 +134,20 @@ static struct cpupool *cpupool_create(
struct cpupool *c;
struct cpupool **q;
int last = 0;
+ int ret;
*perr = -ENOMEM;
if ( (c = alloc_cpupool_struct()) == NULL )
return NULL;
+ ret = arch_cpupool_create(c);
+ if ( ret )
+ {
+ *perr = ret;
+ free_cpupool_struct(c);
+ return NULL;
+ }
+
/* One reference for caller, one reference for cpupool_destroy(). */
atomic_set(&c->refcnt, 2);
@@ -498,6 +507,8 @@ static int cpupool_cpu_add(unsigned int cpu)
{
if ( cpumask_test_cpu(cpu, (*c)->cpu_suspended ) )
{
+ if ( arch_cpupool_cpu_add(*c, cpu) )
+ continue;
ret = cpupool_assign_cpu_locked(*c, cpu);
if ( ret )
goto out;
@@ -516,6 +527,13 @@ static int cpupool_cpu_add(unsigned int cpu)
}
else
{
+ if ( arch_cpupool_cpu_add(cpupool0, cpu) )
+ {
+ /* No fail, just skip adding the cpu to cpupool0 */
+ ret = 0;
+ goto out;
+ }
+
/*
* If we are not resuming, we are hot-plugging cpu, and in which case
* we add it to pool0, as it certainly was there when hot-unplagged
@@ -657,6 +675,9 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
ret = -ENOENT;
if ( c == NULL )
goto addcpu_out;
+ ret = -EINVAL;
+ if ( arch_cpupool_cpu_add(c, cpu) )
+ goto addcpu_out;
ret = cpupool_assign_cpu_locked(c, cpu);
addcpu_out:
spin_unlock(&cpupool_lock);
@@ -707,7 +728,16 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
c = cpupool_find_by_id(op->cpupool_id);
if ( (c != NULL) && cpumask_weight(c->cpu_valid) )
+ {
+ if ( !arch_domain_cpupool_compatible (d, c) )
+ {
+ ret = -EINVAL;
+ spin_unlock(&cpupool_lock);
+ rcu_unlock_domain(d);
+ break;
+ }
ret = cpupool_move_domain_locked(d, c);
+ }
spin_unlock(&cpupool_lock);
cpupool_dprintk("cpupool move_domain(dom=%d)->pool=%d ret %d\n",
@@ -203,4 +203,7 @@ static inline cpumask_t* cpupool_domain_cpumask(struct domain *d)
return d->cpupool->cpu_valid;
}
+int arch_cpupool_create(struct cpupool *c);
+int arch_cpupool_cpu_add(struct cpupool *c, unsigned int cpu);
+bool_t arch_domain_cpupool_compatible(struct domain *d, struct cpupool *c);
#endif /* __XEN_SCHED_IF_H__ */