aarch64: add vfork
authorSzabolcs Nagy <nsz@port70.net>
Sat, 16 Jul 2022 13:55:51 +0000 (15:55 +0200)
committerRich Felker <dalias@aerifal.cx>
Mon, 1 Aug 2022 17:37:39 +0000 (13:37 -0400)
The generic vfork implementation uses clone(SIGCHLD) which has fork
semantics.

Implement vfork as clone(SIGCHLD|CLONE_VM|CLONE_VFORK, 0) instead which
has vfork semantics. (stack == 0 means sp is unchanged in the child.)

Some users rely on vfork semantics when memory overcommit is disabled
or when the vfork child runs code that synchronizes with the parent
process (non-conforming).

src/process/aarch64/vfork.s [new file with mode: 0644]

diff --git a/src/process/aarch64/vfork.s b/src/process/aarch64/vfork.s
new file mode 100644 (file)
index 0000000..429bec8
--- /dev/null
@@ -0,0 +1,9 @@
+.global vfork
+.type vfork,%function
+vfork:
+       mov x8, 220    // SYS_clone
+       mov x0, 0x4111 // SIGCHLD | CLONE_VM | CLONE_VFORK
+       mov x1, 0
+       svc 0
+       .hidden __syscall_ret
+       b __syscall_ret