summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2018-07-03 20:15:58 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2018-07-03 20:15:58 +0000
commit9decf10757b69d8f3d9fc71615993eb79208ce45 (patch)
treede265a7348142ac58cceb9d87e046550489612c8 /sys
parentbf5fb2f6bf3a718abb81ea9ea8df203780dabd82 (diff)
Make intrframe the exact same size as trapframe: instead of pushing
the PPL on top, store it where trapframe puts the trap number. This makes interrupt handlers get called with the correct stack alignment. Also, document the use of if_err to differentiate resumed/recursed interrupts from 'real' ones. tested in snaps ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/genassym.cf6
-rw-r--r--sys/arch/amd64/amd64/spl.S4
-rw-r--r--sys/arch/amd64/amd64/vector.S32
-rw-r--r--sys/arch/amd64/include/frame.h7
-rw-r--r--sys/arch/amd64/include/i82093reg.h4
5 files changed, 28 insertions, 25 deletions
diff --git a/sys/arch/amd64/amd64/genassym.cf b/sys/arch/amd64/amd64/genassym.cf
index bd6892d9979..5d4ddd1c3e3 100644
--- a/sys/arch/amd64/amd64/genassym.cf
+++ b/sys/arch/amd64/amd64/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.36 2018/06/05 06:39:10 guenther Exp $
+# $OpenBSD: genassym.cf,v 1.37 2018/07/03 20:15:57 guenther Exp $
# Written by Artur Grabowski art@openbsd.org, Public Domain
include <sys/param.h>
@@ -76,6 +76,10 @@ member tf_rflags
member tf_rsp
member tf_ss
+struct intrframe
+member if_ppl
+member if_err
+
define FRAMESIZE sizeof(struct trapframe)
struct iretq_frame
diff --git a/sys/arch/amd64/amd64/spl.S b/sys/arch/amd64/amd64/spl.S
index 0c2baffd532..e544520a491 100644
--- a/sys/arch/amd64/amd64/spl.S
+++ b/sys/arch/amd64/amd64/spl.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: spl.S,v 1.14 2018/06/07 04:09:35 guenther Exp $ */
+/* $OpenBSD: spl.S,v 1.15 2018/07/03 20:15:57 guenther Exp $ */
/* $NetBSD: spl.S,v 1.3 2004/06/28 09:13:11 fvdl Exp $ */
/*
@@ -144,7 +144,7 @@ KIDTVEC(spllower)
* r13 - address to resume loop at
*/
KIDTVEC(doreti)
- popq %rbx # get previous priority
+ movq IF_PPL(%rsp),%rbx # get previous priority
decl CPUVAR(IDEPTH)
leaq 1f(%rip),%r13
1: movl %ebx,%eax
diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S
index aa80e9ca7bb..1369da1e07c 100644
--- a/sys/arch/amd64/amd64/vector.S
+++ b/sys/arch/amd64/amd64/vector.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: vector.S,v 1.67 2018/07/01 16:02:12 guenther Exp $ */
+/* $OpenBSD: vector.S,v 1.68 2018/07/03 20:15:57 guenther Exp $ */
/* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */
/*
@@ -472,12 +472,12 @@ _C_LABEL(x2apic_eoi):
KIDTVEC(recurse_lapic_ipi)
INTR_RECURSE_HWFRAME
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTR_REENTRY
jmp 1f
IDTVEC(intr_lapic_ipi)
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTRENTRY(intr_lapic_ipi)
CODEPATCH_START
movl $0,_C_LABEL(local_apic)+LAPIC_EOI
@@ -492,7 +492,7 @@ KIDTVEC_FALLTHROUGH(resume_lapic_ipi)
sti
cld
SMAP_CLAC
- pushq %rbx
+ movq %rbx,IF_PPL(%rsp)
call _C_LABEL(x86_ipi_handler)
jmp _C_LABEL(Xdoreti)
2:
@@ -556,12 +556,12 @@ IDTVEC(ipi_invlrange)
KIDTVEC(recurse_lapic_ltimer)
INTR_RECURSE_HWFRAME
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTR_REENTRY
jmp 1f
IDTVEC(intr_lapic_ltimer)
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTRENTRY(intr_lapic_ltimer)
CODEPATCH_START
movl $0,_C_LABEL(local_apic)+LAPIC_EOI
@@ -576,7 +576,7 @@ KIDTVEC_FALLTHROUGH(resume_lapic_ltimer)
sti
cld
SMAP_CLAC
- pushq %rbx
+ movq %rbx,IF_PPL(%rsp)
xorq %rdi,%rdi
call _C_LABEL(lapic_clockintr)
jmp _C_LABEL(Xdoreti)
@@ -593,12 +593,12 @@ KIDTVEC_FALLTHROUGH(resume_lapic_ltimer)
KIDTVEC(recurse_xen_upcall)
INTR_RECURSE_HWFRAME
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTR_REENTRY
jmp 1f
IDTVEC(intr_xen_upcall)
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTRENTRY(intr_xen_upcall)
call _C_LABEL(xen_intr_ack)
movl CPUVAR(ILEVEL),%ebx
@@ -611,7 +611,7 @@ KIDTVEC_FALLTHROUGH(resume_xen_upcall)
sti
cld
SMAP_CLAC
- pushq %rbx
+ movq %rbx,IF_PPL(%rsp)
call _C_LABEL(xen_intr)
jmp _C_LABEL(Xdoreti)
2:
@@ -628,12 +628,12 @@ KIDTVEC_FALLTHROUGH(resume_xen_upcall)
KIDTVEC(recurse_hyperv_upcall)
INTR_RECURSE_HWFRAME
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTR_REENTRY
jmp 1f
IDTVEC(intr_hyperv_upcall)
pushq $0
- subq $8,%rsp /* unused __if_trapno */
+ subq $8,%rsp /* if_ppl filled in below */
INTRENTRY(intr_hyperv_upcall)
movl CPUVAR(ILEVEL),%ebx
cmpl $IPL_NET,%ebx
@@ -645,7 +645,7 @@ KIDTVEC_FALLTHROUGH(resume_hyperv_upcall)
sti
cld
SMAP_CLAC
- pushq %rbx
+ movq %rbx,IF_PPL(%rsp)
call _C_LABEL(hv_intr)
jmp _C_LABEL(Xdoreti)
2:
@@ -666,7 +666,7 @@ KIDTVEC_FALLTHROUGH(resume_hyperv_upcall)
#define INTRSTUB(name, num, early_ack, late_ack, mask, unmask, level_mask) \
KIDTVEC(recurse_##name##num) ;\
INTR_RECURSE_HWFRAME ;\
- subq $16,%rsp /* space for __if_{trapno,err} */;\
+ subq $16,%rsp /* space for if_{ppl,err} */ ;\
INTR_REENTRY ;\
KIDTVEC_FALLTHROUGH(resume_##name##num) \
movq $IREENT_MAGIC,TF_ERR(%rsp) ;\
@@ -676,7 +676,7 @@ KIDTVEC_FALLTHROUGH(resume_##name##num) \
jmp 1f ;\
IDTVEC(intr_##name##num) ;\
pushq $0 /* dummy error code */ ;\
- subq $8,%rsp /* unused __if_trapno */ ;\
+ subq $8,%rsp /* if_ppl filled in below */ ;\
INTRENTRY(intr_##name##num) ;\
movq CPUVAR(ISOURCES) + (num) * 8, %r14 ;\
mask(num) /* mask it in hardware */ ;\
@@ -689,7 +689,7 @@ IDTVEC(intr_##name##num) ;\
cmpl %ebx,%r13d ;\
jae 10f /* currently masked; hold it */ ;\
1: \
- pushq %r13 ;\
+ movq %r13,IF_PPL(%rsp) ;\
movl %ebx,CPUVAR(ILEVEL) ;\
sti ;\
cld ;\
diff --git a/sys/arch/amd64/include/frame.h b/sys/arch/amd64/include/frame.h
index c6a152398eb..68b72ec04db 100644
--- a/sys/arch/amd64/include/frame.h
+++ b/sys/arch/amd64/include/frame.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: frame.h,v 1.8 2018/04/26 12:47:02 guenther Exp $ */
+/* $OpenBSD: frame.h,v 1.9 2018/07/03 20:15:57 guenther Exp $ */
/* $NetBSD: frame.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */
/*-
@@ -116,7 +116,6 @@ struct trapframe {
* Interrupt stack frame
*/
struct intrframe {
- int64_t if_ppl;
int64_t if_rdi;
int64_t if_rsi;
int64_t if_rdx;
@@ -129,14 +128,14 @@ struct intrframe {
int64_t if_r13;
int64_t if_r14;
int64_t if_r15;
- u_int64_t __if_err; /* for compat with trap frame - err */
+ int64_t if_err; /* IREENT_MAGIC if resume/recurse */
int64_t if_rbx;
int64_t if_rax;
int64_t tf_gs;
int64_t tf_fs;
int64_t tf_es;
int64_t tf_ds;
- u_int64_t __if_trapno; /* for compat with trap frame - trapno */
+ int64_t if_ppl; /* previous priority level */
int64_t if_rbp;
/* below portion defined in hardware */
int64_t if_rip;
diff --git a/sys/arch/amd64/include/i82093reg.h b/sys/arch/amd64/include/i82093reg.h
index e1fcfc9cd45..6f80d399a34 100644
--- a/sys/arch/amd64/include/i82093reg.h
+++ b/sys/arch/amd64/include/i82093reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i82093reg.h,v 1.6 2016/06/29 06:05:15 mlarkin Exp $ */
+/* $OpenBSD: i82093reg.h,v 1.7 2018/07/03 20:15:57 guenther Exp $ */
/* $NetBSD: i82093reg.h,v 1.1 2003/02/26 21:26:10 fvdl Exp $ */
/*-
@@ -160,7 +160,7 @@
ioapic_asm_unlock(num)
#define ioapic_unmask(num) \
- cmpq $IREENT_MAGIC,(TF_ERR+8)(%rsp) ;\
+ cmpq $IREENT_MAGIC,IF_ERR(%rsp) ;\
jne 79f ;\
movq IS_PIC(%r14),%rdi ;\
ioapic_asm_lock(num) ;\