Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Sep 2002 17:16:10 -0400
From:      Daniel Eischen <eischen@vigrid.com>
To:        current@freebsd.org
Subject:   Longer term fix for sigreturn ABI breaking
Message-ID:  <3D98BF1A.4A58EE74@vigrid.com>

next in thread | raw e-mail | index | archive | help
At the end is a potentially longer term fix for the ABI
breakage that was introduced when the i386 mcontext_t
was changed/enlarged.

Someone other than I (Bruce?) should vet this.  It should
solve the libc_r binary compatibility problem, but it may
not fix everything.  Applications that copy ucontext_t's
around (without changing corrupting the mc_fpformat field)
will still break, but there may not be many (if any) of
those.

-- 
Dan Eischen

Index: i386/i386/machdep.c
===================================================================
RCS file: /opt/d/CVS/src/sys/i386/i386/machdep.c,v
retrieving revision 1.539
diff -u -r1.539 machdep.c
--- i386/i386/machdep.c	30 Sep 2002 07:02:22 -0000	1.539
+++ i386/i386/machdep.c	30 Sep 2002 20:42:30 -0000
@@ -680,7 +680,7 @@
 	struct proc *p = td->td_proc;
 	struct trapframe *regs;
 	const ucontext_t *ucp;
-	int cs, eflags, error, ret;
+	int cs, eflags, error;
 
 	error = copyin(uap->sigcntxp, &uc, sizeof(uc));
 	if (error != 0)
@@ -754,9 +754,15 @@
 			return (EINVAL);
 		}
 
-		ret = set_fpcontext(td, &ucp->uc_mcontext);
-		if (ret != 0)
-			return (ret);
+		/*
+		 * Intentionally ignore the error to keep binary
+		 * compatibility with applications that fiddle with
+		 * the FPU save area in the context.  The kernel
+		 * now saves the FPU state in the context, but it
+		 * gets corrupted by those applications that try
+		 * to work around the kernel NOT saving it.
+		 */
+		(void)set_fpcontext(td, &ucp->uc_mcontext);
 		bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs));
 	}
 
@@ -2109,7 +2115,7 @@
  * Set machine context.
  *
  * However, we don't set any but the user modifyable flags, and
- * we we won't touch the cs selector.
+ * we won't touch the cs selector.
  */
 int
 set_mcontext(struct thread *td, const mcontext_t *mcp)
@@ -2147,10 +2153,6 @@
 static void
 get_fpcontext(struct thread *td, mcontext_t *mcp)
 {
-#if 1	/* XXX: tmp hack to restore ability to run releng4 binaries */
-	/* For now, always store the FP state in the PCB. */
-	(void)npxgetregs(td, (union savefpu *)&td->td_pcb->pcb_save);
-#else
 #ifndef DEV_NPX
 	mcp->mc_fpformat = _MC_FPFMT_NODEV;
 	mcp->mc_ownedfp = _MC_FPOWNED_NONE;
@@ -2186,16 +2188,11 @@
 	}
 	mcp->mc_fpformat = npxformat();
 #endif
-#endif	/* tmp hack to restore ability to run releng4 binaries */
 }
 
 static int
 set_fpcontext(struct thread *td, const mcontext_t *mcp)
 {
-#if 1	/* XXX: tmp hack to restore ability to run releng4 binaries */
-	/* For now, the FP state is always stored in the PCB. */
-    	npxsetregs(td, (union savefpu *)&td->td_pcb->pcb_save);
-#else
 	union savefpu *addr;
 
 	if (mcp->mc_fpformat == _MC_FPFMT_NODEV)
@@ -2234,7 +2231,6 @@
 		 */
 	} else
 		return (EINVAL);
-#endif	/* tmp hack to restore ability to run releng4 binaries */
 	return (0);
 }

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D98BF1A.4A58EE74>