From: Keir Fraser Date: Mon, 4 Feb 2008 14:24:57 +0000 (+0000) Subject: Do not allocate vcpu_guest_context on the stack when initialising a X-Git-Tag: 3.1.4-rc1~51 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=dd41a59cc0378a5d16c55e890f547a37a147325d;p=people%2Fvhanquez%2Fxen.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 linux-2.6.18-xen changeset: 402:687ef5a4fcb7c6a0c8fe90ab25ce58a465c1cb4b linux-2.6.18-xen date: Fri Feb 01 11:11:12 2008 +0000 --- diff --git a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c index 8ebc1b4ec..aa1d5a61a 100644 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c @@ -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)