PERFORCE change 20148 for review

Robert Watson rwatson at freebsd.org
Fri Oct 25 19:30:47 GMT 2002


http://perforce.freebsd.org/chv.cgi?CH=20148

Change 20148 by rwatson at rwatson_tislabs on 2002/10/25 12:30:43

	Integ main FreeBSD tree to TrustedBSD base tree: pick up the
	ABI fixes from Peter, which hopefully help stabilize X11
	as well as make 4.x applications work better

Affected files ...

.. //depot/projects/trustedbsd/base/lib/libc/net/getaddrinfo.c#9 integrate
.. //depot/projects/trustedbsd/base/sys/alpha/alpha/locore.s#4 integrate
.. //depot/projects/trustedbsd/base/sys/alpha/alpha/machdep.c#16 integrate
.. //depot/projects/trustedbsd/base/sys/alpha/include/md_var.h#4 integrate
.. //depot/projects/trustedbsd/base/sys/alpha/include/sigframe.h#3 integrate
.. //depot/projects/trustedbsd/base/sys/alpha/include/signal.h#4 integrate
.. //depot/projects/trustedbsd/base/sys/alpha/include/ucontext.h#3 integrate
.. //depot/projects/trustedbsd/base/sys/alpha/osf1/osf1_signal.c#8 integrate
.. //depot/projects/trustedbsd/base/sys/conf/options#26 integrate
.. //depot/projects/trustedbsd/base/sys/geom/geom.h#14 integrate
.. //depot/projects/trustedbsd/base/sys/geom/geom_dev.c#16 integrate
.. //depot/projects/trustedbsd/base/sys/i386/i386/genassym.c#9 integrate
.. //depot/projects/trustedbsd/base/sys/i386/i386/locore.s#6 integrate
.. //depot/projects/trustedbsd/base/sys/i386/i386/machdep.c#22 integrate
.. //depot/projects/trustedbsd/base/sys/i386/include/md_var.h#10 integrate
.. //depot/projects/trustedbsd/base/sys/i386/include/sigframe.h#3 integrate
.. //depot/projects/trustedbsd/base/sys/i386/include/signal.h#5 integrate
.. //depot/projects/trustedbsd/base/sys/i386/include/ucontext.h#5 integrate
.. //depot/projects/trustedbsd/base/sys/i386/isa/npx.c#13 integrate
.. //depot/projects/trustedbsd/base/sys/ia64/ia64/machdep.c#24 integrate
.. //depot/projects/trustedbsd/base/sys/ia64/include/sigframe.h#2 integrate
.. //depot/projects/trustedbsd/base/sys/ia64/include/signal.h#6 integrate
.. //depot/projects/trustedbsd/base/sys/kern/init_sysent.c#22 integrate
.. //depot/projects/trustedbsd/base/sys/kern/kern_sig.c#24 integrate
.. //depot/projects/trustedbsd/base/sys/kern/syscalls.c#22 integrate
.. //depot/projects/trustedbsd/base/sys/kern/syscalls.master#22 integrate
.. //depot/projects/trustedbsd/base/sys/kern/vfs_mount.c#11 integrate
.. //depot/projects/trustedbsd/base/sys/net/if_tun.c#11 integrate
.. //depot/projects/trustedbsd/base/sys/powerpc/include/signal.h#3 integrate
.. //depot/projects/trustedbsd/base/sys/powerpc/powerpc/machdep.c#14 integrate
.. //depot/projects/trustedbsd/base/sys/sparc64/include/signal.h#4 integrate
.. //depot/projects/trustedbsd/base/sys/sparc64/include/tick.h#3 integrate
.. //depot/projects/trustedbsd/base/sys/sparc64/sparc64/iommu.c#7 integrate
.. //depot/projects/trustedbsd/base/sys/sparc64/sparc64/machdep.c#24 integrate
.. //depot/projects/trustedbsd/base/sys/sparc64/sparc64/tick.c#7 integrate
.. //depot/projects/trustedbsd/base/sys/sys/_sigset.h#3 integrate
.. //depot/projects/trustedbsd/base/sys/sys/signal.h#8 integrate
.. //depot/projects/trustedbsd/base/sys/sys/signalvar.h#10 integrate
.. //depot/projects/trustedbsd/base/sys/sys/syscall.h#23 integrate
.. //depot/projects/trustedbsd/base/sys/sys/syscall.mk#23 integrate
.. //depot/projects/trustedbsd/base/sys/sys/syscallsubr.h#2 integrate
.. //depot/projects/trustedbsd/base/sys/sys/sysproto.h#24 integrate
.. //depot/projects/trustedbsd/base/sys/sys/ucontext.h#5 integrate
.. //depot/projects/trustedbsd/base/usr.sbin/Makefile#14 integrate

Differences ...

==== //depot/projects/trustedbsd/base/lib/libc/net/getaddrinfo.c#9 (text+ko) ====

@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/net/getaddrinfo.c,v 1.35 2002/10/25 16:24:28 ume Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/net/getaddrinfo.c,v 1.36 2002/10/25 17:07:02 ume Exp $");
 
 #include "namespace.h"
 #include <sys/types.h>
