]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: add crash stack support for mips64x
authorMauri de Souza Meneguzzo <mauri870@gmail.com>
Thu, 2 Nov 2023 22:15:03 +0000 (22:15 +0000)
committerCherry Mui <cherryyz@google.com>
Mon, 6 Nov 2023 19:45:59 +0000 (19:45 +0000)
Change-Id: I240ea7dd6430f4c89cfdadbfa790e4a70a4fd79d
GitHub-Last-Rev: 585742b5eebad7c03ec313b590e2171491b78b37
GitHub-Pull-Request: golang/go#63905
Reviewed-on: https://go-review.googlesource.com/c/go/+/539295
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>

src/runtime/asm.s
src/runtime/asm_mips64x.s
src/runtime/proc.go

index 81d3bfbb8a0a6a71516d7d8c9a8b69bba975c15c..012a6a095ddeca8ff4a3ef3fb43ddf372d6fafe8 100644 (file)
@@ -15,6 +15,8 @@ TEXT ·mapinitnoop<ABIInternal>(SB),NOSPLIT,$0-0
 
 #ifndef GOARCH_amd64
 #ifndef GOARCH_arm64
+#ifndef GOARCH_mips64
+#ifndef GOARCH_mips64le
 #ifndef GOARCH_riscv64
 // stub to appease shared build mode.
 TEXT ·switchToCrashStack0<ABIInternal>(SB),NOSPLIT,$0-0
@@ -22,3 +24,5 @@ TEXT ·switchToCrashStack0<ABIInternal>(SB),NOSPLIT,$0-0
 #endif
 #endif
 #endif
+#endif
+#endif
index 19592b5695297a41f6868e621a0a4fcd68de150a..80cd87c4af335f6760165e7c9edf9a895df2bf06 100644 (file)
@@ -205,6 +205,29 @@ noswitch:
        ADDV    $8, R29
        JMP     (R4)
 
+// func switchToCrashStack0(fn func())
+TEXT runtime·switchToCrashStack0(SB), NOSPLIT, $0-8
+       MOVV    fn+0(FP), REGCTXT       // context register
+       MOVV    g_m(g), R2      // curm
+
+       // set g to gcrash
+       MOVV    $runtime·gcrash(SB), g // g = &gcrash
+       CALL    runtime·save_g(SB)
+       MOVV    R2, g_m(g)      // g.m = curm
+       MOVV    g, m_g0(R2)     // curm.g0 = g
+
+       // switch to crashstack
+       MOVV    (g_stack+stack_hi)(g), R2
+       ADDV    $(-4*8), R2, R29
+
+       // call target function
+       MOVV    0(REGCTXT), R25
+       JAL     (R25)
+
+       // should never return
+       CALL    runtime·abort(SB)
+       UNDEF
+
 /*
  * support for morestack
  */
@@ -218,6 +241,13 @@ 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.
+       MOVV    R29, (g_sched+gobuf_sp)(g)
+       MOVV    R31, (g_sched+gobuf_pc)(g)
+       MOVV    R3, (g_sched+gobuf_lr)(g)
+       MOVV    REGCTXT, (g_sched+gobuf_ctxt)(g)
+
        // Cannot grow scheduler stack (m->g0).
        MOVV    g_m(g), R7
        MOVV    m_g0(R7), R8
@@ -231,13 +261,6 @@ TEXT runtime·morestack(SB),NOSPLIT|NOFRAME,$0-0
        JAL     runtime·badmorestackgsignal(SB)
        JAL     runtime·abort(SB)
 
-       // Called from f.
-       // Set g->sched to context in f.
-       MOVV    R29, (g_sched+gobuf_sp)(g)
-       MOVV    R31, (g_sched+gobuf_pc)(g)
-       MOVV    R3, (g_sched+gobuf_lr)(g)
-       MOVV    REGCTXT, (g_sched+gobuf_ctxt)(g)
-
        // Called from f.
        // Set m->morebuf to f's caller.
        MOVV    R3, (m_morebuf+gobuf_pc)(R7)    // f's caller's PC
index 9b5f2e9a6d91c368220130a4cd63cc3859095163..7ed30680630f89252860e2b954ac273d7a53f10d 100644 (file)
@@ -574,10 +574,10 @@ func switchToCrashStack(fn func()) {
        abort()
 }
 
-const crashStackImplemented = GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "riscv64"
+const crashStackImplemented = GOARCH == "amd64" || GOARCH == "arm64" || GOARCH == "mips64" || GOARCH == "mips64le" || GOARCH == "riscv64"
 
 //go:noescape
-func switchToCrashStack0(func()) // in assembly
+func switchToCrashStack0(fn func()) // in assembly
 
 func lockedOSThread() bool {
        gp := getg()