nuttx/arch/arm64
Marco Casaroli b63dd89238 arch/arm64: Implement up_addrenv_fork() and provide POSIX fork().
Duplicate an address environment into freshly allocated pages mapped at the
same virtual addresses, which is what POSIX fork() is built on.  It lives in
arm64_addrenv_mmu.c:  an MPU address environment is a set of protection
regions over one physical address space, not a mapping that can be duplicated
at the same virtual addresses.  So ARCH_ARM64 selects ARCH_HAVE_FORK only
in a kernel build with ARCH_ADDRENV.  The condition repeats the
ARCH_ADDRENV dependency, because a select bypasses depends on.

arm64_fork_stack() then lets the child run at the parent's stack addresses.  A
pointer to a stack local taken before fork() must name the same object in the
child that it named in the parent, so the child adopts the parent's stack
geometry rather than being given a relocated copy; the parent's stack is
already in the duplicate, at the parent's address, with its contents.  With a
zero offset arm64_fork_reloc() is then the identity, so the register context
needs no further special casing.

Verified on qemu-armv8a:knsh under qemu-system-aarch64:  ostest's fork_test
reports "Parent and child had independent memory", and vfork_test passes.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-10-08 09:35:07 -03:00
..
include arch/atomic: remove up_testset in spinlock 2026-09-08 08:58:54 +08:00
src arch/arm64: Implement up_addrenv_fork() and provide POSIX fork(). 2026-10-08 09:35:07 -03:00
CMakeLists.txt
Kconfig arch/arm64: AES using the Armv8 Cryptography Extension. 2026-09-21 18:43:36 +08:00