]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add crash stack support for s390x
authorMauri de Souza Meneguzzo <mauri870@gmail.com>
Sat, 2 Dec 2023 15:04:52 +0000 (15:04 +0000)
committerJoel Sing <joel@sing.id.au>
Thu, 25 Jan 2024 09:18:28 +0000 (09:18 +0000)
Change-Id: Ie923f7bbe5ef22e381ae4f421387fbd570622a28
GitHub-Last-Rev: f8f21635025eb6e26c6994679995ade501e870cf
GitHub-Pull-Request: golang/go#63908
Reviewed-on: https://go-review.googlesource.com/c/go/+/539296
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
src/runtime/asm.s
src/runtime/asm_s390x.s
src/runtime/proc.go

index 24cd0c95db64ad21bdd4298c4fcdc428e60da954..74ae8789abc92245e69670583d8d5b0fc669e2a4 100644 (file)
@@ -20,6 +20,7 @@ TEXT ·mapinitnoop<ABIInternal>(SB),NOSPLIT,$0-0
 #ifndef GOARCH_ppc64
 #ifndef GOARCH_ppc64le
 #ifndef GOARCH_riscv64
+#ifndef GOARCH_s390x
 #ifndef GOARCH_wasm
 // stub to appease shared build mode.
 TEXT ·switchToCrashStack0<ABIInternal>(SB),NOSPLIT,$0-0
@@ -32,3 +33,4 @@ TEXT ·switchToCrashStack0<ABIInternal>(SB),NOSPLIT,$0-0
 #endif
 #endif
 #endif
+#endif
index a8e1424bf1813ded69495643380b2fb0c740ae3c..f2354a6d53614a8b0e1713923ea81079218fed66 100644 (file)
@@ -292,6 +292,29 @@ noswitch:
        ADD     $8, R15
        BR      (R3)
 
+// func switchToCrashStack0(fn func())
+TEXT runtime·switchToCrashStack0<ABIInternal>(SB), NOSPLIT, $0-8
+       MOVD    fn+0(FP), R12   // context
+       MOVD    g_m(g), R4      // curm
+
+       // set g to gcrash
+       MOVD    $runtime·gcrash(SB), g // g = &gcrash
+       BL      runtime·save_g(SB)
+       MOVD    R4, g_m(g)      // g.m = curm
+       MOVD    g, m_g0(R4)     // curm.g0 = g
+
+       // switch to crashstack
+       MOVD    (g_stack+stack_hi)(g), R4
+       ADD     $(-4*8), R4, R15
+
+       // call target function
+       MOVD    0(R12), R3      // code pointer
+       BL      (R3)
+
+       // should never return
+       BL      runtime·abort(SB)
+       UNDEF
+
 /*
  * support for morestack
  */
@@ -305,6 +328,14 @@ noswitch:
 // calling the scheduler calling newm calling gc), so we must
 // record an argument size. For that purpose, it has no arguments.
 TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
+       // Called from f.
+       // Set g->sched to context in f.
+       MOVD    R15, (g_sched+gobuf_sp)(g)
+       MOVD    LR, R8
+       MOVD    R8, (g_sched+gobuf_pc)(g)
+       MOVD    R5, (g_sched+gobuf_lr)(g)
+       MOVD    R12, (g_sched+gobuf_ctxt)(g)
+
        // Cannot grow scheduler stack (m->g0).
        MOVD    g_m(g), R7
        MOVD    m_g0(R7), R8
@@ -319,14 +350,6 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
        BL      runtime·badmorestackgsignal(SB)
        BL      runtime·abort(SB)
 
-       // Called from f.
-       // Set g->sched to context in f.
-       MOVD    R15, (g_sched+gobuf_sp)(g)
-       MOVD    LR, R8
-       MOVD    R8, (g_sched+gobuf_pc)(g)
-       MOVD    R5, (g_sched+gobuf_lr)(g)
-       MOVD    R12, (g_sched+gobuf_ctxt)(g)
-
        // Called from f.
        // Set m->morebuf to f's caller.
        MOVD    R5, (m_morebuf+gobuf_pc)(R7)    // f's caller's PC
index c2676c43b2c447653dd16f84218b39ec31dac65d..b3caeb9a7c2536b93115e3ede4432e0f0fc771af 100644 (file)
@@ -579,7 +579,7 @@ func switchToCrashStack(fn func()) {
 // Disable crash stack on Windows for now. Apparently, throwing an exception
 // on a non-system-allocated crash stack causes EXCEPTION_STACK_OVERFLOW and
 // hangs the process (see issue 63938).
-const crashStackImplemented = (GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "mips64" || GOARCH == "mips64le" || GOARCH == "ppc64" || GOARCH == "ppc64le" || GOARCH == "riscv64" || GOARCH == "wasm") && GOOS != "windows"
+const crashStackImplemented = (GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "mips64" || GOARCH == "mips64le" || GOARCH == "ppc64" || GOARCH == "ppc64le" || GOARCH == "riscv64" || GOARCH == "s390x" || GOARCH == "wasm") && GOOS != "windows"
 
 //go:noescape
 func switchToCrashStack0(fn func()) // in assembly