runtime: save/fetch g register during VDSO on linux/loong64

Like arm64, ppc64 and risv64, on loong64, the G register may be temporarily
broken during a VDSO call. If a signal is received during a VDSO call, an
invalid G may be obtained.

See #34391.

Change-Id: Iaffa8cce4f0ef8ef74225c355ec3c20ed238025f
Reviewed-on: https://go-review.googlesource.com/c/go/+/426355
Reviewed-by: WANG Xuerui <git@xen0n.name>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Guoqi Chen 2023-03-29 05:10:45 +08:00 committed by Gopher Robot
parent 1b630b5b00
commit 42023d6f52
2 changed files with 41 additions and 5 deletions

View file

@ -397,7 +397,7 @@ func preemptM(mp *m) {
//go:nosplit
func sigFetchG(c *sigctxt) *g {
switch GOARCH {
case "arm", "arm64", "ppc64", "ppc64le", "riscv64", "s390x":
case "arm", "arm64", "loong64", "ppc64", "ppc64le", "riscv64", "s390x":
if !iscgo && inVDSOPage(c.sigpc()) {
// When using cgo, we save the g on TLS and load it from there
// in sigtramp. Just use that.