From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10D95395AC5; Tue, 12 May 2026 10:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778581134; cv=none; b=iZPo0gyX35I3YrOOmUcyh5AWg66qhdpLMaBS6dx5vOzf9+1VK6C1dMBGKz9vW68/yfG095rmEvjpn1hWG3WPJi7Bul4hktGdPiXqgNpt+eMHBQF4ia7drVIC9offzY01muYpfRH/LXfvxOiNtYKbpQtEsw9iLZ2gt5lBzp4Kz9I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778581134; c=relaxed/simple; bh=U2RKyZFvAJWxf0WCPY/QD6ZBjPhpAW6Y7NJlEYh5m/A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=scMegkAMpDlsBMbdg7YqXwt8aCAUhgxVpHz3PHAn+e6T7ZO2ON4fP0hF8Wj71+OPdnlegetDigwrElHlRulHmzZgmKngWI6jRnw53FD4sebeyajHnUvM/02vtwJtizV9O+xnUa7l7hV4eEa8hyHw36LyykG3OnzI3CwYVj8Xzmc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=RmkRaQVb; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="RmkRaQVb" 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 DEDAA1691; Tue, 12 May 2026 03:18:46 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 801993F7B4; Tue, 12 May 2026 03:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778581132; bh=U2RKyZFvAJWxf0WCPY/QD6ZBjPhpAW6Y7NJlEYh5m/A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RmkRaQVb1rWl0nZAhjmin3dPinyheV0A8H6NPKwNRAZSkz2kDu9erVlPzr8cWejjx RDLHH9k5kuVsFreX56A1KXFJv2KL5a9CTuEm5c+q8PYmn3rHwQsDEq+6LZG6BLvC19 AYqYCePgiYB+a6VmXItxNpzJIusKvB7sDCbP+mKY= Date: Tue, 12 May 2026 11:18:45 +0100 From: Mark Rutland To: Jens Remus Cc: Dylan Hatch , Roman Gushchin , Weinan Liu , Will Deacon , Josh Poimboeuf , Indu Bhagat , Peter Zijlstra , Steven Rostedt , Catalin Marinas , Jiri Kosina , Prasanna Kumar T S M , Puranjay Mohan , Song Liu , joe.lawrence@redhat.com, linux-toolchains@vger.kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Randy Dunlap , Heiko Carstens Subject: Re: [PATCH v5 8/8] unwind: arm64: Use sframe to unwind interrupt frames Message-ID: References: <20260428183643.3796063-1-dylanbhatch@google.com> <20260428183643.3796063-9-dylanbhatch@google.com> <0542f042-14fb-4588-bc3a-5031249d9834@linux.ibm.com> Precedence: bulk X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0542f042-14fb-4588-bc3a-5031249d9834@linux.ibm.com> On Tue, May 12, 2026 at 10:55:28AM +0200, Jens Remus wrote: > On 5/12/2026 5:00 AM, Dylan Hatch wrote: > > On Fri, May 1, 2026 at 9:46 AM Mark Rutland > > wrote: > > >> (1) For correctness, we'll need to address a latent issue with > >> unwinding across an fgraph return trampoline, where the return > >> address is transiently unrecoverable. > >> I think we can solve that with some restructuring of that code, > >> restoring the original address *before* removing that from the > >> fgraph return stack, and ensuring that the unwinder can find it. > > > > If my understanding is correct, the issue arrises in > > return_to_handler as the return address is recovered: > > > > mov x0, sp bl ftrace_return_to_handler // addr = > > ftrace_return_to_hander(fregs); mov x30, x0 // restore the original > > return address > > > > Because ftrace_return_to_handler pops the return address from the > > return stack before it can be restored into the LR, it cannot be > > recovered. > > Based on reliable-stacktrace.rst section "4.4 Rewriting of return > addresses" I wonder whether the following might work: > > - If an unwound RA points at return_to_handler the actual RA needs to > be obtained using ftrace_graph_ret_addr(). This might already be > taken into account if ftrace_graph_ret_addr() is used unconditionally. > > - If an unwound RA points into return_to_handler() mark the stack trace > as unreliable. This could be accomplished by marking LR in > return_to_handler() as undefined (i.e. .cfi_undefined 30) to use > SFrame's outermost frame indication to stop and mark the stack trace > as unreliable: We don't currently have any CFI annotations for return_to_handler(), so if we interrupt that, any unwind will naturally be marked as unreliable. The problem is that we can try an unwind from an interrupted *callee* of return_to_handler(). In that case, we'll unwind through return_to_handler() using the frame pointer, without consulting SFrame. In that case, the PC will be part-way through return_to_handler(), but we only call ftrace_graph_ret_addr() when the PC is the start of return_to_handler, and so we don't even try to recover the return address. We can handle that better by checking whether the PC is *within* return_to_handler(), and aborting when the original return address cannot be recoverted. I'm happy to go put that together, nad longer term I would like to do the better reovery I described above such that we can *always* recover the return address. Mark.