summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2018-07-01 16:02:12 +0000
committerguenther <guenther@openbsd.org>2018-07-01 16:02:12 +0000
commitec74cda27eab626d8fa3b1a587f5c1c2e9724873 (patch)
tree1ff636743a5c1aab29ea981d6297501353934fe9
parentAllow ahci(4) to attach to acpi(4). (diff)
downloadwireguard-openbsd-ec74cda27eab626d8fa3b1a587f5c1c2e9724873.tar.xz
wireguard-openbsd-ec74cda27eab626d8fa3b1a587f5c1c2e9724873.zip
Update IDTVEC, KIDTVEC, and KUENTRY to align with _ALIGN_TRAPS instead of
ALIGN_TEXT. For the places where IDTVEC and KIDTVEC are used in ways that would fail if a trap was inserted, provide IDTVEC_NOALIGN for use directly after other IDTVEC uses, and KIDTVEC_FALLTHROUGH for places where the code intentionally falls through to a KIDTVEC. "objdump -d" shows that this just converts nop-sleds to trap-sleds immediately after an unconditional jmp, or a retq, iretq, or sysretq. ok mortimer@ kettenis@ deraadt@
-rw-r--r--sys/arch/amd64/amd64/vector.S38
-rw-r--r--sys/arch/amd64/include/asm.h14
2 files changed, 26 insertions, 26 deletions
diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S
index 0573123e6b4..aa80e9ca7bb 100644
--- a/sys/arch/amd64/amd64/vector.S
+++ b/sys/arch/amd64/amd64/vector.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: vector.S,v 1.66 2018/06/14 19:57:29 guenther Exp $ */
+/* $OpenBSD: vector.S,v 1.67 2018/07/01 16:02:12 guenther Exp $ */
/* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */
/*
@@ -307,7 +307,7 @@ IDTVEC(trap0d)
IDTVEC(trap0e)
TRAP(T_PAGEFLT)
IDTVEC(intrspurious)
-IDTVEC(trap0f)
+IDTVEC_NOALIGN(trap0f)
iretq
IDTVEC(trap10)
ZTRAP(T_ARITHTRAP)
@@ -318,17 +318,17 @@ IDTVEC(trap12)
IDTVEC(trap13)
ZTRAP(T_XMM)
IDTVEC(trap14)
-IDTVEC(trap15)
-IDTVEC(trap16)
-IDTVEC(trap17)
-IDTVEC(trap18)
-IDTVEC(trap19)
-IDTVEC(trap1a)
-IDTVEC(trap1b)
-IDTVEC(trap1c)
-IDTVEC(trap1d)
-IDTVEC(trap1e)
-IDTVEC(trap1f)
+IDTVEC_NOALIGN(trap15)
+IDTVEC_NOALIGN(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)
/* 20 - 31 reserved for future exp */
ZTRAP(T_RESERVED)
@@ -485,11 +485,11 @@ IDTVEC(intr_lapic_ipi)
movl CPUVAR(ILEVEL),%ebx
cmpl $IPL_IPI,%ebx
jae 2f
-KIDTVEC(resume_lapic_ipi)
+KIDTVEC_FALLTHROUGH(resume_lapic_ipi)
1:
incl CPUVAR(IDEPTH)
movl $IPL_IPI,CPUVAR(ILEVEL)
- sti
+ sti
cld
SMAP_CLAC
pushq %rbx
@@ -569,7 +569,7 @@ IDTVEC(intr_lapic_ltimer)
movl CPUVAR(ILEVEL),%ebx
cmpl $IPL_CLOCK,%ebx
jae 2f
-KIDTVEC(resume_lapic_ltimer)
+KIDTVEC_FALLTHROUGH(resume_lapic_ltimer)
1:
incl CPUVAR(IDEPTH)
movl $IPL_CLOCK,CPUVAR(ILEVEL)
@@ -604,7 +604,7 @@ IDTVEC(intr_xen_upcall)
movl CPUVAR(ILEVEL),%ebx
cmpl $IPL_NET,%ebx
jae 2f
-KIDTVEC(resume_xen_upcall)
+KIDTVEC_FALLTHROUGH(resume_xen_upcall)
1:
incl CPUVAR(IDEPTH)
movl $IPL_NET,CPUVAR(ILEVEL)
@@ -638,7 +638,7 @@ IDTVEC(intr_hyperv_upcall)
movl CPUVAR(ILEVEL),%ebx
cmpl $IPL_NET,%ebx
jae 2f
-KIDTVEC(resume_hyperv_upcall)
+KIDTVEC_FALLTHROUGH(resume_hyperv_upcall)
1:
incl CPUVAR(IDEPTH)
movl $IPL_NET,CPUVAR(ILEVEL)
@@ -668,7 +668,7 @@ KIDTVEC(recurse_##name##num) ;\
INTR_RECURSE_HWFRAME ;\
subq $16,%rsp /* space for __if_{trapno,err} */;\
INTR_REENTRY ;\
-KIDTVEC(resume_##name##num) \
+KIDTVEC_FALLTHROUGH(resume_##name##num) \
movq $IREENT_MAGIC,TF_ERR(%rsp) ;\
movl %ebx,%r13d ;\
movq CPUVAR(ISOURCES) + (num) * 8, %r14 ;\
diff --git a/sys/arch/amd64/include/asm.h b/sys/arch/amd64/include/asm.h
index fa047c095b9..110beb7c5c3 100644
--- a/sys/arch/amd64/include/asm.h
+++ b/sys/arch/amd64/include/asm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asm.h,v 1.12 2018/07/01 12:13:50 mortimer Exp $ */
+/* $OpenBSD: asm.h,v 1.13 2018/07/01 16:02:12 guenther Exp $ */
/* $NetBSD: asm.h,v 1.2 2003/05/02 18:05:47 yamt Exp $ */
/*-
@@ -70,17 +70,17 @@
#ifdef _KERNEL
#define KUTEXT .section .kutext, "ax"
-/*#define KUTEXT .text */
-/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */
#define IDTVEC(name) \
- KUTEXT; ALIGN_TEXT; \
+ KUTEXT; _ALIGN_TRAPS; IDTVEC_NOALIGN(name)
+#define IDTVEC_NOALIGN(name) \
.globl X ## name; .type X ## name,@function; X ## name:
#define KIDTVEC(name) \
- .text; ALIGN_TEXT; \
- .globl X ## name; .type X ## name,@function; X ## name:
+ .text; _ALIGN_TRAPS; IDTVEC_NOALIGN(name)
+#define KIDTVEC_FALLTHROUGH(name) \
+ _ALIGN_TEXT; IDTVEC_NOALIGN(name)
#define KUENTRY(x) \
- KUTEXT; _ALIGN_TEXT; .globl x; .type x,@function; x:
+ KUTEXT; _ALIGN_TRAPS; .globl x; .type x,@function; x:
#endif /* _KERNEL */