Skip to content

Commit 75b494b

Browse files
committed
runtime: implement stackcheck for arm64
1 parent eda42f7 commit 75b494b

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

src/runtime/asm_arm64.s

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,3 +1596,19 @@ TEXT runtime·panicSliceConvert<ABIInternal>(SB),NOSPLIT,$0-16
15961596
TEXT ·getfp<ABIInternal>(SB),NOSPLIT|NOFRAME,$0
15971597
MOVD R29, R0
15981598
RET
1599+
1600+
// check that SP is in range [g->stack.lo, g->stack.hi)
1601+
TEXT runtime·stackcheck(SB), NOSPLIT|NOFRAME, $0-0
1602+
MOVDRSP, R0
1603+
MOVD(g_stack+stack_hi)(g), R4
1604+
CMPR0, R4
1605+
BLEret
1606+
B runtime·abort(SB)
1607+
1608+
MOVD(g_stack+stack_lo)(g), R4
1609+
CMP R0, R4
1610+
BGEret
1611+
B runtime·abort(SB)
1612+
1613+
ret:
1614+
RET

src/runtime/sys_darwin_arm64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ TEXT runtime·mstart_stub(SB),NOSPLIT,$160
360360
MOVDm_g0(R0), g
361361
BL·save_g(SB)
362362

363+
BLruntime·stackcheck(SB)
363364
BLruntime·mstart(SB)
364365

365366
// Restore callee-save registers.

src/runtime/sys_freebsd_arm64.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ TEXT runtime·thr_start(SB),NOSPLIT,$0
8080
// set up g
8181
MOVDm_g0(R0), g
8282
MOVDR0, g_m(g)
83-
BL emptyfunc<>(SB) // fault if stack check is wrong
83+
84+
BL runtime·stackcheck(SB)// fault if stack check is wrong
8485
BL runtime·mstart(SB)
8586

8687
MOVD$2, R8// crash (not reached)

src/runtime/sys_linux_arm64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ good:
707707
// In child, set up new stack
708708
MOVDR10, g_m(R11)
709709
MOVDR11, g
710-
//CALLruntime·stackcheck(SB)
710+
CALLruntime·stackcheck(SB)
711711

712712
nog:
713713
// Call fn

src/runtime/sys_openbsd_arm64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ TEXT runtime·mstart_stub(SB),NOSPLIT,$144
3030
MOVD m_g0(R0), g
3131
BLruntime·save_g(SB)
3232

33+
BLruntime·stackcheck(SB) // fault if stack check is wrong
3334
BLruntime·mstart(SB)
3435

3536
// Restore callee-save registers.

src/runtime/sys_windows_arm64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ TEXT runtime·tstart_stdcall(SB),NOSPLIT,$96-0
219219
MOVDR0, g_stackguard0(g)
220220
MOVDR0, g_stackguard1(g)
221221

222-
BL runtime·emptyfunc(SB)// fault if stack check is wrong
222+
BL runtime·stackcheck(SB)// fault if stack check is wrong
223223
BL runtime·mstart(SB)
224224

225225
RESTORE_R19_TO_R28(8*3)

0 commit comments

Comments
 (0)