Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Sep 2002 21:58:33 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 17956 for review
Message-ID:  <200209230458.g8N4wX5U013473@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=17956

Change 17956 by peter@peter_overcee on 2002/09/22 21:57:56

	unwind more x87/sse entanglement.

Affected files ...

.. //depot/projects/hammer/sys/x86_64/include/npx.h#4 edit
.. //depot/projects/hammer/sys/x86_64/include/pcb.h#2 edit
.. //depot/projects/hammer/sys/x86_64/isa/npx.c#11 edit
.. //depot/projects/hammer/sys/x86_64/x86_64/genassym.c#7 edit
.. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#22 edit

Differences ...

==== //depot/projects/hammer/sys/x86_64/include/npx.h#4 (text+ko) ====

@@ -45,35 +45,14 @@
 #ifndef _MACHINE_NPX_H_
 #define	_MACHINE_NPX_H_
 
-/* Environment information of floating point unit */
-struct env87 {
-	long	en_cw;		/* control word (16bits) */
-	long	en_sw;		/* status word (16bits) */
-	long	en_tw;		/* tag word (16bits) */
-	long	en_fip;		/* floating point instruction pointer */
-	u_short	en_fcs;		/* floating code segment selector */
-	u_short	en_opcode;	/* opcode last executed (11 bits ) */
-	long	en_foo;		/* floating operand offset */
-	long	en_fos;		/* floating operand segment selector */
-};
-
-/* Contents of each floating point accumulator */
+/* Contents of each x87 floating point accumulator */
 struct fpacc87 {
-#ifdef dontdef /* too unportable */
-	u_long	fp_mantlo;	/* mantissa low (31:0) */
-	u_long	fp_manthi;	/* mantissa high (63:32) */
-	int	fp_exp:15;	/* exponent */
-	int	fp_sgn:1;	/* mantissa sign */
-#else
 	u_char	fp_bytes[10];
-#endif
 };
 
