aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_linux_amd64.s
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-02-08 16:59:17 +0100
committerBrad Fitzpatrick <bradfitz@golang.org>2018-02-13 15:33:19 +0000
commit04e6ae6bc3ac9739568b0f1225ee5e2d53cba919 (patch)
tree697005aa758339e344f48a028fc86264658ec0ec /src/runtime/sys_linux_amd64.s
parent4dad4ab57bc0cedcc8d164147262f7f6898282dd (diff)
downloadgo-04e6ae6bc3ac9739568b0f1225ee5e2d53cba919.tar.gz
go-04e6ae6bc3ac9739568b0f1225ee5e2d53cba919.zip
runtime: use Android O friendly syscalls on 64-bit machines
Android O disallows open on 64-bit, so let's use openat with AT_FDCWD to achieve the same behavior. Android O disallows epoll_wait on 64-bit, so let's use epoll_pwait with the last argument as NULL to achieve the same behavior. See here: https://android.googlesource.com/platform/bionic/+/master/libc/seccomp/arm64_app_policy.cpp https://android.googlesource.com/platform/bionic/+/master/libc/seccomp/mips64_app_policy.cpp https://android.googlesource.com/platform/bionic/+/master/libc/seccomp/x86_64_app_policy.cpp Fixes #23750 Change-Id: If8d5a663357471e5d2c1f516151344a9d05b188a Reviewed-on: https://go-review.googlesource.com/92895 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/sys_linux_amd64.s')
-rw-r--r--src/runtime/sys_linux_amd64.s18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s
index 5a94bda7c2..017e7dcaef 100644
--- a/src/runtime/sys_linux_amd64.s
+++ b/src/runtime/sys_linux_amd64.s
@@ -12,7 +12,6 @@
#define SYS_read 0
#define SYS_write 1
-#define SYS_open 2
#define SYS_close 3
#define SYS_mmap 9
#define SYS_munmap 11
@@ -41,9 +40,10 @@
#define SYS_sched_getaffinity 204
#define SYS_epoll_create 213
#define SYS_exit_group 231
-#define SYS_epoll_wait 232
#define SYS_epoll_ctl 233
+#define SYS_openat 257
#define SYS_pselect6 270
+#define SYS_epoll_pwait 281
#define SYS_epoll_create1 291
TEXT runtime·exit(SB),NOSPLIT,$0-4
@@ -65,10 +65,12 @@ TEXT runtime·exitThread(SB),NOSPLIT,$0-8
JMP 0(PC)
TEXT runtime·open(SB),NOSPLIT,$0-20
- MOVQ name+0(FP), DI
- MOVL mode+8(FP), SI
- MOVL perm+12(FP), DX
- MOVL $SYS_open, AX
+ // This uses openat instead of open, because Android O blocks open.
+ MOVL $-100, DI // AT_FDCWD, so this acts like open
+ MOVQ name+0(FP), SI
+ MOVL mode+8(FP), DX
+ MOVL perm+12(FP), R10
+ MOVL $SYS_openat, AX
SYSCALL
CMPQ AX, $0xfffffffffffff001
JLS 2(PC)
@@ -655,11 +657,13 @@ TEXT runtime·epollctl(SB),NOSPLIT,$0
// int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout);
TEXT runtime·epollwait(SB),NOSPLIT,$0
+ // This uses pwait instead of wait, because Android O blocks wait.
MOVL epfd+0(FP), DI
MOVQ ev+8(FP), SI
MOVL nev+16(FP), DX
MOVL timeout+20(FP), R10
- MOVL $SYS_epoll_wait, AX
+ MOVQ $0, R8
+ MOVL $SYS_epoll_pwait, AX
SYSCALL
MOVL AX, ret+24(FP)
RET