@@ -217,14 +217,14 @@
 static const struct afd *find_afd(int);
 static int addrconfig(struct addrinfo *);
 #ifdef INET6
-static int ip6_str2scopeid(char *, struct sockaddr_in6 *);
+static int ip6_str2scopeid(char *, struct sockaddr_in6 *, u_int32_t *);
 #endif
 
 static struct addrinfo *getanswer(const querybuf *, int, const char *, int,
 	const struct addrinfo *);
+static int _dns_getaddrinfo(void *, void *, va_list);
 static void _sethtent(void);
 static void _endhtent(void);
-static int _dns_getaddrinfo(void *, void *, va_list);
 static struct addrinfo *_gethtent(const char *, const struct addrinfo *);
 static int _files_getaddrinfo(void *, void *, va_list);
 #ifdef YP
@@ -346,8 +346,9 @@
 	if (*p == '\0')
 		return NO;
 	ep = NULL;
+	errno = 0;
 	(void)strtoul(p, &ep, 10);
-	if (ep && *ep == '\0')
+	if (errno == 0 && ep && *ep == '\0')
 		return YES;
 	else
 		return NO;
@@ -822,13 +823,13 @@
 
 	error = explore_numeric(pai, addr, servname, res);
 	if (error == 0) {
-		int scopeid;
+		u_int32_t scopeid;
 
 		for (cur = *res; cur; cur = cur->ai_next) {
 			if (cur->ai_family != AF_INET6)
 				continue;
 			sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr;
-			if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) {
+			if (ip6_str2scopeid(scope, sin6, &scopeid) == -1) {
 				free(hostname2);
 				return(EAI_NODATA); /* XXX: is return OK? */
 			}
@@ -1080,14 +1081,17 @@
 #ifdef INET6
 /* convert a string to a scope identifier. XXX: IPv6 specific */
 static int
-ip6_str2scopeid(scope, sin6)
+ip6_str2scopeid(scope, sin6, scopeid)
 	char *scope;
 	struct sockaddr_in6 *sin6;
+	u_int32_t *scopeid;
 {
-	int scopeid;
-	struct in6_addr *a6 = &sin6->sin6_addr;
+	u_long lscopeid;
+	struct in6_addr *a6;
 	char *ep;
 
+	a6 = &sin6->sin6_addr;
+
 	/* empty scopeid portion is invalid */
 	if (*scope == '\0')
 		return -1;
@@ -1098,10 +1102,10 @@
 		 * and interfaces, so we simply use interface indices for
 		 * like-local scopes.
 		 */
-		scopeid = if_nametoindex(scope);
-		if (scopeid == 0)
+		*scopeid = if_nametoindex(scope);
+		if (*scopeid == 0)
 			goto trynumeric;
-		return(scopeid);
+		return 0;
 	}
 
 	/* still unclear about literal, allow numeric only - placeholder */
@@ -1114,9 +1118,11 @@
 
 	/* try to convert to a numeric id as a last resort */
   trynumeric:
-	scopeid = (int)strtoul(scope, &ep, 10);
-	if (*ep == '\0')
-		return scopeid;
+	errno = 0;
+	lscopeid = strtoul(scope, &ep, 10);
+	*scopeid = (u_int32_t)(lscopeid & 0xffffffffUL);
+	if (errno == 0 && ep && *ep == '\0' && *scopeid == lscopeid)
+		return 0;
 	else
 		return -1;
 }
@@ -1447,6 +1453,7 @@
 		q.answer = buf->buf;
 		q.anslen = sizeof(buf->buf);
 		q.next = &q2;
+		q2.name = name;
 		q2.qclass = C_IN;
 		q2.qtype = T_A;
 		q2.answer = buf2->buf;

==== //depot/projects/trustedbsd/base/sys/alpha/alpha/locore.s#4 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/alpha/locore.s,v 1.21 2002/02/07 20:58:42 julian Exp $
+ * $FreeBSD: src/sys/alpha/alpha/locore.s,v 1.22 2002/10/25 19:10:55 peter Exp $
  */
 
 /*
@@ -53,6 +53,8 @@
  * rights to redistribute these changes.
  */
 
+#include "opt_compat.h"
+
 #include <machine/asm.h>
 #include <sys/syscall.h>
 #include <assym.s>
@@ -190,15 +192,55 @@
 	jsr	ra, (t12)		/* call the signal handler (t12==pv) */
 	ldq	a0, 0(sp)		/* get the sigcontext pointer */
 	lda	sp, 16(sp)
-	CALLSYS_NOERROR(sigreturn)	/* and call sigreturn() with it. */
+	ldiq	v0, SYS_sigreturn
+	call_pal PAL_OSF1_callsys	/* and call sigreturn() with it. */
 	mov	v0, a0			/* if that failed, get error code */
-	CALLSYS_NOERROR(exit)		/* and call exit() with it. */
-XNESTED(esigcode,0)
+	ldiq	v0, SYS_exit
+	call_pal PAL_OSF1_callsys	/* and call exit() with it. */
 	END(sigcode)
 
+#ifdef COMPAT_43
+NESTED(osigcode,0,0,ra,0,0)
+	lda	sp, -16(sp)		/* save the sigcontext pointer */
+	stq	a2, 0(sp)
+	jsr	ra, (t12)		/* call the signal handler (t12==pv) */
+	ldq	a0, 0(sp)		/* get the sigcontext pointer */
+	lda	sp, 16(sp)
+	ldiq	v0, 103			/* Old 3.x SYS_sigreturn */
+	call_pal PAL_OSF1_callsys	/* and call sigreturn() with it. */
+	mov	v0, a0			/* if that failed, get error code */
+	ldiq	v0, SYS_exit
+	call_pal PAL_OSF1_callsys	/* and call exit() with it. */
+	END(osigcode)
+#endif
+
+#ifdef COMPAT_FREEBSD4
+NESTED(freebsd4_sigcode,0,0,ra,0,0)
+	lda	sp, -16(sp)		/* save the sigcontext pointer */
+	stq	a2, 0(sp)
+	jsr	ra, (t12)		/* call the signal handler (t12==pv) */
+	ldq	a0, 0(sp)		/* get the sigcontext pointer */
+	lda	sp, 16(sp)
+	ldiq	v0, 344			/* Old 4.x SYS_sigreturn */
+	call_pal PAL_OSF1_callsys	/* and call sigreturn() with it. */
+	mov	v0, a0			/* if that failed, get error code */
+	ldiq	v0, SYS_exit
+	call_pal PAL_OSF1_callsys	/* and call exit() with it. */
+	END(freebsd4_sigcode)
+#endif
+EXPORT(esigcode)			/* end of all sigcode */
+	
 	.data
-	EXPORT(szsigcode)
-	.quad	esigcode-sigcode
+EXPORT(szsigcode)
+	.long	esigcode-sigcode
+#ifdef COMPAT_43
+EXPORT(szosigcode)
+	.long	esigcode-osigcode
+#endif
+#ifdef COMPAT_FREEBSD4
+EXPORT(szfreebsd4_sigcode)
+	.long	esigcode-freebsd4_sigcode
+#endif
 	.text
 	
 /**************************************************************************/

==== //depot/projects/trustedbsd/base/sys/alpha/alpha/machdep.c#16 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/alpha/machdep.c,v 1.186 2002/09/20 17:50:50 phk Exp $
+ * $FreeBSD: src/sys/alpha/alpha/machdep.c,v 1.187 2002/10/25 19:10:55 peter Exp $
  */
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -232,6 +232,10 @@
 #ifdef COMPAT_43
 void osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code);
 #endif
