Skip to content

Commit

Permalink
runtime: netbsd-arm64 fixes
Browse files Browse the repository at this point in the history
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 <[email protected]>
Trust: Benny Siegert <[email protected]>
  • Loading branch information
bsiegert committed Sep 28, 2020
1 parent 72a9dec commit 8ab020a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/runtime/cgo/gcc_netbsd_arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
11 changes: 9 additions & 2 deletions src/runtime/sys_netbsd_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8ab020a

Please sign in to comment.