-/* Floating point context */
-struct save87 {
-	struct	env87 sv_env;	/* floating point control/status */
-	struct	fpacc87	sv_ac[8];	/* accumulator contents, 0-7 */
-	u_char	sv_pad0[4];	/* padding for (now unused) saved status word */
+/* Contents of each SSE extended accumulator */
+struct  xmmacc {
+	u_char	xmm_bytes[16];
 };
 
 struct  envxmm {
@@ -88,12 +67,7 @@
 	u_int32_t	en_mxcsr_mask;	/* valid bits in mxcsr */
 };
 
-/* Contents of each SSE extended accumulator */
-struct  xmmacc {
-	u_char	xmm_bytes[16];
-};
-
-struct  savexmm {
+struct  savefpu {
 	struct	envxmm	sv_env;
 	struct {
 		struct fpacc87	fp_acc;
@@ -103,11 +77,6 @@
 	u_char sv_pad[96];
 } __attribute__((aligned(16)));
 
-union	savefpu {
-	struct	save87	sv_87;
-	struct	savexmm	sv_xmm;
-};
-
 /*
  * The hardware default control word for i387's and later coprocessors is
  * 0x37F, giving:
@@ -132,10 +101,10 @@
 void	npxdrop(void);
 void	npxexit(struct thread *td);
 int	npxformat(void);
-int	npxgetregs(struct thread *td, union savefpu *addr);
+int	npxgetregs(struct thread *td, struct savefpu *addr);
 void	npxinit(u_short control);
-void	npxsave(union savefpu *addr);
-void	npxsetregs(struct thread *td, union savefpu *addr);
+void	npxsave(struct savefpu *addr);
+void	npxsetregs(struct thread *td, struct savefpu *addr);
 int	npxtrap(void);
 #endif
 

==== //depot/projects/hammer/sys/x86_64/include/pcb.h#2 (text+ko) ====

@@ -61,7 +61,7 @@
 	int     pcb_dr6;
 	int     pcb_dr7;
 
-	union	savefpu	pcb_save;
+	struct	savefpu	pcb_save;
 	u_int	pcb_flags;
 #define	FP_SOFTFP	0x01	/* process using software fltng pnt emulator */
 #define	PCB_DBREGS	0x02	/* process using debug registers */

==== //depot/projects/hammer/sys/x86_64/isa/npx.c#11 (text+ko) ====

@@ -111,15 +111,13 @@
 static	int	npx_attach(device_t dev);
 static	void	npx_identify(driver_t *driver, device_t parent);
 static	int	npx_probe(device_t dev);
-static	void	fpusave(union savefpu *);
-static	void	fpurstor(union savefpu *);
 
 int	hw_float = 1;
 SYSCTL_INT(_hw,HW_FLOATINGPT, floatingpoint,
 	CTLFLAG_RD, &hw_float, 0, 
 	"Floatingpoint instructions executed in hardware");
 
-static	union savefpu		npx_cleanstate;
+static	struct savefpu		npx_cleanstate;
 static	bool_t			npx_cleanstate_ready;
 
 /*
@@ -198,7 +196,7 @@
 	if (npx_cleanstate_ready == 0) {
 		s = intr_disable();
 		stop_emulating();
-		fpusave(&npx_cleanstate);
+		fxsave(&npx_cleanstate);
 		start_emulating();
 		npx_cleanstate_ready = 1;
 		intr_restore(s);
@@ -213,7 +211,7 @@
 npxinit(control)
 	u_short control;
 {
-	static union savefpu dummy;
+	static struct savefpu dummy;
 	register_t savecrit;
 
 	/*
@@ -541,7 +539,7 @@
 		 * instructions are broken the same as frstor, so our
 		 * treatment does not amplify the breakage.
 		 */
-		fpurstor(&pcb->pcb_save);
+		fxrstor(&pcb->pcb_save);
 	}
 	intr_restore(s);
 
@@ -573,11 +571,11 @@
  */
 void
 npxsave(addr)
-	union savefpu *addr;
+	struct savefpu *addr;
 {
 
 	stop_emulating();
-	fpusave(addr);
+	fxsave(addr);
 
 	start_emulating();
 	PCPU_SET(fpcurthread, NULL);
@@ -605,7 +603,7 @@
 int
 npxgetregs(td, addr)
 	struct thread *td;
-	union savefpu *addr;
+	struct savefpu *addr;
 {
 	register_t s;
 
@@ -619,7 +617,7 @@
 
 	s = intr_disable();
 	if (curthread == PCPU_GET(fpcurthread)) {
-		fpusave(addr);
+		fxsave(addr);
 		intr_restore(s);
 		return (_MC_FPOWNED_FPU);
 	} else {
@@ -635,13 +633,13 @@
 void
 npxsetregs(td, addr)
 	struct thread *td;
-	union savefpu *addr;
+	struct savefpu *addr;
 {
 	register_t s;
 
 	s = intr_disable();
 	if (curthread == PCPU_GET(fpcurthread)) {
-		fpurstor(addr);
+		fxrstor(addr);
 		intr_restore(s);
 	} else {
 		intr_restore(s);
@@ -649,22 +647,6 @@
 	}
 }
 
-static void
-fpusave(addr)
-	union savefpu *addr;
-{
-	
-	fxsave(addr);
-}
-
-static void
-fpurstor(addr)
-	union savefpu *addr;
-{
-
-	fxrstor(addr);
-}
-
 static device_method_t npx_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_identify,	npx_identify),

==== //depot/projects/hammer/sys/x86_64/x86_64/genassym.c#7 (text+ko) ====

@@ -136,7 +136,7 @@
 ASSYM(PCB_SPARE, offsetof(struct pcb, __pcb_spare));
 ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
 ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
-ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu));
+ASSYM(PCB_SAVEFPU_SIZE, sizeof(struct savefpu));
 ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
 
 ASSYM(PCB_SIZE, sizeof(struct pcb));

==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#22 (text+ko) ====

@@ -1544,7 +1544,7 @@
 static void
 get_fpcontext(struct thread *td, mcontext_t *mcp)
 {
-	union savefpu *addr;
+	struct savefpu *addr;
 
 	/*
 	 * XXX mc_fpstate might be misaligned, since its declaration is not
@@ -1558,14 +1558,14 @@
 	 * called, although this requires knowing too much about
 	 * npxgetregs()'s internals.
 	 */
-	addr = (union savefpu *)&mcp->mc_fpstate;
+	addr = (struct savefpu *)&mcp->mc_fpstate;
 	if (td == PCPU_GET(fpcurthread) && ((uintptr_t)(void *)addr & 0xF)) {
 		do
 			addr = (void *)((char *)addr + 4);
 		while ((uintptr_t)(void *)addr & 0xF);
 	}
 	mcp->mc_ownedfp = npxgetregs(td, addr);
-	if (addr != (union savefpu *)&mcp->mc_fpstate) {
+	if (addr != (struct savefpu *)&mcp->mc_fpstate) {
 		bcopy(addr, &mcp->mc_fpstate, sizeof(mcp->mc_fpstate));
 		bzero(&mcp->mc_spare2, sizeof(mcp->mc_spare2));
 	}
@@ -1575,12 +1575,11 @@
 static int
 set_fpcontext(struct thread *td, const mcontext_t *mcp)
 {
-	union savefpu *addr;
+	struct savefpu *addr;
 
 	if (mcp->mc_fpformat == _MC_FPFMT_NODEV)
 		return (0);
-	else if (mcp->mc_fpformat != _MC_FPFMT_387 &&
-	    mcp->mc_fpformat != _MC_FPFMT_XMM)
+	else if (mcp->mc_fpformat != _MC_FPFMT_XMM)
 		return (EINVAL);
 	else if (mcp->mc_ownedfp == _MC_FPOWNED_NONE)
 		/* We don't care what state is left in the FPU or PCB. */
@@ -1588,7 +1587,7 @@
 	else if (mcp->mc_ownedfp == _MC_FPOWNED_FPU ||
 	    mcp->mc_ownedfp == _MC_FPOWNED_PCB) {
 		/* XXX align as above. */
-		addr = (union savefpu *)&mcp->mc_fpstate;
+		addr = (struct savefpu *)&mcp->mc_fpstate;
 		if (td == PCPU_GET(fpcurthread) &&
 		    ((uintptr_t)(void *)addr & 0xF)) {
 			do

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209230458.g8N4wX5U013473>