From 1a0ea1a08b26f25d3795ca46e4a831a8ca4859ad Mon Sep 17 00:00:00 2001 From: Guilherme Souza <32180229+gqgs@users.noreply.github.com> Date: Tue, 11 May 2021 21:37:56 +0000 Subject: runtime: fix typo in proc.go Change-Id: I12c0befc5772a5c902a55aeb06a30ec7a34a3bd6 GitHub-Last-Rev: 7d41e1bcb9f6304e1b868701740279e845c99a66 GitHub-Pull-Request: golang/go#46112 Reviewed-on: https://go-review.googlesource.com/c/go/+/319053 Reviewed-by: Keith Randall Reviewed-by: Ian Lance Taylor --- src/runtime/proc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 378d5e32f5..66a06feb24 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -3136,7 +3136,7 @@ func checkIdleGCNoP() (*p, *g) { // an available P and available worker G. // // We can attempt to acquire these in either order, though both have - // synchonization concerns (see below). Workers are almost always + // synchronization concerns (see below). Workers are almost always // available (see comment in findRunnableGCWorker for the one case // there may be none). Since we're slightly less likely to find a P, // check for that first. -- cgit v1.3-5-g9baa From 03886707f9e8db668bd1fd7b8f99799dba0408e3 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 6 May 2021 11:38:46 -0400 Subject: runtime: fix handling of SPWRITE functions in traceback It is valid to see SPWRITE functions at the top of a GC stack traceback, in the case where they self-preempted during the stack growth check and haven't actually modified SP in a traceback-unfriendly manner yet. The current check is therefore too aggressive. isAsyncSafePoint is taking care of not async-preempting SPWRITE functions because it doesn't async-preempt any assembly functions at all. But perhaps it will in the future. To keep a check that SPWRITE assembly functions are not async-preempted, add one in preemptPark. Then relax the check in traceback to avoid triggering on self-preempted SPWRITE functions. The long and short of this is that the assembly we corrected in x/crypto issue #44269 was incredibly dodgy but not technically incompatible with the Go runtime. After this change, the original x/crypto assembly no longer causes GC traceback crashes during "GOGC=1 go test -count=1000". But we'll still leave the corrected assembly. This also means that we don't need to worry about diagnosing SPWRITE assembly functions that may exist in the wild. They will be skipped for async preemption and no harm no foul. Fixes #44269, which was open pending some kind of check for bad SPWRITE functions in the wild. (No longer needed.) Change-Id: I6000197b62812bbd2cd92da28eab422634cf75a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/317669 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Cherry Mui --- src/runtime/preempt.go | 2 ++ src/runtime/proc.go | 15 +++++++++++++++ src/runtime/traceback.go | 17 ++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/preempt.go b/src/runtime/preempt.go index 372185266f..1d5aae1363 100644 --- a/src/runtime/preempt.go +++ b/src/runtime/preempt.go @@ -413,6 +413,8 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) (bool, uintptr) { // // TODO: Are there cases that are safe but don't have a // locals pointer map, like empty frame functions? + // It might be possible to preempt any assembly functions + // except the ones that have funcFlag_SPWRITE set in f.flag. return false, 0 } name := funcname(f) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 66a06feb24..ded406cc28 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -3570,6 +3570,21 @@ func preemptPark(gp *g) { throw("bad g status") } gp.waitreason = waitReasonPreempted + + if gp.asyncSafePoint { + // Double-check that async preemption does not + // happen in SPWRITE assembly functions. + // isAsyncSafePoint must exclude this case. + f := findfunc(gp.sched.pc) + if !f.valid() { + throw("preempt at unknown pc") + } + if f.flag&funcFlag_SPWRITE != 0 { + println("runtime: unexpected SPWRITE function", funcname(f), "in async preempt") + throw("preempt SPWRITE") + } + } + // Transition from _Grunning to _Gscan|_Gpreempted. We can't // be in _Grunning when we dropg because then we'd be running // without an M, but the moment we're in _Gpreempted, diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 167d51c452..89780edc1f 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -219,18 +219,25 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in // This function marks the top of the stack. Stop the traceback. frame.lr = 0 flr = funcInfo{} - } else if flag&funcFlag_SPWRITE != 0 { + } else if flag&funcFlag_SPWRITE != 0 && (callback == nil || n > 0) { // The function we are in does a write to SP that we don't know // how to encode in the spdelta table. Examples include context // switch routines like runtime.gogo but also any code that switches // to the g0 stack to run host C code. Since we can't reliably unwind // the SP (we might not even be on the stack we think we are), // we stop the traceback here. + // This only applies for profiling signals (callback == nil). + // + // For a GC stack traversal (callback != nil), we should only see + // a function when it has voluntarily preempted itself on entry + // during the stack growth check. In that case, the function has + // not yet had a chance to do any writes to SP and is safe to unwind. + // isAsyncSafePoint does not allow assembly functions to be async preempted, + // and preemptPark double-checks that SPWRITE functions are not async preempted. + // So for GC stack traversal we leave things alone (this if body does not execute for n == 0) + // at the bottom frame of the stack. But farther up the stack we'd better not + // find any. if callback != nil { - // Finding an SPWRITE should only happen for a profiling signal, which can - // arrive at any time. For a GC stack traversal (callback != nil), - // we shouldn't see this case, and we must be sure to walk the - // entire stack or the GC is invalid. So crash. println("traceback: unexpected SPWRITE function", funcname(f)) throw("traceback") } -- cgit v1.3-5-g9baa From 07ff596404b03a8e01ed53f1553c59eb215dc697 Mon Sep 17 00:00:00 2001 From: Jonathan Swinney Date: Sat, 17 Apr 2021 01:12:28 +0000 Subject: runtime/internal/atomic: add LSE atomics instructions to arm64 As a follow up to an earlier change[1] to add ARMv8+LSE instructions in the compiler generated atomic intrinsics, make the same change in the runtime library. Since not all ARMv8 systems support LSE instructions, they are protected by a feature-flag branch. [1]: golang.org/cl/234217 commit: ecc3f5112eba Change-Id: I0e2fb22e78d5eddb6547863667a8865946679a00 Reviewed-on: https://go-review.googlesource.com/c/go/+/310591 Reviewed-by: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Trust: Heschi Kreinick --- src/runtime/internal/atomic/atomic_arm64.go | 9 ++- src/runtime/internal/atomic/atomic_arm64.s | 93 ++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 17 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/internal/atomic/atomic_arm64.go b/src/runtime/internal/atomic/atomic_arm64.go index 131c687e1b..3c8736997f 100644 --- a/src/runtime/internal/atomic/atomic_arm64.go +++ b/src/runtime/internal/atomic/atomic_arm64.go @@ -7,7 +7,14 @@ package atomic -import "unsafe" +import ( + "unsafe" + "internal/cpu" +) + +const ( + offsetARM64HasATOMICS = unsafe.Offsetof(cpu.ARM64.HasATOMICS) +) //go:noescape func Xadd(ptr *uint32, delta int32) uint32 diff --git a/src/runtime/internal/atomic/atomic_arm64.s b/src/runtime/internal/atomic/atomic_arm64.s index 587e7f05e2..e9467afecd 100644 --- a/src/runtime/internal/atomic/atomic_arm64.s +++ b/src/runtime/internal/atomic/atomic_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#include "go_asm.h" #include "textflag.h" TEXT ·Casint32(SB), NOSPLIT, $0-17 @@ -127,10 +128,15 @@ TEXT ·Store64(SB), NOSPLIT, $0-16 TEXT ·Xchg(SB), NOSPLIT, $0-20 MOVD ptr+0(FP), R0 MOVW new+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + SWPALW R1, (R0), R2 + MOVW R2, ret+16(FP) + RET +load_store_loop: LDAXRW (R0), R2 STLXRW R1, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVW R2, ret+16(FP) RET @@ -142,10 +148,15 @@ again: TEXT ·Xchg64(SB), NOSPLIT, $0-24 MOVD ptr+0(FP), R0 MOVD new+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + SWPALD R1, (R0), R2 + MOVD R2, ret+16(FP) + RET +load_store_loop: LDAXR (R0), R2 STLXR R1, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVD R2, ret+16(FP) RET @@ -160,12 +171,20 @@ TEXT ·Cas(SB), NOSPLIT, $0-17 MOVD ptr+0(FP), R0 MOVW old+8(FP), R1 MOVW new+12(FP), R2 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MOVD R1, R3 + CASALW R3, (R0), R2 + CMP R1, R3 + CSET EQ, R0 + MOVB R0, ret+16(FP) + RET +load_store_loop: LDAXRW (R0), R3 CMPW R1, R3 BNE ok STLXRW R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop ok: CSET EQ, R0 MOVB R0, ret+16(FP) @@ -183,12 +202,20 @@ TEXT ·Cas64(SB), NOSPLIT, $0-25 MOVD ptr+0(FP), R0 MOVD old+8(FP), R1 MOVD new+16(FP), R2 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MOVD R1, R3 + CASALD R3, (R0), R2 + CMP R1, R3 + CSET EQ, R0 + MOVB R0, ret+24(FP) + RET +load_store_loop: LDAXR (R0), R3 CMP R1, R3 BNE ok STLXR R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop ok: CSET EQ, R0 MOVB R0, ret+24(FP) @@ -201,11 +228,17 @@ ok: TEXT ·Xadd(SB), NOSPLIT, $0-20 MOVD ptr+0(FP), R0 MOVW delta+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDADDALW R1, (R0), R2 + ADD R1, R2 + MOVW R2, ret+16(FP) + RET +load_store_loop: LDAXRW (R0), R2 ADDW R2, R1, R2 STLXRW R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVW R2, ret+16(FP) RET @@ -216,11 +249,17 @@ again: TEXT ·Xadd64(SB), NOSPLIT, $0-24 MOVD ptr+0(FP), R0 MOVD delta+8(FP), R1 -again: + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDADDALD R1, (R0), R2 + ADD R1, R2 + MOVD R2, ret+16(FP) + RET +load_store_loop: LDAXR (R0), R2 ADD R2, R1, R2 STLXR R2, (R0), R3 - CBNZ R3, again + CBNZ R3, load_store_loop MOVD R2, ret+16(FP) RET @@ -236,37 +275,59 @@ TEXT ·Xchguintptr(SB), NOSPLIT, $0-24 TEXT ·And8(SB), NOSPLIT, $0-9 MOVD ptr+0(FP), R0 MOVB val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MVN R1, R2 + LDCLRALB R2, (R0), R3 + RET +load_store_loop: LDAXRB (R0), R2 AND R1, R2 STLXRB R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET TEXT ·Or8(SB), NOSPLIT, $0-9 MOVD ptr+0(FP), R0 MOVB val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDORALB R1, (R0), R2 + RET +load_store_loop: LDAXRB (R0), R2 ORR R1, R2 STLXRB R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET // func And(addr *uint32, v uint32) TEXT ·And(SB), NOSPLIT, $0-12 MOVD ptr+0(FP), R0 MOVW val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + MVN R1, R2 + LDCLRALW R2, (R0), R3 + RET +load_store_loop: LDAXRW (R0), R2 AND R1, R2 STLXRW R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET // func Or(addr *uint32, v uint32) TEXT ·Or(SB), NOSPLIT, $0-12 MOVD ptr+0(FP), R0 MOVW val+8(FP), R1 + MOVBU internal∕cpu·ARM64+const_offsetARM64HasATOMICS(SB), R4 + CBZ R4, load_store_loop + LDORALW R1, (R0), R2 + RET +load_store_loop: LDAXRW (R0), R2 ORR R1, R2 STLXRW R2, (R0), R3 - CBNZ R3, -3(PC) + CBNZ R3, load_store_loop RET -- cgit v1.3-5-g9baa From 2c76a6f7f85365cefb5200b2b3408fd6bd421b3d Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 12 May 2021 17:55:42 +0200 Subject: all: add //go:build lines to assembly files Don't add them to files in vendor and cmd/vendor though. These will be pulled in by updating the respective dependencies. For #41184 Change-Id: Icc57458c9b3033c347124323f33084c85b224c70 Reviewed-on: https://go-review.googlesource.com/c/go/+/319389 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Russ Cox --- src/cmd/compile/internal/ssa/flags_amd64_test.s | 2 -- src/cmd/compile/internal/ssa/flags_arm64_test.s | 2 -- src/cmd/dist/vfp_arm.s | 3 ++- src/cmd/dist/vfp_default.s | 3 ++- src/crypto/cipher/xor_ppc64x.s | 1 + src/crypto/md5/md5block_ppc64x.s | 1 + src/crypto/x509/internal/macos/corefoundation.s | 1 + src/crypto/x509/internal/macos/security.s | 1 + src/internal/bytealg/compare_mips64x.s | 1 + src/internal/bytealg/compare_mipsx.s | 1 + src/internal/bytealg/compare_ppc64x.s | 1 + src/internal/bytealg/count_ppc64x.s | 1 + src/internal/bytealg/equal_mips64x.s | 1 + src/internal/bytealg/equal_mipsx.s | 1 + src/internal/bytealg/equal_ppc64x.s | 1 + src/internal/bytealg/index_ppc64x.s | 1 + src/internal/bytealg/indexbyte_mips64x.s | 1 + src/internal/bytealg/indexbyte_mipsx.s | 1 + src/internal/bytealg/indexbyte_ppc64x.s | 1 + src/internal/cpu/cpu_x86.s | 1 + src/math/big/arith_386.s | 1 + src/math/big/arith_amd64.s | 1 + src/math/big/arith_arm.s | 1 + src/math/big/arith_arm64.s | 1 + src/math/big/arith_mips64x.s | 4 +++- src/math/big/arith_mipsx.s | 4 +++- src/math/big/arith_ppc64x.s | 4 +++- src/math/big/arith_riscv64.s | 1 + src/math/big/arith_s390x.s | 3 ++- src/math/big/arith_wasm.s | 1 + src/math/floor_ppc64x.s | 1 + src/math/modf_ppc64x.s | 1 + src/math/sqrt_mipsx.s | 1 + src/math/sqrt_ppc64x.s | 1 + src/math/sqrt_riscv64.s | 2 -- src/reflect/asm_mips64x.s | 1 + src/reflect/asm_mipsx.s | 1 + src/reflect/asm_ppc64x.s | 1 + src/runtime/asm_mips64x.s | 1 + src/runtime/asm_mipsx.s | 1 + src/runtime/asm_ppc64x.s | 1 + src/runtime/atomic_mips64x.s | 1 + src/runtime/atomic_mipsx.s | 1 + src/runtime/atomic_ppc64x.s | 1 + src/runtime/cgo/asm_mips64x.s | 1 + src/runtime/cgo/asm_mipsx.s | 1 + src/runtime/cgo/asm_ppc64x.s | 1 + src/runtime/cgo/asm_riscv64.s | 2 -- src/runtime/duff_mips64x.s | 1 + src/runtime/duff_ppc64x.s | 1 + src/runtime/internal/atomic/atomic_mips64x.s | 1 + src/runtime/internal/atomic/atomic_mipsx.s | 1 + src/runtime/internal/atomic/atomic_ppc64x.s | 2 +- src/runtime/internal/atomic/sys_nonlinux_arm.s | 3 ++- src/runtime/libfuzzer_amd64.s | 1 + src/runtime/libfuzzer_arm64.s | 1 + src/runtime/memclr_386.s | 1 + src/runtime/memclr_amd64.s | 1 + src/runtime/memclr_mips64x.s | 1 + src/runtime/memclr_mipsx.s | 1 + src/runtime/memclr_ppc64x.s | 1 + src/runtime/memmove_386.s | 1 + src/runtime/memmove_amd64.s | 1 + src/runtime/memmove_mips64x.s | 1 + src/runtime/memmove_mipsx.s | 1 + src/runtime/memmove_ppc64x.s | 1 + src/runtime/mkduff.go | 2 ++ src/runtime/mkpreempt.go | 1 + src/runtime/msan_amd64.s | 1 + src/runtime/msan_arm64.s | 1 + src/runtime/preempt_mips64x.s | 1 + src/runtime/preempt_mipsx.s | 1 + src/runtime/preempt_ppc64x.s | 1 + src/runtime/race_amd64.s | 1 + src/runtime/race_arm64.s | 1 + src/runtime/race_ppc64le.s | 1 + src/runtime/rt0_linux_mips64x.s | 1 + src/runtime/rt0_linux_mipsx.s | 1 + src/runtime/sys_aix_ppc64.s | 3 --- src/runtime/sys_linux_mips64x.s | 1 + src/runtime/sys_linux_mipsx.s | 1 + src/runtime/sys_linux_ppc64x.s | 1 + src/runtime/tls_arm.s | 1 + src/runtime/tls_mips64x.s | 1 + src/runtime/tls_mipsx.s | 1 + src/runtime/tls_ppc64x.s | 1 + src/runtime/wincallback.go | 2 ++ src/runtime/zcallback_windows.s | 2 ++ src/sync/atomic/asm.s | 1 + src/sync/atomic/race.s | 1 + 90 files changed, 98 insertions(+), 19 deletions(-) (limited to 'src/runtime') diff --git a/src/cmd/compile/internal/ssa/flags_amd64_test.s b/src/cmd/compile/internal/ssa/flags_amd64_test.s index 8bd87019af..7402f6badb 100644 --- a/src/cmd/compile/internal/ssa/flags_amd64_test.s +++ b/src/cmd/compile/internal/ssa/flags_amd64_test.s @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 - #include "textflag.h" TEXT ·asmAddFlags(SB),NOSPLIT,$0-24 diff --git a/src/cmd/compile/internal/ssa/flags_arm64_test.s b/src/cmd/compile/internal/ssa/flags_arm64_test.s index f201bcc994..639d7e3aed 100644 --- a/src/cmd/compile/internal/ssa/flags_arm64_test.s +++ b/src/cmd/compile/internal/ssa/flags_arm64_test.s @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build arm64 - #include "textflag.h" TEXT ·asmAddFlags(SB),NOSPLIT,$0-24 diff --git a/src/cmd/dist/vfp_arm.s b/src/cmd/dist/vfp_arm.s index d571f8b82a..525ee9b366 100644 --- a/src/cmd/dist/vfp_arm.s +++ b/src/cmd/dist/vfp_arm.s @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build gc,arm +//go:build gc +// +build gc #include "textflag.h" diff --git a/src/cmd/dist/vfp_default.s b/src/cmd/dist/vfp_default.s index 84829beeff..0c1e16b0aa 100644 --- a/src/cmd/dist/vfp_default.s +++ b/src/cmd/dist/vfp_default.s @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !arm,gc +//go:build gc && !arm +// +build gc,!arm #include "textflag.h" diff --git a/src/crypto/cipher/xor_ppc64x.s b/src/crypto/cipher/xor_ppc64x.s index 4cef31d0ee..2ba6d9639c 100644 --- a/src/crypto/cipher/xor_ppc64x.s +++ b/src/crypto/cipher/xor_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/crypto/md5/md5block_ppc64x.s b/src/crypto/md5/md5block_ppc64x.s index e1f859e337..8c28ec2473 100644 --- a/src/crypto/md5/md5block_ppc64x.s +++ b/src/crypto/md5/md5block_ppc64x.s @@ -10,6 +10,7 @@ // Licence: I hereby disclaim the copyright on this code and place it // in the public domain. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/crypto/x509/internal/macos/corefoundation.s b/src/crypto/x509/internal/macos/corefoundation.s index a9efaa299d..cda2336c9d 100644 --- a/src/crypto/x509/internal/macos/corefoundation.s +++ b/src/crypto/x509/internal/macos/corefoundation.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && !ios // +build darwin,!ios #include "textflag.h" diff --git a/src/crypto/x509/internal/macos/security.s b/src/crypto/x509/internal/macos/security.s index 09ce5c6c76..0038f25b27 100644 --- a/src/crypto/x509/internal/macos/security.s +++ b/src/crypto/x509/internal/macos/security.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin && !ios // +build darwin,!ios #include "textflag.h" diff --git a/src/internal/bytealg/compare_mips64x.s b/src/internal/bytealg/compare_mips64x.s index 4f05fceaca..b472e510bc 100644 --- a/src/internal/bytealg/compare_mips64x.s +++ b/src/internal/bytealg/compare_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/internal/bytealg/compare_mipsx.s b/src/internal/bytealg/compare_mipsx.s index 9ac5ba5687..dcc4916e56 100644 --- a/src/internal/bytealg/compare_mipsx.s +++ b/src/internal/bytealg/compare_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/internal/bytealg/compare_ppc64x.s b/src/internal/bytealg/compare_ppc64x.s index 7819da31cd..83444fa826 100644 --- a/src/internal/bytealg/compare_ppc64x.s +++ b/src/internal/bytealg/compare_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/internal/bytealg/count_ppc64x.s b/src/internal/bytealg/count_ppc64x.s index a64d7d792d..94163cbd8a 100644 --- a/src/internal/bytealg/count_ppc64x.s +++ b/src/internal/bytealg/count_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64le || ppc64 // +build ppc64le ppc64 #include "go_asm.h" diff --git a/src/internal/bytealg/equal_mips64x.s b/src/internal/bytealg/equal_mips64x.s index 641e3ff06c..c2f7d3997e 100644 --- a/src/internal/bytealg/equal_mips64x.s +++ b/src/internal/bytealg/equal_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/internal/bytealg/equal_mipsx.s b/src/internal/bytealg/equal_mipsx.s index 1cabc70178..11e5549e45 100644 --- a/src/internal/bytealg/equal_mipsx.s +++ b/src/internal/bytealg/equal_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/internal/bytealg/equal_ppc64x.s b/src/internal/bytealg/equal_ppc64x.s index 18171eaedc..5f0fea521b 100644 --- a/src/internal/bytealg/equal_ppc64x.s +++ b/src/internal/bytealg/equal_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/internal/bytealg/index_ppc64x.s b/src/internal/bytealg/index_ppc64x.s index b7a1e2d7a2..3ed9442125 100644 --- a/src/internal/bytealg/index_ppc64x.s +++ b/src/internal/bytealg/index_ppc64x.s @@ -21,6 +21,7 @@ // work is still needed for a big endian // implementation on power9. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/internal/bytealg/indexbyte_mips64x.s b/src/internal/bytealg/indexbyte_mips64x.s index 6ebf0dee24..0f377f5a4c 100644 --- a/src/internal/bytealg/indexbyte_mips64x.s +++ b/src/internal/bytealg/indexbyte_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/internal/bytealg/indexbyte_mipsx.s b/src/internal/bytealg/indexbyte_mipsx.s index e44440b5f9..bed015bbd6 100644 --- a/src/internal/bytealg/indexbyte_mipsx.s +++ b/src/internal/bytealg/indexbyte_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/internal/bytealg/indexbyte_ppc64x.s b/src/internal/bytealg/indexbyte_ppc64x.s index 6e14e80af1..8e13c5a56e 100644 --- a/src/internal/bytealg/indexbyte_ppc64x.s +++ b/src/internal/bytealg/indexbyte_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/internal/cpu/cpu_x86.s b/src/internal/cpu/cpu_x86.s index 93c712d784..0df5da1cc7 100644 --- a/src/internal/cpu/cpu_x86.s +++ b/src/internal/cpu/cpu_x86.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build 386 || amd64 // +build 386 amd64 #include "textflag.h" diff --git a/src/math/big/arith_386.s b/src/math/big/arith_386.s index d0ea949fe6..acf2b06665 100644 --- a/src/math/big/arith_386.s +++ b/src/math/big/arith_386.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !math_big_pure_go // +build !math_big_pure_go #include "textflag.h" diff --git a/src/math/big/arith_amd64.s b/src/math/big/arith_amd64.s index 61043ca2d9..59be952200 100644 --- a/src/math/big/arith_amd64.s +++ b/src/math/big/arith_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !math_big_pure_go // +build !math_big_pure_go #include "textflag.h" diff --git a/src/math/big/arith_arm.s b/src/math/big/arith_arm.s index cbf7445e7a..f2872d80a1 100644 --- a/src/math/big/arith_arm.s +++ b/src/math/big/arith_arm.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !math_big_pure_go // +build !math_big_pure_go #include "textflag.h" diff --git a/src/math/big/arith_arm64.s b/src/math/big/arith_arm64.s index 22357d088e..7bfe08e7b7 100644 --- a/src/math/big/arith_arm64.s +++ b/src/math/big/arith_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !math_big_pure_go // +build !math_big_pure_go #include "textflag.h" diff --git a/src/math/big/arith_mips64x.s b/src/math/big/arith_mips64x.s index 804b9fe06e..4b5c502440 100644 --- a/src/math/big/arith_mips64x.s +++ b/src/math/big/arith_mips64x.s @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !math_big_pure_go,mips64 !math_big_pure_go,mips64le +//go:build !math_big_pure_go && (mips64 || mips64le) +// +build !math_big_pure_go +// +build mips64 mips64le #include "textflag.h" diff --git a/src/math/big/arith_mipsx.s b/src/math/big/arith_mipsx.s index efdecb80f3..e72e6d6377 100644 --- a/src/math/big/arith_mipsx.s +++ b/src/math/big/arith_mipsx.s @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !math_big_pure_go,mips !math_big_pure_go,mipsle +//go:build !math_big_pure_go && (mips || mipsle) +// +build !math_big_pure_go +// +build mips mipsle #include "textflag.h" diff --git a/src/math/big/arith_ppc64x.s b/src/math/big/arith_ppc64x.s index b299ccc2fb..68c6286494 100644 --- a/src/math/big/arith_ppc64x.s +++ b/src/math/big/arith_ppc64x.s @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !math_big_pure_go,ppc64 !math_big_pure_go,ppc64le +//go:build !math_big_pure_go && (ppc64 || ppc64le) +// +build !math_big_pure_go +// +build ppc64 ppc64le #include "textflag.h" diff --git a/src/math/big/arith_riscv64.s b/src/math/big/arith_riscv64.s index a2f7666c7b..2e950ddd0f 100644 --- a/src/math/big/arith_riscv64.s +++ b/src/math/big/arith_riscv64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !math_big_pure_go && riscv64 // +build !math_big_pure_go,riscv64 #include "textflag.h" diff --git a/src/math/big/arith_s390x.s b/src/math/big/arith_s390x.s index e96480699a..ad822f76b3 100644 --- a/src/math/big/arith_s390x.s +++ b/src/math/big/arith_s390x.s @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !math_big_pure_go,s390x +//go:build !math_big_pure_go +// +build !math_big_pure_go #include "textflag.h" diff --git a/src/math/big/arith_wasm.s b/src/math/big/arith_wasm.s index add1064469..e8605f1e15 100644 --- a/src/math/big/arith_wasm.s +++ b/src/math/big/arith_wasm.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !math_big_pure_go // +build !math_big_pure_go #include "textflag.h" diff --git a/src/math/floor_ppc64x.s b/src/math/floor_ppc64x.s index 29b92a62c3..584c27e28f 100644 --- a/src/math/floor_ppc64x.s +++ b/src/math/floor_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/math/modf_ppc64x.s b/src/math/modf_ppc64x.s index caa435eef9..1303067661 100644 --- a/src/math/modf_ppc64x.s +++ b/src/math/modf_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/math/sqrt_mipsx.s b/src/math/sqrt_mipsx.s index c619c19ec2..291d4af39c 100644 --- a/src/math/sqrt_mipsx.s +++ b/src/math/sqrt_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/math/sqrt_ppc64x.s b/src/math/sqrt_ppc64x.s index 174b63e35a..c929da2159 100644 --- a/src/math/sqrt_ppc64x.s +++ b/src/math/sqrt_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/math/sqrt_riscv64.s b/src/math/sqrt_riscv64.s index f223510c42..0dbdbc99ed 100644 --- a/src/math/sqrt_riscv64.s +++ b/src/math/sqrt_riscv64.s @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build riscv64 - #include "textflag.h" // func archSqrt(x float64) float64 diff --git a/src/reflect/asm_mips64x.s b/src/reflect/asm_mips64x.s index ae661262cb..8d01c5fb7e 100644 --- a/src/reflect/asm_mips64x.s +++ b/src/reflect/asm_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/reflect/asm_mipsx.s b/src/reflect/asm_mipsx.s index 47fef844a1..6ea8233108 100644 --- a/src/reflect/asm_mipsx.s +++ b/src/reflect/asm_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/reflect/asm_ppc64x.s b/src/reflect/asm_ppc64x.s index 010811c31a..d955e4110f 100644 --- a/src/reflect/asm_ppc64x.s +++ b/src/reflect/asm_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/asm_mips64x.s b/src/runtime/asm_mips64x.s index c3b57e472a..d4d2280105 100644 --- a/src/runtime/asm_mips64x.s +++ b/src/runtime/asm_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/asm_mipsx.s b/src/runtime/asm_mipsx.s index 1d828b03cf..ea7edf20cf 100644 --- a/src/runtime/asm_mipsx.s +++ b/src/runtime/asm_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s index 2c39b38912..942cc14f17 100644 --- a/src/runtime/asm_ppc64x.s +++ b/src/runtime/asm_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/runtime/atomic_mips64x.s b/src/runtime/atomic_mips64x.s index 6f42412502..e2118e6a20 100644 --- a/src/runtime/atomic_mips64x.s +++ b/src/runtime/atomic_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/atomic_mipsx.s b/src/runtime/atomic_mipsx.s index ed078a2d8a..1eacd273b4 100644 --- a/src/runtime/atomic_mipsx.s +++ b/src/runtime/atomic_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/atomic_ppc64x.s b/src/runtime/atomic_ppc64x.s index 57f672f330..b63de2dbd3 100644 --- a/src/runtime/atomic_ppc64x.s +++ b/src/runtime/atomic_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/cgo/asm_mips64x.s b/src/runtime/cgo/asm_mips64x.s index e51cdf3d12..ba948071fa 100644 --- a/src/runtime/cgo/asm_mips64x.s +++ b/src/runtime/cgo/asm_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/cgo/asm_mipsx.s b/src/runtime/cgo/asm_mipsx.s index 1127c8beb4..fd5d78ef97 100644 --- a/src/runtime/cgo/asm_mipsx.s +++ b/src/runtime/cgo/asm_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/cgo/asm_ppc64x.s b/src/runtime/cgo/asm_ppc64x.s index f4efc1e67d..9dec8d04ce 100644 --- a/src/runtime/cgo/asm_ppc64x.s +++ b/src/runtime/cgo/asm_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/cgo/asm_riscv64.s b/src/runtime/cgo/asm_riscv64.s index b4ddbb020f..fcd1d36ca8 100644 --- a/src/runtime/cgo/asm_riscv64.s +++ b/src/runtime/cgo/asm_riscv64.s @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build riscv64 - #include "textflag.h" // Called by C code generated by cmd/cgo. diff --git a/src/runtime/duff_mips64x.s b/src/runtime/duff_mips64x.s index c4e04ccc9d..a897d7fd9b 100644 --- a/src/runtime/duff_mips64x.s +++ b/src/runtime/duff_mips64x.s @@ -2,6 +2,7 @@ // Run go generate from src/runtime to update. // See mkduff.go for comments. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/duff_ppc64x.s b/src/runtime/duff_ppc64x.s index d6b89ba940..d4e3b409d2 100644 --- a/src/runtime/duff_ppc64x.s +++ b/src/runtime/duff_ppc64x.s @@ -2,6 +2,7 @@ // Run go generate from src/runtime to update. // See mkduff.go for comments. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/internal/atomic/atomic_mips64x.s b/src/runtime/internal/atomic/atomic_mips64x.s index 2751c6f808..fba668f94a 100644 --- a/src/runtime/internal/atomic/atomic_mips64x.s +++ b/src/runtime/internal/atomic/atomic_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/internal/atomic/atomic_mipsx.s b/src/runtime/internal/atomic/atomic_mipsx.s index 3f61321450..c0835d66ed 100644 --- a/src/runtime/internal/atomic/atomic_mipsx.s +++ b/src/runtime/internal/atomic/atomic_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/internal/atomic/atomic_ppc64x.s b/src/runtime/internal/atomic/atomic_ppc64x.s index 37c8515d37..dca26cb334 100644 --- a/src/runtime/internal/atomic/atomic_ppc64x.s +++ b/src/runtime/internal/atomic/atomic_ppc64x.s @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" - // For more details about how various memory models are // enforced on POWER, the following paper provides more // details about how they enforce C/C++ like models. This diff --git a/src/runtime/internal/atomic/sys_nonlinux_arm.s b/src/runtime/internal/atomic/sys_nonlinux_arm.s index 57568b2238..04036ca970 100644 --- a/src/runtime/internal/atomic/sys_nonlinux_arm.s +++ b/src/runtime/internal/atomic/sys_nonlinux_arm.s @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !linux,arm +//go:build !linux +// +build !linux #include "textflag.h" diff --git a/src/runtime/libfuzzer_amd64.s b/src/runtime/libfuzzer_amd64.s index 890fde341b..13645fc7af 100644 --- a/src/runtime/libfuzzer_amd64.s +++ b/src/runtime/libfuzzer_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build libfuzzer // +build libfuzzer #include "go_asm.h" diff --git a/src/runtime/libfuzzer_arm64.s b/src/runtime/libfuzzer_arm64.s index 121673e092..4ad8242804 100644 --- a/src/runtime/libfuzzer_arm64.s +++ b/src/runtime/libfuzzer_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build libfuzzer // +build libfuzzer #include "go_asm.h" diff --git a/src/runtime/memclr_386.s b/src/runtime/memclr_386.s index d2ef17f7ce..046c344119 100644 --- a/src/runtime/memclr_386.s +++ b/src/runtime/memclr_386.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memclr_amd64.s b/src/runtime/memclr_amd64.s index 5d2bebb901..a10f57bd8c 100644 --- a/src/runtime/memclr_amd64.s +++ b/src/runtime/memclr_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memclr_mips64x.s b/src/runtime/memclr_mips64x.s index d7a3251e20..bc037013fe 100644 --- a/src/runtime/memclr_mips64x.s +++ b/src/runtime/memclr_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/memclr_mipsx.s b/src/runtime/memclr_mipsx.s index eb2a8a7219..3d21c3c414 100644 --- a/src/runtime/memclr_mipsx.s +++ b/src/runtime/memclr_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/memclr_ppc64x.s b/src/runtime/memclr_ppc64x.s index 7512620894..65639322b2 100644 --- a/src/runtime/memclr_ppc64x.s +++ b/src/runtime/memclr_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/memmove_386.s b/src/runtime/memmove_386.s index d99546c633..1a43a1f724 100644 --- a/src/runtime/memmove_386.s +++ b/src/runtime/memmove_386.s @@ -23,6 +23,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memmove_amd64.s b/src/runtime/memmove_amd64.s index f1e3403596..24c6529f58 100644 --- a/src/runtime/memmove_amd64.s +++ b/src/runtime/memmove_amd64.s @@ -23,6 +23,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +//go:build !plan9 // +build !plan9 #include "go_asm.h" diff --git a/src/runtime/memmove_mips64x.s b/src/runtime/memmove_mips64x.s index 8a1b88afba..fef3c6be82 100644 --- a/src/runtime/memmove_mips64x.s +++ b/src/runtime/memmove_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "textflag.h" diff --git a/src/runtime/memmove_mipsx.s b/src/runtime/memmove_mipsx.s index 6c86558f8d..cd02fc25c4 100644 --- a/src/runtime/memmove_mipsx.s +++ b/src/runtime/memmove_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "textflag.h" diff --git a/src/runtime/memmove_ppc64x.s b/src/runtime/memmove_ppc64x.s index dbd835506f..fd16ad8129 100644 --- a/src/runtime/memmove_ppc64x.s +++ b/src/runtime/memmove_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "textflag.h" diff --git a/src/runtime/mkduff.go b/src/runtime/mkduff.go index 8632fe08a3..da191cc594 100644 --- a/src/runtime/mkduff.go +++ b/src/runtime/mkduff.go @@ -179,6 +179,7 @@ func copyARM64(w io.Writer) { func tagsPPC64x(w io.Writer) { fmt.Fprintln(w) + fmt.Fprintln(w, "//go:build ppc64 || ppc64le") fmt.Fprintln(w, "// +build ppc64 ppc64le") fmt.Fprintln(w) } @@ -202,6 +203,7 @@ func copyPPC64x(w io.Writer) { func tagsMIPS64x(w io.Writer) { fmt.Fprintln(w) + fmt.Fprintln(w, "//go:build mips64 || mips64le") fmt.Fprintln(w, "// +build mips64 mips64le") fmt.Fprintln(w) } diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go index 3a9e6cc478..6c980540f5 100644 --- a/src/runtime/mkpreempt.go +++ b/src/runtime/mkpreempt.go @@ -123,6 +123,7 @@ func header(arch string) { fmt.Fprintf(out, "// Code generated by mkpreempt.go; DO NOT EDIT.\n\n") if beLe[arch] { base := arch[:len(arch)-1] + fmt.Fprintf(out, "//go:build %s || %sle\n", base, base) fmt.Fprintf(out, "// +build %s %sle\n\n", base, base) } fmt.Fprintf(out, "#include \"go_asm.h\"\n") diff --git a/src/runtime/msan_amd64.s b/src/runtime/msan_amd64.s index 669e9ca73f..1bb57a3b7e 100644 --- a/src/runtime/msan_amd64.s +++ b/src/runtime/msan_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build msan // +build msan #include "go_asm.h" diff --git a/src/runtime/msan_arm64.s b/src/runtime/msan_arm64.s index f19906cfc8..93ade8dd89 100644 --- a/src/runtime/msan_arm64.s +++ b/src/runtime/msan_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build msan // +build msan #include "go_asm.h" diff --git a/src/runtime/preempt_mips64x.s b/src/runtime/preempt_mips64x.s index 0d0c157c36..b755425bc5 100644 --- a/src/runtime/preempt_mips64x.s +++ b/src/runtime/preempt_mips64x.s @@ -1,5 +1,6 @@ // Code generated by mkpreempt.go; DO NOT EDIT. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/preempt_mipsx.s b/src/runtime/preempt_mipsx.s index 86d3a918d3..c1bff60859 100644 --- a/src/runtime/preempt_mipsx.s +++ b/src/runtime/preempt_mipsx.s @@ -1,5 +1,6 @@ // Code generated by mkpreempt.go; DO NOT EDIT. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/runtime/preempt_ppc64x.s b/src/runtime/preempt_ppc64x.s index 90634386db..70bd91982b 100644 --- a/src/runtime/preempt_ppc64x.s +++ b/src/runtime/preempt_ppc64x.s @@ -1,5 +1,6 @@ // Code generated by mkpreempt.go; DO NOT EDIT. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/runtime/race_amd64.s b/src/runtime/race_amd64.s index 58a919efe8..8d4813eadd 100644 --- a/src/runtime/race_amd64.s +++ b/src/runtime/race_amd64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race #include "go_asm.h" diff --git a/src/runtime/race_arm64.s b/src/runtime/race_arm64.s index 82e3caadc8..c6d5b91edc 100644 --- a/src/runtime/race_arm64.s +++ b/src/runtime/race_arm64.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race #include "go_asm.h" diff --git a/src/runtime/race_ppc64le.s b/src/runtime/race_ppc64le.s index 069e4d86dd..963e57099c 100644 --- a/src/runtime/race_ppc64le.s +++ b/src/runtime/race_ppc64le.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race #include "go_asm.h" diff --git a/src/runtime/rt0_linux_mips64x.s b/src/runtime/rt0_linux_mips64x.s index 55506755df..fabd8570b5 100644 --- a/src/runtime/rt0_linux_mips64x.s +++ b/src/runtime/rt0_linux_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips64 || mips64le) // +build linux // +build mips64 mips64le diff --git a/src/runtime/rt0_linux_mipsx.s b/src/runtime/rt0_linux_mipsx.s index 74b8f50b73..9f5842b51a 100644 --- a/src/runtime/rt0_linux_mipsx.s +++ b/src/runtime/rt0_linux_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips || mipsle) // +build linux // +build mips mipsle diff --git a/src/runtime/sys_aix_ppc64.s b/src/runtime/sys_aix_ppc64.s index a56d043f42..c171c191c0 100644 --- a/src/runtime/sys_aix_ppc64.s +++ b/src/runtime/sys_aix_ppc64.s @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix -// +build ppc64 ppc64le - // // System calls and other sys.stuff for ppc64, Aix // diff --git a/src/runtime/sys_linux_mips64x.s b/src/runtime/sys_linux_mips64x.s index 0206cb88bd..e18d291445 100644 --- a/src/runtime/sys_linux_mips64x.s +++ b/src/runtime/sys_linux_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips64 || mips64le) // +build linux // +build mips64 mips64le diff --git a/src/runtime/sys_linux_mipsx.s b/src/runtime/sys_linux_mipsx.s index d5317d3957..b3970be9cf 100644 --- a/src/runtime/sys_linux_mipsx.s +++ b/src/runtime/sys_linux_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (mips || mipsle) // +build linux // +build mips mipsle diff --git a/src/runtime/sys_linux_ppc64x.s b/src/runtime/sys_linux_ppc64x.s index 46387288d5..05b5916db4 100644 --- a/src/runtime/sys_linux_ppc64x.s +++ b/src/runtime/sys_linux_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && (ppc64 || ppc64le) // +build linux // +build ppc64 ppc64le diff --git a/src/runtime/tls_arm.s b/src/runtime/tls_arm.s index e42de8deb4..879caac9e1 100644 --- a/src/runtime/tls_arm.s +++ b/src/runtime/tls_arm.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows #include "go_asm.h" diff --git a/src/runtime/tls_mips64x.s b/src/runtime/tls_mips64x.s index 888c0efec6..779d64ba31 100644 --- a/src/runtime/tls_mips64x.s +++ b/src/runtime/tls_mips64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips64 || mips64le // +build mips64 mips64le #include "go_asm.h" diff --git a/src/runtime/tls_mipsx.s b/src/runtime/tls_mipsx.s index d2ffcd954c..ada8d06a9e 100644 --- a/src/runtime/tls_mipsx.s +++ b/src/runtime/tls_mipsx.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build mips || mipsle // +build mips mipsle #include "go_asm.h" diff --git a/src/runtime/tls_ppc64x.s b/src/runtime/tls_ppc64x.s index 25d796fcc6..7e935d0eb2 100644 --- a/src/runtime/tls_ppc64x.s +++ b/src/runtime/tls_ppc64x.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ppc64 || ppc64le // +build ppc64 ppc64le #include "go_asm.h" diff --git a/src/runtime/wincallback.go b/src/runtime/wincallback.go index 8411c98412..a7a787d8f6 100644 --- a/src/runtime/wincallback.go +++ b/src/runtime/wincallback.go @@ -22,7 +22,9 @@ func genasm386Amd64() { buf.WriteString(`// Code generated by wincallback.go using 'go generate'. DO NOT EDIT. +//go:build 386 || amd64 // +build 386 amd64 + // runtime·callbackasm is called by external code to // execute Go implemented callback function. It is not // called from the start, instead runtime·compilecallback diff --git a/src/runtime/zcallback_windows.s b/src/runtime/zcallback_windows.s index 37ffb38aca..e451c2b9d0 100644 --- a/src/runtime/zcallback_windows.s +++ b/src/runtime/zcallback_windows.s @@ -1,6 +1,8 @@ // Code generated by wincallback.go using 'go generate'. DO NOT EDIT. +//go:build 386 || amd64 // +build 386 amd64 + // runtime·callbackasm is called by external code to // execute Go implemented callback function. It is not // called from the start, instead runtime·compilecallback diff --git a/src/sync/atomic/asm.s b/src/sync/atomic/asm.s index f86726f3a1..7b8c9b9430 100644 --- a/src/sync/atomic/asm.s +++ b/src/sync/atomic/asm.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !race // +build !race #include "textflag.h" diff --git a/src/sync/atomic/race.s b/src/sync/atomic/race.s index fd6ca22700..0866487cc7 100644 --- a/src/sync/atomic/race.s +++ b/src/sync/atomic/race.s @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race // This file is here only to allow external functions. -- cgit v1.3-5-g9baa From 02699f810a05215060ba2181f394d551819ad7d4 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Thu, 13 May 2021 18:19:42 -0400 Subject: runtime: mark osyield nosplit on OpenBSD osyield is called in code paths that are not allowed to split stack, e.g. casgstatus called from entersyscall/exitsyscall. It is nosplit on all other platforms. Mark it nosplit on OpenBSD as well. Change-Id: I3fed5d7f58b3d50610beca6eed2c7e902b8ec52c Reviewed-on: https://go-review.googlesource.com/c/go/+/319969 Trust: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Go Bot Reviewed-by: Joel Sing --- src/runtime/sys_openbsd1.go | 1 + 1 file changed, 1 insertion(+) (limited to 'src/runtime') diff --git a/src/runtime/sys_openbsd1.go b/src/runtime/sys_openbsd1.go index 6f9ad356d4..cb5d35879c 100644 --- a/src/runtime/sys_openbsd1.go +++ b/src/runtime/sys_openbsd1.go @@ -23,6 +23,7 @@ func thrwakeup(ident uintptr, n int32) int32 { } func thrwakeup_trampoline() +//go:nosplit func osyield() { libcCall(unsafe.Pointer(funcPC(sched_yield_trampoline)), unsafe.Pointer(nil)) } -- cgit v1.3-5-g9baa From bade680867c9b1eecc7b5d177ed94c455a72e50a Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Wed, 12 May 2021 12:11:03 -0500 Subject: runtime/cgo: fix crosscall2 on ppc64x Some uses of crosscall2 did not work on ppc64le and probably aix-ppc64. In particular, if there was a main program compiled with -buildmode=pie and used a plugin which invoked crosscall2, then failures could occur due to R2 getting set incorrectly along the way. The problem was due to R2 being saved on the caller's stack; it is now saved on the crosscall2 stack. More details can be found in the issue. This adds a testcase where the main program is built with pie and the plugin invokes crosscall2. This also changes the save of the CR bits from MOVD to MOVW as it should be. Fixes #43228 Change-Id: Ib5673e25a2ec5ee46bf9a1ffb0cb1f3ef5449086 Reviewed-on: https://go-review.googlesource.com/c/go/+/319489 Run-TryBot: Lynn Boger Reviewed-by: Cherry Mui Trust: Heschi Kreinick --- misc/cgo/testplugin/plugin_test.go | 7 +++++++ src/runtime/cgo/asm_ppc64x.s | 12 ++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/runtime') diff --git a/misc/cgo/testplugin/plugin_test.go b/misc/cgo/testplugin/plugin_test.go index 28a8c669c0..a6accc1dfb 100644 --- a/misc/cgo/testplugin/plugin_test.go +++ b/misc/cgo/testplugin/plugin_test.go @@ -263,6 +263,13 @@ func TestIssue25756(t *testing.T) { } } +// Test with main using -buildmode=pie with plugin for issue #43228 +func TestIssue25756pie(t *testing.T) { + goCmd(t, "build", "-buildmode=plugin", "-o", "life.so", "./issue25756/plugin") + goCmd(t, "build", "-buildmode=pie", "-o", "issue25756pie.exe", "./issue25756/main.go") + run(t, "./issue25756pie.exe") +} + func TestMethod(t *testing.T) { // Exported symbol's method must be live. goCmd(t, "build", "-buildmode=plugin", "-o", "plugin.so", "./method/plugin.go") diff --git a/src/runtime/cgo/asm_ppc64x.s b/src/runtime/cgo/asm_ppc64x.s index 9dec8d04ce..187b2d42f6 100644 --- a/src/runtime/cgo/asm_ppc64x.s +++ b/src/runtime/cgo/asm_ppc64x.s @@ -12,17 +12,20 @@ // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr) // Saves C callee-saved registers and calls cgocallback with three arguments. // fn is the PC of a func(a unsafe.Pointer) function. +// The value of R2 is saved on the new stack frame, and not +// the caller's frame due to issue #43228. TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 // Start with standard C stack frame layout and linkage MOVD LR, R0 MOVD R0, 16(R1) // Save LR in caller's frame MOVW CR, R0 // Save CR in caller's frame - MOVD R0, 8(R1) - MOVD R2, 24(R1) // Save TOC in caller's frame + MOVW R0, 8(R1) BL saveregs2<>(SB) MOVDU R1, (-288-3*8-FIXED_FRAME)(R1) + // Save the caller's R2 + MOVD R2, 24(R1) // Initialize Go ABI environment BL runtime·reginit(SB) @@ -41,12 +44,13 @@ TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0 MOVD R6, FIXED_FRAME+16(R1) // ctxt uintptr BL runtime·cgocallback(SB) + // Restore the caller's R2 + MOVD 24(R1), R2 ADD $(288+3*8+FIXED_FRAME), R1 BL restoreregs2<>(SB) - MOVD 24(R1), R2 - MOVD 8(R1), R0 + MOVW 8(R1), R0 MOVFL R0, $0xff MOVD 16(R1), R0 MOVD R0, LR -- cgit v1.3-5-g9baa