Skip to content

Commit

Permalink
settls implementation for tamago/amd64
Browse files Browse the repository at this point in the history
  • Loading branch information
abarisani committed Dec 17, 2024
1 parent 349313d commit f3910e8
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/runtime/sys_tamago_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
// license that can be found in the LICENSE file.

//
// System calls and other sys.stuff for arm, tamago
// System calls and other sys.stuff for amd64, tamago
//

#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"

#define IA32_MSR_FS_BASE 0xc0000100

#define SYS_arch_prctl 158

TEXT runtime·rt0_amd64_tamago(SB),NOSPLIT|NOFRAME|TOPFRAME,$0
Expand Down Expand Up @@ -114,18 +116,6 @@ ok:
JNE bad_cpu
#endif

#ifdef NEED_DARWIN_SUPPORT
MOVQ $commpage64_version, BX
CMPW (BX), $13 // cpu_capabilities64 undefined in versions < 13
JL bad_cpu
MOVQ $commpage64_cpu_capabilities64, BX
MOVQ (BX), BX
MOVQ $NEED_DARWIN_SUPPORT, CX
ANDQ CX, BX
CMPQ BX, CX
JNE bad_cpu
#endif

CALL runtime·check(SB)

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

// This is needed by asm_amd64.s
TEXT runtime·settls(SB),NOSPLIT,$32
MOVW runtime·testBinary(SB), AX
CMPW AX, $0
JA testing

MOVQ $IA32_MSR_FS_BASE, CX
MOVQ $0x0, DX
MOVQ $0xfffffffffffffff8, AX // -8(FS)
WRMSR
RET

testing:
ADDQ $8, DI // ELF wants to use -8(FS)
MOVQ DI, SI
MOVQ $0x1002, DI // ARCH_SET_FS
Expand Down

0 comments on commit f3910e8

Please sign in to comment.