Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932502AbcLLWLu (ORCPT ); Mon, 12 Dec 2016 17:11:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49928 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932182AbcLLWLs (ORCPT ); Mon, 12 Dec 2016 17:11:48 -0500 Date: Mon, 12 Dec 2016 16:11:47 -0600 From: Josh Poimboeuf To: Borislav Petkov Cc: x86-ml , lkml , Andy Lutomirski Subject: Re: WARNING: kernel stack frame pointer at ffffffff82e03f40 in swapper:0 has bad value (null) Message-ID: <20161212221147.twp2nlcolokzq4a4@treble> References: <20161210161749.gvboowyhtffvpoo3@pd.tnic> <20161210170444.trpnnq4gtkx5djqm@treble> <20161210172802.gpgjjndo56d43mi4@pd.tnic> <20161212154542.ul6cnzjtkbvooluh@treble> <20161212175023.455mlwhmnqfew2nu@pd.tnic> <20161212181025.uz3gk3jasuskqfmf@treble> <20161212211627.yuodrw35xwq3hmn7@treble> <20161212213446.imd3hpt3nudomu7r@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161212213446.imd3hpt3nudomu7r@pd.tnic> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 12 Dec 2016 22:11:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2105 Lines: 68 On Mon, Dec 12, 2016 at 10:34:46PM +0100, Borislav Petkov wrote: > On Mon, Dec 12, 2016 at 03:16:27PM -0600, Josh Poimboeuf wrote: > > I still can't figure out what could cause this, nor can I recreate it. > > Want my .config? Yes, please. > > Andy, any idea? I'm trying to figure out why a stack trace of the > > initial task, early in start_kernel(), would show start_cpu() on the > > stack *twice*. The start_cpu() entry on the stack at ffffffffbce03f50 > > is right where it's supposed to be. But then there's another > > start_cpu() entry at 0xffffffffbce03f48 which is pointed to by the frame > > pointer chain. I can't figure out where that one came from and why the > > stack is offset by a word, compared to all the other idle task stacks > > I've seen. > > Btw, why do you have: > > call 1f # put return address on stack for unwinder > > there in start_cpu() instead of > > push $start_cpu > > or so? That CALL looks strange there. If you want to put the return > address, just push start_cpu's address and that's it. > > Or am I missing something? Yeah, it's kind of obtuse. The problem with "push $start_cpu" is that it will show up on the stack trace as: secondary_startup_64+0x90/0x90 instead of what you would expect: start_cpu+0x0/0x14 That's because the printk '%pB' modifier is smart enough to know that the beginning of a function isn't a valid function call return address. The only way such an address could end up on the stack would be if the previous function made a tail call. So it shows the end of the previous function instead. That said, the code could probably be made a little clearer by changing "call 1f" to "push $1f" and then move the '1' label to after the lretq instruction, like: pushq $1f # put return address on stack for unwinder 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 1: ENDPROC(start_cpu) That shows: start_cpu+0x14/0x14 Which is more accurate anyway. I'll make a patch. -- Josh