+#ifdef COMPAT_FREEBSD4
+static void freebsd4_sendsig(sig_t catcher, int sig, sigset_t *mask,
+    u_long code);
+#endif
 
 static void identifycpu(void);
 
@@ -1250,7 +1254,7 @@
 	/*
 	 * Set up the registers to return to sigcode.
 	 */
-	frame->tf_regs[FRAME_PC] = PS_STRINGS - (esigcode - sigcode);
+	frame->tf_regs[FRAME_PC] = PS_STRINGS - szosigcode;
 	frame->tf_regs[FRAME_A0] = sig;
 	frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
 	PROC_LOCK(p);
@@ -1264,6 +1268,121 @@
 }
 #endif
 
+#ifdef COMPAT_FREEBSD4
+static void
+freebsd4_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
+{
+	struct proc *p;
+	struct thread *td;
+	struct trapframe *frame;
+	struct sigacts *psp;
+	struct sigframe4 sf, *sfp;
+	int oonstack, rndfsize;
+
+	td = curthread;
+	p = td->td_proc;
+	PROC_LOCK_ASSERT(p, MA_OWNED);
+	psp = p->p_sigacts;
+
+	frame = td->td_frame;
+	oonstack = sigonstack(alpha_pal_rdusp());
+	rndfsize = ((sizeof(sf) + 15) / 16) * 16;
+
+	/* save user context */
+	bzero(&sf, sizeof(sf));
+	sf.sf_uc.uc_sigmask = *mask;
+	sf.sf_uc.uc_stack = p->p_sigstk;
+	sf.sf_uc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK)
+	    ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE;
+	sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0;
+
+	fill_regs(td, (struct reg *)sf.sf_uc.uc_mcontext.mc_regs);
+	sf.sf_uc.uc_mcontext.mc_regs[R_SP] = alpha_pal_rdusp();
+	sf.sf_uc.uc_mcontext.mc_regs[R_ZERO] = 0xACEDBADE;   /* magic number */
+	sf.sf_uc.uc_mcontext.mc_regs[R_PS] = frame->tf_regs[FRAME_PS];
+	sf.sf_uc.uc_mcontext.mc_regs[R_PC] = frame->tf_regs[FRAME_PC];
+	sf.sf_uc.uc_mcontext.mc_regs[R_TRAPARG_A0] =
+	    frame->tf_regs[FRAME_TRAPARG_A0];
+	sf.sf_uc.uc_mcontext.mc_regs[R_TRAPARG_A1] =
+	    frame->tf_regs[FRAME_TRAPARG_A1];
+	sf.sf_uc.uc_mcontext.mc_regs[R_TRAPARG_A2] =
+	    frame->tf_regs[FRAME_TRAPARG_A2];
+
+	/*
+	 * Allocate and validate space for the signal handler
+	 * context. Note that if the stack is in P0 space, the
+	 * call to grow() is a nop, and the useracc() check
+	 * will fail if the process has not already allocated
+	 * the space with a `brk'.
+	 */
+	if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack &&
+	    SIGISMEMBER(psp->ps_sigonstack, sig)) {
+		sfp = (struct sigframe4 *)((caddr_t)p->p_sigstk.ss_sp +
+		    p->p_sigstk.ss_size - rndfsize);
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+		p->p_sigstk.ss_flags |= SS_ONSTACK;
+#endif
+	} else
+		sfp = (struct sigframe4 *)(alpha_pal_rdusp() - rndfsize);
+	PROC_UNLOCK(p);
+
+	/* save the floating-point state, if necessary, then copy it. */
+	alpha_fpstate_save(td, 1);
+	sf.sf_uc.uc_mcontext.mc_ownedfp = td->td_md.md_flags & MDTD_FPUSED;
+	bcopy(&td->td_pcb->pcb_fp,
+	      (struct fpreg *)sf.sf_uc.uc_mcontext.mc_fpregs,
+	      sizeof(struct fpreg));
+	sf.sf_uc.uc_mcontext.mc_fp_control = td->td_pcb->pcb_fp_control;
+
+#ifdef COMPAT_OSF1
+	/*
+	 * XXX Create an OSF/1-style sigcontext and associated goo.
+	 */
+#endif
+
+	/*
+	 * copy the frame out to userland.
+	 */
+	if (copyout((caddr_t)&sf, (caddr_t)sfp, sizeof(sf)) != 0) {
+		/*
+		 * Process has trashed its stack; give it an illegal
+		 * instruction to halt it in its tracks.
+		 */
+		PROC_LOCK(p);
+		SIGACTION(p, SIGILL) = SIG_DFL;
+		SIGDELSET(p->p_sigignore, SIGILL);
+		SIGDELSET(p->p_sigcatch, SIGILL);
+		SIGDELSET(p->p_sigmask, SIGILL);
+		psignal(p, SIGILL);
+		return;
+	}
+
+	/*
+	 * Set up the registers to return to sigcode.
+	 */
+	frame->tf_regs[FRAME_PC] = PS_STRINGS - szfreebsd4_sigcode;
+	frame->tf_regs[FRAME_A0] = sig;
+	PROC_LOCK(p);
+	if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) {
+		frame->tf_regs[FRAME_A1] = (u_int64_t)&(sfp->sf_si);
+
+		/* Fill in POSIX parts */
+		sf.sf_si.si_signo = sig;
+		sf.sf_si.si_code = code;
+		sf.sf_si.si_addr = (void*)frame->tf_regs[FRAME_TRAPARG_A0];
+		sf.sf_si.si_pid = p->p_pid;
+		sf.sf_si.si_uid = p->p_ucred->cr_uid;
+	}
+	else
+		frame->tf_regs[FRAME_A1] = code;
+
+	frame->tf_regs[FRAME_A2] = (u_int64_t)&(sfp->sf_uc);
+	frame->tf_regs[FRAME_T12] = (u_int64_t)catcher;	/* t12 is pv */
+	frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
+	alpha_pal_wrusp((unsigned long)sfp);
+}
+#endif	/* COMPAT_FREEBSD4 */
+
 void
 sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
 {
@@ -1278,6 +1397,12 @@
 	p = td->td_proc;
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 	psp = p->p_sigacts;
+#ifdef COMPAT_FREEBSD4
+	if (SIGISMEMBER(psp->ps_freebsd4, sig)) {
+		freebsd4_sendsig(catcher, sig, mask, code);
+		return;
+	}
+#endif
 #ifdef COMPAT_43
 	if (SIGISMEMBER(psp->ps_osigset, sig)) {
 		osendsig(catcher, sig, mask, code);
@@ -1377,7 +1502,7 @@
 	/*
 	 * Set up the registers to return to sigcode.
 	 */
-	frame->tf_regs[FRAME_PC] = PS_STRINGS - (esigcode - sigcode);
+	frame->tf_regs[FRAME_PC] = PS_STRINGS - szsigcode;
 	frame->tf_regs[FRAME_A0] = sig;
 	PROC_LOCK(p);
 	if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) {
@@ -1419,13 +1544,13 @@
  *
  * MPSAFE
  */
+#ifdef COMPAT_43
 int
 osigreturn(struct thread *td,
 	struct osigreturn_args /* {
 		struct osigcontext *sigcntxp;
 	} */ *uap)
 {
-#ifdef COMPAT_43
 	struct osigcontext *scp, ksc;
 	struct proc *p = td->td_proc;
 
@@ -1479,10 +1604,82 @@
 	    sizeof(struct fpreg));
 	td->td_pcb->pcb_fp_control = ksc.sc_fp_control;
 	return (EJUSTRETURN);
-#else /* !COMPAT_43 */
-	return (ENOSYS);
+}
 #endif /* COMPAT_43 */
+
+#ifdef COMPAT_FREEBSD4
+/*
+ * MPSAFE
+ */
+int
+freebsd4_sigreturn(struct thread *td,
+	struct freebsd4_sigreturn_args /* {
+		const struct ucontext4 *sigcntxp;
+	} */ *uap)
+{
+	struct ucontext4 uc;
+	const struct ucontext4 *ucp;
+	struct pcb *pcb;
+	unsigned long val;
+	struct proc *p;
+	int error;
+
+	ucp = uap->sigcntxp;
+	pcb = td->td_pcb;
+	p = td->td_proc;
+
+	/*
+	 * Fetch the entire context structure at once for speed.
+	 * Note that struct osigcontext is smaller than a ucontext_t,
+	 * so even if copyin() faults, we may have actually gotten a complete
+	 * struct osigcontext.
+	 */
+	error = copyin(ucp, &uc, sizeof(ucontext_t));
+	if (error != 0) {
+#ifdef COMPAT_43
+		if (((struct osigcontext*)&uc)->sc_regs[R_ZERO] == 0xACEDBADE)
+			return osigreturn(td, (struct osigreturn_args *)uap);
+#endif
+		return (error);
+	}
+
+#ifdef COMPAT_43
+	 if (((struct osigcontext*)&uc)->sc_regs[R_ZERO] == 0xACEDBADE)
+		  return osigreturn(td, (struct osigreturn_args *)uap);
+#endif
+
+	/*
+	 * Restore the user-supplied information
+	 */
+	set_regs(td, (struct reg *)uc.uc_mcontext.mc_regs);
+	val = (uc.uc_mcontext.mc_regs[R_PS] | ALPHA_PSL_USERSET) &
+	    ~ALPHA_PSL_USERCLR;
+	td->td_frame->tf_regs[FRAME_PS] = val;
+	td->td_frame->tf_regs[FRAME_PC] = uc.uc_mcontext.mc_regs[R_PC];
+	td->td_frame->tf_regs[FRAME_FLAGS] = 0; /* full restore */
+	alpha_pal_wrusp(uc.uc_mcontext.mc_regs[R_SP]);
+
+	PROC_LOCK(p);
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+	if (uc.uc_mcontext.mc_onstack & 1)
+		p->p_sigstk.ss_flags |= SS_ONSTACK;
+	else
+		p->p_sigstk.ss_flags &= ~SS_ONSTACK;
+#endif
+
+	p->p_sigmask = uc.uc_sigmask;
+	SIG_CANTMASK(p->p_sigmask);
+	signotify(p);
+	PROC_UNLOCK(p);
+
+	/* XXX ksc.sc_ownedfp ? */
+	alpha_fpstate_drop(td);
+	bcopy((struct fpreg *)uc.uc_mcontext.mc_fpregs,
+	      &td->td_pcb->pcb_fp, sizeof(struct fpreg));
+	td->td_pcb->pcb_fp_control = uc.uc_mcontext.mc_fp_control;
+	return (EJUSTRETURN);
 }
+#endif /* COMPAT_FREEBSD4 */
 
 /*
  * MPSAFE
@@ -1498,6 +1695,7 @@
 	struct pcb *pcb;
 	unsigned long val;
 	struct proc *p;
+	int error;
 
 	ucp = uap->sigcntxp;
 	pcb = td->td_pcb;
@@ -1507,21 +1705,22 @@
 	if (sigdebug & SDB_FOLLOW)
 	    printf("sigreturn: pid %d, scp %p\n", p->p_pid, ucp);
 #endif
-
 	/*
 	 * Fetch the entire context structure at once for speed.
 	 * Note that struct osigcontext is smaller than a ucontext_t,
 	 * so even if copyin() faults, we may have actually gotten a complete
 	 * struct osigcontext.
+	 * XXX we'll *still* be getting osigcontext's here due to longjmp(3)
+	 * brain damage.
 	 */
-	if (copyin(ucp, &uc, sizeof(ucontext_t))) {
+	error = copyin(ucp, &uc, sizeof(ucontext_t));
+	if (error != 0) {
 #ifdef COMPAT_43
 		if (((struct osigcontext*)&uc)->sc_regs[R_ZERO] == 0xACEDBADE)
 			return osigreturn(td, (struct osigreturn_args *)uap);
 #endif
-		return (EFAULT);
+		return (error);
 	}
-
 #ifdef COMPAT_43
 	 if (((struct osigcontext*)&uc)->sc_regs[R_ZERO] == 0xACEDBADE)
 		  return osigreturn(td, (struct osigreturn_args *)uap);

==== //depot/projects/trustedbsd/base/sys/alpha/include/md_var.h#4 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/include/md_var.h,v 1.20 2002/08/30 04:04:34 peter Exp $
+ * $FreeBSD: src/sys/alpha/include/md_var.h,v 1.21 2002/10/25 19:10:55 peter Exp $
  */
 
 #ifndef _MACHINE_MD_VAR_H_
@@ -36,6 +36,12 @@
 extern	char	sigcode[];
 extern	char	esigcode[];
 extern	int	szsigcode;
+#ifdef COMPAT_43
+extern	int	szosigcode;
+#endif
+#ifdef COMPAT_FREEBSD4
+extern	int	szfreebsd4_sigcode;
+#endif
 extern	long	Maxmem;
 extern	int	busdma_swi_pending;
 

==== //depot/projects/trustedbsd/base/sys/alpha/include/sigframe.h#3 (text+ko) ====

@@ -25,16 +25,18 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/include/sigframe.h,v 1.3 2002/02/17 17:40:25 deischen Exp $
+ * $FreeBSD: src/sys/alpha/include/sigframe.h,v 1.4 2002/10/25 19:10:55 peter Exp $
  */
 
 #ifndef _MACHINE_SIGFRAME_H_
 #define _MACHINE_SIGFRAME_H_ 1
 
-#ifdef _KERNEL
-struct osigframe {
-	struct osigcontext	sf_sc;
-	osiginfo_t		sf_si;
+#if defined(_KERNEL) && defined(COMPAT_FREEBSD4)
+/* FreeBSD 4.x */
+struct sigframe4 {
+	unsigned long		__spare__;
+	struct ucontext4	sf_uc;
+	siginfo_t		sf_si;
 };
 #endif
 

==== //depot/projects/trustedbsd/base/sys/alpha/include/signal.h#4 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/alpha/include/signal.h,v 1.9 2002/10/13 00:31:46 mike Exp $ */
+/* $FreeBSD: src/sys/alpha/include/signal.h,v 1.10 2002/10/25 19:10:55 peter Exp $ */
 /* From: NetBSD: signal.h,v 1.3 1997/04/06 08:47:43 cgd Exp */
 
 /*
@@ -47,7 +47,7 @@
 /*
  * Only the kernel should need these old type definitions.
  */
-#ifdef _KERNEL
+#if defined(_KERNEL) && defined(COMPAT_43)
 /*
  * Information pushed on stack when a signal is delivered.
  * This is used by the kernel to restore state following
@@ -58,8 +58,6 @@
  * Note that sc_regs[] and sc_fpregs[]+sc_fpcr are inline
  * representations of 'struct reg' and 'struct fpreg', respectively.
  */
-typedef unsigned int osigset_t;
-
 struct  osigcontext {
 	long	sc_onstack;             /* sigstack state to restore */
 	long	sc_mask;                /* signal mask to restore */

==== //depot/projects/trustedbsd/base/sys/alpha/include/ucontext.h#3 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/include/ucontext.h,v 1.4 2002/01/10 02:36:30 deischen Exp $
+ * $FreeBSD: src/sys/alpha/include/ucontext.h,v 1.5 2002/10/25 19:10:55 peter Exp $
  */
 
 #ifndef _MACHINE_UCONTEXT_H_
@@ -50,4 +50,16 @@
 	long	__spare__[6];
 } mcontext_t;
 
+#if defined(_KERNEL) && defined(COMPAT_FREEBSD4)
+struct mcontext4 {
+	long	mc_onstack;		/* XXX - sigcontext compat. */
+	unsigned long mc_regs[37];
+	unsigned long mc_fpregs[32];
+	unsigned long mc_fpcr;
+	unsigned long mc_fp_control;
+	long	mc_ownedfp;
+	long	__spare__[7];
+};
+#endif
+
 #endif /* !_MACHINE_UCONTEXT_H_ */

==== //depot/projects/trustedbsd/base/sys/alpha/osf1/osf1_signal.c#8 (text+ko) ====

@@ -30,9 +30,14 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/osf1/osf1_signal.c,v 1.22 2002/10/01 17:15:46 jmallett Exp $
+ * $FreeBSD: src/sys/alpha/osf1/osf1_signal.c,v 1.23 2002/10/25 19:10:55 peter Exp $
  */
 
+#include "opt_compat.h"
+#ifndef COMPAT_43
+#error "COMPAT_OSF1 requires COMPAT_43"
+#endif
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/sysproto.h>
@@ -101,7 +106,6 @@
 #define	osf1_sigismember(s, n)	(*(s) & sigmask(n))
 #define	osf1_sigaddset(s, n)	(*(s) |= sigmask(n))
 
-
 void
 osf1_to_bsd_sigset(oss, bss)
 	const osf1_sigset_t *oss;
@@ -747,9 +751,6 @@
 	return (EJUSTRETURN);
 }
 
-extern int
-osigstack(struct thread *td, struct osf1_osigstack_args *uap);
-
 int
 osf1_osigstack(td, uap)
 	register struct thread *td;
@@ -761,5 +762,5 @@
 
 /*	uprintf("osf1_osigstack: oss = %p, nss = %p",uap->oss, uap->nss);
 	uprintf(" stack ptr = %p\n",p->p_sigacts->ps_sigstk.ss_sp);*/
-	return(osigstack(td, uap));
+	return(osigstack(td, (struct osigstack_args *)uap));
 }

==== //depot/projects/trustedbsd/base/sys/conf/options#26 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/options,v 1.361 2002/10/24 17:21:40 rwatson Exp $
+# $FreeBSD: src/sys/conf/options,v 1.362 2002/10/25 19:10:55 peter Exp $
 #
 #        On the handling of kernel options
 #
@@ -77,6 +77,7 @@
 COMPAT_43	opt_compat.h
 COMPAT_FREEBSD4	opt_compat.h
 COMPAT_SUNOS	opt_compat.h
+NO_COMPAT_FREEBSD4	opt_compat.h
 COMPILING_LINT	opt_global.h
 CY_PCI_FASTINTR
 CONSPEED	opt_comconsole.h

==== //depot/projects/trustedbsd/base/sys/geom/geom.h#14 (text+ko) ====

@@ -32,7 +32,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/geom/geom.h,v 1.34 2002/10/20 19:18:06 phk Exp $
+ * $FreeBSD: src/sys/geom/geom.h,v 1.35 2002/10/25 18:42:42 phk Exp $
  */
 
 #ifndef _GEOM_GEOM_H_
@@ -192,6 +192,9 @@
 	} u;
 };
 
