Text file
src/runtime/asan_loong64.s
1 // Copyright 2023 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 R4
11 #define RARG1 R5
12 #define RARG2 R6
13 #define RARG3 R7
14 #define FARG R8
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 MOVV addr+0(FP), RARG0
20 MOVV sz+8(FP), RARG1
21 MOVV sp+16(FP), RARG2
22 MOVV pc+24(FP), RARG3
23 // void __asan_read_go(void *addr, uintptr_t sz, void *sp, void *pc);
24 MOVV $__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 MOVV addr+0(FP), RARG0
30 MOVV sz+8(FP), RARG1
31 MOVV sp+16(FP), RARG2
32 MOVV pc+24(FP), RARG3
33 // void __asan_write_go(void *addr, uintptr_t sz, void *sp, void *pc);
34 MOVV $__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 MOVV addr+0(FP), RARG0
40 MOVV sz+8(FP), RARG1
41 // void __asan_unpoison_go(void *addr, uintptr_t sz);
42 MOVV $__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 MOVV addr+0(FP), RARG0
48 MOVV sz+8(FP), RARG1
49 // void __asan_poison_go(void *addr, uintptr_t sz);
50 MOVV $__asan_poison_go(SB), FARG
51 JMP asancall<>(SB)
52
53 // func runtime·asanregisterglobals(addr unsafe.Pointer, n uintptr)
54 TEXT runtime·asanregisterglobals(SB), NOSPLIT, $0-16
55 MOVV addr+0(FP), RARG0
56 MOVV n+8(FP), RARG1
57 // void __asan_register_globals_go(void *addr, uintptr_t n);
58 MOVV $__asan_register_globals_go(SB), FARG
59 JMP asancall<>(SB)
60
61 // func runtime·lsanregisterrootregion(addr unsafe.Pointer, n uintptr)
62 TEXT runtime·lsanregisterrootregion(SB), NOSPLIT, $0-16
63 MOVV addr+0(FP), RARG0
64 MOVV n+8(FP), RARG1
65 // void __lsan_register_root_region_go(void *addr, uintptr_t n);
66 MOVV $__lsan_register_root_region_go(SB), FARG
67 JMP asancall<>(SB)
68
69 // func runtime·lsanunregisterrootregion(addr unsafe.Pointer, n uintptr)
70 TEXT runtime·lsanunregisterrootregion(SB), NOSPLIT, $0-16
71 MOVV addr+0(FP), RARG0
72 MOVV n+8(FP), RARG1
73 // void __lsan_unregister_root_region_go(void *addr, uintptr_t n);
74 MOVV $__lsan_unregister_root_region_go(SB), FARG
75 JMP asancall<>(SB)
76
77 // func runtime·lsandoleakcheck()
78 TEXT runtime·lsandoleakcheck(SB), NOSPLIT, $0-0
79 // void __lsan_do_leak_check_go(void);
80 MOVV $__lsan_do_leak_check_go(SB), FARG
81 JMP asancall<>(SB)
82
83 // Switches SP to g0 stack and calls (FARG). Arguments already set.
84 TEXT asancall<>(SB), NOSPLIT, $0-0
85 MOVV R3, R23 // callee-saved
86 BEQ g, g0stack // no g, still on a system stack
87 MOVV g_m(g), R14
88 MOVV m_g0(R14), R15
89 BEQ R15, g, g0stack
90
91 MOVV (g_sched+gobuf_sp)(R15), R9
92 MOVV R9, R3
93
94 g0stack:
95 JAL (FARG)
96 MOVV R23, R3
97 RET
98
View as plain text