From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946AbbCZNcW (ORCPT ); Thu, 26 Mar 2015 09:32:22 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:36305 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752795AbbCZNcT (ORCPT ); Thu, 26 Mar 2015 09:32:19 -0400 Message-ID: <551409DE.50702@oracle.com> Date: Thu, 26 Mar 2015 09:30:06 -0400 From: Boris Ostrovsky User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Andy Lutomirski , x86@kernel.org, linux-kernel@vger.kernel.org CC: Borislav Petkov , Oleg Nesterov , Denys Vlasenko , xen-devel Subject: Re: [PATCH 2/2] x86: Replace this_cpu_sp0 with current_top_of_stack and fix it on x86_32 References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/06/2015 08:50 PM, Andy Lutomirski wrote: > I broke 32-bit kernels. The implementation of sp0 was correct as > far as I can tell, but sp0 was much weirder on x86_32 than I > realized. It has the following issues: > > - Init's sp0 is inconsistent with everything else's: non-init tasks > are offset by 8 bytes. (I have no idea why, and the comment is unhelpful.) > > - vm86 does crazy things to sp0. > > Fix it up by replacing this_cpu_sp0() with current_top_of_stack() > and using a new percpu variable to track the top of the stack on > x86_32. > > Fixes: 75182b1632a8 x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0() > Signed-off-by: Andy Lutomirski > --- ... > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index febc6aabc72e..759388c538cf 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -806,6 +806,8 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) > #ifdef CONFIG_X86_32 > /* Stack for startup_32 can be just as for start_secondary onwards */ > irq_ctx_init(cpu); > + per_cpu(cpu_current_top_of_stack, cpu) = > + (unsigned long)task_stack_page(idle) + THREAD_SIZE; > #else > clear_tsk_thread_flag(idle, TIF_FORK); > initial_gs = per_cpu_offset(cpu); Andy, We need a similar change for Xen, otherwise 32-bit PV guests are not happy. Is the patch above final (and then should I submit a separate patch) or are you still working on it (and if so, please add the change below)? -boris diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index 1c5e760..561d6f5 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c @@ -444,6 +444,8 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle) per_cpu(current_task, cpu) = idle; #ifdef CONFIG_X86_32 irq_ctx_init(cpu); + per_cpu(cpu_current_top_of_stack, cpu) = + (unsigned long)task_stack_page(idle) + THREAD_SIZE; #else clear_tsk_thread_flag(idle, TIF_FORK); #endif