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  // Switches SP to g0 stack and calls (X14). Arguments already set.
    56  TEXT	asancall<>(SB), NOSPLIT, $0-0
    57  	MOV	X2, X8		// callee-saved
    58  	BEQZ	g, g0stack	// no g, still on a system stack
    59  	MOV	g_m(g), X21
    60  	MOV	m_g0(X21), X21
    61  	BEQ	X21, g, g0stack
    62  
    63  	MOV	(g_sched+gobuf_sp)(X21), X2
    64  
    65  g0stack:
    66  	JALR	RA, X14
    67  	MOV	X8, X2
    68  	RET
    69  

View as plain text