git: 2b8c4137d497 - main - arm64: fix stack unwinding past exception handlers

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Wed, 10 May 2023 12:06:53 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=2b8c4137d49762587c946a67840df0bfd1ee2f2f

commit 2b8c4137d49762587c946a67840df0bfd1ee2f2f
Author:     Zachary Leaf <zachary.leaf@arm.com>
AuthorDate: 2023-05-09 16:04:44 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-05-10 11:54:54 +0000

    arm64: fix stack unwinding past exception handlers
    
    Commit 281402e0a563 ("arm64: Shave off two instructions in exceptions")
    removed the instruction that set the frame pointer (x29) as it appeared
    to be unused.
    
    The frame pointer is used in arm64/db_trace.c:db_stack_trace_cmd() when
    unwinding state, and hence still needs to be set.
    
    Add back the instruction to save_registers to properly update frame
    pointer.
    
    Reported by: andrew
    Sponsored by: Arm Ltd
---
 sys/arm64/arm64/exception.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S
index c82b8307ab17..a568d1264b53 100644
--- a/sys/arm64/arm64/exception.S
+++ b/sys/arm64/arm64/exception.S
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
 .endm
 
 .macro	save_registers el
+	add	x29, sp, #(TF_SIZE)
 .if \el == 0
 #if defined(PERTHREAD_SSP)
 	/* Load the SSP canary to sp_el0 */