From patchwork Wed Apr 13 14:05:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhavan T. Venkataraman" X-Patchwork-Id: 12812074 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 B7E9FC4332F for ; Wed, 13 Apr 2022 14:08:08 +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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H3HjnY6KosPApFiVSbK8xEUAdlZA1+4XQXtLM74jYnI=; b=Jbb/2eBrJ9qBs0 bNudZfneBG7jRwUv/dBwIweiirtPwO9K69sBscyjlupiCZ5vu7zqqAEaoy9nZgkJZxmn5CyrwITin Uby7eAIjRldKqeYAFkS8zBbWtR1m4wqasIcxfvmn/h+KlBaUf9oM4gOTUFdIGpXVLSDevS0HqBa5H ORurjAJfR9phMuJKYVkDWQK+X5TCDfj8TczFWiF6BPfwOE8Z1Y3tqndTM0gc4UUme/wHQLzOqaQ0V 9wDbaZFKN0EgMA/QWonlZ1MzJsWHdYpPNkvFbrMRinV47S1EI1ZaSrrYoyLLLJ6/n5DQ6tNM8HtVp XGyN3Hs2+18oq8pJC7+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nede3-001KHB-Cp; Wed, 13 Apr 2022 14:06:55 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nedcy-001Joo-P6 for linux-arm-kernel@lists.infradead.org; Wed, 13 Apr 2022 14:05:51 +0000 Received: from x64host.home (unknown [47.189.24.195]) by linux.microsoft.com (Postfix) with ESMTPSA id B8FB220C34D4; Wed, 13 Apr 2022 07:05:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B8FB220C34D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1649858748; bh=f/N9Y3AhHP+6L0TxuoLGQXAr5xuXJnauRqGxyO1ZK4A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Yy4A1rcENqnynxGYVqOz9YprcPsMzJ/nG7o3/WWZQhe6MrXhKE0lZPK9CwLfBLoDh 5Fo8NqKsS/71ebUW91iSA5V5R3jN0bT7GGpJT4cIk7bpcuRq9ewvLW/9L6x43fkuq+ X0YN7Lak/1EcMQfQsIS+VtEPhUB8CUK/1JJXkhOA= From: madvenka@linux.microsoft.com To: mark.rutland@arm.com, broonie@kernel.org, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, madvenka@linux.microsoft.com Subject: [PATCH v14 6/7] arm64: Introduce arch_stack_walk_reliable() Date: Wed, 13 Apr 2022 09:05:27 -0500 Message-Id: <20220413140528.3815-7-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220413140528.3815-1-madvenka@linux.microsoft.com> References: <20220413140528.3815-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220413_070548_913094_DF7D4DC7 X-CRM114-Status: GOOD ( 10.43 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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; +}