From ce3d8c4d773d1ae2f51c6959de066dece8377698 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 13 Jan 2007 21:15:57 +0000 Subject: [PATCH] Pull in a few bits from FreeBSD. Add a structure size field and floating point management fields to the signal context and mcontext/ucontext. These fields will allow us to optimize the floating point save/restore in the future. --- sys/cpu/i386/include/signal.h | 8 +++++++- sys/cpu/i386/include/ucontext.h | 16 +++++++++++++++- sys/platform/pc32/i386/machdep.c | 5 ++++- sys/platform/vkernel/i386/cpu_regs.c | 5 ++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/sys/cpu/i386/include/signal.h b/sys/cpu/i386/include/signal.h index 863a757e74..5a91439d22 100644 --- a/sys/cpu/i386/include/signal.h +++ b/sys/cpu/i386/include/signal.h @@ -32,7 +32,7 @@ * * @(#)signal.h 8.1 (Berkeley) 6/11/93 * $FreeBSD: src/sys/i386/include/signal.h,v 1.12 1999/11/12 13:52:11 marcel Exp $ - * $DragonFly: src/sys/cpu/i386/include/signal.h,v 1.8 2007/01/08 03:33:37 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/signal.h,v 1.9 2007/01/13 21:15:55 dillon Exp $ */ #ifndef _CPU_SIGNAL_H_ @@ -94,8 +94,14 @@ struct sigcontext { int sc_esp; int sc_ss; + int mc_len; + int mc_fpformat; + int mc_ownedfp; + /* * Full FPU state is 512 bytes. Add another 16 bytes worth of spare. + * + * This field must be 16-byte aligned. */ int sc_fpregs[128]; /* machine state (FPU): */ int sc_spare[16]; diff --git a/sys/cpu/i386/include/ucontext.h b/sys/cpu/i386/include/ucontext.h index fee1bbb9ca..46f0887e9c 100644 --- a/sys/cpu/i386/include/ucontext.h +++ b/sys/cpu/i386/include/ucontext.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.4 1999/10/11 20:33:09 luoqi Exp $ - * $DragonFly: src/sys/cpu/i386/include/ucontext.h,v 1.4 2007/01/08 03:33:37 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/ucontext.h,v 1.5 2007/01/13 21:15:55 dillon Exp $ */ #ifndef _CPU_UCONTEXT_H_ @@ -60,8 +60,22 @@ typedef struct __mcontext { int mc_esp; /* machine state */ int mc_ss; + int mc_len; + int mc_fpformat; + int mc_ownedfp; + + /* 16 byte aligned */ + int mc_fpregs[128]; /* full fp state */ int __spare__[16]; } mcontext_t; +#define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */ +#define _MC_FPFMT_387 0x10001 +#define _MC_FPFMT_XMM 0x10002 + +#define _MC_FPOWNED_NONE 0x20000 /* FP state not used */ +#define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */ +#define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */ + #endif /* !_CPU_UCONTEXT_H_ */ diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index 0389d407bc..2b17675c82 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.113 2007/01/09 07:03:32 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.114 2007/01/13 21:15:56 dillon Exp $ */ #include "use_apm.h" @@ -440,6 +440,9 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) sf.sf_uc.uc_mcontext.mc_onstack = oonstack; bcopy(regs, &sf.sf_uc.uc_mcontext.mc_gs, sizeof(struct trapframe)); + /* make the size of the saved context visible to userland */ + sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); + /* Allocate and validate space for the signal handler context. */ /* XXX lwp flags */ if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack && diff --git a/sys/platform/vkernel/i386/cpu_regs.c b/sys/platform/vkernel/i386/cpu_regs.c index ba0ffc68aa..330517796d 100644 --- a/sys/platform/vkernel/i386/cpu_regs.c +++ b/sys/platform/vkernel/i386/cpu_regs.c @@ -37,7 +37,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/cpu_regs.c,v 1.8 2007/01/11 10:08:24 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/cpu_regs.c,v 1.9 2007/01/13 21:15:57 dillon Exp $ */ #include "use_ether.h" @@ -239,6 +239,9 @@ sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) sf.sf_uc.uc_mcontext.mc_onstack = oonstack; bcopy(regs, &sf.sf_uc.uc_mcontext.mc_gs, sizeof(struct trapframe)); + /* make the size of the saved context visible to userland */ + sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); + /* Allocate and validate space for the signal handler context. */ /* XXX lwp flags */ if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack && -- 2.41.0