Text file
src/runtime/asan_riscv64.s
1 // Copyright 2022 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 // Called from instrumented code.
11 // func runtime·doasanread(addr unsafe.Pointer, sz, sp, pc uintptr)
12 TEXT runtime·doasanread(SB), NOSPLIT, $0-32
13 MOV addr+0(FP), X10
14 MOV sz+8(FP), X11
15 MOV sp+16(FP), X12
16 MOV pc+24(FP), X13
17 // void __asan_read_go(void *addr, uintptr_t sz);
18 MOV $__asan_read_go(SB), X14
19 JMP asancall<>(SB)
20
21 // func runtime·doasanwrite(addr unsafe.Pointer, sz, sp, pc uintptr)
22 TEXT runtime·doasanwrite(SB), NOSPLIT, $0-32
23 MOV addr+0(FP), X10
24 MOV sz+8(FP), X11
25 MOV sp+16(FP), X12
26 MOV pc+24(FP), X13
27 // void __asan_write_go(void *addr, uintptr_t sz);
28 MOV $__asan_write_go(SB), X14
29 JMP asancall<>(SB)
30
31 // func runtime·asanunpoison(addr unsafe.Pointer, sz uintptr)
32 TEXT runtime·asanunpoison(SB), NOSPLIT, $0-16
33 MOV addr+0(FP), X10
34 MOV sz+8(FP), X11
35 // void __asan_unpoison_go(void *addr, uintptr_t sz);
36 MOV $__asan_unpoison_go(SB), X14
37 JMP asancall<>(SB)
38
39 // func runtime·asanpoison(addr unsafe.Pointer, sz uintptr)
40 TEXT runtime·asanpoison(SB), NOSPLIT, $0-16
41 MOV addr+0(FP), X10
42 MOV sz+8(FP), X11
43 // void __asan_poison_go(void *addr, uintptr_t sz);
44 MOV $__asan_poison_go(SB), X14
45 JMP asancall<>(SB)
46
47 // func runtime·asanregisterglobals(addr unsafe.Pointer, n uintptr)
48 TEXT runtime·asanregisterglobals(SB), NOSPLIT, $0-16
49 MOV addr+0(FP), X10
50 MOV n+8(FP), X11
51 // void __asan_register_globals_go(void *addr, uintptr_t n);
52 MOV $__asan_register_globals_go(SB), X14
53 JMP asancall<>(SB)
54
55 // func runtime·lsanregisterrootregion(addr unsafe.Pointer, n uintptr)
56 TEXT runtime·lsanregisterrootregion(SB), NOSPLIT, $0-16
57 MOV addr+0(FP), X10
58 MOV n+8(FP), X11
59 // void __lsan_register_root_region_go(void *addr, uintptr_t n);
60 MOV $__lsan_register_root_region_go(SB), X14
61 JMP asancall<>(SB)
62
63 // func runtime·lsanunregisterrootregion(addr unsafe.Pointer, n uintptr)
64 TEXT runtime·lsanunregisterrootregion(SB), NOSPLIT, $0-16
65 MOV addr+0(FP), X10
66 MOV n+8(FP), X11
67 // void __lsan_unregister_root_region_go(void *addr, uintptr_t n);
68 MOV $__lsan_unregister_root_region_go(SB), X14
69 JMP asancall<>(SB)
70
71 // func runtime·lsandoleakcheck()
72 TEXT runtime·lsandoleakcheck(SB), NOSPLIT, $0-0
73 // void __lsan_do_leak_check_go(void);
74 MOV $__lsan_do_leak_check_go(SB), X14
75 JMP asancall<>(SB)
76
77 // Switches SP to g0 stack and calls (X14). Arguments already set.
78 TEXT asancall<>(SB), NOSPLIT, $0-0
79 MOV X2, X8 // callee-saved
80 BEQZ g, g0stack // no g, still on a system stack
81 MOV g_m(g), X21
82 MOV m_g0(X21), X21
83 BEQ X21, g, g0stack
84
85 MOV (g_sched+gobuf_sp)(X21), X2
86
87 g0stack:
88 JALR RA, X14
89 MOV X8, X2
90 RET
91
View as plain text