From patchwork Mon Jan 17 14:56:07 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: 12715512 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 2FE5AC433F5 for ; Mon, 17 Jan 2022 15:02:15 +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=JthSnWeUchrCKZLZpFjawzZxitaSVY+LWd0vGDm0gDQ=; b=LL+Yc8UzPB5dYj EsoA7kOF4bk+Us7NytEO13tj3ufWNhC5aEo1BOqpDQ762d/oiPmS4y96z2w1hE+0z3TzVjps176bZ zA2UGBvwjvCUxZvHlAFUuaWb2theW/QUXz8ze2CoUaBNWAW6OU6NxBlwQolVXS+HUvitK6HvaoYyu /SHg5eJmuMEx+2iOsUH62NvMiC7kT2N1f9G+IRrgYlCxK4sz5K8HQbpTwUN9St5aHowZDEODyneW7 WRJWxA0tqoco9Aa83fQ5fSB4jzRTKOQkiPPt3kzeQDzEwOCfStsguxoZnziFVBqG1puocFikffS8r y4MBtzlHBzN05UKQ+6hA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9TV0-00FIOB-0A; Mon, 17 Jan 2022 15:00:47 +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 1n9TQw-00FGLa-Rf for linux-arm-kernel@lists.infradead.org; Mon, 17 Jan 2022 14:56:36 +0000 Received: from x64host.home (unknown [47.187.212.181]) by linux.microsoft.com (Postfix) with ESMTPSA id E01E020B9135; Mon, 17 Jan 2022 06:56:33 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E01E020B9135 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1642431394; bh=9WA4XIJPEMIkNXPJTh9pLlS/9AGYwYxQhbHnVCj+qRU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JkM2/+NpbTQG+du2kijrRPRMkIZMfpMXMTwwDq6efmyIjMR2f/GcoJt8ILlKe8uK/ B8EeGSFFFqWJGRym4RB5KmjqrO4a/C6o/sUHL++7RQxz8+7F6wBVuHehjbgpvnazfo v48/w/AhOq85aFjGBpjR29V6p7rJ+wN6WoPbBwko= 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 v13 10/11] arm64: Introduce arch_stack_walk_reliable() Date: Mon, 17 Jan 2022 08:56:07 -0600 Message-Id: <20220117145608.6781-11-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220117145608.6781-1-madvenka@linux.microsoft.com> References: <95691cae4f4504f33d0fc9075541b1e7deefe96f> <20220117145608.6781-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-20220117_065634_956441_3B4F29C9 X-CRM114-Status: GOOD ( 10.99 ) 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 8bfe31cbee46..4902fac5745f 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -342,3 +342,25 @@ 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_fn, + void *cookie, + struct task_struct *task) +{ + struct unwind_state state; + bool reliable; + + if (task == current) + unwind_init_from_current(&state, task); + else + unwind_init_from_task(&state, task); + + reliable = unwind(&state, consume_fn, cookie); + return reliable ? 0 : -EINVAL; +}