github.com/comwrg/go/src@v0.0.0-20220319063731-c238d0440370/runtime/msan_amd64.s (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build msan 6 // +build msan 7 8 #include "go_asm.h" 9 #include "go_tls.h" 10 #include "funcdata.h" 11 #include "textflag.h" 12 13 // This is like race_amd64.s, but for the msan calls. 14 // See race_amd64.s for detailed comments. 15 16 #ifdef GOOS_windows 17 #define RARG0 CX 18 #define RARG1 DX 19 #define RARG2 R8 20 #define RARG3 R9 21 #else 22 #define RARG0 DI 23 #define RARG1 SI 24 #define RARG2 DX 25 #define RARG3 CX 26 #endif 27 28 // func runtime·domsanread(addr unsafe.Pointer, sz uintptr) 29 // Called from msanread. 30 TEXT runtime·domsanread(SB), NOSPLIT, $0-16 31 MOVQ addr+0(FP), RARG0 32 MOVQ size+8(FP), RARG1 33 // void __msan_read_go(void *addr, uintptr_t sz); 34 MOVQ $__msan_read_go(SB), AX 35 JMP msancall<>(SB) 36 37 // func runtime·msanwrite(addr unsafe.Pointer, sz uintptr) 38 // Called from instrumented code. 39 TEXT runtime·msanwrite(SB), NOSPLIT, $0-16 40 MOVQ addr+0(FP), RARG0 41 MOVQ size+8(FP), RARG1 42 // void __msan_write_go(void *addr, uintptr_t sz); 43 MOVQ $__msan_write_go(SB), AX 44 JMP msancall<>(SB) 45 46 // func runtime·msanmalloc(addr unsafe.Pointer, sz uintptr) 47 TEXT runtime·msanmalloc(SB), NOSPLIT, $0-16 48 MOVQ addr+0(FP), RARG0 49 MOVQ size+8(FP), RARG1 50 // void __msan_malloc_go(void *addr, uintptr_t sz); 51 MOVQ $__msan_malloc_go(SB), AX 52 JMP msancall<>(SB) 53 54 // func runtime·msanfree(addr unsafe.Pointer, sz uintptr) 55 TEXT runtime·msanfree(SB), NOSPLIT, $0-16 56 MOVQ addr+0(FP), RARG0 57 MOVQ size+8(FP), RARG1 58 // void __msan_free_go(void *addr, uintptr_t sz); 59 MOVQ $__msan_free_go(SB), AX 60 JMP msancall<>(SB) 61 62 // func runtime·msanmove(dst, src unsafe.Pointer, sz uintptr) 63 TEXT runtime·msanmove(SB), NOSPLIT, $0-24 64 MOVQ dst+0(FP), RARG0 65 MOVQ src+8(FP), RARG1 66 MOVQ size+16(FP), RARG2 67 // void __msan_memmove(void *dst, void *src, uintptr_t sz); 68 MOVQ $__msan_memmove(SB), AX 69 JMP msancall<>(SB) 70 71 // Switches SP to g0 stack and calls (AX). Arguments already set. 72 TEXT msancall<>(SB), NOSPLIT, $0-0 73 get_tls(R12) 74 MOVQ g(R12), R14 75 MOVQ SP, R12 // callee-saved, preserved across the CALL 76 CMPQ R14, $0 77 JE call // no g; still on a system stack 78 79 MOVQ g_m(R14), R13 80 // Switch to g0 stack. 81 MOVQ m_g0(R13), R10 82 CMPQ R10, R14 83 JE call // already on g0 84 85 MOVQ (g_sched+gobuf_sp)(R10), SP 86 call: 87 ANDQ $~15, SP // alignment for gcc ABI 88 CALL AX 89 MOVQ R12, SP 90 RET