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 7CFA2C433EF for ; Sun, 26 Jun 2022 08:59:07 +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=1e/JpQDW4f+mTTqFIRm+l7HnBFB8IOWq6ruN97sG/sM=; b=3P0KNtRoJ3wW9r nGKYR7hHy5RX8QXeHhMFfRM4OWl2aqClFUGhJE9GUDBnI/Dym02Nj4eSCQascFcHlBZ61b5iX7Tqz QnTgHyEBkIPPJEVBxAttnjiJAtDMMA4PQ1ES1z2+bH8wT6JJqk27lyG/3bpn3P1h2RPwgYyn5Mw5G HTuYcsTg21k+kpKIRGDvQeSl7duZ8KGpVqhmf7ZOtFBvl8whgYdwL2CdlLNzGm6utorW5ow36fGW2 p4AMlOzxT9e9lbVf+Qw3Oc+fSZQGIXgq4jnPrQvgye4wU1XS+ZwDdj+mZ1oAj7gkb+E8VnGvatdBe M4ZP3TTwbikNkmIcTnxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5O5p-00AksL-Ai; Sun, 26 Jun 2022 08:58:09 +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 1o5O5m-00Akr9-9c for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2022 08:58:07 +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 0C347D6E; Sun, 26 Jun 2022 01:58:03 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.71.61]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE4C73F792; Sun, 26 Jun 2022 01:58:00 -0700 (PDT) Date: Sun, 26 Jun 2022 09:57:57 +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 6/6] arm64: Introduce arch_stack_walk_reliable() Message-ID: References: <20220617210717.27126-1-madvenka@linux.microsoft.com> <20220617210717.27126-7-madvenka@linux.microsoft.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220617210717.27126-7-madvenka@linux.microsoft.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_015806_446066_5CF1AFC5 X-CRM114-Status: GOOD ( 21.27 ) 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:17PM -0500, madvenka@linux.microsoft.com wrote: > From: "Madhavan T. Venkataraman" > > Introduce arch_stack_walk_reliable() for ARM64. This works like > arch_stack_walk() except that it returns -EINVAL if the stack trace is not > reliable. > > Until all the reliability checks are in place, arch_stack_walk_reliable() > may not be used by livepatch. But it may be used by debug and test code. For the moment I would strongly perfer *not* to add this until we have the missing bits and pieces sorted out. Until then, I'd like to ensure that any infrastructure we add is immediately useful and tested. One way to do that would be to enhance the stack dumping code (i.e. dump_backtrace()) to log some metadata. As an end-goal, I'd like to get to a point where we can do: * Explicit logging when trace terminate at the final frame, e.g. stacktrace: function_c+offset/total function_b+offset/total function_a+offset/total * Explicit logging of early termination, e.g. stacktrace: function_c+offset/total * Unreliability on individual elements, e.g. stacktrace: function_c+offset/total function_b+offset/total (?) function_a+offset/total * Annotations for special unwinding, e.g. stacktrace: function_c+offset/total (K) // kretprobes trampoline function_b+offset/total (F) // ftrace trampoline function_a+offset/total (FK) // ftrace and kretprobes other_function+offset/total (P) // from pt_regs::pc another_function+offset/total (L?) // from pt_regs::lr, unreliable something_else+offset/total Note: the comments here are just to explain the idea, I don't expect those in the actual output. That'll justify some of the infrastructure we need for reliable unwinding, and ensure that it is tested, well before we actually enable reliable stacktracing. Thanks, Mark. > > Signed-off-by: Madhavan T. Venkataraman > Reviewed-by: Mark Brown > --- > arch/arm64/kernel/stacktrace.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c > index eda8581f7dbe..8016ba0e2c96 100644 > --- a/arch/arm64/kernel/stacktrace.c > +++ b/arch/arm64/kernel/stacktrace.c > @@ -383,3 +383,26 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, > > unwind(&state, consume_entry, cookie); > } > + > +/* > + * arch_stack_walk_reliable() may not be used for livepatch until all of > + * the reliability checks are in place in unwind_consume(). However, > + * debug and test code can choose to use it even if all the checks are not > + * in place. > + */ > +noinline int notrace arch_stack_walk_reliable( > + stack_trace_consume_fn consume_entry, > + void *cookie, > + struct task_struct *task) > +{ > + struct unwind_state state; > + bool reliable; > + > + if (task == current) > + unwind_init_from_caller(&state); > + else > + unwind_init_from_task(&state, task); > + > + reliable = unwind(&state, consume_entry, cookie); > + return reliable ? 0 : -EINVAL; > +} > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel