1
0
mirror of https://github.com/golang/go synced 2024-11-17 14:04:48 -07:00

runtime: netbsd-arm64 fixes

Add missing declaration of crosscall1.

Fix stack alignment for pipe2 return value.

Work around kernel clobbering of r28 on aarch64 by reloading from ucontext.
https://nxr.netbsd.org/xref/src/sys/arch/aarch64/aarch64/sig_machdep.c#104

Update #30824

Change-Id: I7f9472939f4c02953f8c207308610118f5d3c54c
Reviewed-on: https://go-review.googlesource.com/c/go/+/257645
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Benny Siegert <bsiegert@gmail.com>
This commit is contained in:
Benny Siegert 2020-09-26 19:40:17 +00:00
parent 72a9dec156
commit 8ab020adb2
2 changed files with 11 additions and 2 deletions

View File

@ -53,6 +53,8 @@ _cgo_sys_thread_start(ThreadStart *ts)
}
}
extern void crosscall1(void (*fn)(void), void (*setg_gcc)(void*), void *g);
static void*
threadentry(void *v)
{

View File

@ -169,11 +169,12 @@ pipeok:
// func pipe2(flags int32) (r, w int32, errno int32)
TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
ADD $8, RSP, R0
ADD $16, RSP, R0
MOVW flags+0(FP), R1
SVC $SYS_pipe2
BCC 2(PC)
BCC pipe2ok
NEG R0, R0
pipe2ok:
MOVW R0, errno+16(FP)
RET
@ -319,6 +320,12 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192
MOVD R26, 8*11(RSP)
MOVD R27, 8*12(RSP)
MOVD g, 8*13(RSP)
// Unclobber g for now (kernel uses it as ucontext ptr)
// See https://github.com/golang/go/issues/30824#issuecomment-492772426
// This is only correct in the non-cgo case.
// XXX should use lwp_getprivate as suggested.
// 8*36 is ucontext.uc_mcontext.__gregs[_REG_X28]
MOVD 8*36(g), g
MOVD R29, 8*14(RSP)
FMOVD F8, 8*15(RSP)
FMOVD F9, 8*16(RSP)