The branch main has been updated by jhb:

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

commit a1e07f21dc7458d85bd0d04c294f0389d4591666
Author:     Alfredo Mazzinghi <[email protected]>
AuthorDate: 2026-04-22 23:46:14 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2026-05-27 13:43:09 +0000

    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
---
 sys/arm64/arm64/swtch.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S
index b3bf88135e57..0cc0d7462ae6 100644
--- a/sys/arm64/arm64/swtch.S
+++ b/sys/arm64/arm64/swtch.S
@@ -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.

Reply via email to