Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp816021iog; Fri, 17 Jun 2022 14:28:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vpo5rFbYUrqZYswOj4LloYK5WprRbqCCLU2shl4iWaf+XkzLP+dn0xQHqhUac5/69xjIuW X-Received: by 2002:a05:6a00:170b:b0:51b:d1fd:5335 with SMTP id h11-20020a056a00170b00b0051bd1fd5335mr12015598pfc.28.1655501310225; Fri, 17 Jun 2022 14:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655501310; cv=none; d=google.com; s=arc-20160816; b=j6npb7kFjcaSGZaXMR9/G07uyfgQL1+KnQgDEKYP57pK980xs0nY9gDGTMx05PeAgM QfMTpbTzPnOg033fnNK9uPmNIpjmjDyDfvS63wu/kw1tOAVmY3Hb+hZ3DQEC17Ek5fSl rHEn40BRK2KEWpjzEFJZCUYWQlIfrFskk7u+JAu4sRtxYsTz8i8kOah4mZQx/R7uQo6Y re/tBmfxarES+7GFWKAJh0narXLGPBojI782XzbO+EfMYr18qRh7BkBdsO10XyOSx3zd EmP9hRGCrtQrPvF8bHYkcxRvaqQoJDHHprn8H6GQ9iOCCNsX/Ba4kX+Rird88upyHLxo MPrw== 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=f/N9Y3AhHP+6L0TxuoLGQXAr5xuXJnauRqGxyO1ZK4A=; b=cSAwE6foVjFxr8a3Anssh5YG3XKu/ln3nvee8WIhOdySiiIp50Yh6l52RoBT/qh/Nn yjEiJ+IXTpd0+uDHHOoResCVCbzwHSIwFvfK66brS8pAxWJiVjnHQe1cjrYj5KKqLmzM vsraaMVrq/G3K8qpSNvT86NM6mi7m+qnNoTocgrnn1Pd18sDTp0wNXw67INvmIGVVWMy MrzicQIOIUm5hm54amUmaBy6UBYtuRwZOk5Yu4yRIEAwX0iwM3l5VuFVZnnjpynEBuIj owiMjLr9WNR5/EOAZYfK+milOMXnhtvLcrMYpKEEGMCDz4UAHyztaEOZqDhmvtFqq4ur pl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=VNAIwf+e; 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 19-20020a630213000000b003fcbc8b5e7dsi5716639pgc.811.2022.06.17.14.28.19; Fri, 17 Jun 2022 14:28:30 -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=VNAIwf+e; 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 S1383660AbiFQVHs (ORCPT + 99 others); Fri, 17 Jun 2022 17:07:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383569AbiFQVHa (ORCPT ); Fri, 17 Jun 2022 17:07:30 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 449105E75D; Fri, 17 Jun 2022 14:07:30 -0700 (PDT) Received: from x64host.home (unknown [47.189.24.195]) by linux.microsoft.com (Postfix) with ESMTPSA id 54E0C20C3491; Fri, 17 Jun 2022 14:07:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 54E0C20C3491 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1655500050; bh=f/N9Y3AhHP+6L0TxuoLGQXAr5xuXJnauRqGxyO1ZK4A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VNAIwf+ewXol7bbQBTpEOIUBY5ntVrWcjGgnn2B7NrAFkfKWLl3hJnJK/yAtle/Cz jihQyHIfGZo8JFrhojKgT80w5Ad9Btnjy9CfqQcnDmeYWrl0BDk/S/Kn8Hxo+7zq/b 2PwXSPSvJjxwFOa6in6pergEGa5Q1tN1+qaxjz/w= 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 6/6] arm64: Introduce arch_stack_walk_reliable() Date: Fri, 17 Jun 2022 16:07:17 -0500 Message-Id: <20220617210717.27126-7-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" 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. 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