x86: Reduce restrictions on dom0_max_vcpus.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 8 Aug 2008 10:22:44 +0000 (11:22 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 8 Aug 2008 10:22:44 +0000 (11:22 +0100)
Place a BUILD_BUG_ON() in mm.c to replace one of the restrictions.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/domain_build.c
xen/arch/x86/mm.c

index 8bb24c9dd6cd1cffb7bdf0a3c20b71b36c466a01..d4388a666982a4e18e908fadf65fb45f136f8c7e 100644 (file)
@@ -704,16 +704,12 @@ int __init construct_dom0(
 
     if ( opt_dom0_max_vcpus == 0 )
         opt_dom0_max_vcpus = num_online_cpus();
-    if ( opt_dom0_max_vcpus > num_online_cpus() )
-        opt_dom0_max_vcpus = num_online_cpus();
     if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS )
         opt_dom0_max_vcpus = MAX_VIRT_CPUS;
-    if ( opt_dom0_max_vcpus > BITS_PER_GUEST_LONG(d) )
-        opt_dom0_max_vcpus = BITS_PER_GUEST_LONG(d);
     printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus);
 
     for ( i = 1; i < opt_dom0_max_vcpus; i++ )
-        (void)alloc_vcpu(d, i, i);
+        (void)alloc_vcpu(d, i, i % num_online_cpus());
 
     /* Set up CR3 value for write_ptbase */
     if ( paging_mode_enabled(v->domain) )
index 9aa18a9c3cc90dd2c75998b6f228a54c5525896e..c6855d76d663677c54eb50f9bba0b46d6cf3e3de 100644 (file)
@@ -2218,6 +2218,12 @@ static inline cpumask_t vcpumask_to_pcpumask(
     cpumask_t    pmask = CPU_MASK_NONE;
     struct vcpu *v;
 
+    /*
+     * Callers copy only a single guest-sized longword from the guest.
+     * This must be wide enough to reference all VCPUs. Worst case is 32 bits.
+     */
+    BUILD_BUG_ON(MAX_VIRT_CPUS > 32);
+
     while ( vmask != 0 )
     {
         vcpu_id = find_first_set_bit(vmask);