]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime/internal/atomic: add memory barrier for mips Cas on failure
authorMauri de Souza Meneguzzo <mauri870@gmail.com>
Tue, 17 Oct 2023 22:54:27 +0000 (22:54 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 24 Oct 2023 17:49:25 +0000 (17:49 +0000)
Add a memory barrier on the failure case of the
compare-and-swap for mips, this avoids potential
race conditions.

For #63506

Change-Id: I3df1479d1438ba72aa72567eb3dea76ff745e98d
GitHub-Last-Rev: 2101b9fd446f28f856986b27d20f92cd4a1f4fef
GitHub-Pull-Request: golang/go#63604
Reviewed-on: https://go-review.googlesource.com/c/go/+/536116
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/runtime/internal/atomic/atomic_mipsx.go
src/runtime/internal/atomic/atomic_mipsx.s

index 5dd15a0b0221904e64ff93e974119a2f6081721a..e3dcde1bde944ad239f2cebc97369a6d695cd131 100644 (file)
@@ -48,11 +48,6 @@ func unlock() {
        spinUnlock(&lock.state)
 }
 
-//go:nosplit
-func unlockNoFence() {
-       lock.state = 0
-}
-
 //go:nosplit
 func Xadd64(addr *uint64, delta int64) (new uint64) {
        lockAndCheck(addr)
@@ -85,7 +80,7 @@ func Cas64(addr *uint64, old, new uint64) (swapped bool) {
                return true
        }
 
-       unlockNoFence()
+       unlock()
        return false
 }
 
index 390e9ce7acc386f74c16ead53cfcdf37e4703965..8f5fc53cb77eab776cc29d3c8ee88b1e8d38620d 100644 (file)
@@ -28,6 +28,7 @@ try_cas:
        MOVB    R3, ret+12(FP)
        RET
 cas_fail:
+       SYNC
        MOVB    R0, ret+12(FP)
        RET