nuttx/Documentation/guides
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
..
build Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
chip-specific Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
concurrency arch/arm64: Implement up_addrenv_fork() and provide POSIX fork(). 2026-10-08 09:35:07 -03:00
drivers Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
filesystem Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
image docs/guides/bootsequence: Migrate UML diagram to PlantUML 2026-02-15 08:47:23 +01:00
languages Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
networking Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
nsh Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
porting Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
programs Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
security Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
simulation Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00
index.rst Documentation: brand new layout for NuttX documentation. 2026-10-08 01:40:54 +08:00