From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31F06CCFA16 for ; Mon, 30 Sep 2024 18:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=w7czQGAn923z7OqqHAIVdhDU+Pa9TgXMfMlppsAdfQw=; b=tL37cf6QhOHdWAx1Z4/94N4wmP fqESMrHyz4i1ceIESYI6K2NKFRaAUCMV+uamKcnLDh35ADnBEKpdvUkr+dRBbiEIXyQj3Vxg8bw76 d5Y3jQm1tbEyZhnjjyxPCEJEOIXc1EevljUYKv4GNwIrvwQaj6R9uZ6ghcsLlnnlk7kjyVBu8UPAj Xoduj3fLQWKJb+lPyWPRQr+sE2OBvfqATHAgLH1x1rgGQHnJmC/eRiW1eTqVNuMsHP4yl0FtBdP5f q7Oqhxg3jPO0jHamJbK9QgcPWneqhXeaJz6kO184phrH9jVdrSQxEGWkHHtxrxP6VFaNiOOk8PrFX 7OP4Ntyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svLUY-00000000Z9k-0foW; Mon, 30 Sep 2024 18:51:30 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svLPT-00000000YFq-3292 for linux-arm-kernel@lists.infradead.org; Mon, 30 Sep 2024 18:46:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 196E0A40BF5; Mon, 30 Sep 2024 18:46:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E9D1C4CEC7; Mon, 30 Sep 2024 18:46:12 +0000 (UTC) Date: Mon, 30 Sep 2024 14:46:59 -0400 From: Steven Rostedt To: Will Deacon Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, "Masami Hiramatsu (Google)" , Florent Revest , linux-trace-kernel@vger.kernel.org, LKML , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland Subject: Re: [PATCH v14 03/19] function_graph: Pass ftrace_regs to entryfunc Message-ID: <20240930144659.5aaf7be4@gandalf.local.home> In-Reply-To: <20240917082624.GC27290@willie-the-truck> References: <172615368656.133222.2336770908714920670.stgit@devnote2> <172615372005.133222.15797801841635819220.stgit@devnote2> <20240915044614.5721947e@rorschach.local.home> <20240917082624.GC27290@willie-the-truck> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240930_114615_906719_EDC195EF X-CRM114-Status: GOOD ( 24.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 17 Sep 2024 09:26:25 +0100 Will Deacon wrote: > On Sun, Sep 15, 2024 at 04:46:14AM -0400, Steven Rostedt wrote: > > Can I get an Acked-by from the AARCH64 maintainers for this patch? > > Sorry, I wasn't CC'd on the thread, so I missed this. Here's the lore link that starts it all: https://lore.kernel.org/all/172615368656.133222.2336770908714920670.stgit@devnote2/ There's also a v15: https://lore.kernel.org/linux-trace-kernel/172639136989.366111.11359590127009702129.stgit@devnote2/ > > > On Fri, 13 Sep 2024 00:08:40 +0900 > > "Masami Hiramatsu (Google)" wrote: > > > > > From: Masami Hiramatsu (Google) > > > > > > Pass ftrace_regs to the fgraph_ops::entryfunc(). If ftrace_regs is not > > > available, it passes a NULL instead. User callback function can access > > > some registers (including return address) via this ftrace_regs. > > Under which circumstances is 'ftrace_regs' NULL? When the arch does not define: HAVE_DYNAMIC_FTRACE_WITH_ARGS or HAVE_DYNAMIC_FTRACE_WITH_REGS If HAVE_DYNAMIC_FTRACE_WITH_REGS is defined but not the WITH_ARGS, and the ops used to register the function callback does not set FTRACE_OPS_FL_SAVE_REGS. Otherwise it should be set. > > The arm64 implementation of ftrace_graph_func() is: > > > > diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c > > > index a650f5e11fc5..bc647b725e6a 100644 > > > --- a/arch/arm64/kernel/ftrace.c > > > +++ b/arch/arm64/kernel/ftrace.c > > > @@ -481,7 +481,25 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent, > > > void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, > > > struct ftrace_ops *op, struct ftrace_regs *fregs) > > > { > > > - prepare_ftrace_return(ip, &fregs->lr, fregs->fp); > > > + unsigned long return_hooker = (unsigned long)&return_to_handler; > > > + unsigned long frame_pointer = fregs->fp; > > Which dereferences the unchecked pointer here ^^. Just above the visible portion of the patch, we have: #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs) { Which means fregs will be available. The "WITH_ARGS" config tells us that the arch will supply the function with valid fregs to the ftrace callback (which this is). -- Steve