aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/msan_arm64.s
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-11-16 21:28:26 -0500
committerCherry Zhang <cherryyz@google.com>2020-12-03 15:40:11 +0000
commit07cba70d5794747044ce5f2f3b34de139193e2a5 (patch)
treec469bb083550371669e3c76388ba0af7e5f10a4f /src/runtime/msan_arm64.s
parentd0c0dc682c1fb15241d84df11715e706a5bc0da7 (diff)
downloadgo-07cba70d5794747044ce5f2f3b34de139193e2a5.tar.gz
go-07cba70d5794747044ce5f2f3b34de139193e2a5.zip
cmd/compile, runtime: use __msan_memmove for moving data, split msanread to fields
Currently, for data moving, we generate an msanread of the source, followed by an msanwrite of the destination. msanread checks the source is initialized. This has a problem: if the source is an aggregate type containing alignment paddings, the padding bytes may not be thought as initialized by MSAN. If we copy the aggregate type by value, if it counts as a read, MSAN reports using uninitialized data. This CL changes it to use __msan_memmove for data copying, which tells MSAN to propagate initialized-ness but not check for it. Caveat: technically __msan_memmove is not a public API of MSAN, although the C compiler does generate direct calls to it. Also, when instrumenting a load of a struct, split the instrumentation to fields, instead of generating an msanread for the whole struct. This skips padding bytes, which may not be considered initialized in MSAN. Fixes #42820. Change-Id: Id861c8bbfd94cfcccefcc58eaf9e4eb43b4d85c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/270859 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/msan_arm64.s')
-rw-r--r--src/runtime/msan_arm64.s10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/runtime/msan_arm64.s b/src/runtime/msan_arm64.s
index 5e29f1aefb..f19906cfc8 100644
--- a/src/runtime/msan_arm64.s
+++ b/src/runtime/msan_arm64.s
@@ -9,6 +9,7 @@
#define RARG0 R0
#define RARG1 R1
+#define RARG2 R2
#define FARG R3
// func runtime·domsanread(addr unsafe.Pointer, sz uintptr)
@@ -45,6 +46,15 @@ TEXT runtime·msanfree(SB), NOSPLIT, $0-16
MOVD $__msan_free_go(SB), FARG
JMP msancall<>(SB)
+// func runtime·msanmove(dst, src unsafe.Pointer, sz uintptr)
+TEXT runtime·msanmove(SB), NOSPLIT, $0-24
+ MOVD dst+0(FP), RARG0
+ MOVD src+8(FP), RARG1
+ MOVD size+16(FP), RARG2
+ // void __msan_memmove(void *dst, void *src, uintptr_t sz);
+ MOVD $__msan_memmove(SB), FARG
+ JMP msancall<>(SB)
+
// Switches SP to g0 stack and calls (FARG). Arguments already set.
TEXT msancall<>(SB), NOSPLIT, $0-0
MOVD RSP, R19 // callee-saved