From: Keir Fraser Date: Fri, 1 Feb 2008 11:11:12 +0000 (+0000) Subject: Do not allocate vcpu_guest_context on the stack when initialising a X-Git-Tag: xen-3.2.0~14 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c746ff4b7dcb9846b20af419e940ce3d2718a360;p=legacy%2Flinux-2.6.18-xen.git Do not allocate vcpu_guest_context on the stack when initialising a new VCPU. It is too big for 4kB stacks. Original patch by Donald Dutile backported from upstream pv_ops work. Signed-off-by: Keir Fraser --- diff --git a/drivers/xen/core/smpboot.c b/drivers/xen/core/smpboot.c index 9f64d836..84352157 100644 --- a/drivers/xen/core/smpboot.c +++ b/drivers/xen/core/smpboot.c @@ -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)