From cbdf9ade5604917593af3ce5ce576a465edfca83 Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Wed, 15 May 2019 02:12:10 +0000 Subject: runtime: save/restore callee saved registers in arm64's sigtramp ARM64's R19-R29 and F8-F15 are callee saved registers, which should be saved in the beginning of sigtramp, and restored at the end. fixes #31827 Change-Id: I622e03f1a13fec969d3a11b6a303a8a492e02bcd Reviewed-on: https://go-review.googlesource.com/c/go/+/177045 Run-TryBot: Ben Shi TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- src/runtime/sys_linux_arm64.s | 46 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'src/runtime/sys_linux_arm64.s') diff --git a/src/runtime/sys_linux_arm64.s b/src/runtime/sys_linux_arm64.s index 321d74254c..2835b6ca1c 100644 --- a/src/runtime/sys_linux_arm64.s +++ b/src/runtime/sys_linux_arm64.s @@ -316,7 +316,29 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32 BL (R11) RET -TEXT runtime·sigtramp(SB),NOSPLIT,$24 +TEXT runtime·sigtramp(SB),NOSPLIT,$192 + // Save callee-save registers in the case of signal forwarding. + // Please refer to https://golang.org/issue/31827 . + MOVD R19, 8*4(RSP) + MOVD R20, 8*5(RSP) + MOVD R21, 8*6(RSP) + MOVD R22, 8*7(RSP) + MOVD R23, 8*8(RSP) + MOVD R24, 8*9(RSP) + MOVD R25, 8*10(RSP) + MOVD R26, 8*11(RSP) + MOVD R27, 8*12(RSP) + MOVD g, 8*13(RSP) + MOVD R29, 8*14(RSP) + FMOVD F8, 8*15(RSP) + FMOVD F9, 8*16(RSP) + FMOVD F10, 8*17(RSP) + FMOVD F11, 8*18(RSP) + FMOVD F12, 8*19(RSP) + FMOVD F13, 8*20(RSP) + FMOVD F14, 8*21(RSP) + FMOVD F15, 8*22(RSP) + // this might be called in external code context, // where g is not set. // first save R0, because runtime·load_g will clobber it @@ -330,6 +352,28 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$24 MOVD R2, 24(RSP) MOVD $runtime·sigtrampgo(SB), R0 BL (R0) + + // Restore callee-save registers. + MOVD 8*4(RSP), R19 + MOVD 8*5(RSP), R20 + MOVD 8*6(RSP), R21 + MOVD 8*7(RSP), R22 + MOVD 8*8(RSP), R23 + MOVD 8*9(RSP), R24 + MOVD 8*10(RSP), R25 + MOVD 8*11(RSP), R26 + MOVD 8*12(RSP), R27 + MOVD 8*13(RSP), g + MOVD 8*14(RSP), R29 + FMOVD 8*15(RSP), F8 + FMOVD 8*16(RSP), F9 + FMOVD 8*17(RSP), F10 + FMOVD 8*18(RSP), F11 + FMOVD 8*19(RSP), F12 + FMOVD 8*20(RSP), F13 + FMOVD 8*21(RSP), F14 + FMOVD 8*22(RSP), F15 + RET TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0 -- cgit v1.3