Skip to content

Commit

Permalink
runtime, syscall: update openbsd for changes to syskill
Browse files Browse the repository at this point in the history
Change the openbsd runtime to use the current sys_kill and sys_thrkill
system calls.

Prior to OpenBSD 5.9 the sys_kill system call could be used with both
processes and threads. In OpenBSD 5.9 this functionality was split into
a sys_kill system call for processes (with a new syscall number) and a
sys_thrkill system call for threads. The original/legacy system call was
retained in OpenBSD 5.9 and OpenBSD 6.0, however has been removed and
will not exist in the upcoming OpenBSD 6.1 release.

Note: This change is needed to make Go work on OpenBSD 6.1 (to be
released in May 2017) and should be included in the Go 1.8 release.
This change also drops support for OpenBSD 5.8, which is already an
unsupported OpenBSD release.

Change-Id: I525ed9b57c66c0c6f438dfa32feb29c7eefc72b0
Reviewed-on: https://go-review.googlesource.com/34093
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
4a6f656c authored and bradfitz committed Dec 12, 2016
1 parent cbcc1db commit f91ddaa
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
4 changes: 4 additions & 0 deletions api/except.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,7 @@ pkg unicode, const Version = "6.2.0"
pkg unicode, const Version = "6.3.0"
pkg unicode, const Version = "7.0.0"
pkg unicode, const Version = "8.0.0"
pkg syscall (openbsd-386), const SYS_KILL = 37
pkg syscall (openbsd-386-cgo), const SYS_KILL = 37
pkg syscall (openbsd-amd64), const SYS_KILL = 37
pkg syscall (openbsd-amd64-cgo), const SYS_KILL = 37
9 changes: 5 additions & 4 deletions src/runtime/sys_openbsd_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ TEXT runtime·usleep(SB),NOSPLIT,$24
INT $0x80
RET

TEXT runtime·raise(SB),NOSPLIT,$12
TEXT runtime·raise(SB),NOSPLIT,$16
MOVL $299, AX // sys_getthrid
INT $0x80
MOVL $0, 0(SP)
MOVL AX, 4(SP) // arg 1 - pid
MOVL AX, 4(SP) // arg 1 - tid
MOVL sig+0(FP), AX
MOVL AX, 8(SP) // arg 2 - signum
MOVL $37, AX // sys_kill
MOVL $0, 12(SP) // arg 3 - tcb
MOVL $119, AX // sys_thrkill
INT $0x80
RET

Expand All @@ -97,7 +98,7 @@ TEXT runtime·raiseproc(SB),NOSPLIT,$12
MOVL AX, 4(SP) // arg 1 - pid
MOVL sig+0(FP), AX
MOVL AX, 8(SP) // arg 2 - signum
MOVL $37, AX // sys_kill
MOVL $122, AX // sys_kill
INT $0x80
RET

Expand Down
7 changes: 4 additions & 3 deletions src/runtime/sys_openbsd_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
TEXT runtime·raise(SB),NOSPLIT,$16
MOVL $299, AX // sys_getthrid
SYSCALL
MOVQ AX, DI // arg 1 - pid
MOVQ AX, DI // arg 1 - tid
MOVL sig+0(FP), SI // arg 2 - signum
MOVL $37, AX // sys_kill
MOVQ $0, DX // arg 3 - tcb
MOVL $119, AX // sys_thrkill
SYSCALL
RET

Expand All @@ -167,7 +168,7 @@ TEXT runtime·raiseproc(SB),NOSPLIT,$16
SYSCALL
MOVQ AX, DI // arg 1 - pid
MOVL sig+0(FP), SI // arg 2 - signum
MOVL $37, AX // sys_kill
MOVL $122, AX // sys_kill
SYSCALL
RET

Expand Down
7 changes: 4 additions & 3 deletions src/runtime/sys_openbsd_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
TEXT runtime·raise(SB),NOSPLIT,$12
MOVW $0x12B, R12
SWI $0 // sys_getthrid
// arg 1 - pid, already in R0
// arg 1 - tid, already in R0
MOVW sig+0(FP), R1 // arg 2 - signum
MOVW $37, R12 // sys_kill
MOVW $0, R2 // arg 3 - tcb
MOVW $119, R12 // sys_thrkill
SWI $0
RET

Expand All @@ -98,7 +99,7 @@ TEXT runtime·raiseproc(SB),NOSPLIT,$12
SWI $0 // sys_getpid
// arg 1 - pid, already in R0
MOVW sig+0(FP), R1 // arg 2 - signum
MOVW $37, R12 // sys_kill
MOVW $122, R12 // sys_kill
SWI $0
RET

Expand Down
2 changes: 1 addition & 1 deletion src/syscall/zsysnum_openbsd_386.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const (
SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); }
SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); }
SYS_SYNC = 36 // { void sys_sync(void); }
SYS_KILL = 37 // { int sys_kill(int pid, int signum); }
SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); }
SYS_GETPPID = 39 // { pid_t sys_getppid(void); }
SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); }
Expand Down Expand Up @@ -113,6 +112,7 @@ const (
SYS_READV = 120 // { ssize_t sys_readv(int fd, \
SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, \
SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); }
SYS_KILL = 122 // { int sys_kill(int pid, int signum); }
SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); }
SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); }
SYS_SETREGID = 127 // { int sys_setregid(gid_t rgid, gid_t egid); }
Expand Down
2 changes: 1 addition & 1 deletion src/syscall/zsysnum_openbsd_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const (
SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); }
SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); }
SYS_SYNC = 36 // { void sys_sync(void); }
SYS_KILL = 37 // { int sys_kill(int pid, int signum); }
SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); }
SYS_GETPPID = 39 // { pid_t sys_getppid(void); }
SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); }
Expand Down Expand Up @@ -112,6 +111,7 @@ const (
SYS_GETSOCKOPT = 118 // { int sys_getsockopt(int s, int level, int name, \
SYS_READV = 120 // { ssize_t sys_readv(int fd, \
SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, \
SYS_KILL = 122 // { int sys_kill(int pid, int signum); }
SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); }
SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); }
SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); }
Expand Down
2 changes: 1 addition & 1 deletion src/syscall/zsysnum_openbsd_arm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const (
SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); }
SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); }
SYS_SYNC = 36 // { void sys_sync(void); }
SYS_KILL = 37 // { int sys_kill(int pid, int signum); }
SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); }
SYS_GETPPID = 39 // { pid_t sys_getppid(void); }
SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); }
Expand Down Expand Up @@ -118,6 +117,7 @@ const (
SYS_GETSOCKOPT = 118 // { int sys_getsockopt(int s, int level, int name, \
SYS_READV = 120 // { ssize_t sys_readv(int fd, \
SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, \
SYS_KILL = 122 // { int sys_kill(int pid, int signum); }
SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); }
SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); }
SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); }
Expand Down

0 comments on commit f91ddaa

Please sign in to comment.