git: 1a2aa2ffb502 - main - rtld: Clear x29 and lr for thread_start to conform Aarch64 ABI pcs

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Fri, 07 Jul 2023 16:56:22 UTC
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a2aa2ffb502403dc1f087722d1482c3c6e8d12b

commit 1a2aa2ffb502403dc1f087722d1482c3c6e8d12b
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-07-07 16:55:43 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-07-07 16:55:43 +0000

    rtld: Clear x29 and lr for thread_start to conform Aarch64 ABI pcs
    
    Strictly speaking, SYS V Aarch64 ABI does not states that lr should be
    cleared, however gdb relies on lr and tryes to unwind stack further.
    
    Reviewed by:
    Differential Revision:  https://reviews.freebsd.org/D40841
---
 sys/arm64/arm64/vm_machdep.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c
index e111995f09b0..7d6e83eb078d 100644
--- a/sys/arm64/arm64/vm_machdep.c
+++ b/sys/arm64/arm64/vm_machdep.c
@@ -223,6 +223,8 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
 		tf->tf_sp = STACKALIGN((uintptr_t)stack->ss_sp + stack->ss_size);
 	tf->tf_elr = (register_t)entry;
 	tf->tf_x[0] = (register_t)arg;
+	tf->tf_x[29] = 0;
+	tf->tf_lr = 0;
 }
 
 int