+/* geom_dev.c */
+int g_dev_print(void);
+
 /* geom_dump.c */
 void g_hexdump(void *ptr, int length);
 void g_trace(int level, char *, ...);

==== //depot/projects/trustedbsd/base/sys/geom/geom_dev.c#16 (text+ko) ====

@@ -32,7 +32,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/geom/geom_dev.c,v 1.29 2002/10/20 20:28:24 phk Exp $
+ * $FreeBSD: src/sys/geom/geom_dev.c,v 1.31 2002/10/25 18:42:42 phk Exp $
  */
 
 #include <sys/param.h>
@@ -87,6 +87,20 @@
 	G_CLASS_INITIALIZER
 };
 
+int
+g_dev_print(void)
+{
+	struct g_geom *gp;
+
+	if (LIST_EMPTY(&g_dev_class.geom))
+		return (0);
+	printf("List of GEOM disk devices:\n  ");
+	LIST_FOREACH(gp, &g_dev_class.geom, geom)
+		printf(" %s", gp->name);
+	printf("\n");
+	return (1);
+}
+
 static void
 g_dev_clone(void *arg __unused, char *name, int namelen __unused, dev_t *dev)
 {
@@ -95,7 +109,6 @@
 	if (*dev != NODEV)
 		return;
 
-	g_trace(G_T_TOPOLOGY, "g_dev_clone(%s)", name);
 	g_waitidle();
 
 	/* XXX: can I drop Giant here ??? */

==== //depot/projects/trustedbsd/base/sys/i386/i386/genassym.c#9 (text+ko) ====

@@ -34,9 +34,10 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)genassym.c	5.11 (Berkeley) 5/10/91
- * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.129 2002/09/16 19:25:08 mini Exp $
+ * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.130 2002/10/25 19:10:56 peter Exp $
  */
 
