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 34666C433EF for ; Sun, 26 Jun 2022 07:41:04 +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:In-Reply-To:MIME-Version:References: 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=BJcMCY2ocMQAYyfgxIFHnqKnP23o7wO+fRN9QI10Ywk=; b=SMUO8Cw90wv9PK 9bTWDrUH4qidpdSlfZiP/vJ3Jtrz3ur+TBgaOmBu0Tlt2DDRBIlMCBA9RvzmLZiNjMNOEbUZZ8agp fau4WtYLIdqJ3haB4XgYmjKrBuXzhG359PltShq+T/U4xu+sNBK89LYpvvTXOQSrCnjZCisglo4a9 sfnOW73bUFzuGhgucPu+FLfHa/JhEeqH3rIlLsqjVUESKMkvGwhIcEdTje3aI3XdPjbNPavOrw4kV khzEDvIdWdIVCmDClhiVlVGMVj/BmeIDF1nsituoNuDQ1wS6Q7ykcjzeY0zI3DsWFsna9F4VzITZB vRKfWREJCwXs0L7r4EMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MsG-00AQ4Q-7W; Sun, 26 Jun 2022 07:40:04 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5MsC-00AQ2W-Ni for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2022 07:40:02 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A8D9DD6E; Sun, 26 Jun 2022 00:39:56 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.71.61]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A78A03F792; Sun, 26 Jun 2022 00:39:54 -0700 (PDT) Date: Sun, 26 Jun 2022 08:39:52 +0100 From: Mark Rutland To: madvenka@linux.microsoft.com Cc: broonie@kernel.org, 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 Subject: Re: [PATCH v15 2/6] arm64: Copy the task argument to unwind_state Message-ID: References: <20220617210717.27126-1-madvenka@linux.microsoft.com> <20220617210717.27126-3-madvenka@linux.microsoft.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220617210717.27126-3-madvenka@linux.microsoft.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_004000_910488_C40365B6 X-CRM114-Status: GOOD ( 22.97 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jun 17, 2022 at 04:07:13PM -0500, madvenka@linux.microsoft.com wrote: > 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 Acked-by: Mark Rutland Mark. > --- > 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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel