From patchwork Tue Jun 18 16:23:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puranjay Mohan X-Patchwork-Id: 13702714 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 798DAC27C4F for ; Tue, 18 Jun 2024 16:24:12 +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: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=FdXf8VdYMmBnxXvT8vW3/38EnqNky0DqaZHLzWlXq3I=; b=2crELOdUf8pPXyyulQp3OwWnh2 u0ncOxyeyfNYSg0LvOaz7lwFOwDpkAIPuHXv3JXRS9QzOiyEhEjnNx3l930AdokuFeI5kCVKsOL/P njA4DKMdD/qR/3XCNkF2nDC9HV1B5EGkGJS70Zw4KoZtHgWXqYpz29y8RTw13x+ZRqKGkxPash30h yz6+FFLOkHW86i2lmkbcS/p+QtYrwRCbYt0YUERBNH/EVl+gN22vdV5Rakm/xlGg3WEEiEdduIrqd ZyHKOiPXxDubg8L8XTBHbkUfNMG3RlR4arPxheZNjCsasVjMv9++HUILLLAlvHvKiH2BNdzRf1Us7 gVzKKMRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJbcm-0000000FqAP-2JEh; Tue, 18 Jun 2024 16:24:00 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJbcj-0000000Fq8Z-20fh for linux-arm-kernel@lists.infradead.org; Tue, 18 Jun 2024 16:23:59 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C61CA611E6; Tue, 18 Jun 2024 16:23:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FEE7C3277B; Tue, 18 Jun 2024 16:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718727836; bh=4xeT/qCYi2F1Gnln/3rac4dX/aw8TdWIfRPIPf+PvlU=; h=From:To:Cc:Subject:Date:From; b=jAOi3Qtnlp/JkgKpv7517ZGMfJYwJszop2rzFqupi9ipJPxse4ji1zTR0dmqulBtd xfgjFSUjWAioQ1l/SSkSMTqDnDjy1d5ZfgPPc3lslzBNXtsihCTu9Dp6+Itmq3Wgi8 c8d0AaBXIFVo4auBvlJn2RjkJSWTTIzUpM8cTK4XbizQxw7LS7/0+7Bi4cGc+X2+m1 c4qwD7HplA/WXmlJ6wXQteJy0yP7d/s6mZ/GnGD0V0A6iPPrJe55IeVK08SkgU10hs hKFh/9rq2s9XBdSZuKCa7FZmaJFZ+cr3CL/CIfcMgEo8K6SCX5od7N26wj8HG8WgJd n8hrAuV8GiEEg== From: Puranjay Mohan To: Catalin Marinas , Will Deacon , Puranjay Mohan , Mark Rutland , "Madhavan T. Venkataraman" , Kalesh Singh , chenqiwu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org Cc: puranjay12@gmail.com Subject: [PATCH] arm64: stacktrace: fix the usage of ftrace_graph_ret_addr() Date: Tue, 18 Jun 2024 16:23:42 +0000 Message-Id: <20240618162342.28275-1-puranjay@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240618_092357_607777_7DEEA10F X-CRM114-Status: GOOD ( 13.13 ) 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 ftrace_graph_ret_addr() takes an 'idx' integer pointer that is used to optimize the stack unwinding process. arm64 currently passes `NULL` for this parameter which stops it from utilizing these optimizations. Further, the current code for ftrace_graph_ret_addr() will just return the passed in return address if it is NULL which will break this usage. Pass a valid integer pointer to ftrace_graph_ret_addr() similar to x86_64's stack unwinder. Signed-off-by: Puranjay Mohan Reviewed-by: Steven Rostedt (Google) Reviewed-by: Mark Rutland Tested-by: Mark Rutland Acked-by: Will Deacon Acked-by: Steven Rostedt (Google) --- arch/arm64/kernel/stacktrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 6b3258860377..2729faaee4b4 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -25,6 +25,7 @@ * * @common: Common unwind state. * @task: The task being unwound. + * @graph_idx: Used by ftrace_graph_ret_addr() for optimized stack unwinding. * @kr_cur: When KRETPROBES is selected, holds the kretprobe instance * associated with the most recently encountered replacement lr * value. @@ -32,6 +33,7 @@ struct kunwind_state { struct unwind_state common; struct task_struct *task; + int graph_idx; #ifdef CONFIG_KRETPROBES struct llist_node *kr_cur; #endif @@ -106,7 +108,7 @@ kunwind_recover_return_address(struct kunwind_state *state) if (state->task->ret_stack && (state->common.pc == (unsigned long)return_to_handler)) { unsigned long orig_pc; - orig_pc = ftrace_graph_ret_addr(state->task, NULL, + orig_pc = ftrace_graph_ret_addr(state->task, &state->graph_idx, state->common.pc, (void *)state->common.fp); if (WARN_ON_ONCE(state->common.pc == orig_pc))