Text file
src/runtime/asan_arm64.s
1 // Copyright 2021 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 asan
6
7 #include "go_asm.h"
8 #include "textflag.h"
9
10 #define RARG0 R0
11 #define RARG1 R1
12 #define RARG2 R2
13 #define RARG3 R3
14 #define FARG R4
15
16 // Called from instrumented code.
17 // func runtime·doasanread(addr unsafe.Pointer, sz, sp, pc uintptr)
18 TEXT runtime·doasanread(SB), NOSPLIT, $0-32
19 MOVD addr+0(FP), RARG0
20 MOVD size+8(FP), RARG1
21 MOVD sp+16(FP), RARG2
22 MOVD pc+24(FP), RARG3
23 // void __asan_read_go(void *addr, uintptr_t sz, void *sp, void *pc);
24 MOVD $__asan_read_go(SB), FARG
25 JMP asancall<>(SB)
26
27 // func runtime·doasanwrite(addr unsafe.Pointer, sz, sp, pc uintptr)
28 TEXT runtime·doasanwrite(SB), NOSPLIT, $0-32
29 MOVD addr+0(FP), RARG0
30 MOVD size+8(FP), RARG1
31 MOVD sp+16(FP), RARG2
32 MOVD pc+24(FP), RARG3
33 // void __asan_write_go(void *addr, uintptr_t sz, void *sp, void *pc);
34 MOVD $__asan_write_go(SB), FARG
35 JMP asancall<>(SB)
36
37 // func runtime·asanunpoison(addr unsafe.Pointer, sz uintptr)
38 TEXT runtime·asanunpoison(SB), NOSPLIT, $0-16
39 MOVD addr+0(FP), RARG0
40 MOVD size+8(FP), RARG1
41 // void __asan_unpoison_go(void *addr, uintptr_t sz);
42 MOVD $__asan_unpoison_go(SB), FARG
43 JMP asancall<>(SB)
44
45 // func runtime·asanpoison(addr unsafe.Pointer, sz uintptr)
46 TEXT runtime·asanpoison(SB), NOSPLIT, $0-16
47 MOVD addr+0(FP), RARG0
48 MOVD size+8(FP), RARG1
49 // void __asan_poison_go(void *addr, uintptr_t sz);
50 MOVD $__asan_poison_go(SB), FARG
51 JMP asancall<>(SB)
52
53 // Switches SP to g0 stack and calls (FARG). Arguments already set.
54 TEXT asancall<>(SB), NOSPLIT, $0-0
55 MOVD RSP, R19 // callee-saved
56 CBZ g, g0stack // no g, still on a system stack
57 MOVD g_m(g), R10
58 MOVD m_g0(R10), R11
59 CMP R11, g
60 BEQ g0stack
61
62 MOVD (g_sched+gobuf_sp)(R11), R5
63 MOVD R5, RSP
64
65 g0stack:
66 BL (FARG)
67 MOVD R19, RSP
68 RET
69
View as plain text