From 592bf0955345d92d8e48d1671fa8a03d1a5209f9 Mon Sep 17 00:00:00 2001 From: Grooooot Date: Mon, 6 Jan 2020 10:20:38 +0800 Subject: [PATCH 1/2] golang: modification of spec Signed-off-by: Grooooot --- ...ndled-tzdata-at-runtime-except-for-t.patch | 88 ------------------- golang-gdbinit | 1 - golang.spec | 3 +- 3 files changed, 1 insertion(+), 91 deletions(-) delete mode 100644 0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch delete mode 100644 golang-gdbinit diff --git a/0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch b/0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch deleted file mode 100644 index 422ca2b..0000000 --- a/0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch +++ /dev/null @@ -1,88 +0,0 @@ -From edce31a2904846ae74e3c011f2cf5fddc963459e Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jakub=20=C4=8Cajka?= -Date: Thu, 22 Mar 2018 12:07:32 +0100 -Subject: [PATCH 1/3] Don't use the bundled tzdata at runtime, except for the - internal test suite - ---- - src/time/internal_test.go | 7 +++++-- - src/time/zoneinfo_test.go | 3 ++- - src/time/zoneinfo_unix.go | 2 -- - 3 files changed, 7 insertions(+), 5 deletions(-) - -diff --git a/src/time/internal_test.go b/src/time/internal_test.go -index 76d5524124..e81ace5f64 100644 ---- a/src/time/internal_test.go -+++ b/src/time/internal_test.go -@@ -4,13 +4,15 @@ - - package time - -+import "runtime" -+ - func init() { - // force US/Pacific for time zone tests - ForceUSPacificForTesting() - } - - func initTestingZone() { -- z, err := loadLocation("America/Los_Angeles", zoneSources[len(zoneSources)-1:]) -+ z, err := loadLocation("America/Los_Angeles", zoneSources) - if err != nil { - panic("cannot load America/Los_Angeles for testing: " + err.Error()) - } -@@ -21,8 +23,9 @@ func initTestingZone() { - var OrigZoneSources = zoneSources - - func forceZipFileForTesting(zipOnly bool) { -- zoneSources = make([]string, len(OrigZoneSources)) -+ zoneSources = make([]string, len(OrigZoneSources)+1) - copy(zoneSources, OrigZoneSources) -+ zoneSources = append(zoneSources, runtime.GOROOT()+"/lib/time/zoneinfo.zip") - if zipOnly { - zoneSources = zoneSources[len(zoneSources)-1:] - } -diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go -index 7a55d4f618..6063ca1195 100644 ---- a/src/time/zoneinfo_test.go -+++ b/src/time/zoneinfo_test.go -@@ -8,6 +8,7 @@ import ( - "fmt" - "os" - "reflect" -+ "runtime" - "testing" - "time" - ) -@@ -128,7 +129,7 @@ func TestLoadLocationFromTZData(t *testing.T) { - t.Fatal(err) - } - -- tzinfo, err := time.LoadTzinfo(locationName, time.OrigZoneSources[len(time.OrigZoneSources)-1]) -+ tzinfo, err := time.LoadTzinfo(locationName, runtime.GOROOT()+"/lib/time/zoneinfo.zip") - if err != nil { - t.Fatal(err) - } -diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go -index 88313aa0ed..d9596115ef 100644 ---- a/src/time/zoneinfo_unix.go -+++ b/src/time/zoneinfo_unix.go -@@ -12,7 +12,6 @@ - package time - - import ( -- "runtime" - "syscall" - ) - -@@ -22,7 +21,6 @@ var zoneSources = []string{ - "/usr/share/zoneinfo/", - "/usr/share/lib/zoneinfo/", - "/usr/lib/locale/TZ/", -- runtime.GOROOT() + "/lib/time/zoneinfo.zip", - } - - func initLocal() { --- -2.14.3 - diff --git a/golang-gdbinit b/golang-gdbinit deleted file mode 100644 index ecddca6..0000000 --- a/golang-gdbinit +++ /dev/null @@ -1 +0,0 @@ -add-auto-load-safe-path /usr/lib/golang/src/runtime/runtime-gdb.py diff --git a/golang.spec b/golang.spec index ce03886..401a94e 100644 --- a/golang.spec +++ b/golang.spec @@ -62,7 +62,7 @@ Name: golang Version: 1.13 -Release: 3.1 +Release: 3.2 Summary: The Go Programming Language License: BSD and Public Domain URL: http://golang.org/ @@ -150,7 +150,6 @@ Obsoletes: %{name}-vim < 1.4 Obsoletes: emacs-%{name} < 1.4 Requires: openEuler-rpm-config -Patch6001: 0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch Patch6002: 0002-syscall-expose-IfInfomsg.X__ifi_pad-on-s390x.patch Patch6003: 0003-golang-delete-pem-files.patch Patch6004: 0004-syscall-implement-rawVforkSyscall-for-linux-arm64.patch -- Gitee From 8b0d15042169953347221d5835029a50bef09bd3 Mon Sep 17 00:00:00 2001 From: Grooooot Date: Wed, 8 Jan 2020 15:04:53 +0800 Subject: [PATCH 2/2] runtime: use innermost frame's func name for async preemption check We don't asynchronously preempt if we are in the runtime. We do this by checking the function name. However, it failed to take inlining into account. If a runtime function gets inlined into a non-runtime function, it can be preempted, and bad things can happen. One instance of this is dounlockOSThread inlined into UnlockOSThread which is in turn inlined into a non-runtime function. Fix this by using the innermost frame's function name. Change-Id: Ifa036ce1320700aaaefd829b4bee0d04d05c395d Reviewed-on: https://go-review.googlesource.com/c/go/+/211978 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Austin Clements Signed-off-by: Grooooot --- ...o1.13-runtime-ensure-memmove-write-p.patch | 117 ++++++++++++++++++ golang.spec | 1 + 2 files changed, 118 insertions(+) create mode 100644 0012-release-branch.go1.13-runtime-ensure-memmove-write-p.patch diff --git a/0012-release-branch.go1.13-runtime-ensure-memmove-write-p.patch b/0012-release-branch.go1.13-runtime-ensure-memmove-write-p.patch new file mode 100644 index 0000000..2ef2331 --- /dev/null +++ b/0012-release-branch.go1.13-runtime-ensure-memmove-write-p.patch @@ -0,0 +1,117 @@ +From f1887468d1ae9781407f24a2b121ed34a6dfec4c Mon Sep 17 00:00:00 2001 +From: Cherry Zhang +Date: Fri, 27 Dec 2019 12:02:00 -0500 +Subject: [PATCH] [release-branch.go1.13] runtime: ensure memmove write pointer atomically on ARM64 + +If a pointer write is not atomic, if the GC is running +concurrently, it may observe a partially updated pointer, which +may point to unallocated or already dead memory. Most pointer +writes, like the store instructions generated by the compiler, +are already atomic. But we still need to be careful in places +like memmove. In memmove, we don't know which bits are pointers +(or too expensive to query), so we ensure that all aligned +pointer-sized units are written atomically. + +Fixes #36361. +Updates #36101. + +Change-Id: I1b3ca24c6b1ac8a8aaf9ee470115e9a89ec1b00b +Reviewed-on: https://go-review.googlesource.com/c/go/+/212626 +Reviewed-by: Austin Clements +(cherry picked from commit ffbc02761abb47106ce88e09290a31513b5f6c8a) +--- + +diff --git a/src/runtime/memmove_arm64.s b/src/runtime/memmove_arm64.s +index ac29f94..cedb018 100644 +--- a/src/runtime/memmove_arm64.s ++++ b/src/runtime/memmove_arm64.s +@@ -22,7 +22,7 @@ + CMP R3, R4 + BLT backward + +- // Copying forward proceeds by copying R7/8 words then copying R6 bytes. ++ // Copying forward proceeds by copying R7/32 quadwords then R6 <= 31 tail bytes. + // R3 and R4 are advanced as we copy. + + // (There may be implementations of armv8 where copying by bytes until +@@ -30,11 +30,12 @@ + // optimization, but the on the one tested so far (xgene) it did not + // make a significance difference.) + +- CBZ R7, noforwardlarge // Do we need to do any doubleword-by-doubleword copying? ++ CBZ R7, noforwardlarge // Do we need to do any quadword copying? + + ADD R3, R7, R9 // R9 points just past where we copy by word + + forwardlargeloop: ++ // Copy 32 bytes at a time. + LDP.P 32(R4), (R8, R10) + STP.P (R8, R10), 32(R3) + LDP -16(R4), (R11, R12) +@@ -43,10 +44,26 @@ + CBNZ R7, forwardlargeloop + + noforwardlarge: +- CBNZ R6, forwardtail // Do we need to do any byte-by-byte copying? ++ CBNZ R6, forwardtail // Do we need to copy any tail bytes? + RET + + forwardtail: ++ // There are R6 <= 31 bytes remaining to copy. ++ // This is large enough to still contain pointers, ++ // which must be copied atomically. ++ // Copy the next 16 bytes, then 8 bytes, then any remaining bytes. ++ TBZ $4, R6, 3(PC) // write 16 bytes if R6&16 != 0 ++ LDP.P 16(R4), (R8, R10) ++ STP.P (R8, R10), 16(R3) ++ ++ TBZ $3, R6, 3(PC) // write 8 bytes if R6&8 != 0 ++ MOVD.P 8(R4), R8 ++ MOVD.P R8, 8(R3) ++ ++ AND $7, R6 ++ CBNZ R6, 2(PC) ++ RET ++ + ADD R3, R6, R9 // R9 points just past the destination memory + + forwardtailloop: +@@ -90,7 +107,7 @@ + RET + + backward: +- // Copying backwards proceeds by copying R6 bytes then copying R7/8 words. ++ // Copying backwards first copies R6 <= 31 tail bytes, then R7/32 quadwords. + // R3 and R4 are advanced to the end of the destination/source buffers + // respectively and moved back as we copy. + +@@ -99,13 +116,28 @@ + + CBZ R6, nobackwardtail // Do we need to do any byte-by-byte copying? + +- SUB R6, R3, R9 // R9 points at the lowest destination byte that should be copied by byte. ++ AND $7, R6, R12 ++ CBZ R12, backwardtaillarge ++ ++ SUB R12, R3, R9 // R9 points at the lowest destination byte that should be copied by byte. + backwardtailloop: ++ // Copy sub-pointer-size tail. + MOVBU.W -1(R4), R8 + MOVBU.W R8, -1(R3) + CMP R9, R3 + BNE backwardtailloop + ++backwardtaillarge: ++ // Do 8/16-byte write if possible. ++ // See comment at forwardtail. ++ TBZ $3, R6, 3(PC) ++ MOVD.W -8(R4), R8 ++ MOVD.W R8, -8(R3) ++ ++ TBZ $4, R6, 3(PC) ++ LDP.W -16(R4), (R8, R10) ++ STP.W (R8, R10), -16(R3) ++ + nobackwardtail: + CBNZ R7, backwardlarge // Do we need to do any doubleword-by-doubleword copying? + RET diff --git a/golang.spec b/golang.spec index 401a94e..90d012e 100644 --- a/golang.spec +++ b/golang.spec @@ -160,6 +160,7 @@ Patch6008: 0008-runtime-don-t-save-G-during-VDSO-if-we-re-handling-s.patch Patch6009: 0009-release-branch.go1.13-net-http-don-t-cache-http2.err.patch Patch6010: 0010-release-branch.go1.13-net-http-fix-Server.ConnContex.patch Patch6011: 0011-release-branch.go1.13-runtime-fix-textOff-for-multip.patch +Patch6012: 0012-release-branch.go1.13-runtime-ensure-memmove-write-p.patch ExclusiveArch: %{golang_arches} -- Gitee