arm64: Adjust the kernel stack pointer at the end of fork_trampoline

All other paths that return from the kernel to userspace pop the user
trapframe off of the kernel stack pointer before returning to
userspace in restore_registers.  fork_trampoline was missing this, so
all of the user faults after fork pushed another trapframe leaving a
trapframe's worth of wasted space on the kstack.

This would be fatal after a future change to remove duplicate
initialization of td_frame in cpu_fork() as without this fix each time
a thread was recycled it would "lose" another trapframe's worth of
space.

Reviewed by:	kib, andrew
Pull Request:	https://ron-dev.freebsd.org/FreeBSD/src/pulls/23
This commit is contained in:
Alfredo Mazzinghi
2026-04-22 19:46:14 -04:00
committed by John Baldwin
parent bd15d6ef12
commit a1e07f21dc
+2
View File
@@ -276,6 +276,8 @@ ENTRY(fork_trampoline)
ldp x26, x27, [sp, #TF_X + 26 * 8]
ldp x28, x29, [sp, #TF_X + 28 * 8]
add sp, sp, #(TF_SIZE)
/*
* No need for interrupts reenabling since PSR
* will be set to the desired value anyway.