summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2023-04-17 00:02:15 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2023-04-17 00:02:15 +0000
commit138836e1d4e1f43b7a160e30365b45440e2923d3 (patch)
tree1a34e4126340f9b77a37ba2381261c492f18d127 /sys/arch/amd64
parentac04d922dcaa3320a9ca9f50c8b613eda7eca996 (diff)
Add endbr64 instructions to most of the ENTRY() macros.
The IDTVEC() and KIDTVEC() macros also get a endbr64, and therefore we need to change the way that vectors are aliased with a new IDTVEC_ALIAS() macro. with guenther, jsg
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/vector.S24
-rw-r--r--sys/arch/amd64/include/asm.h15
-rw-r--r--sys/arch/amd64/include/frameasm.h3
3 files changed, 23 insertions, 19 deletions
diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S
index c56c4b00cb4..a7c1d5dd726 100644
--- a/sys/arch/amd64/amd64/vector.S
+++ b/sys/arch/amd64/amd64/vector.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: vector.S,v 1.91 2023/04/16 05:39:33 guenther Exp $ */
+/* $OpenBSD: vector.S,v 1.92 2023/04/17 00:02:14 deraadt Exp $ */
/* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */
/*
@@ -348,7 +348,7 @@ IDTVEC(trap0d)
IDTVEC(trap0e)
TRAP(T_PAGEFLT)
IDTVEC(intrspurious)
-IDTVEC_NOALIGN(trap0f)
+IDTVEC_ALIAS(trap0f, intrspurious)
iretq
IDTVEC(trap10)
ZTRAP(T_ARITHTRAP)
@@ -362,16 +362,16 @@ IDTVEC(trap14)
ZTRAP(T_VE)
IDTVEC(trap15)
TRAP(T_CP)
-IDTVEC(trap16)
-IDTVEC_NOALIGN(trap17)
-IDTVEC_NOALIGN(trap18)
-IDTVEC_NOALIGN(trap19)
-IDTVEC_NOALIGN(trap1a)
-IDTVEC_NOALIGN(trap1b)
-IDTVEC_NOALIGN(trap1c)
-IDTVEC_NOALIGN(trap1d)
-IDTVEC_NOALIGN(trap1e)
-IDTVEC_NOALIGN(trap1f)
+IDTVEC(trap1f)
+IDTVEC_ALIAS(trap16, trap1f)
+IDTVEC_ALIAS(trap17, trap1f)
+IDTVEC_ALIAS(trap18, trap1f)
+IDTVEC_ALIAS(trap19, trap1f)
+IDTVEC_ALIAS(trap1a, trap1f)
+IDTVEC_ALIAS(trap1b, trap1f)
+IDTVEC_ALIAS(trap1c, trap1f)
+IDTVEC_ALIAS(trap1d, trap1f)
+IDTVEC_ALIAS(trap1e, trap1f)
/* 22 - 31 reserved for future exp */
ZTRAP(T_RESERVED)
diff --git a/sys/arch/amd64/include/asm.h b/sys/arch/amd64/include/asm.h
index b4053a07e8d..86806e69a7e 100644
--- a/sys/arch/amd64/include/asm.h
+++ b/sys/arch/amd64/include/asm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asm.h,v 1.23 2022/12/01 00:26:15 guenther Exp $ */
+/* $OpenBSD: asm.h,v 1.24 2023/04/17 00:02:14 deraadt Exp $ */
/* $NetBSD: asm.h,v 1.2 2003/05/02 18:05:47 yamt Exp $ */
/*-
@@ -84,11 +84,14 @@
#define KTEXT_PAGE_END .popsection
#define IDTVEC(name) \
- KUTEXT; _ALIGN_TRAPS; IDTVEC_NOALIGN(name)
+ KUTEXT; _ALIGN_TRAPS; IDTVEC_NOALIGN(name); endbr64
#define GENTRY(x) .globl x; _FENTRY(x)
#define IDTVEC_NOALIGN(name) GENTRY(X ## name)
+#define IDTVEC_ALIAS(alias,sym) \
+ .global X ## alias; \
+ X ## alias = X ## sym;
#define KIDTVEC(name) \
- .text; _ALIGN_TRAPS; IDTVEC_NOALIGN(name)
+ .text; _ALIGN_TRAPS; IDTVEC_NOALIGN(name); endbr64
#define KIDTVEC_FALLTHROUGH(name) \
_ALIGN_TEXT; IDTVEC_NOALIGN(name)
#define KUENTRY(x) \
@@ -166,10 +169,10 @@
# define RETGUARD_SYMBOL(x)
#endif
-#define ENTRY(y) _ENTRY(y); _PROF_PROLOGUE
+#define ENTRY(y) _ENTRY(y); endbr64; _PROF_PROLOGUE
#define NENTRY(y) _NENTRY(y)
-#define ASENTRY(y) _NENTRY(y); _PROF_PROLOGUE
-#define ENTRY_NB(y) _ENTRY_NB(y); _PROF_PROLOGUE
+#define ASENTRY(y) _NENTRY(y); endbr64; _PROF_PROLOGUE
+#define ENTRY_NB(y) _ENTRY_NB(y); endbr64; _PROF_PROLOGUE
#define END(y) .size y, . - y
#define STRONG_ALIAS(alias,sym) \
diff --git a/sys/arch/amd64/include/frameasm.h b/sys/arch/amd64/include/frameasm.h
index a3274bc9735..5f1de16748d 100644
--- a/sys/arch/amd64/include/frameasm.h
+++ b/sys/arch/amd64/include/frameasm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: frameasm.h,v 1.25 2020/11/12 23:29:16 guenther Exp $ */
+/* $OpenBSD: frameasm.h,v 1.26 2023/04/17 00:02:14 deraadt Exp $ */
/* $NetBSD: frameasm.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */
#ifndef _AMD64_MACHINE_FRAMEASM_H
@@ -63,6 +63,7 @@
*/
#define INTRENTRY_LABEL(label) X##label##_untramp
#define INTRENTRY(label) \
+ endbr64 ; \
testb $SEL_RPL,IRETQ_CS(%rsp) ; \
je INTRENTRY_LABEL(label) ; \
swapgs ; \