]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: open up space for callee's arg spill slot in mcall (regabi version)
authorCherry Zhang <cherryyz@google.com>
Mon, 19 Apr 2021 17:58:07 +0000 (13:58 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 19 Apr 2021 18:37:15 +0000 (18:37 +0000)
mcall calls fn with an argument. Currently, in the regabi version
of mcall it does not reserve space for that argument's spill slot.
If the callee spills its argument, it may clobber things on the
g0 stack at 0(SP) (e.g. the old SP saved in cgocallback).

Reserve the space.

Change-Id: I85a314273cd996c7fac8fd0b03cd9033faae9c5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/311489
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/asm_amd64.s

index ca6b1501d1f7202d12d7eeb1f79f5b60199f08df..1e6d8189c97a70d18138aa342e90b39014f59720 100644 (file)
@@ -302,8 +302,10 @@ goodm:
        get_tls(CX)             // Set G in TLS
        MOVQ    R14, g(CX)
        MOVQ    (g_sched+gobuf_sp)(R14), SP     // sp = g0.sched.sp
+       PUSHQ   AX      // open up space for fn's arg spill slot
        MOVQ    0(DX), R12
        CALL    R12             // fn(g)
+       POPQ    AX
        JMP     runtime·badmcall2(SB)
        RET
 #else