+#include "opt_compat.h"
 #include "opt_kstack_pages.h"
 
 #include <sys/param.h>
@@ -151,12 +152,20 @@
 ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
 ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags));
 ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
+#ifdef COMPAT_43
 ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc));
+#endif
 ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
+#ifdef COMPAT_43
 ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps));
 ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs));
 ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs));
 ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno));
+#endif
+#ifdef COMPAT_FREEBSD4
+ASSYM(UC4_EFLAGS, offsetof(struct ucontext4, uc_mcontext.mc_eflags));
+ASSYM(UC4_GS, offsetof(struct ucontext4, uc_mcontext.mc_gs));
+#endif
 ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags));
 ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs));
 ASSYM(ENOENT, ENOENT);

==== //depot/projects/trustedbsd/base/sys/i386/i386/locore.s#6 (text+ko) ====

@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)locore.s	7.3 (Berkeley) 5/13/91
- * $FreeBSD: src/sys/i386/i386/locore.s,v 1.159 2002/09/17 01:48:57 peter Exp $
+ * $FreeBSD: src/sys/i386/i386/locore.s,v 1.160 2002/10/25 19:10:56 peter Exp $
  *
  *		originally from: locore.s, by William F. Jolitz
  *
@@ -406,6 +406,22 @@
 	int	$0x80			/* enter kernel with args */
 0:	jmp	0b
 
