mirror of
https://github.com/golang/go
synced 2024-11-13 17:40:23 -07:00
runtime: fix TLS handling for netbsd
Set the TLS base using the _lwp_setprivate() syscall, instead of via sysarch(). NetBSD tracks the pointer passed to _lwp_setprivate() and restores this value when restoring mcontext. If sysarch() is used directly, restoring an mcontext trashes the FS/GS value, resulting in a segfault when we next try to access the TLS. R=golang-dev, r CC=golang-dev https://golang.org/cl/6206062
This commit is contained in:
parent
e393a8292e
commit
b42ebb6fbf
@ -296,13 +296,11 @@ TEXT runtime·setldt(SB),7,$8
|
||||
|
||||
TEXT runtime·settls(SB),7,$16
|
||||
// adjust for ELF: wants to use -8(GS) and -4(GS) for g and m
|
||||
MOVL 20(SP), CX
|
||||
MOVL base+0(FP), CX
|
||||
ADDL $8, CX
|
||||
MOVL CX, 0(CX)
|
||||
MOVL $0, 0(SP) // syscall gap
|
||||
MOVL $16, 4(SP) // X86_SET_GSBASE (x86/sysarch.h)
|
||||
MOVL CX, 8(SP) // pointer to base
|
||||
MOVL $165, AX // sys_sysarch
|
||||
MOVL CX, 4(SP) // arg 1 - ptr
|
||||
MOVL $317, AX // sys__lwp_setprivate
|
||||
INT $0x80
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
|
@ -179,7 +179,6 @@ TEXT runtime·sigaction(SB),7,$-8
|
||||
LEAQ runtime·sigreturn_tramp(SB), R10
|
||||
MOVQ $3, R8 // arg 5 - version
|
||||
MOVL $340, AX // sys___sigaction_sigtramp
|
||||
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
@ -253,11 +252,8 @@ TEXT runtime·sigaltstack(SB),7,$-8
|
||||
// set tls base to DI
|
||||
TEXT runtime·settls(SB),7,$8
|
||||
// adjust for ELF: wants to use -16(FS) and -8(FS) for g and m
|
||||
ADDQ $16, DI
|
||||
MOVQ DI, 0(SP)
|
||||
MOVQ SP, SI
|
||||
MOVQ $17, DI // X86_64_SET_FSBASE (x86/sysarch.h)
|
||||
MOVQ $165, AX // sys_sysarch
|
||||
ADDQ $16, DI // arg 1 - ptr
|
||||
MOVQ $317, AX // sys__lwp_setprivate
|
||||
SYSCALL
|
||||
JCC 2(PC)
|
||||
MOVL $0xf1, 0xf1 // crash
|
||||
|
Loading…
Reference in New Issue
Block a user