1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:04:44 -07:00

runtime: M-targeted signals for Linux

We'll add a test once all of the POSIX platforms are done.

For #10958, #24543.

Change-Id: If7e3f14e8391791364877629bf415d9f8e788b0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/201401
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Austin Clements 2019-10-03 10:19:38 -04:00
parent 3706cd85d3
commit 334291d1f6
9 changed files with 121 additions and 1 deletions

View File

@ -332,7 +332,9 @@ func gettid() uint32
func minit() { func minit() {
minitSignals() minitSignals()
// for debuggers, in case cgo created the thread // Cgo-created threads and the bootstrap m are missing a
// procid. We need this for asynchronous preemption and its
// useful in debuggers.
getg().m.procid = uint64(gettid()) getg().m.procid = uint64(gettid())
} }
@ -454,3 +456,11 @@ func sysSigaction(sig uint32, new, old *sigactiont) {
// rt_sigaction is implemented in assembly. // rt_sigaction is implemented in assembly.
//go:noescape //go:noescape
func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32 func rt_sigaction(sig uintptr, new, old *sigactiont, size uintptr) int32
func getpid() int
func tgkill(tgid, tid, sig int)
// signalM sends a signal to mp.
func signalM(mp *m, sig int) {
tgkill(getpid(), int(mp.procid), sig)
}

View File

@ -188,6 +188,20 @@ TEXT runtime·raiseproc(SB),NOSPLIT,$12
INVOKE_SYSCALL INVOKE_SYSCALL
RET RET
TEXT ·getpid(SB),NOSPLIT,$0-4
MOVL $SYS_getpid, AX
INVOKE_SYSCALL
MOVL AX, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT,$0
MOVL $SYS_tgkill, AX
MOVL tgid+0(FP), BX
MOVL tid+4(FP), CX
MOVL sig+8(FP), DX
INVOKE_SYSCALL
RET
TEXT runtime·setitimer(SB),NOSPLIT,$0-12 TEXT runtime·setitimer(SB),NOSPLIT,$0-12
MOVL $SYS_setittimer, AX MOVL $SYS_setittimer, AX
MOVL mode+0(FP), BX MOVL mode+0(FP), BX

View File

@ -171,6 +171,20 @@ TEXT runtime·raiseproc(SB),NOSPLIT,$0
SYSCALL SYSCALL
RET RET
TEXT ·getpid(SB),NOSPLIT,$0-8
MOVL $SYS_getpid, AX
SYSCALL
MOVQ AX, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT,$0
MOVQ tgid+0(FP), DI
MOVQ tid+8(FP), SI
MOVQ sig+16(FP), DX
MOVL $SYS_tgkill, AX
SYSCALL
RET
TEXT runtime·setitimer(SB),NOSPLIT,$0-24 TEXT runtime·setitimer(SB),NOSPLIT,$0-24
MOVL mode+0(FP), DI MOVL mode+0(FP), DI
MOVQ new+8(FP), SI MOVQ new+8(FP), SI

View File

@ -172,6 +172,20 @@ TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
SWI $0 SWI $0
RET RET
TEXT ·getpid(SB),NOSPLIT,$0-4
MOVW $SYS_getpid, R7
SWI $0
MOVW R0, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT,$0-12
MOVW tgid+0(FP), R0
MOVW tid+4(FP), R1
MOVW sig+8(FP), R2
MOVW $SYS_tgkill, R7
SWI $0
RET
TEXT runtime·mmap(SB),NOSPLIT,$0 TEXT runtime·mmap(SB),NOSPLIT,$0
MOVW addr+0(FP), R0 MOVW addr+0(FP), R0
MOVW n+4(FP), R1 MOVW n+4(FP), R1

View File

@ -175,6 +175,20 @@ TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
SVC SVC
RET RET
TEXT ·getpid(SB),NOSPLIT|NOFRAME,$0-8
MOVD $SYS_getpid, R8
SVC
MOVD R0, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT,$0-24
MOVD tgid+0(FP), R0
MOVD tid+8(FP), R1
MOVD sig+16(FP), R2
MOVD $SYS_tgkill, R8
SVC
RET
TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24 TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24
MOVW mode+0(FP), R0 MOVW mode+0(FP), R0
MOVD new+8(FP), R1 MOVD new+8(FP), R1

View File

@ -177,6 +177,20 @@ TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
SYSCALL SYSCALL
RET RET
TEXT ·getpid(SB),NOSPLIT|NOFRAME,$0-8
MOVV $SYS_getpid, R2
SYSCALL
MOVV R2, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT|NOFRAME,$0-24
MOVV tgid+0(FP), R4
MOVV tid+8(FP), R5
MOVV sig+16(FP), R6
MOVV $SYS_tgkill, R2
SYSCALL
RET
TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24 TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24
MOVW mode+0(FP), R4 MOVW mode+0(FP), R4
MOVV new+8(FP), R5 MOVV new+8(FP), R5

View File

@ -183,6 +183,20 @@ TEXT runtime·raiseproc(SB),NOSPLIT,$0
SYSCALL SYSCALL
RET RET
TEXT ·getpid(SB),NOSPLIT,$0-4
MOVW $SYS_getpid, R2
SYSCALL
MOVW R2, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT,$0-12
MOVW tgid+0(FP), R4
MOVW tid+4(FP), R5
MOVW sig+8(FP), R6
MOVW $SYS_tgkill, R2
SYSCALL
RET
TEXT runtime·setitimer(SB),NOSPLIT,$0-12 TEXT runtime·setitimer(SB),NOSPLIT,$0-12
MOVW mode+0(FP), R4 MOVW mode+0(FP), R4
MOVW new+4(FP), R5 MOVW new+4(FP), R5

View File

@ -156,6 +156,18 @@ TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
SYSCALL $SYS_kill SYSCALL $SYS_kill
RET RET
TEXT ·getpid(SB),NOSPLIT|NOFRAME,$0-8
SYSCALL $SYS_getpid
MOVD R3, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT|NOFRAME,$0-24
MOVD tgid+0(FP), R3
MOVD tid+8(FP), R4
MOVD sig+16(FP), R5
SYSCALL $SYS_tgkill
RET
TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24 TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24
MOVW mode+0(FP), R3 MOVW mode+0(FP), R3
MOVD new+8(FP), R4 MOVD new+8(FP), R4

View File

@ -163,6 +163,20 @@ TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
SYSCALL SYSCALL
RET RET
TEXT ·getpid(SB),NOSPLIT|NOFRAME,$0-8
MOVW $SYS_getpid, R1
SYSCALL
MOVD R2, ret+0(FP)
RET
TEXT ·tgkill(SB),NOSPLIT|NOFRAME,$0-24
MOVD tgid+0(FP), R2
MOVD tid+8(FP), R3
MOVD sig+16(FP), R4
MOVW $SYS_tgkill, R1
SYSCALL
RET
TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24 TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24
MOVW mode+0(FP), R2 MOVW mode+0(FP), R2
MOVD new+8(FP), R3 MOVD new+8(FP), R3