diff options
author | 2018-06-24 00:49:25 +0000 | |
---|---|---|
committer | 2018-06-24 00:49:25 +0000 | |
commit | 0dc8bfa22fe958beefcb4ef84a1b44bc70b79dee (patch) | |
tree | cfdee0724729a05f486d5d7323d893e0627ebcc1 | |
parent | Small wording tweak which is slightly closer to the ever elusive truth. (diff) | |
download | wireguard-openbsd-0dc8bfa22fe958beefcb4ef84a1b44bc70b79dee.tar.xz wireguard-openbsd-0dc8bfa22fe958beefcb4ef84a1b44bc70b79dee.zip |
Move signal generation from fputrap() to where it's called in trap()
-rw-r--r-- | sys/arch/amd64/amd64/fpu.c | 22 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 9 | ||||
-rw-r--r-- | sys/arch/amd64/include/fpu.h | 4 |
3 files changed, 15 insertions, 20 deletions
diff --git a/sys/arch/amd64/amd64/fpu.c b/sys/arch/amd64/amd64/fpu.c index a853bd2c342..7a32b1aa69a 100644 --- a/sys/arch/amd64/amd64/fpu.c +++ b/sys/arch/amd64/amd64/fpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.c,v 1.40 2018/06/05 06:39:10 guenther Exp $ */ +/* $OpenBSD: fpu.c,v 1.41 2018/06/24 00:49:25 guenther Exp $ */ /* $NetBSD: fpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /*- @@ -36,9 +36,6 @@ #include <sys/systm.h> #include <sys/proc.h> #include <sys/user.h> -#include <sys/signalvar.h> - -#include <uvm/uvm_extern.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -48,7 +45,6 @@ #include <machine/specialreg.h> #include <machine/fpu.h> -void trap(struct trapframe *); /* * The mask of enabled XSAVE features. @@ -89,27 +85,25 @@ fpuinit(struct cpu_info *ci) /* * Record the FPU state and reinitialize it all except for the control word. - * Then generate a SIGFPE. + * Returns the code to include in an SIGFPE. * * Reinitializing the state allows naive SIGFPE handlers to longjmp without * doing any fixups. */ -void -fputrap(struct trapframe *frame) +int +fputrap(int type) { struct cpu_info *ci = curcpu(); struct proc *p = curproc; struct savefpu *sfp = &p->p_addr->u_pcb.pcb_savefpu; u_int32_t mxcsr, statbits; u_int16_t cw; - int code; - union sigval sv; KASSERT(ci->ci_flags & CPUF_USERXSTATE); ci->ci_flags &= ~CPUF_USERXSTATE; fpusavereset(sfp); - if (frame->tf_trapno == T_XMM) { + if (type == T_XMM) { mxcsr = sfp->fp_fxsave.fx_mxcsr; statbits = mxcsr; mxcsr &= ~0x3f; @@ -124,11 +118,7 @@ fputrap(struct trapframe *frame) } sfp->fp_ex_tw = sfp->fp_fxsave.fx_ftw; sfp->fp_ex_sw = sfp->fp_fxsave.fx_fsw; - code = x86fpflags_to_siginfo (statbits); - sv.sival_ptr = (void *)frame->tf_rip; /* XXX - ? */ - KERNEL_LOCK(); - trapsignal(p, SIGFPE, frame->tf_err, code, sv); - KERNEL_UNLOCK(); + return x86fpflags_to_siginfo(statbits); } static int diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 850ce7e3cb0..48b584a277d 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.70 2018/06/15 20:41:15 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.71 2018/06/24 00:49:25 guenther Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -273,6 +273,7 @@ trap(struct trapframe *frame) struct proc *p = curproc; int type = (int)frame->tf_trapno; union sigval sv; + int code; verify_smap(__func__); uvmexp.traps++; @@ -350,7 +351,11 @@ trap(struct trapframe *frame) case T_ARITHTRAP|T_USER: case T_XMM|T_USER: - fputrap(frame); + code = fputrap(type); + sv.sival_ptr = (void *)frame->tf_rip; + KERNEL_LOCK(); + trapsignal(p, SIGFPE, type &~ T_USER, code, sv); + KERNEL_UNLOCK(); goto out; case T_PAGEFLT: /* allow page faults in kernel mode */ diff --git a/sys/arch/amd64/include/fpu.h b/sys/arch/amd64/include/fpu.h index 78db1e413d3..67232001c8f 100644 --- a/sys/arch/amd64/include/fpu.h +++ b/sys/arch/amd64/include/fpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.h,v 1.14 2018/06/05 06:39:11 guenther Exp $ */ +/* $OpenBSD: fpu.h,v 1.15 2018/06/24 00:49:25 guenther Exp $ */ /* $NetBSD: fpu.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ #ifndef _MACHINE_FPU_H_ @@ -64,7 +64,7 @@ extern uint32_t fpu_mxcsr_mask; extern uint64_t xsave_mask; void fpuinit(struct cpu_info *); -void fputrap(struct trapframe *); +int fputrap(int _type); void fpusave(struct savefpu *); void fpusavereset(struct savefpu *); void fpu_kernel_enter(void); |