From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752022AbcFTBQl (ORCPT ); Sun, 19 Jun 2016 21:16:41 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:41253 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751910AbcFTBQe (ORCPT ); Sun, 19 Jun 2016 21:16:34 -0400 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.98.203 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Mon, 20 Jun 2016 09:46:02 +0900 From: Namhyung Kim To: Steven Rostedt CC: , Linus Torvalds , Ingo Molnar , Andrew Morton , Matt Fleming , Masami Hiramatsu Subject: Re: [PATCH 3/3] ftrace/x86: Set ftrace_stub to weak to prevent gcc from using short jumps to it Message-ID: <20160620004602.GD25962@sejong> References: <20160522202846.576089843@goodmis.org> <20160522203001.366892803@goodmis.org> MIME-Version: 1.0 In-Reply-To: <20160522203001.366892803@goodmis.org> User-Agent: Mutt/1.6.1 (2016-04-27) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/06/20 09:46:10, Serialize by Router on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/06/20 09:46:11, Serialize complete at 2016/06/20 09:46:11 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steve, On Sun, May 22, 2016 at 04:28:49PM -0400, Steven Rostedt wrote: > From: Steven Rostedt > > Matt Fleming reported seeing crashes when enabling and disabling > function profiling which uses function graph tracer. Later Namhyung Kim > hit a similar issue and he found that the issue was due to the jmp to > ftrace_stub in ftrace_graph_call was only two bytes, and when it was > changed to jump to the tracing code, it overwrote the ftrace_stub that > was after it. > > Masami Hiramatsu bisected this down to a binutils change: > > 8dcea93252a9ea7dff57e85220a719e2a5e8ab41 is the first bad commit > commit 8dcea93252a9ea7dff57e85220a719e2a5e8ab41 > Author: H.J. Lu > Date: Fri May 15 03:17:31 2015 -0700 > > Add -mshared option to x86 ELF assembler > > This patch adds -mshared option to x86 ELF assembler. By default, > assembler will optimize out non-PLT relocations against defined non-weak > global branch targets with default visibility. The -mshared option tells > the assembler to generate code which may go into a shared library > where all non-weak global branch targets with default visibility can > be preempted. The resulting code is slightly bigger. This option > only affects the handling of branch instructions. > > Declaring ftrace_stub as a weak call prevents gas from using two byte > jumps to it, which would be converted to a jump to the function graph > code. > > Link: http://lkml.kernel.org/r/20160516230035.1dbae571@gandalf.local.home Shouldn't it go to the stable tree? Thanks, Namhyung > > Reported-by: Matt Fleming > Reported-by: Namhyung Kim > Tested-by: Matt Fleming > Reviewed-by: Masami Hiramatsu > Signed-off-by: Steven Rostedt > --- > arch/x86/kernel/mcount_64.S | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S > index ed48a9f465f8..61924222a9e1 100644 > --- a/arch/x86/kernel/mcount_64.S > +++ b/arch/x86/kernel/mcount_64.S > @@ -182,7 +182,8 @@ GLOBAL(ftrace_graph_call) > jmp ftrace_stub > #endif > > -GLOBAL(ftrace_stub) > +/* This is weak to keep gas from relaxing the jumps */ > +WEAK(ftrace_stub) > retq > END(ftrace_caller) > > -- > 2.8.0.rc3 > >