From patchwork Thu Mar 28 18:40:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puranjay Mohan X-Patchwork-Id: 13609291 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 1603ACD1283 for ; Thu, 28 Mar 2024 18:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ie39sYk9x2dCu04k04x0WWHXvG6OZatqFTqRN8Jui1Y=; b=a2lW9aq1hXuX+3 5RUSJkCt9O7gYZXz9tWiRPEJueO0Kg4dF/dz4aTkDXWdVZTNB5aBV7RHSBp3E6vH/QblGjj1Ys+io yLQ64J/cmIdeSU0NBFJ6SJKUivQ397LGzRmMpw9SWSNH2yI84+nUE/GCXvzjifh3QvRLGDyXCiPnN Uojn2nH/09ygGQMWn23GiZ4yavPxQvSlyXArshGwmIe8qEvHOtv5PEaQYXdNRDPmEvrByZ6NMmGby cOm/ER9ibSPkhShX+egGJEVS7aftIdFxQN0VlvXQShkdD+KyerEAXVUnY7PRCmbc8N6DmH2xtOK8i tSM51Wqnhxz9kPTIgxJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpufy-0000000FDVH-0bTJ; Thu, 28 Mar 2024 18:40:34 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpufv-0000000FDUB-4AHb for linux-riscv@lists.infradead.org; Thu, 28 Mar 2024 18:40:33 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41494c0405eso7866755e9.3 for ; Thu, 28 Mar 2024 11:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711651229; x=1712256029; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X5HiuWpEGn7cY1cM9xGgQQ/PHhgGCf83PSLXysQQN/k=; b=EhFhueN76ojg07qWFZsn3ZZznPhDsj2TsCzEbe5FVfjKYrsVTEESNV55zMD3e+G30W UxQBpZGAdU7/GkHDyMkyxePhsAkHZx2KWGPbbWzbmzJ4n0ClXTmkEjnP3Q/18CNkjnjn UckdkjdzJ+zUra7GILV2dYi9+MwM71vvwGQPtwjr/c6ERfU6vPH+ULDmq32Q35sbVlZ4 /pfBj6DdLQdnzB9/qgKHd+/YLzRZ1/IWa/CYY5RvvP1qZrsM+imqfqhgoT3pKfm7ohqw j2H3abFWNWfscc5wCsoU2caxG5ufUDfV5WqVCA3aQOqMgipYIBH530wznYlHxL9Jo8io ZqtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711651229; x=1712256029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X5HiuWpEGn7cY1cM9xGgQQ/PHhgGCf83PSLXysQQN/k=; b=jlqp32JOlIk89PG6lKVGhSGnss9EQjM45fs1M0R99A6rpBSjp1s+DgqEZRySrF6Ovr T+AUwpczB3KAXyFKLmtoCaTNuVPrX5AMsUvBaO+WF6V5lM0YVUpag3KYo86yDiWsohXt b4yEIqwAkPkPbUqVUwcVI4USIdbX9gORi4Q0LM+yiSTglvDTcSJuRel/PyF0keEk3zRb W/fdXjUxOAxCiWXROBlFAOSlOgwbcy/7dHwa4gv2v4qCCZJNFoJ4HHtCm1R+zUjwCT7B 1jrwgzMruCKn5yQs1uQFaEebE7I2TfvcrYTz3XZkgcG6QWfKCxxMuq63lv4dARVLPflP MJ/w== X-Forwarded-Encrypted: i=1; AJvYcCXlDt6Z5geInCt70fWt98XUqB+7Ct1I5VfLHvr0AxWl7tcSsNbbPejHLZZeZqDrDul6zWEMoZBfPRd1bpbyCCiVXOCcg8Ppi4Ym2OnQsJiz X-Gm-Message-State: AOJu0Yy0z3Z0XGCRlkJLTaJCWuwcuZ+rrYwZS/TtgLtVzQr+P2HAEkp+ +LgAc4uSsJqDk/idItblXeKiYrZQ7mjC7KC+KDXza4unAlz4XBRf X-Google-Smtp-Source: AGHT+IEhP9iRRtULEumOWwr08ZL9lifFDb1imTRVTFD6498BJOclfcgjhfx8rAmWuu2GenkUlyrkTQ== X-Received: by 2002:a05:600c:3b17:b0:414:1325:e8a8 with SMTP id m23-20020a05600c3b1700b004141325e8a8mr124213wms.39.1711651229193; Thu, 28 Mar 2024 11:40:29 -0700 (PDT) Received: from localhost (54-240-197-231.amazon.com. [54.240.197.231]) by smtp.gmail.com with ESMTPSA id bh8-20020a05600c3d0800b004132ae838absm3045508wmb.43.2024.03.28.11.40.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2024 11:40:29 -0700 (PDT) From: Puranjay Mohan To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= Cc: puranjay12@gmail.com Subject: [PATCH 1/2] riscv: stacktrace: use arch_stack_walk() in place of walk_stackframe Date: Thu, 28 Mar 2024 18:40:19 +0000 Message-Id: <20240328184020.34278-2-puranjay12@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240328184020.34278-1-puranjay12@gmail.com> References: <20240328184020.34278-1-puranjay12@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240328_114032_055051_5314DE6D X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently, dump_backtrace(), __get_wchan(), and perf_callchain_kernel() directly call walk_stackframe(). Make then call arch_stack_walk() which is a wrapper around walk_stackframe() and make walk_stackframe() static. This allows making changes to walk_stackframe() without disturbing the users of arch_stack_walk() which is the exposed function. Signed-off-by: Puranjay Mohan --- arch/riscv/include/asm/stacktrace.h | 2 -- arch/riscv/kernel/perf_callchain.c | 2 +- arch/riscv/kernel/stacktrace.c | 26 ++++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h index b1495a7e06ce6..32213e37c379f 100644 --- a/arch/riscv/include/asm/stacktrace.h +++ b/arch/riscv/include/asm/stacktrace.h @@ -11,8 +11,6 @@ struct stackframe { unsigned long ra; }; -extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, - bool (*fn)(void *, unsigned long), void *arg); extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task, const char *loglvl); diff --git a/arch/riscv/kernel/perf_callchain.c b/arch/riscv/kernel/perf_callchain.c index 3348a61de7d99..c023e0b1eb814 100644 --- a/arch/riscv/kernel/perf_callchain.c +++ b/arch/riscv/kernel/perf_callchain.c @@ -74,5 +74,5 @@ static bool fill_callchain(void *entry, unsigned long pc) void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs) { - walk_stackframe(NULL, regs, fill_callchain, entry); + arch_stack_walk(fill_callchain, entry, NULL, regs); } diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c index 64a9c093aef93..e28f7b2e4b6a6 100644 --- a/arch/riscv/kernel/stacktrace.c +++ b/arch/riscv/kernel/stacktrace.c @@ -18,8 +18,9 @@ extern asmlinkage void ret_from_exception(void); -void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, - bool (*fn)(void *, unsigned long), void *arg) +static __always_inline void +walk_stackframe(struct task_struct *task, struct pt_regs *regs, + bool (*fn)(void *, unsigned long), void *arg) { unsigned long fp, sp, pc; int level = 0; @@ -76,8 +77,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, #else /* !CONFIG_FRAME_POINTER */ -void notrace walk_stackframe(struct task_struct *task, - struct pt_regs *regs, bool (*fn)(void *, unsigned long), void *arg) +static __always_inline void +walk_stackframe(struct task_struct *task, struct pt_regs *regs, + bool (*fn)(void *, unsigned long), void *arg) { unsigned long sp, pc; unsigned long *ksp; @@ -107,6 +109,12 @@ void notrace walk_stackframe(struct task_struct *task, #endif /* CONFIG_FRAME_POINTER */ +noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, + struct task_struct *task, struct pt_regs *regs) +{ + walk_stackframe(task, regs, consume_entry, cookie); +} + static bool print_trace_address(void *arg, unsigned long pc) { const char *loglvl = arg; @@ -118,7 +126,7 @@ static bool print_trace_address(void *arg, unsigned long pc) noinline void dump_backtrace(struct pt_regs *regs, struct task_struct *task, const char *loglvl) { - walk_stackframe(task, regs, print_trace_address, (void *)loglvl); + arch_stack_walk(print_trace_address, (void *)loglvl, task, regs); } void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl) @@ -143,13 +151,7 @@ unsigned long __get_wchan(struct task_struct *task) if (!try_get_task_stack(task)) return 0; - walk_stackframe(task, NULL, save_wchan, &pc); + arch_stack_walk(save_wchan, &pc, task, NULL); put_task_stack(task); return pc; } - -noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, - struct task_struct *task, struct pt_regs *regs) -{ - walk_stackframe(task, regs, consume_entry, cookie); -} From patchwork Thu Mar 28 18:40:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Puranjay Mohan X-Patchwork-Id: 13609293 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 977B1CD11DF for ; Thu, 28 Mar 2024 18:40: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6VgO8TAq5vK5f5AIlH1yPhyYW3RcbiwwFcGAttxV0BY=; b=INiZkFdX8soeGD XTaDcrlk1nD3WNEqtMx0BhaXwLObJrEflHsdccYqqTHkvKxUpQpQoaiuWMDLbfgg/1lCTb+ChMSge 59CAQYnO3+PNdZRD3efqoSlLRd16O5YWiL1yabS/I2S9usudIzMcw6VktfLD8MxIpxiVeFi7p8IFn Q7ZQnXUX90Js5meKz8kazY18IxfvpxJ7+rM2E7uKZdtRrh4yPFkBOVJBcbyQCsh3W0oQbyXRu0cY5 lIV6rVe6XoMARtRFP/AW8Njkpw4W7XHk83GAU1q+iGAQ8c78pDlD1xW0oEPuevR3mbw/9J65qPCPi 5WZqHhx9Et464pHwdKfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpug2-0000000FDWf-1r2w; Thu, 28 Mar 2024 18:40:38 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpufx-0000000FDUO-405o for linux-riscv@lists.infradead.org; Thu, 28 Mar 2024 18:40:35 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4149532da36so9050525e9.0 for ; Thu, 28 Mar 2024 11:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711651231; x=1712256031; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wAOQkTdKXTaBL7Qciv0ydA9PkCnbK+OLuX0dvpnwkyo=; b=GMWQf6VHB7sXMuiExQSogXPm2ynE4q44AHvzGhYD32q8Bzr7bHVOBPTnj0z1mnsPj7 kloXmLrnIMCq1G40Jva1yMvBc5u65jhbOUMLq8PN0y9S2buktDrGfwYElKZIbU2bPnZ+ Mlcq0ekuHgn2VwIjAob3TTVMwiQjZIx6hKnPsxtQtW1eQFjpCH7UzgAwNUaYD3EkQ9dY fncWHKU+VHbwBjZJ02/bYLeEdcScxCRS8Q3z6YkvaInqAyiUKRt0bIGr/j4leykkvrNH FMjLP0+kTaYMA5t+khLbUpVEeYczFlJiu7LdF+AehxFBGUGxf4NmEgB4gxyWIyV3UFCb Lm0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711651231; x=1712256031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wAOQkTdKXTaBL7Qciv0ydA9PkCnbK+OLuX0dvpnwkyo=; b=gWv7Vv87QaNm+AuNC56TTP+jzfbgEYMeZjaTN2bNzyfcsvKUwmtkFN9nJWnfI2Xb8z fM1XgBd7XX3HzdSLVtw0ijavsq80/Wj82GZl06CKJiGjY0zXJrBiRumTeBsCjLiKFPHZ xs6bRKLkpOLSx9nIu7L83agSuqOseMn2cAAMF7z4YOJ3vzLzcGgPeMIqsWqUXzRoMb9j vs5M1lbnbC6jHyyjafQBYYEaZubYksIkUHLd3YKAKLNO440A0t7nm5694i/zijt79bxq ZNzVfVYAirs8W8GippZo9Wa0sWPI1axVsQP5YscNX6XF4bUEV//1T0dfQwUm7gGnKjBU Df2A== X-Forwarded-Encrypted: i=1; AJvYcCXetOZqy6qZd4wZq1nx79fqm3+POG+uRyHzf/jyq1vXoGtu/fQy6IVClmoG4o2csWeGryXZdk4Rs++8V1oE2fnu9EYdbzeO1E0e47uJO+L0 X-Gm-Message-State: AOJu0YyUx05bMw0Ats6fWRmlY+NyR+D+qNJZ/OvjMcxjbkKMzd9geWvy RuAmaKGgwFl+YoVtJTT7jiNsNhxRnaoD1m+Y5HzTf1QjespUgX2e X-Google-Smtp-Source: AGHT+IGkeYHwiRZkr52SSP8OsgcXPmyzoOnpkNo7qZq10LSJmGPGKaRRqPv8tAL/pYZXos9qB/4zPw== X-Received: by 2002:a05:600c:3c8c:b0:414:a69:f0b1 with SMTP id bg12-20020a05600c3c8c00b004140a69f0b1mr140663wmb.13.1711651231344; Thu, 28 Mar 2024 11:40:31 -0700 (PDT) Received: from localhost (54-240-197-231.amazon.com. [54.240.197.231]) by smtp.gmail.com with ESMTPSA id g15-20020a05600c4ecf00b0041493009a8bsm6272490wmq.11.2024.03.28.11.40.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2024 11:40:31 -0700 (PDT) From: Puranjay Mohan To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= Cc: puranjay12@gmail.com Subject: [PATCH 2/2] riscv: stacktrace: make walk_stackframe() more robust Date: Thu, 28 Mar 2024 18:40:20 +0000 Message-Id: <20240328184020.34278-3-puranjay12@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240328184020.34278-1-puranjay12@gmail.com> References: <20240328184020.34278-1-puranjay12@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240328_114034_019757_0E84C75B X-CRM114-Status: GOOD ( 16.43 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently walk_stackframe() provides only a cookie and the PC to the consume_entry function. This doesn't allow the implementation of advanced stack walkers that need access to SP and FP as well. Change walk_stackframe to provide a struct unwind_state to the consume_entry function. This unwind_state has all information that is available to walk_stackframe. The information provided to the callback will not always be live/useful, the callback would be aware of the different configurations the information in unwind_state can be. For example: if CONFIG_FRAME_POINTER is not available, unwind_state->fp will always be zero. This commit doesn't make any functional changes. Signed-off-by: Puranjay Mohan --- arch/riscv/kernel/stacktrace.c | 55 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c index e28f7b2e4b6a6..92c41c87b267b 100644 --- a/arch/riscv/kernel/stacktrace.c +++ b/arch/riscv/kernel/stacktrace.c @@ -14,15 +14,26 @@ #include +struct unwind_state { + unsigned long fp; + unsigned long sp; + unsigned long pc; + struct pt_regs *regs; + struct task_struct *task; +}; + +typedef bool (*unwind_consume_fn)(void *cookie, const struct unwind_state *state); + #ifdef CONFIG_FRAME_POINTER extern asmlinkage void ret_from_exception(void); static __always_inline void walk_stackframe(struct task_struct *task, struct pt_regs *regs, - bool (*fn)(void *, unsigned long), void *arg) + unwind_consume_fn fn, void *arg) { unsigned long fp, sp, pc; + struct unwind_state state; int level = 0; if (regs) { @@ -40,12 +51,17 @@ walk_stackframe(struct task_struct *task, struct pt_regs *regs, sp = task->thread.sp; pc = task->thread.ra; } + state.task = task; + state.regs = regs; for (;;) { unsigned long low, high; struct stackframe *frame; - if (unlikely(!__kernel_text_address(pc) || (level++ >= 0 && !fn(arg, pc)))) + state.sp = sp; + state.fp = fp; + state.pc = pc; + if (unlikely(!__kernel_text_address(pc) || (level++ >= 0 && !fn(arg, &state)))) break; /* Validate frame pointer */ @@ -64,7 +80,10 @@ walk_stackframe(struct task_struct *task, struct pt_regs *regs, pc = ftrace_graph_ret_addr(current, NULL, frame->ra, &frame->ra); if (pc == (unsigned long)ret_from_exception) { - if (unlikely(!__kernel_text_address(pc) || !fn(arg, pc))) + state.sp = sp; + state.fp = fp; + state.pc = pc; + if (unlikely(!__kernel_text_address(pc) || !fn(arg, &state))) break; pc = ((struct pt_regs *)sp)->epc; @@ -79,9 +98,10 @@ walk_stackframe(struct task_struct *task, struct pt_regs *regs, static __always_inline void walk_stackframe(struct task_struct *task, struct pt_regs *regs, - bool (*fn)(void *, unsigned long), void *arg) + unwind_consume_fn fn, void *arg) { unsigned long sp, pc; + struct unwind_state state; unsigned long *ksp; if (regs) { @@ -99,9 +119,14 @@ walk_stackframe(struct task_struct *task, struct pt_regs *regs, if (unlikely(sp & 0x7)) return; + state.task = task; + state.regs = regs; + state.sp = sp; + state.fp = 0; ksp = (unsigned long *)sp; while (!kstack_end(ksp)) { - if (__kernel_text_address(pc) && unlikely(!fn(arg, pc))) + state.pc = pc; + if (__kernel_text_address(pc) && unlikely(!fn(arg, &state))) break; pc = READ_ONCE_NOCHECK(*ksp++) - 0x4; } @@ -109,10 +134,28 @@ walk_stackframe(struct task_struct *task, struct pt_regs *regs, #endif /* CONFIG_FRAME_POINTER */ +struct unwind_consume_entry_data { + stack_trace_consume_fn consume_entry; + void *cookie; +}; + +static __always_inline bool +arch_unwind_consume_entry(void *cookie, const struct unwind_state *state) +{ + struct unwind_consume_entry_data *data = cookie; + + return data->consume_entry(data->cookie, state->pc); +} + noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, struct task_struct *task, struct pt_regs *regs) { - walk_stackframe(task, regs, consume_entry, cookie); + struct unwind_consume_entry_data data = { + .consume_entry = consume_entry, + .cookie = cookie, + }; + + walk_stackframe(task, regs, arch_unwind_consume_entry, &data); } static bool print_trace_address(void *arg, unsigned long pc)