nuttx/arch/xtensa/include
Marco Casaroli 55a5c6628e arch/xtensa: Provide vfork().
Xtensa selected neither fork primitive, so vfork() was simply absent.  This
wires it onto the two-primitive semantics.

There is no assembly entry point and none is needed.  Every exception entry
already runs SPILL_ALL_WINDOWS, so the whole context of the calling thread is
in its exception frame and copying its stack copies a complete frame chain.
A flat build reaches that frame through SYS_save_context, issued inline so
that the recorded stack pointer belongs to a frame that stays alive for the
whole operation; a build with syscalls reaches it through xcp.sregs, recorded
by xtensa_swint() for the duration of the call.

The stack copy needs more than a relocated stack pointer here.  A windowed
ABI stores each frame's caller stack pointer absolutely, in the base save
area below the frame, so a copy taken at a different address still names the
parent throughout and the child's first retw would underflow onto the
parent's stack.  xtensa_fork_rebase() walks that chain and adds the
relocation offset to each link.  The copy also starts one base save area
below the stack pointer rather than at it, because the frame the child
resumes into keeps its caller's spilled a0-a3 there.

Ported from the per-architecture work, reduced to the two primitives.

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-28 23:08:31 +08:00
..
esp32 xtensa/espressif: Update common-source integration for Xtensa devices 2026-03-29 00:33:11 +08:00
esp32s2 xtensa/espressif: Update common-source integration for Xtensa devices 2026-03-29 00:33:11 +08:00
esp32s3 xtensa/espressif: Update common-source integration for Xtensa devices 2026-03-29 00:33:11 +08:00
lx6 arch/xtensa: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
lx7 arch/xtensa: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
xtensa arch/xtensa: remove the use of XCHAL_SYSCALL_LEVEL 2026-01-23 10:52:43 +08:00
.gitignore Remove exra whitespace from files (#189) 2020-01-31 09:24:49 -06:00
arch.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
elf.h xtensa: support coredump by register set alignment 2024-12-13 18:21:37 +08:00
inttypes.h arch: xtensa: fix INT32_C macro to match int32_t type 2026-02-02 10:47:55 +08:00
irq.h arch/xtensa: Provide vfork(). 2026-08-28 23:08:31 +08:00
limits.h arch/xtensa: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
loadstore.h arch/xtensa: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
setjmp.h arch/xtensa: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
simcall.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
spinlock.h arch/xtensa: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
stdarg.h arch/xtensa: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
syscall.h xtensa: change write intset register to syscall instruction 2024-12-27 00:25:55 +08:00
types.h arch/xtensa: use compiler's definition of uint32 and int32 2025-04-18 09:32:58 +08:00