aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/rt0_openbsd_arm64.s
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2020-05-20 02:13:57 +1000
committerJoel Sing <joel@sing.id.au>2020-05-26 17:02:46 +0000
commit20160b37c6b7d12e25987baf2d95ba861b327a3b (patch)
tree0aa3c324148f930bca7e41ec1d55d06b5bd84cea /src/runtime/rt0_openbsd_arm64.s
parentbcda68447b31b86bc3829fca80454ca1a2a572e0 (diff)
downloadgo-20160b37c6b7d12e25987baf2d95ba861b327a3b.tar.gz
go-20160b37c6b7d12e25987baf2d95ba861b327a3b.zip
runtime, syscall: correct openbsd/arm and openbsd/arm64 syscalls for OpenBSD 6.7
Add two no op instructions following svc on openbsd/arm64 and swi on openbsd/arm. All except some of the most recent arm64 processors have a speculative execution flaw that occurs across a syscall boundary, which cannot be mitigated in the kernel. In order to protect against this leak a speculation barrier needs to be placed after an svc or swi instruction. In order to avoid the performance impact of these instructions, the OpenBSD 6.7 kernel returns execution two instructions past the svc or swi call. For now two hardware no ops are added, which allows syscalls to work with both 6.6 and 6.7. These should be replaced with real speculation barriers once OpenBSD 6.8 is released. Updates #36435 Change-Id: I06153cb0998199242cca8761450e53599c3e7de4 Reviewed-on: https://go-review.googlesource.com/c/go/+/234381 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/rt0_openbsd_arm64.s')
-rw-r--r--src/runtime/rt0_openbsd_arm64.s8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/runtime/rt0_openbsd_arm64.s b/src/runtime/rt0_openbsd_arm64.s
index ab8ea97f4f..12408f2eec 100644
--- a/src/runtime/rt0_openbsd_arm64.s
+++ b/src/runtime/rt0_openbsd_arm64.s
@@ -4,6 +4,12 @@
#include "textflag.h"
+// See comment in runtime/sys_openbsd_arm64.s re this construction.
+#define INVOKE_SYSCALL \
+ SVC; \
+ NOOP; \
+ NOOP
+
TEXT _rt0_arm64_openbsd(SB),NOSPLIT|NOFRAME,$0
MOVD 0(RSP), R0 // argc
ADD $8, RSP, R1 // argv
@@ -101,5 +107,5 @@ TEXT main(SB),NOSPLIT|NOFRAME,$0
exit:
MOVD $0, R0
MOVD $1, R8 // sys_exit
- SVC
+ INVOKE_SYSCALL
B exit