+#ifdef COMPAT_FREEBSD4
+	ALIGN_TEXT
+freebsd4_sigcode:
+	call	*SIGF_HANDLER(%esp)	/* call signal handler */
+	lea	SIGF_UC(%esp),%eax	/* get ucontext_t */
+	pushl	%eax
+	testl	$PSL_VM,UC4_EFLAGS(%eax)
+	jne	9f
+	movl	UC4_GS(%eax),%gs	/* restore %gs */
+9:
+	movl	$344,%eax		/* 4.x SYS_sigreturn */
+	pushl	%eax			/* junk to fake return addr. */
+	int	$0x80			/* enter kernel with args */
+0:	jmp	0b
+#endif
+
 #ifdef COMPAT_43
 	ALIGN_TEXT
 osigcode:
@@ -416,7 +432,7 @@
 	jne	9f
 	movl	SC_GS(%eax),%gs		/* restore %gs */
 9:
-	movl	$SYS_osigreturn,%eax
+	movl	$103,%eax		/* 3.x SYS_sigreturn */
 	pushl	%eax			/* junk to fake return addr. */
 	int	$0x80			/* enter kernel with args */
 0:	jmp	0b
@@ -426,10 +442,16 @@
 esigcode:
 
 	.data
-	.globl	szsigcode, szosigcode
+	.globl	szsigcode
 szsigcode:
 	.long	esigcode-sigcode
