Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755746AbdCGSes (ORCPT ); Tue, 7 Mar 2017 13:34:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52196 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754383AbdCGSep (ORCPT ); Tue, 7 Mar 2017 13:34:45 -0500 Date: Tue, 7 Mar 2017 11:38:21 -0600 From: Josh Poimboeuf To: Pavel Machek Cc: kernel list , mingo@kernel.org, luto@kernel.org, bp@alien8.de, brgerst@gmail.com, dvlasenk@redhat.com, hpa@zytor.com, torvalds@linux-foundation.org, peterz@infradead.org, tglx@linutronix.de Subject: Re: v4.10: kernel stack frame pointer .. has bad value (null) Message-ID: <20170307173821.yknj5htr7plgdwxv@treble> References: <20170221231216.y56gb62vkn5ewgea@treble> <20170222210548.GC8467@amd> <20170222212103.tigzbw5sfrwd7uwh@treble> <20170222224755.GA4310@amd> <20170222225614.4z4z24uz6l2iz6qm@treble> <20170222231808.hmr6ulbvfnrg2at7@treble> <20170223201039.GB5177@amd> <20170225050439.7dplheb6nyne4nkm@treble> <20170302234514.3qcqdozibcltkdai@treble> <20170306163807.GA20689@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170306163807.GA20689@amd> 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.38]); Tue, 07 Mar 2017 17:38:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2082 Lines: 50 On Mon, Mar 06, 2017 at 05:38:07PM +0100, Pavel Machek wrote: > Sorry for the delay. This is on v4.11-rc1, but that should be similar. > > pavel@duo:~$ gcc --version > gcc (Debian 4.9.2-10) 4.9.2 > > And here's the disassemble: > > c402d200 : > c402d200: 57 push %edi > c402d201: 8d 7c 24 08 lea 0x8(%esp),%edi > c402d205: 83 e4 f8 and $0xfffffff8,%esp > c402d208: ff 77 fc pushl -0x4(%edi) > c402d20b: 55 push %ebp > c402d20c: 89 e5 mov %esp,%ebp > c402d20e: 57 push %edi > c402d20f: 56 push %esi > c402d210: 83 ec 10 sub $0x10,%esp Thanks. This confirms what I was thinking, the function prologue is wack. It's realigning the stack, but it's not the "normal" realign pattern. Instead it makes a fake frame header, which saves a duplicate copy of the return address ("pushl -0x4(%edi)") in a place the unwinder wasn't expecting. I did some digging in gcc to figure out why this can happen. gcc uses something called a Dynamic Realign Argument Pointer (DRAP), which, when enabled, makes a prologue like the above. It's almost always enabled for aligned stacks when -maccumulate-outgoing-args isn't set. So I'm thinking we should have -maccumulate-outgoing-args always enabled on x86_32 just like we already do on x86_64. Can you verify the warning is fixed with the following patch? ----- diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu index 6647ed4..53ec1e4 100644 --- a/arch/x86/Makefile_32.cpu +++ b/arch/x86/Makefile_32.cpu @@ -61,7 +61,7 @@ ifeq ($(CONFIG_JUMP_LABEL), y) ADD_ACCUMULATE_OUTGOING_ARGS := y endif -cflags-$(ADD_ACCUMULATE_OUTGOING_ARGS) += $(call cc-option,-maccumulate-outgoing-args) +cflags-y += $(call cc-option,-maccumulate-outgoing-args) # Bug fix for binutils: this option is required in order to keep # binutils from generating NOPL instructions against our will.