]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Do not allocate vcpu_guest_context on the stack when initialising a
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 4 Feb 2008 14:24:57 +0000 (14:24 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 4 Feb 2008 14:24:57 +0000 (14:24 +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>
linux-2.6.18-xen changeset:   402:687ef5a4fcb7c6a0c8fe90ab25ce58a465c1cb4b
linux-2.6.18-xen date:        Fri Feb 01 11:11:12 2008 +0000

linux-2.6-xen-sparse/drivers/xen/core/smpboot.c

index 8ebc1b4eca98e509d507432f864322968abd5365..aa1d5a61a388199db35dd71d4c98413b34866446 100644 (file)
@@ -183,7 +183,11 @@ static void cpu_bringup_and_idle(void)
 
 static void 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];
@@ -194,6 +198,8 @@ static void 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;
@@ -243,7 +249,10 @@ static void 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)