From patchwork Mon Jan 3 16:52:11 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: 12702685 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 46979C433EF for ; Mon, 3 Jan 2022 16:58:09 +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=MTr5R8QFW+IWcxzXDL9547M6PYtoP0RlCVeyplzhUFM=; b=RBBYSxNLNCd9GY l1FSJEIJPlPD7pn4V0RuG48G6cffN5MxCrobv5R8PeOC6UldPus2cMr6UtMhsmguombHRW3/dtOky Q5q6GCdBBr3VQKTW5sZJ/oqwwDO2Nz5HFx6551KiGUwoCCGOKFKF4jVvsEDTzDuWRg+7NkBSDjHRm hIEKqbnQlzGsJu0Xyg6ep6AE+hFm0MrK9e5e03uiH8Pbpz/lJC6Y1ZCBRGGA+yXUtq7bHaNhCN6KV Oq60j8AvUZtRIWilTGkrSEp8/e5ld5A/OMCqm46Lzr+0dVpfbIOF4Y7gbxOpGDilgzD/SOnlI/e39 IJ+MpKpJdedPDe9J4TGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4Qd6-009aUt-Q3; Mon, 03 Jan 2022 16:56:17 +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 1n4QZp-009Ytd-PA for linux-arm-kernel@lists.infradead.org; Mon, 03 Jan 2022 16:52:55 +0000 Received: from x64host.home (unknown [47.187.212.181]) by linux.microsoft.com (Postfix) with ESMTPSA id CD80820B718C; Mon, 3 Jan 2022 08:52:52 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CD80820B718C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1641228773; bh=Xl9WNOn2tIO3ZNBmKyfL3l0gpuWXAeRGb/t+fi8lT7g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DLLIH/0vgG5cY3yu8dxaLG84DI5X1L8kuUyceZqgHJ8WBRCQynD9wt8f1nvnpmNuf AXGUshRAiIAx6uEP3IYinO7Elp2/gKAfFOMNm52uy618CDHh3HaJL3kA/LPIM+lKhH U9OuORKn2LgyTs9Z5cWrV0z8tQRAnjhsfhV/cmhE= 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 v12 09/10] arm64: Introduce arch_stack_walk_reliable() Date: Mon, 3 Jan 2022 10:52:11 -0600 Message-Id: <20220103165212.9303-10-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220103165212.9303-1-madvenka@linux.microsoft.com> References: <0d0eb36f348fb5a6af6eb592c0525f6e94007328> <20220103165212.9303-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-20220103_085253_877996_AC324165 X-CRM114-Status: GOOD ( 10.80 ) 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 1db1ccb61241..717d30833252 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -339,3 +339,27 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, unwind(&state); } + +/* + * 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; + + unwind_init_common(&state, task, NULL, consume_fn, cookie); + + if (task == current) + unwind_init_current(&state); + else + unwind_init_task(&state); + + reliable = unwind(&state); + return reliable ? 0 : -EINVAL; +}