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 F08EBCEB2D9 for ; Tue, 1 Oct 2024 01:59:26 +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=PfLx/3Bmce7c54a5n9TF2pBZ3OvmhnxjieXQTdpAUNY=; b=df08RaeZ23bYJXjlOiM3/V9d+H rl84cGtKMDEgK9B+20MUiVQzkkGcKAszXOzXYgS93JU34mcSoTbmF5UXqUPl3Jz2tIHKNj41M1bTU +SJnv4KJL+OEyqVPyIshQVf6JVH/MVFkeoAJQgqR2bPPbn9H8pvcQ1Fm51Yiigm/oFzJnPlPIVbfo m4Bvu8gjTDy94nyJJQf8oYDTSxXul0m2IQuM5fu3Ra6DbAwpfm0X/veE0LOBOHh+/3NbYPQg3Q+j4 a0pAyH4ncZdN48nMefHI0FW1vvDwEqxKQXi79+8PfBVBC9cAPh+PstP2zYxpu04ulHQHVKqc645Eg cW/6KdUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svSAW-00000001JPV-24xN; Tue, 01 Oct 2024 01:59:16 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svS9I-00000001J76-3wTf for linux-arm-kernel@lists.infradead.org; Tue, 01 Oct 2024 01:58:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 72F0C5C4D95; Tue, 1 Oct 2024 01:57:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88933C4CEC7; Tue, 1 Oct 2024 01:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727747879; bh=IYEMmh/FsI2Dol2j7J7yefHUkiDeEMb7ZjHXw8AaVy4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pDWPDii8fCQnzNfylwXI5t/KB4gMatH/u/1Lus+CoQQGVv8EnqgLWSm7hlN9x5eNX dL0LtoGdsxTfo6HpvjBJph8kHlmsCMQfh8KaTTGcX/ToPFtQCwtg8BSbwVBzLzhN33 KFmXaGmz7S968N4dvxEfEbVFW/eoDDmt0/eS5doa+/izqXBm3xvdp9Fl4QjFyGCulU UyanrmFW6xjylrGilbVZYaR76R0MRsj0pDvQvCk7+4fZzE7DXTxSwfHNFRluAGDeNk bljeN3UYNmTbvUY0eOIWD3npibDIVpDPq6UdijjUO+8R/m8RJ5S6Ds7IGtKnyCvFQ+ dNRgf7gyLhiZA== Date: Tue, 1 Oct 2024 10:57:53 +0900 From: Masami Hiramatsu (Google) To: Steven Rostedt Cc: Will Deacon , 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: <20241001105753.723314ca371e9f484c88bcac@kernel.org> In-Reply-To: <20240930144659.5aaf7be4@gandalf.local.home> References: <172615368656.133222.2336770908714920670.stgit@devnote2> <172615372005.133222.15797801841635819220.stgit@devnote2> <20240915044614.5721947e@rorschach.local.home> <20240917082624.GC27290@willie-the-truck> <20240930144659.5aaf7be4@gandalf.local.home> X-Mailer: Sylpheed 3.7.0 (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_185801_143454_6D7B5A05 X-CRM114-Status: GOOD ( 29.74 ) 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 Mon, 30 Sep 2024 14:46:59 -0400 Steven Rostedt wrote: > 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. I will add this condition in the description in next version. Thank you, > > > > > 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 > -- Masami Hiramatsu (Google)