Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753093AbcD2U2r (ORCPT ); Fri, 29 Apr 2016 16:28:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46282 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753015AbcD2U2p (ORCPT ); Fri, 29 Apr 2016 16:28:45 -0400 Date: Fri, 29 Apr 2016 15:28:39 -0500 From: Josh Poimboeuf To: Brian Gerst Cc: Jessica Yu , Jiri Kosina , Miroslav Benes , Ingo Molnar , Peter Zijlstra , Michael Ellerman , Heiko Carstens , live-patching@vger.kernel.org, Linux Kernel Mailing List , the arch/x86 maintainers , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Vojtech Pavlik , Jiri Slaby , Petr Mladek , Chris J Arges , Andy Lutomirski Subject: Re: [RFC PATCH v2 03/18] x86/asm/head: standardize the bottom of the stack for idle tasks Message-ID: <20160429202839.czi7f2cabf2ehh6q@treble> References: <9268772b31cc7bc4dc40c617e3baf45e07322145.1461875890.git.jpoimboe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1986 Lines: 48 On Fri, Apr 29, 2016 at 02:46:10PM -0400, Brian Gerst wrote: > On Thu, Apr 28, 2016 at 4:44 PM, Josh Poimboeuf wrote: > > Thanks to all the recent x86 entry code refactoring, most tasks' kernel > > stacks start at the same offset right above their saved pt_regs, > > regardless of which syscall was used to enter the kernel. That creates > > a nice convention which makes it straightforward to identify the > > "bottom" of the stack, which can be useful for stack walking code which > > needs to verify the stack is sane. > > > > However there are still a few types of tasks which don't yet follow that > > convention: > > > > 1) CPU idle tasks, aka the "swapper" tasks > > > > 2) freshly forked TIF_FORK tasks which don't have a stack at all > > > > Make the idle tasks conform to the new stack bottom convention by > > starting their stack at a sizeof(pt_regs) offset from the end of the > > stack page. > > > > Signed-off-by: Josh Poimboeuf > > --- > > arch/x86/kernel/head_64.S | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S > > index 6dbd2c0..0b12311 100644 > > --- a/arch/x86/kernel/head_64.S > > +++ b/arch/x86/kernel/head_64.S > > @@ -296,8 +296,9 @@ ENTRY(start_cpu) > > * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect, > > * address given in m16:64. > > */ > > - movq initial_code(%rip),%rax > > - pushq $0 # fake return address to stop unwinder > > + call 1f # put return address on stack for unwinder > > +1: xorq %rbp, %rbp # clear frame pointer > > + movq initial_code(%rip), %rax > > pushq $__KERNEL_CS # set correct cs > > pushq %rax # target address in negative space > > lretq > > This chunk looks like it should be a separate patch. Agreed, thanks. -- Josh