aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/asm_linux_arm64.s
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2022-07-14 21:18:15 -0700
committerGopher Robot <gobot@golang.org>2022-09-09 15:34:16 +0000
commitbca17d16ca0dabbe1b533bb78f367d64e076fe73 (patch)
tree3cf5053ab51cc2944e6eb187d263a3ba6f0203f8 /src/syscall/asm_linux_arm64.s
parentf53b2111e489e61461837737cf69371a043d4fd9 (diff)
downloadgo-bca17d16ca0dabbe1b533bb78f367d64e076fe73.tar.xz
syscall: add CgroupFD support for ForkExec on Linux
Implement CLONE_INTO_CGROUP feature, allowing to put a child in a specified cgroup in a clean and simple way. Note that the feature only works for cgroup v2, and requires Linux kernel 5.7 or newer. Using the feature requires a new syscall, clone3. Currently this is the only reason to use clone3, but the code is structured in a way so that other cases may be easily added in the future. Add a test case. While at it, try to simplify the syscall calling code in forkAndExecInChild1, which became complicated over time because: 1. It was using either rawVforkSyscall or RawSyscall6 depending on whether CLONE_NEWUSER was set. 2. On Linux/s390, the first two arguments to clone(2) system call are swapped (which deserved a mention in Linux ABI hall of shame). It was worked around in rawVforkSyscall on s390, but had to be implemented via a switch/case when using RawSyscall6, making the code less clear. Let's - modify rawVforkSyscall to have two arguments (which is also required for clone3); - remove the arguments workaround from s390 asm, instead implementing arguments swap in the caller (which still looks ugly but at least it's done once and is clearly documented now); - use rawVforkSyscall for all cases (since it is essentially similar to RawSyscall6, except for having less parameters, not returning r2, and saving/restoring the return address before/after syscall on 386 and amd64). Updates #51246. Change-Id: Ifcd418ebead9257177338ffbcccd0bdecb94474e Reviewed-on: https://go-review.googlesource.com/c/go/+/417695 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/syscall/asm_linux_arm64.s')
-rw-r--r--src/syscall/asm_linux_arm64.s14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/syscall/asm_linux_arm64.s b/src/syscall/asm_linux_arm64.s
index be78ac8ac4..7fa789a349 100644
--- a/src/syscall/asm_linux_arm64.s
+++ b/src/syscall/asm_linux_arm64.s
@@ -4,10 +4,10 @@
#include "textflag.h"
-// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
-TEXT ·rawVforkSyscall(SB),NOSPLIT,$0-32
+// func rawVforkSyscall(trap, a1, a2 uintptr) (r1, err uintptr)
+TEXT ·rawVforkSyscall(SB),NOSPLIT,$0-40
MOVD a1+8(FP), R0
- MOVD $0, R1
+ MOVD a2+16(FP), R1
MOVD $0, R2
MOVD $0, R3
MOVD $0, R4
@@ -17,13 +17,13 @@ TEXT ·rawVforkSyscall(SB),NOSPLIT,$0-32
CMN $4095, R0
BCC ok
MOVD $-1, R4
- MOVD R4, r1+16(FP) // r1
+ MOVD R4, r1+24(FP) // r1
NEG R0, R0
- MOVD R0, err+24(FP) // errno
+ MOVD R0, err+32(FP) // errno
RET
ok:
- MOVD R0, r1+16(FP) // r1
- MOVD ZR, err+24(FP) // errno
+ MOVD R0, r1+24(FP) // r1
+ MOVD ZR, err+32(FP) // errno
RET
// func rawSyscallNoError(trap uintptr, a1, a2, a3 uintptr) (r1, r2 uintptr);