From: Cherry Zhang Date: Tue, 2 Feb 2021 23:25:39 +0000 (-0500) Subject: [dev.regabi] runtime: zero X15 in racecall X-Git-Tag: go1.17beta1~1539^2~30 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=946351d5a27d7dc5550f579ddfec926790903fc5;p=gostls13.git [dev.regabi] runtime: zero X15 in racecall racecall can be called in ABIInternal context (e.g. raceread calling racecalladdr calling racecall) without wrapper. racecall calls C code, which doesn't preserve our special registers. Set them explicitly in racecall upon returning from C. Change-Id: Ic990479c1fca6bb8a3b151325c7a89be8331a530 Reviewed-on: https://go-review.googlesource.com/c/go/+/289709 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Michael Knyszek Reviewed-by: Jeremy Faller --- diff --git a/src/runtime/race_amd64.s b/src/runtime/race_amd64.s index cf0a51462f..fd41b5690a 100644 --- a/src/runtime/race_amd64.s +++ b/src/runtime/race_amd64.s @@ -412,6 +412,9 @@ call: ANDQ $~15, SP // alignment for gcc ABI CALL AX MOVQ R12, SP + // Back to Go world, set special registers. + // The g register (R14) is preserved in C. + XORPS X15, X15 RET // C->Go callback thunk that allows to call runtime·racesymbolize from C code.