mirror of
https://github.com/apache/nuttx.git
synced 2026-10-10 15:50:23 +00:00
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> |
||
|---|---|---|
| .. | ||
| build | ||
| chip-specific | ||
| concurrency | ||
| drivers | ||
| filesystem | ||
| image | ||
| languages | ||
| networking | ||
| nsh | ||
| porting | ||
| programs | ||
| security | ||
| simulation | ||
| index.rst | ||