+#ifdef COMPAT_FREEBSD4
+	.globl	szfreebsd4_sigcode
+szfreebsd4_sigcode:
+	.long	esigcode-freebsd4_sigcode
+#endif
 #ifdef COMPAT_43
+	.globl	szosigcode
 szosigcode:
 	.long	esigcode-osigcode
 #endif

==== //depot/projects/trustedbsd/base/sys/i386/i386/machdep.c#22 (text+ko) ====

@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)machdep.c	7.4 (Berkeley) 6/3/91
- * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.543 2002/10/20 20:48:56 phk Exp $
+ * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.545 2002/10/25 19:10:56 peter Exp $
  */
 
 #include "opt_atalk.h"
@@ -165,6 +165,10 @@
 #ifdef COMPAT_43
 static void osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code);
 #endif
+#ifdef COMPAT_FREEBSD4
+static void freebsd4_sendsig(sig_t catcher, int sig, sigset_t *mask,
+    u_long code);
+#endif
 
 static int
 sysctl_hw_physmem(SYSCTL_HANDLER_ARGS)
@@ -286,8 +290,7 @@
 	sigset_t *mask;
 	u_long code;
 {
-	struct osigframe sf;
-	struct osigframe *fp;
+	struct osigframe sf, *fp;
 	struct proc *p;
 	struct thread *td;
 	struct sigacts *psp;
@@ -408,6 +411,129 @@
 }
 #endif /* COMPAT_43 */
 
