diff options
| author | Alfredo Mazzinghi <am2419@cl.cam.ac.uk> | 2026-04-22 23:46:14 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2026-05-27 13:43:09 +0000 |
| commit | a1e07f21dc7458d85bd0d04c294f0389d4591666 (patch) | |
| tree | 4c4cc0cc7521ecdf4be466a8a9bb659e446cef42 | |
| parent | bd15d6ef126ee4c0eac931117f6bbbf6f9a3fc72 (diff) | |
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
| -rw-r--r-- | sys/arm64/arm64/swtch.S | 2 |
1 files changed, 2 insertions, 0 deletions
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. |
