Add two no op instructions following swi for Go on openbsd/arm.
arm processors have the same speculative execution flaw that occurs across a syscall boundary, which was previously addressed in the arm64 port.
This commit is contained in:
parent
50fd437c2b
commit
4f68b69023
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.84 2020/03/06 15:26:18 espie Exp $
|
||||
# $OpenBSD: Makefile,v 1.85 2020/03/20 08:02:29 jsing Exp $
|
||||
|
||||
ONLY_FOR_ARCHS = ${GO_ARCHS}
|
||||
|
||||
@ -8,7 +8,7 @@ BIN_BOOTSTRAP_VERSION = 1.13.7
|
||||
COMMENT = Go programming language
|
||||
|
||||
VERSION = 1.13.7
|
||||
REVISION = 0
|
||||
REVISION = 1
|
||||
DISTNAME = go${VERSION}.src
|
||||
PKGNAME = go-${VERSION}
|
||||
PKGSPEC = ${FULLPKGNAME:S/go-/go-=/}
|
||||
|
263
lang/go/patches/patch-src_runtime_sys_openbsd_arm_s
Normal file
263
lang/go/patches/patch-src_runtime_sys_openbsd_arm_s
Normal file
@ -0,0 +1,263 @@
|
||||
$OpenBSD: patch-src_runtime_sys_openbsd_arm_s,v 1.3 2020/03/20 08:02:29 jsing Exp $
|
||||
|
||||
Index: src/runtime/sys_openbsd_arm.s
|
||||
--- src/runtime/sys_openbsd_arm.s.orig
|
||||
+++ src/runtime/sys_openbsd_arm.s
|
||||
@@ -13,11 +13,15 @@
|
||||
#define CLOCK_REALTIME $0
|
||||
#define CLOCK_MONOTONIC $3
|
||||
|
||||
+#define NOOP MOVW R0, R0
|
||||
+
|
||||
// Exit the entire program (like C exit)
|
||||
TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW code+0(FP), R0 // arg 1 - status
|
||||
MOVW $1, R12 // sys_exit
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $0, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
RET
|
||||
@@ -27,6 +31,8 @@ TEXT runtime·exitThread(SB),NOSPLIT,$0-4
|
||||
MOVW wait+0(FP), R0 // arg 1 - notdead
|
||||
MOVW $302, R12 // sys___threxit
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $1, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
JMP 0(PC)
|
||||
@@ -37,6 +43,8 @@ TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW perm+8(FP), R2 // arg 3 - perm
|
||||
MOVW $5, R12 // sys_open
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+12(FP)
|
||||
RET
|
||||
@@ -45,6 +53,8 @@ TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW fd+0(FP), R0 // arg 1 - fd
|
||||
MOVW $6, R12 // sys_close
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+4(FP)
|
||||
RET
|
||||
@@ -55,6 +65,8 @@ TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW n+8(FP), R2 // arg 3 - nbyte
|
||||
MOVW $3, R12 // sys_read
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+12(FP)
|
||||
RET
|
||||
@@ -65,6 +77,8 @@ TEXT runtime·write(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVW n+8(FP), R2 // arg 3 - nbyte
|
||||
MOVW $4, R12 // sys_write
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+12(FP)
|
||||
RET
|
||||
@@ -83,25 +97,35 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
|
||||
MOVW $0, R1 // arg 2 - rmtp
|
||||
MOVW $91, R12 // sys_nanosleep
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RET
|
||||
|
||||
TEXT runtime·raise(SB),NOSPLIT,$12
|
||||
MOVW $299, R12 // sys_getthrid
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
// arg 1 - tid, already in R0
|
||||
MOVW sig+0(FP), R1 // arg 2 - signum
|
||||
MOVW $0, R2 // arg 3 - tcb
|
||||
MOVW $119, R12 // sys_thrkill
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RET
|
||||
|
||||
TEXT runtime·raiseproc(SB),NOSPLIT,$12
|
||||
MOVW $20, R12
|
||||
SWI $0 // sys_getpid
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
// arg 1 - pid, already in R0
|
||||
MOVW sig+0(FP), R1 // arg 2 - signum
|
||||
MOVW $122, R12 // sys_kill
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RET
|
||||
|
||||
TEXT runtime·mmap(SB),NOSPLIT,$16
|
||||
@@ -120,6 +144,8 @@ TEXT runtime·mmap(SB),NOSPLIT,$16
|
||||
ADD $4, R13
|
||||
MOVW $197, R12 // sys_mmap
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
SUB $4, R13
|
||||
MOVW $0, R1
|
||||
MOVW.CS R0, R1 // if error, move to R1
|
||||
@@ -133,6 +159,8 @@ TEXT runtime·munmap(SB),NOSPLIT,$0
|
||||
MOVW n+4(FP), R1 // arg 2 - len
|
||||
MOVW $73, R12 // sys_munmap
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $0, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
RET
|
||||
@@ -143,6 +171,8 @@ TEXT runtime·madvise(SB),NOSPLIT,$0
|
||||
MOVW flags+8(FP), R2 // arg 2 - flags
|
||||
MOVW $75, R12 // sys_madvise
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $-1, R0
|
||||
MOVW R0, ret+12(FP)
|
||||
RET
|
||||
@@ -153,6 +183,8 @@ TEXT runtime·setitimer(SB),NOSPLIT,$0
|
||||
MOVW old+8(FP), R2 // arg 3 - old value
|
||||
MOVW $69, R12 // sys_setitimer
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RET
|
||||
|
||||
// func walltime() (sec int64, nsec int32)
|
||||
@@ -161,6 +193,8 @@ TEXT runtime·walltime(SB), NOSPLIT, $32
|
||||
MOVW $8(R13), R1 // arg 2 - tp
|
||||
MOVW $87, R12 // sys_clock_gettime
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
|
||||
MOVW 8(R13), R0 // sec - l32
|
||||
MOVW 12(R13), R1 // sec - h32
|
||||
@@ -179,6 +213,8 @@ TEXT runtime·nanotime(SB),NOSPLIT,$32
|
||||
MOVW $8(R13), R1 // arg 2 - tp
|
||||
MOVW $87, R12 // sys_clock_gettime
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
|
||||
MOVW 8(R13), R0 // sec - l32
|
||||
MOVW 12(R13), R4 // sec - h32
|
||||
@@ -200,6 +236,8 @@ TEXT runtime·sigaction(SB),NOSPLIT,$0
|
||||
MOVW old+8(FP), R2 // arg 3 - old sigaction
|
||||
MOVW $46, R12 // sys_sigaction
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $3, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
RET
|
||||
@@ -209,6 +247,8 @@ TEXT runtime·obsdsigprocmask(SB),NOSPLIT,$0
|
||||
MOVW new+4(FP), R1 // arg 2 - new
|
||||
MOVW $48, R12 // sys_sigprocmask
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $3, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
MOVW R0, ret+8(FP)
|
||||
@@ -251,6 +291,8 @@ TEXT runtime·tfork(SB),NOSPLIT,$0
|
||||
MOVW psize+4(FP), R1 // arg 2 - psize
|
||||
MOVW $8, R12 // sys___tfork
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
|
||||
// Return if syscall failed.
|
||||
B.CC 4(PC)
|
||||
@@ -284,6 +326,8 @@ TEXT runtime·sigaltstack(SB),NOSPLIT,$0
|
||||
MOVW old+4(FP), R1 // arg 2 - old sigaltstack
|
||||
MOVW $288, R12 // sys_sigaltstack
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW.CS $0, R8 // crash on syscall failure
|
||||
MOVW.CS R8, (R8)
|
||||
RET
|
||||
@@ -291,6 +335,8 @@ TEXT runtime·sigaltstack(SB),NOSPLIT,$0
|
||||
TEXT runtime·osyield(SB),NOSPLIT,$0
|
||||
MOVW $298, R12 // sys_sched_yield
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RET
|
||||
|
||||
TEXT runtime·thrsleep(SB),NOSPLIT,$4
|
||||
@@ -303,6 +349,8 @@ TEXT runtime·thrsleep(SB),NOSPLIT,$4
|
||||
ADD $4, R13
|
||||
MOVW $94, R12 // sys___thrsleep
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
SUB $4, R13
|
||||
MOVW R0, ret+20(FP)
|
||||
RET
|
||||
@@ -312,6 +360,8 @@ TEXT runtime·thrwakeup(SB),NOSPLIT,$0
|
||||
MOVW n+4(FP), R1 // arg 2 - n
|
||||
MOVW $301, R12 // sys___thrwakeup
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW R0, ret+8(FP)
|
||||
RET
|
||||
|
||||
@@ -327,6 +377,8 @@ TEXT runtime·sysctl(SB),NOSPLIT,$8
|
||||
ADD $4, R13
|
||||
MOVW $202, R12 // sys___sysctl
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
SUB $4, R13
|
||||
MOVW.CC $0, R0
|
||||
RSB.CS $0, R0
|
||||
@@ -337,6 +389,8 @@ TEXT runtime·sysctl(SB),NOSPLIT,$8
|
||||
TEXT runtime·kqueue(SB),NOSPLIT,$0
|
||||
MOVW $269, R12 // sys_kqueue
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RSB.CS $0, R0
|
||||
MOVW R0, ret+0(FP)
|
||||
RET
|
||||
@@ -354,6 +408,8 @@ TEXT runtime·kevent(SB),NOSPLIT,$8
|
||||
ADD $4, R13
|
||||
MOVW $72, R12 // sys_kevent
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RSB.CS $0, R0
|
||||
SUB $4, R13
|
||||
MOVW R0, ret+24(FP)
|
||||
@@ -366,6 +422,8 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0
|
||||
MOVW $1, R2 // arg 3 - arg (FD_CLOEXEC)
|
||||
MOVW $92, R12 // sys_fcntl
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
RET
|
||||
|
||||
TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
|
||||
@@ -375,5 +433,7 @@ TEXT runtime·read_tls_fallback(SB),NOSPLIT|NOFRAME,$0
|
||||
MOVM.WP [R1, R2, R3, R12], (R13)
|
||||
MOVW $330, R12 // sys___get_tcb
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVM.IAW (R13), [R1, R2, R3, R12]
|
||||
RET
|
59
lang/go/patches/patch-src_syscall_asm_openbsd_arm_s
Normal file
59
lang/go/patches/patch-src_syscall_asm_openbsd_arm_s
Normal file
@ -0,0 +1,59 @@
|
||||
$OpenBSD: patch-src_syscall_asm_openbsd_arm_s,v 1.1 2020/03/20 08:02:29 jsing Exp $
|
||||
|
||||
Index: src/syscall/asm_openbsd_arm.s
|
||||
--- src/syscall/asm_openbsd_arm.s.orig
|
||||
+++ src/syscall/asm_openbsd_arm.s
|
||||
@@ -15,6 +15,8 @@
|
||||
// func RawSyscall(trap int32, a1, a2, a3 int32) (r1, r2, err int32);
|
||||
// func RawSyscall6(trap int32, a1, a2, a3, a4, a5, a6 int32) (r1, r2, err int32);
|
||||
|
||||
+#define NOOP MOVW R0, R0
|
||||
+
|
||||
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
BL runtime·entersyscall(SB)
|
||||
MOVW trap+0(FP), R12 // syscall number
|
||||
@@ -22,6 +24,8 @@ TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||
MOVW a2+8(FP), R1 // arg 2
|
||||
MOVW a3+12(FP), R2 // arg 3
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW $0, R2
|
||||
BCS error
|
||||
MOVW R0, r1+16(FP) // ret 1
|
||||
@@ -47,6 +51,8 @@ TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||
MOVW R13, R4
|
||||
MOVW $a5+20(FP), R13 // arg 5 to arg 6 are passed on stack
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW R4, R13
|
||||
MOVW $0, R2
|
||||
BCS error6
|
||||
@@ -73,6 +79,8 @@ TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||
MOVW R13, R4
|
||||
MOVW $a5+20(FP), R13 // arg 5 to arg 9 are passed on stack
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW R4, R13
|
||||
MOVW $0, R2
|
||||
BCS error9
|
||||
@@ -95,6 +103,8 @@ TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||
MOVW a2+8(FP), R1 // arg 2
|
||||
MOVW a3+12(FP), R2 // arg 3
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW $0, R2
|
||||
BCS errorr
|
||||
MOVW R0, r1+16(FP) // ret 1
|
||||
@@ -117,6 +127,8 @@ TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||
MOVW R13, R4
|
||||
MOVW $a5+20(FP), R13 // arg 5 to arg 6 are passed on stack
|
||||
SWI $0
|
||||
+ NOOP
|
||||
+ NOOP
|
||||
MOVW R4, R13
|
||||
MOVW $0, R2
|
||||
BCS errorr6
|
Loading…
Reference in New Issue
Block a user