+#ifdef COMPAT_FREEBSD4
+static void
+freebsd4_sendsig(catcher, sig, mask, code)
+	sig_t catcher;
+	int sig;
+	sigset_t *mask;
+	u_long code;
+{
+	struct sigframe4 sf, *sfp;
+	struct proc *p;
+	struct thread *td;
+	struct sigacts *psp;
+	struct trapframe *regs;
+	int oonstack;
+
+	td = curthread;
+	p = td->td_proc;
+	PROC_LOCK_ASSERT(p, MA_OWNED);
+	psp = p->p_sigacts;
+	regs = td->td_frame;
+	oonstack = sigonstack(regs->tf_esp);
+
+	/* Save user context. */
+	bzero(&sf, sizeof(sf));
+	sf.sf_uc.uc_sigmask = *mask;
+	sf.sf_uc.uc_stack = p->p_sigstk;
+	sf.sf_uc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK)
+	    ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE;
+	sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0;
+	sf.sf_uc.uc_mcontext.mc_gs = rgs();
+	bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs));
+
+	/* Allocate space for the signal handler context. */
+	if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack &&
+	    SIGISMEMBER(psp->ps_sigonstack, sig)) {
+		sfp = (struct sigframe4 *)(p->p_sigstk.ss_sp +
+		    p->p_sigstk.ss_size - sizeof(struct sigframe4));
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+		p->p_sigstk.ss_flags |= SS_ONSTACK;
+#endif
+	} else
+		sfp = (struct sigframe4 *)regs->tf_esp - 1;
+	PROC_UNLOCK(p);
+
+	/* Translate the signal if appropriate. */
+	if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize)
+		sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
+
+	/* Build the argument list for the signal handler. */
+	sf.sf_signum = sig;
+	sf.sf_ucontext = (register_t)&sfp->sf_uc;
+	PROC_LOCK(p);
+	if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) {
+		/* Signal handler installed with SA_SIGINFO. */
+		sf.sf_siginfo = (register_t)&sfp->sf_si;
+		sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher;
+
+		/* Fill in POSIX parts */
+		sf.sf_si.si_signo = sig;
+		sf.sf_si.si_code = code;
+		sf.sf_si.si_addr = (void *)regs->tf_err;
+		sf.sf_si.si_pid = p->p_pid;
+		sf.sf_si.si_uid = p->p_ucred->cr_uid;
+	} else {
+		/* Old FreeBSD-style arguments. */
+		sf.sf_siginfo = code;
+		sf.sf_addr = regs->tf_err;
+		sf.sf_ahu.sf_handler = catcher;
+	}
+	PROC_UNLOCK(p);
+
+	/*

>>> TRUNCATED FOR MAIL (1000 lines) <<<
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list