riscv64: add vfork
authorPedro Falcato <pedro.falcato@gmail.com>
Thu, 9 Feb 2023 16:34:12 +0000 (16:34 +0000)
committerRich Felker <dalias@aerifal.cx>
Thu, 9 Feb 2023 17:33:35 +0000 (12:33 -0500)
Implement vfork() using clone(CLONE_VM | CLONE_VFORK | ...).

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

diff --git a/src/process/riscv64/vfork.s b/src/process/riscv64/vfork.s
new file mode 100644 (file)
index 0000000..c93dca2
--- /dev/null
@@ -0,0 +1,12 @@
+.global vfork
+.type vfork,@function
+vfork:
+       /* riscv does not have SYS_vfork, so we must use clone instead */
+       /* note: riscv's clone = clone(flags, sp, ptidptr, tls, ctidptr) */
+       li a7, 220
+       li a0, 0x100 | 0x4000 | 17 /* flags = CLONE_VM | CLONE_VFORK | SIGCHLD */
+       mv a1, sp
+       /* the other arguments are ignoreable */
+       ecall
+       .hidden __syscall_ret
+       j __syscall_ret