xen: add assertion in default_vcpu0_location to protect against broken masks
authorIan Campbell <ian.campbell@citrix.com>
Tue, 3 Jul 2012 09:52:33 +0000 (10:52 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 3 Jul 2012 09:52:33 +0000 (10:52 +0100)
When setting up the cpu sibling/etc masks on ARM I accidentally and
incorrectly omitted a CPU from it's own sibling mask which caused this
function to return an invalid cpu number which caused errors later when we
tried to access per_cpu data for that invalid cpu.

Add an assert to catch this in the future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xen/common/domctl.c

index 9f1a9ada8c6840eabfae1f6e85ae2a93c53a55b1..7ca6b08fa5634f5048fae23f54a80a3dbfe4e31b 100644 (file)
@@ -192,6 +192,7 @@ static unsigned int default_vcpu0_location(cpumask_t *online)
     cpu = cpumask_first(&cpu_exclude_map);
     if ( cpumask_weight(&cpu_exclude_map) > 1 )
         cpu = cpumask_next(cpu, &cpu_exclude_map);
+    ASSERT(cpu < nr_cpu_ids);
     for_each_cpu(i, online)
     {
         if ( cpumask_test_cpu(i, &cpu_exclude_map) )