Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp804376iog; Fri, 17 Jun 2022 14:10:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tS/YUAP1Jda/ldBR3OqYz0ueTmjhnPaEWtoi2sA9oNSDadtRNOBRyGUHGZgs6Jh3PVKtAB X-Received: by 2002:aa7:dbd7:0:b0:433:55a6:e3c4 with SMTP id v23-20020aa7dbd7000000b0043355a6e3c4mr15155044edt.74.1655500214199; Fri, 17 Jun 2022 14:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655500214; cv=none; d=google.com; s=arc-20160816; b=U8hXhGUyzNDI15A99r78eCWpMr8pzaVtlMiQL5RYT6kV6hfvwdvwvzhunHaOa1bb4l gcjppU8c9hjckv4/gaMUDSSU1WJaws/MiuRy2BNHIGNqWWlnJuNqJZxx1wwNHTLcu0NR uBcr9rXhu7T/nKf0mxf+gLNMycIf31QzWOin9/H8QygwHBwHxoVDRCLa91kYUhhds8K1 96hmgcz9vICmdukV4B8ENinw459cGSwmHYbYMHYlPglSpG2YPC1PoHnH95DWOTk9n48P Pi2giNNuGvbZDkpQk7FwpUhSiXhX+F/P08dsqIhWYMeiBGx9/pgPSAGRHCrQzxc6n/k2 aCdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature:dkim-filter; bh=4OYwsLak9eV14Lqr9wB+riHSEW5S0byajhIbP13YtuM=; b=qdasTudlnshfKDl7MmJS9GAdk18jDAwL8XIRLzIn7EVmfr5YeXmUlbdUcozuwNeG6I 0lhI/FZbuPGFQWl4aws3EdEV/JiChg7VDnsAgui+Y2mrs1aEBT6rcPbhtK1YCWFQbiyz 09o0g2p0HIQ+mNtkTqj9ktzdWXURRj3bO6F4lUDJcKKXkgnm28wVWCe4+mVlQEdqYWUx gysxQiorNS93toNAabCIFYTKFa7JcF1FDkR4JsHX595KLdHDqynzxO/DJk8Ch1C6S2n2 3kmpSx5eYfqFICFp9zoqEuZMaaYpw0mHX++ud0bCHqnyXCVvfFh4U3A8PU/rRUMFMO3H VTUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=NHcRNHW3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a1709064dd300b007165339eb13si3849896ejw.624.2022.06.17.14.09.48; Fri, 17 Jun 2022 14:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=NHcRNHW3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383561AbiFQVHa (ORCPT + 99 others); Fri, 17 Jun 2022 17:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350908AbiFQVH1 (ORCPT ); Fri, 17 Jun 2022 17:07:27 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7DE6C5E170; Fri, 17 Jun 2022 14:07:26 -0700 (PDT) Received: from x64host.home (unknown [47.189.24.195]) by linux.microsoft.com (Postfix) with ESMTPSA id 86B1320C3497; Fri, 17 Jun 2022 14:07:25 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 86B1320C3497 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655500046; bh=4OYwsLak9eV14Lqr9wB+riHSEW5S0byajhIbP13YtuM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NHcRNHW3qMsPN8XpBfaza4SLuStnGT0ip20a0XQVToKUrAWJXDl3xN5xJtSBF5H2a tVZo+mLonzjULpFET9TnXsBQvtCA/Qk4493o8pdVDTVNad4xf3z4Ji4c+AaumjfojH wb0d2gDJfP5/2sXcvsohEKJkqM9NIWbD9DFIR8a8= From: madvenka@linux.microsoft.com To: broonie@kernel.org, mark.rutland@arm.com, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jamorris@linux.microsoft.com, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, madvenka@linux.microsoft.com Subject: [PATCH v15 2/6] arm64: Copy the task argument to unwind_state Date: Fri, 17 Jun 2022 16:07:13 -0500 Message-Id: <20220617210717.27126-3-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220617210717.27126-1-madvenka@linux.microsoft.com> References: <20220617210717.27126-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Madhavan T. Venkataraman" Copy the task argument passed to arch_stack_walk() to unwind_state so that it can be passed to unwind functions via unwind_state rather than as a separate argument. The task is a fundamental part of the unwind state. Signed-off-by: Madhavan T. Venkataraman Reviewed-by: Mark Brown --- arch/arm64/kernel/stacktrace.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index e44f93ff25f0..8e43444d50e2 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -38,6 +38,8 @@ * @kr_cur: When KRETPROBES is selected, holds the kretprobe instance * associated with the most recently encountered replacement lr * value. + * + * @task: The task being unwound. */ struct unwind_state { unsigned long fp; @@ -48,10 +50,13 @@ struct unwind_state { #ifdef CONFIG_KRETPROBES struct llist_node *kr_cur; #endif + struct task_struct *task; }; -static void unwind_init_common(struct unwind_state *state) +static void unwind_init_common(struct unwind_state *state, + struct task_struct *task) { + state->task = task; #ifdef CONFIG_KRETPROBES state->kr_cur = NULL; #endif @@ -80,7 +85,7 @@ static void unwind_init_common(struct unwind_state *state) static inline void unwind_init_from_regs(struct unwind_state *state, struct pt_regs *regs) { - unwind_init_common(state); + unwind_init_common(state, current); state->fp = regs->regs[29]; state->pc = regs->pc; @@ -96,7 +101,7 @@ static inline void unwind_init_from_regs(struct unwind_state *state, */ static __always_inline void unwind_init_from_caller(struct unwind_state *state) { - unwind_init_common(state); + unwind_init_common(state, current); state->fp = (unsigned long)__builtin_frame_address(1); state->pc = (unsigned long)__builtin_return_address(0); @@ -115,7 +120,7 @@ static __always_inline void unwind_init_from_caller(struct unwind_state *state) static inline void unwind_init_from_task(struct unwind_state *state, struct task_struct *task) { - unwind_init_common(state); + unwind_init_common(state, task); state->fp = thread_saved_fp(task); state->pc = thread_saved_pc(task); @@ -128,9 +133,9 @@ static inline void unwind_init_from_task(struct unwind_state *state, * records (e.g. a cycle), determined based on the location and fp value of A * and the location (but not the fp value) of B. */ -static int notrace unwind_next(struct task_struct *tsk, - struct unwind_state *state) +static int notrace unwind_next(struct unwind_state *state) { + struct task_struct *tsk = state->task; unsigned long fp = state->fp; struct stack_info info; @@ -204,8 +209,7 @@ static int notrace unwind_next(struct task_struct *tsk, } NOKPROBE_SYMBOL(unwind_next); -static void notrace unwind(struct task_struct *tsk, - struct unwind_state *state, +static void notrace unwind(struct unwind_state *state, stack_trace_consume_fn consume_entry, void *cookie) { while (1) { @@ -213,7 +217,7 @@ static void notrace unwind(struct task_struct *tsk, if (!consume_entry(cookie, state->pc)) break; - ret = unwind_next(tsk, state); + ret = unwind_next(state); if (ret < 0) break; } @@ -259,12 +263,15 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, { struct unwind_state state; - if (regs) + if (regs) { + if (task != current) + return; unwind_init_from_regs(&state, regs); - else if (task == current) + } else if (task == current) { unwind_init_from_caller(&state); - else + } else { unwind_init_from_task(&state, task); + } - unwind(task, &state, consume_entry, cookie); + unwind(&state, consume_entry, cookie); } -- 2.25.1