From 36444aeb04312f204bac7d1caa39aad62eadea4c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 8 Aug 2008 11:22:44 +0100 Subject: [PATCH] x86: Reduce restrictions on dom0_max_vcpus. Place a BUILD_BUG_ON() in mm.c to replace one of the restrictions. Signed-off-by: Keir Fraser --- xen/arch/x86/domain_build.c | 6 +----- xen/arch/x86/mm.c | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index 8bb24c9dd6..d4388a6669 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -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) ) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 9aa18a9c3c..c6855d76d6 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -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); -- 2.30.2