From patchwork Fri Nov 24 11:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13467537 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 AB735C61D97 for ; Fri, 24 Nov 2023 11:05:54 +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:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2EZJNymajvzOZnCqCg7fBw9kjHWBQcBkduNLXg05nn4=; b=ALJBVGeD2d9ky4 vA89kSMSqQyvKeUcSxFeXux1i+ljeA5h9OxF2Fx2yDVbgR0Y46izBDeb4q8x6S6mo6QRXSFgrn/xS TVmSkKipW8Z6cojvgkiCVV2MeZjrp4fa/UX5JWch3M0ey7q458MhE0uKy8P5ZyFMhtAttHb2eZGKL SeJxH3BiW83xbIfCW/0KLlolzdB1jc6m3qyv0JYw46oi4rNP/BMEoCjz5cqXFCvy3mSDBLWy4321k 1RhIg56cwrvE+ohka6j/p2r6z7tJuhz8hdb8eaT9WNQApGrWOp4iGy9QJBUp76j8E/rROUYcjclxd p5q53polnbB64a2Y7bXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r6U00-006wNl-1L; Fri, 24 Nov 2023 11:05:28 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r6Tzx-006wMp-2b for linux-arm-kernel@lists.infradead.org; Fri, 24 Nov 2023 11:05:27 +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 C072F1063; Fri, 24 Nov 2023 03:06:07 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 37A7C3F7A6; Fri, 24 Nov 2023 03:05:20 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: broonie@kernel.org, catalin.marinas@arm.com, kaleshsingh@google.com, madvenka@linux.microsoft.com, mark.rutland@arm.com, puranjay12@gmail.com, will@kernel.org Subject: [PATCH 0/2] arm64: stacktrace: add kunwind_stack_walk() Date: Fri, 24 Nov 2023 11:05:09 +0000 Message-Id: <20231124110511.2795958-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231124_030525_895468_5B3C64CD X-CRM114-Status: UNSURE ( 8.30 ) X-CRM114-Notice: Please train this message. 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 Currently arm64 uses the generic arch_stack_walk() interface for all stack walking code. This only passes a PC value and cookie to the unwind callback, whereas we'd like to pass some additional information in some cases. For example, the BPF exception unwinder wants the FP, for reliable stacktrace we'll want to perform additional checks on other portions of unwind state, and we'd like to expand the information printed by dump_backtrace() to include provenance and reliability information. These patches refactor arm64's stacktrace code into a new kunwind_stack_walk() function that provides the full unwind state to callback functions. The existing arch_stack_walk() interface is unchanged, and is implemented atop kunwind_stack_walk(). I had originally intended to send this with additional patches that would have dump_backtrace() use this to identify and report exception boundaries and fgraph/kretprobes PC recovery, but due to LPC and bug hunting over the last few weeks I haven't managed to get all of that ready just yet. Puranjay has a need for this for BPF: https://lore.kernel.org/linux-arm-kernel/20230917000045.56377-1-puranjay12@gmail.com/ Hence I'm sending this as-is as preparatory rework. Thanks, Mark. Mark Rutland (2): arm64: stacktrace: factor out kernel unwind state arm64: stacktrace: factor out kunwind_stack_walk() arch/arm64/include/asm/stacktrace/common.h | 19 +-- arch/arm64/include/asm/stacktrace/nvhe.h | 2 +- arch/arm64/kernel/stacktrace.c | 146 ++++++++++++++------- 3 files changed, 104 insertions(+), 63 deletions(-) Reviewed-by: Mark Brown Reviewed-by: Madhavan T. Venkataraman