From nobody Thu Dec 18 09:45:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1E761F7570 for ; Tue, 17 Dec 2024 16:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734452989; cv=none; b=HqusLcxcw6BjuGp3K7WrdfAVmGbJaKShvcXZl3bkRvw+IafprtywepQJdwsJTesnO79EpTY1NiT4SEQlXa3Av2T8JKZQEhLhX6wR9REkK/v4r2h0ZZITWer7Ojmd21ciNDR3ycR8Eb69fNoIR0ShnBnXTeGxMp+yWEGv5PMInXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734452989; c=relaxed/simple; bh=ftlei99CJZc1Z0+jLBFENc3sLEE4iqRbQrRDg0WxLPo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=pkfbcnyGmMFAX/Fehta49gifp4P2zP/5xqBTJAlIopkfurmEntBVDupdn44/7zVEaWabj5wTLOjVTVkAdfA4m0kulO5qfb2fcNQ2l6xnhxB3ZBun5n+uxaMIMZZgk1bOtXNP7Xzlf8Gnw+/DApk/JR46GndCiq+HnYlCOwaOC80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C967C4CEDF; Tue, 17 Dec 2024 16:29:49 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tNaSn-00000008afL-2Yjy; Tue, 17 Dec 2024 11:30:25 -0500 Message-ID: <20241217163025.461545709@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 17 Dec 2024 11:18:42 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Al Viro , Michal Simek , Jeff Xie , Al Viro Subject: [for-linus v2][PATCH 2/2] ftrace: Do not find "true_parent" if HAVE_DYNAMIC_FTRACE_WITH_ARGS is not set References: <20241217161840.069495339@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt When function tracing and function graph tracing are both enabled (in different instances) the "parent" of some of the function tracing events is "return_to_handler" which is the trampoline used by function graph tracing. To fix this, ftrace_get_true_parent_ip() was introduced that returns the "true" parent ip instead of the trampoline. To do this, the ftrace_regs_get_stack_pointer() is used, which uses kernel_stack_pointer(). The problem is that microblaze does not implement kerenl_stack_pointer() so when function graph tracing is enabled, the build fails. But microblaze also does not enabled HAVE_DYNAMIC_FTRACE_WITH_= ARGS. That option has to be enabled by the architecture to reliably get the values from the fregs parameter passed in. When that config is not set, the architecture can also pass in NULL, which is not tested for in that function and could cause the kernel to crash. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: Mark Rutland Cc: Al Viro Cc: Michal Simek Cc: Jeff Xie Link: https://lore.kernel.org/20241216164633.6df18e87@gandalf.local.home Fixes: 60b1f578b578 ("ftrace: Get the true parent ip for function tracer") Reported-by: Al Viro Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_functions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 74c353164ca1..d358c9935164 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -176,7 +176,8 @@ static void function_trace_start(struct trace_array *tr) tracing_reset_online_cpus(&tr->array_buffer); } =20 -#ifdef CONFIG_FUNCTION_GRAPH_TRACER +/* fregs are guaranteed not to be NULL if HAVE_DYNAMIC_FTRACE_WITH_ARGS is= set */ +#if defined(CONFIG_FUNCTION_GRAPH_TRACER) && defined(CONFIG_HAVE_DYNAMIC_F= TRACE_WITH_ARGS) static __always_inline unsigned long function_get_true_parent_ip(unsigned long parent_ip, struct ftrace_regs *f= regs) { --=20 2.45.2