]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
Do not allocate vcpu_guest_context on the stack when initialising a
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 1 Feb 2008 11:11:12 +0000 (11:11 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 1 Feb 2008 11:11:12 +0000 (11:11 +0000)
new VCPU. It is too big for 4kB stacks.
Original patch by Donald Dutile <ddutile@redhat.com> backported from
upstream pv_ops work.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
drivers/xen/core/smpboot.c

index 9f64d8369212742ecaffbf0454d5deecd17f22ab..84352157502cff67eeb9f8f8c62f71988ee67e9d 100644 (file)
@@ -182,7 +182,11 @@ static void __cpuinit cpu_bringup_and_idle(void)
 
 static void __cpuinit cpu_initialize_context(unsigned int cpu)
 {
-       vcpu_guest_context_t ctxt;
+       /* vcpu_guest_context_t is too large to allocate on the stack.
+        * Hence we allocate statically and protect it with a lock */
+       static vcpu_guest_context_t ctxt;
+       static DEFINE_SPINLOCK(ctxt_lock);
+
        struct task_struct *idle = idle_task(cpu);
 #ifdef __x86_64__
        struct desc_ptr *gdt_descr = &cpu_gdt_descr[cpu];
@@ -193,6 +197,8 @@ static void __cpuinit cpu_initialize_context(unsigned int cpu)
        if (cpu_test_and_set(cpu, cpu_initialized_map))
                return;
 
+       spin_lock(&ctxt_lock);
+
        memset(&ctxt, 0, sizeof(ctxt));
 
        ctxt.flags = VGCF_IN_KERNEL;
@@ -242,7 +248,10 @@ static void __cpuinit cpu_initialize_context(unsigned int cpu)
        ctxt.gs_base_kernel = (unsigned long)(cpu_pda(cpu));
 #endif
 
-       BUG_ON(HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, &ctxt));
+       if (HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, &ctxt))
+               BUG();
+
+       spin_unlock(&ctxt_lock);
 }
 
 void __init smp_prepare_cpus(unsigned int max_cpus)