Skip to content

Commit f3910e8

Browse files
committed
settls implementation for tamago/amd64
1 parent 349313d commit f3910e8

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/runtime/sys_tamago_amd64.s

+14-13
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
// license that can be found in the LICENSE file.
44

55
//
6-
// System calls and other sys.stuff for arm, tamago
6+
// System calls and other sys.stuff for amd64, tamago
77
//
88

99
#include "go_asm.h"
1010
#include "go_tls.h"
1111
#include "textflag.h"
1212

13+
#define IA32_MSR_FS_BASE 0xc0000100
14+
1315
#define SYS_arch_prctl 158
1416

1517
TEXT runtime·rt0_amd64_tamago(SB),NOSPLIT|NOFRAME|TOPFRAME,$0
@@ -114,18 +116,6 @@ ok:
114116
JNE bad_cpu
115117
#endif
116118

117-
#ifdef NEED_DARWIN_SUPPORT
118-
MOVQ $commpage64_version, BX
119-
CMPW (BX), $13 // cpu_capabilities64 undefined in versions < 13
120-
JL bad_cpu
121-
MOVQ $commpage64_cpu_capabilities64, BX
122-
MOVQ (BX), BX
123-
MOVQ $NEED_DARWIN_SUPPORT, CX
124-
ANDQ CX, BX
125-
CMPQ BX, CX
126-
JNE bad_cpu
127-
#endif
128-
129119
CALL runtime·check(SB)
130120

131121
MOVL 24(SP), AX // copy argc
@@ -167,6 +157,17 @@ TEXT runtime·GetG(SB),NOSPLIT,$0-16
167157

168158
// This is needed by asm_amd64.s
169159
TEXT runtime·settls(SB),NOSPLIT,$32
160+
MOVW runtime·testBinary(SB), AX
161+
CMPW AX, $0
162+
JA testing
163+
164+
MOVQ $IA32_MSR_FS_BASE, CX
165+
MOVQ $0x0, DX
166+
MOVQ $0xfffffffffffffff8, AX // -8(FS)
167+
WRMSR
168+
RET
169+
170+
testing:
170171
ADDQ $8, DI // ELF wants to use -8(FS)
171172
MOVQ DI, SI
172173
MOVQ $0x1002, DI // ARCH_SET_FS

0 commit comments

Comments
 (0)