Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Oct 2002 18:51:03 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 20328 for review
Message-ID:  <200210290251.g9T2p3oS055576@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=20328

Change 20328 by peter@peter_daintree on 2002/10/28 18:50:14

	integ i386_hammer

Affected files ...

.. //depot/projects/hammer/sys/x86_64/conf/GENERIC.hints#4 integrate
.. //depot/projects/hammer/sys/x86_64/include/float.h#2 integrate
.. //depot/projects/hammer/sys/x86_64/include/md_var.h#8 integrate
.. //depot/projects/hammer/sys/x86_64/include/proc.h#4 integrate
.. //depot/projects/hammer/sys/x86_64/include/reg.h#3 integrate
.. //depot/projects/hammer/sys/x86_64/include/sigframe.h#3 integrate
.. //depot/projects/hammer/sys/x86_64/include/signal.h#5 integrate
.. //depot/projects/hammer/sys/x86_64/include/ucontext.h#4 integrate
.. //depot/projects/hammer/sys/x86_64/isa/intr_machdep.c#6 integrate
.. //depot/projects/hammer/sys/x86_64/isa/npx.c#13 integrate
.. //depot/projects/hammer/sys/x86_64/pci/pci_bus.c#6 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/elf_machdep.c#4 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/genassym.c#8 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#17 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#26 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/trap.c#13 integrate

Differences ...

==== //depot/projects/hammer/sys/x86_64/conf/GENERIC.hints#4 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/i386/conf/GENERIC.hints,v 1.9 2002/10/09 17:00:46 jhb Exp $
+# $FreeBSD: src/sys/i386/conf/GENERIC.hints,v 1.10 2002/10/22 17:32:27 jhb Exp $
 hint.fdc.0.at="isa"
 hint.fdc.0.port="0x3F0"
 hint.fdc.0.irq="6"
@@ -28,7 +28,6 @@
 hint.sc.0.at="isa"
 hint.sc.0.flags="0x100"
 hint.vt.0.at="isa"
-hint.pmtimer.0.at="isa"
 hint.pcic.0.at="isa"
 # hint.pcic.0.irq="10"	# Default to polling
 hint.pcic.0.port="0x3e0"

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

@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)float.h	7.1 (Berkeley) 5/8/90
- * $FreeBSD: src/sys/i386/include/float.h,v 1.8 1999/08/28 00:44:11 peter Exp $
+ * $FreeBSD: src/sys/i386/include/float.h,v 1.9 2002/10/25 07:02:52 imp Exp $
  */
 
 #ifndef _MACHINE_FLOAT_H_
@@ -60,13 +60,14 @@
 #define DBL_MAX		1.7976931348623157E+308
 #define DBL_MAX_10_EXP	308
 
-#define LDBL_MANT_DIG	DBL_MANT_DIG
-#define LDBL_EPSILON	DBL_EPSILON
-#define LDBL_DIG	DBL_DIG
-#define LDBL_MIN_EXP	DBL_MIN_EXP
-#define LDBL_MIN	DBL_MIN
-#define LDBL_MIN_10_EXP	DBL_MIN_10_EXP
-#define LDBL_MAX_EXP	DBL_MAX_EXP
-#define LDBL_MAX	DBL_MAX
-#define LDBL_MAX_10_EXP	DBL_MAX_10_EXP
+
+#define LDBL_MANT_DIG	64
+#define LDBL_EPSILON	1.0842021724855044340E-19L
+#define LDBL_DIG	18
+#define LDBL_MIN_EXP	(-16381)
+#define LDBL_MIN	3.3621031431120935063E-4932L
+#define LDBL_MIN_10_EXP	(-4931)
+#define LDBL_MAX_EXP	16384
+#define LDBL_MAX	1.1897314953572317650E+4932L
+#define LDBL_MAX_10_EXP	4932
 #endif /* _MACHINE_FLOAT_H_ */

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

@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/i386/include/md_var.h,v 1.53 2002/08/30 04:04:35 peter Exp $
+ * $FreeBSD: src/sys/i386/include/md_var.h,v 1.54 2002/10/25 19:10:56 peter Exp $
  */
 
 #ifndef _MACHINE_MD_VAR_H_
@@ -47,6 +47,9 @@
 extern	char	kstack[];
 extern	char	sigcode[];
 extern	int	szsigcode;
+#ifdef COMPAT_FREEBSD4
+extern	int	szfreebsd4_sigcode;
+#endif
 
 typedef void alias_for_inthand_t(u_int cs, u_int ef, u_int esp, u_int ss);
 struct	thread;

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

@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)proc.h	7.1 (Berkeley) 5/15/91
- * $FreeBSD: src/sys/i386/include/proc.h,v 1.18 2002/10/01 14:08:08 phk Exp $
+ * $FreeBSD: src/sys/i386/include/proc.h,v 1.19 2002/10/25 20:06:16 jhb Exp $
  */
 
 #ifndef _MACHINE_PROC_H_
@@ -55,7 +55,7 @@
 };
 
 struct mdproc {
-	struct proc_ldt *md_ldt;	/* per-process ldt */
+	struct proc_ldt *md_ldt;	/* (j) per-process ldt */
 };
 
 #ifdef	_KERNEL

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

@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)reg.h	5.5 (Berkeley) 1/18/91
- * $FreeBSD: src/sys/i386/include/reg.h,v 1.27 2002/08/29 06:17:46 jake Exp $
+ * $FreeBSD: src/sys/i386/include/reg.h,v 1.28 2002/10/20 20:48:56 phk Exp $
  */
 
 #ifndef _MACHINE_REG_H_
@@ -121,20 +121,17 @@
  * Register set accessible via /proc/$pid/dbregs.
  */
 struct dbreg {
-	unsigned int  dr0;	/* debug address register 0 */
-	unsigned int  dr1;	/* debug address register 1 */
-	unsigned int  dr2;	/* debug address register 2 */
-	unsigned int  dr3;	/* debug address register 3 */
-	unsigned int  dr4;	/* reserved */
-	unsigned int  dr5;	/* reserved */
-	unsigned int  dr6;	/* debug status register */
-	unsigned int  dr7;	/* debug control register */
+	unsigned int  dr[8];	/* debug registers */
+				/* Index 0-3: debug address registers */
+				/* Index 4-5: reserved */
+				/* Index 6: debug status */
+				/* Index 7: debug control */
 };
 
 #define DBREG_DR7_EXEC      0x00      /* break on execute       */
 #define DBREG_DR7_WRONLY    0x01      /* break on write         */
 #define DBREG_DR7_RDWR      0x03      /* break on read or write */
-#define DBREG_DRX(d,x) ((&d->dr0)[x]) /* reference dr0 - dr7 by
+#define DBREG_DRX(d,x) (d->dr[(x)]) /* reference dr0 - dr7 by
                                          register number */
 
 

==== //depot/projects/hammer/sys/x86_64/include/sigframe.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/i386/include/sigframe.h,v 1.7 2002/02/17 17:40:31 deischen Exp $
+ * $FreeBSD: src/sys/i386/include/sigframe.h,v 1.8 2002/10/25 19:10:56 peter Exp $
  */
 
 #ifndef _MACHINE_SIGFRAME_H_
@@ -34,6 +34,25 @@
 /*
  * Signal frames, arguments passed to application signal handlers.
  */
+#ifdef _KERNEL
+#ifdef COMPAT_FREEBSD4
+/* FreeBSD 4.x */
+struct sigframe4 {
+	register_t	sf_signum;
+	register_t	sf_siginfo;	/* code or pointer to sf_si */
+	register_t	sf_ucontext;	/* points to sf_uc */
+	register_t	sf_addr;	/* undocumented 4th arg */
+
+	union {
+		__siginfohandler_t	*sf_action;
+		__sighandler_t		*sf_handler;
+	} sf_ahu;
+	struct ucontext4 sf_uc;		/* = *sf_ucontext */
+	siginfo_t	sf_si;		/* = *sf_siginfo (SA_SIGINFO case) */
+};
+#endif
+#endif
+
 struct sigframe {
 	/*
 	 * The first four members may be used by applications.

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

@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)signal.h	8.1 (Berkeley) 6/11/93
- * $FreeBSD: src/sys/i386/include/signal.h,v 1.17 2002/10/13 00:31:46 mike Exp $
+ * $FreeBSD: src/sys/i386/include/signal.h,v 1.18 2002/10/25 19:10:56 peter Exp $
  */
 
 #ifndef _MACHINE_SIGNAL_H_

==== //depot/projects/hammer/sys/x86_64/include/ucontext.h#4 (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/i386/include/ucontext.h,v 1.7 2002/10/04 14:50:55 deischen Exp $
+ * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.8 2002/10/25 19:10:56 peter Exp $
  */
 
 #ifndef _MACHINE_UCONTEXT_H_
@@ -72,6 +72,34 @@
 } mcontext_t;
 
 #ifdef _KERNEL
+#ifdef COMPAT_FREEBSD4
+/* For 4.x binaries */
+struct mcontext4 {
+	int	mc_onstack;		/* XXX - sigcontext compat. */
+	int	mc_gs;
+	int	mc_fs;
+	int	mc_es;
+	int	mc_ds;
+	int	mc_edi;
+	int	mc_esi;
+	int	mc_ebp;
+	int	mc_isp;
+	int	mc_ebx;
+	int	mc_edx;
+	int	mc_ecx;
+	int	mc_eax;
+	int	mc_trapno;
+	int	mc_err;
+	int	mc_eip;
+	int	mc_cs;
+	int	mc_eflags;
+	int	mc_esp;			/* machine state */
+	int	mc_ss;
+	int	mc_fpregs[28];		/* env87 + fpacc87 + u_long */
+	int	__spare__[17];
+};
+#endif
+
 struct thread;
 
 void	get_mcontext(struct thread *td, mcontext_t *mcp);

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

@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)isa.c	7.2 (Berkeley) 5/13/91
- * $FreeBSD: src/sys/i386/isa/intr_machdep.c,v 1.72 2002/07/08 09:12:22 peter Exp $
+ * $FreeBSD: src/sys/i386/isa/intr_machdep.c,v 1.73 2002/10/20 18:02:46 phk Exp $
  */
 
 #include "opt_auto_eoi.h"
@@ -78,32 +78,32 @@
 static struct	mtx ithds_table_lock;	/* protect the ithds table */
 
 static inthand_t *fastintr[ICU_LEN] = {
-	&IDTVEC(fastintr0), &IDTVEC(fastintr1),
-	&IDTVEC(fastintr2), &IDTVEC(fastintr3),
-	&IDTVEC(fastintr4), &IDTVEC(fastintr5),
-	&IDTVEC(fastintr6), &IDTVEC(fastintr7),
-	&IDTVEC(fastintr8), &IDTVEC(fastintr9),
-	&IDTVEC(fastintr10), &IDTVEC(fastintr11),
-	&IDTVEC(fastintr12), &IDTVEC(fastintr13),
-	&IDTVEC(fastintr14), &IDTVEC(fastintr15),
+	IDTVEC(fastintr0), IDTVEC(fastintr1),
+	IDTVEC(fastintr2), IDTVEC(fastintr3),
+	IDTVEC(fastintr4), IDTVEC(fastintr5),
+	IDTVEC(fastintr6), IDTVEC(fastintr7),
+	IDTVEC(fastintr8), IDTVEC(fastintr9),
+	IDTVEC(fastintr10), IDTVEC(fastintr11),
+	IDTVEC(fastintr12), IDTVEC(fastintr13),
+	IDTVEC(fastintr14), IDTVEC(fastintr15),
 };
 
 static unpendhand_t *fastunpend[ICU_LEN] = {
-	&IDTVEC(fastunpend0), &IDTVEC(fastunpend1),
-	&IDTVEC(fastunpend2), &IDTVEC(fastunpend3),
-	&IDTVEC(fastunpend4), &IDTVEC(fastunpend5),
-	&IDTVEC(fastunpend6), &IDTVEC(fastunpend7),
-	&IDTVEC(fastunpend8), &IDTVEC(fastunpend9),
-	&IDTVEC(fastunpend10), &IDTVEC(fastunpend11),
-	&IDTVEC(fastunpend12), &IDTVEC(fastunpend13),
-	&IDTVEC(fastunpend14), &IDTVEC(fastunpend15),
+	IDTVEC(fastunpend0), IDTVEC(fastunpend1),
+	IDTVEC(fastunpend2), IDTVEC(fastunpend3),
+	IDTVEC(fastunpend4), IDTVEC(fastunpend5),
+	IDTVEC(fastunpend6), IDTVEC(fastunpend7),
+	IDTVEC(fastunpend8), IDTVEC(fastunpend9),
+	IDTVEC(fastunpend10), IDTVEC(fastunpend11),
+	IDTVEC(fastunpend12), IDTVEC(fastunpend13),
+	IDTVEC(fastunpend14), IDTVEC(fastunpend15),
 };
 
 static inthand_t *slowintr[ICU_LEN] = {
-	&IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3),
-	&IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7),
-	&IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11),
-	&IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15),
+	IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3),
+	IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7),
+	IDTVEC(intr8), IDTVEC(intr9), IDTVEC(intr10), IDTVEC(intr11),
+	IDTVEC(intr12), IDTVEC(intr13), IDTVEC(intr14), IDTVEC(intr15),
 };
 
 static driver_intr_t isa_strayintr;
@@ -492,7 +492,7 @@
 		 * initialize the ICU, since it may cause an
 		 * immediate interrupt.
 		 */
-		if (icu_setup(irq, &sched_ithd, arg, flags) != 0)
+		if (icu_setup(irq, sched_ithd, arg, flags) != 0)
 			panic("inthand_add: Can't initialize ICU");
 
 	if (errcode)

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

@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)npx.c	7.2 (Berkeley) 5/12/91
- * $FreeBSD: src/sys/i386/isa/npx.c,v 1.132 2002/09/28 17:14:47 phk Exp $
+ * $FreeBSD: src/sys/i386/isa/npx.c,v 1.134 2002/10/25 19:12:16 peter Exp $
  */
 
 #include "opt_debug_npx.h"
@@ -76,7 +76,7 @@
  * 387 and 287 Numeric Coprocessor Extension (NPX) Driver.
  */
 
-#ifdef	__GNUC__
+#if defined(__GNUC__) && !defined(lint)
 
 #define	fldcw(addr)		__asm("fldcw %0" : : "m" (*(addr)))
 #define	fnclex()		__asm("fnclex")
@@ -645,6 +645,7 @@
 		intr_restore(s);
 		bcopy(addr, &td->td_pcb->pcb_save, sizeof(*addr));
 	}
+	curthread->td_pcb->pcb_flags |= PCB_NPXINITDONE;
 }
 
 static device_method_t npx_methods[] = {

==== //depot/projects/hammer/sys/x86_64/pci/pci_bus.c#6 (text+ko) ====

@@ -23,7 +23,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/i386/pci/pci_bus.c,v 1.93 2002/10/16 18:38:35 jhb Exp $
+ * $FreeBSD: src/sys/i386/pci/pci_bus.c,v 1.95 2002/10/20 17:54:17 phk Exp $
  *
  */
 

==== //depot/projects/hammer/sys/x86_64/x86_64/elf_machdep.c#4 (text+ko) ====

@@ -22,7 +22,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/i386/i386/elf_machdep.c,v 1.11 2002/09/01 21:41:23 jake Exp $
+ * $FreeBSD: src/sys/i386/i386/elf_machdep.c,v 1.12 2002/10/19 19:16:03 marcel Exp $
  */
 
 #include <sys/param.h>
@@ -170,3 +170,17 @@
 	}
 	return(0);
 }
+
+int
+elf_cpu_load_file(linker_file_t lf __unused)
+{
+
+	return (0);
+}
+
+int
+elf_cpu_unload_file(linker_file_t lf __unused)
+{
+
+	return (0);
+}

==== //depot/projects/hammer/sys/x86_64/x86_64/genassym.c#8 (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>
@@ -146,12 +147,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/hammer/sys/x86_64/x86_64/locore.s#17 (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
  *

==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#26 (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.542 2002/10/12 05:32:23 jeff Exp $
+ * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.545 2002/10/25 19:10:56 peter Exp $
  */
 
 #include "opt_atalk.h"
@@ -151,6 +151,11 @@
 long physmem = 0;
 int cold = 1;
 
+#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)
 {
@@ -259,6 +264,129 @@
  * frame pointer, it returns to the user
  * specified pc, psl.
  */
+#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);
+
+	/*
+	 * If we're a vm86 process, we want to save the segment registers.
+	 * We also change eflags to be our emulated eflags, not the actual
+	 * eflags.
+	 */
+	if (regs->tf_eflags & PSL_VM) {
+		struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
+		struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86;
+
+		sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs;
+		sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs;
+		sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es;
+		sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds;
+
+		if (vm86->vm86_has_vme == 0)
+			sf.sf_uc.uc_mcontext.mc_eflags =
+			    (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) |
+			    (vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
+
+		/*
+		 * Clear PSL_NT to inhibit T_TSSFLT faults on return from
+		 * syscalls made by the signal handler.  This just avoids
+		 * wasting time for our lazy fixup of such faults.  PSL_NT
+		 * does nothing in vm86 mode, but vm86 programs can set it
+		 * almost legitimately in probes for old cpu types.
+		 */
+		tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
+	}
+
+	/*
+	 * Copy the sigframe out to the user's stack.
+	 */
+	if (copyout(&sf, sfp, sizeof(*sfp)) != 0) {
+#ifdef DEBUG
+		printf("process %ld has trashed its stack\n", (long)p->p_pid);
+#endif
+		PROC_LOCK(p);
+		sigexit(td, SIGILL);
+	}
+
+	regs->tf_esp = (int)sfp;
+	regs->tf_eip = PS_STRINGS - szfreebsd4_sigcode;
+	regs->tf_eflags &= ~PSL_T;
+	regs->tf_cs = _ucodesel;
+	regs->tf_ds = _udatasel;
+	regs->tf_es = _udatasel;
+	regs->tf_fs = _udatasel;
+	regs->tf_ss = _udatasel;
+	PROC_LOCK(p);
+}
+#endif	/* COMPAT_FREEBSD4 */
+
 void
 sendsig(catcher, sig, mask, code)
 	sig_t catcher;
@@ -266,18 +394,23 @@
 	sigset_t *mask;
 	u_long code;
 {
-	struct sigframe sf;
+	struct sigframe sf, *sfp;
 	struct proc *p;
 	struct thread *td;
 	struct sigacts *psp;
 	struct trapframe *regs;
-	struct sigframe *sfp;
 	int oonstack;
 
 	td = curthread;
 	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
 	regs = td->td_frame;
 	oonstack = sigonstack(regs->tf_esp);
 
@@ -366,7 +499,118 @@
  *
  * MPSAFE
  */
+#ifdef COMPAT_FREEBSD4
+/*
+ * MPSAFE
+ */
 int
+freebsd4_sigreturn(td, uap)
+	struct thread *td;
+	struct freebsd4_sigreturn_args /* {
+		const ucontext4 *sigcntxp;
+	} */ *uap;
+{
+	struct ucontext4 uc;
+	struct proc *p = td->td_proc;
+	struct trapframe *regs;
+	const struct ucontext4 *ucp;
+	int cs, eflags, error;
+
+	error = copyin(uap->sigcntxp, &uc, sizeof(uc));
+	if (error != 0)
+		return (error);
+	ucp = &uc;
+	regs = td->td_frame;
+	eflags = ucp->uc_mcontext.mc_eflags;
+	if (eflags & PSL_VM) {
+		struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
+		struct vm86_kernel *vm86;
+
+		/*
+		 * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
+		 * set up the vm86 area, and we can't enter vm86 mode.
+		 */
+		if (td->td_pcb->pcb_ext == 0)
+			return (EINVAL);
+		vm86 = &td->td_pcb->pcb_ext->ext_vm86;
+		if (vm86->vm86_inited == 0)
+			return (EINVAL);
+
+		/* Go back to user mode if both flags are set. */
+		if ((eflags & PSL_VIP) && (eflags & PSL_VIF))
+			trapsignal(p, SIGBUS, 0);
+
+		if (vm86->vm86_has_vme) {
+			eflags = (tf->tf_eflags & ~VME_USERCHANGE) |
+			    (eflags & VME_USERCHANGE) | PSL_VM;
+		} else {
+			vm86->vm86_eflags = eflags;	/* save VIF, VIP */
+			eflags = (tf->tf_eflags & ~VM_USERCHANGE) |
+			    (eflags & VM_USERCHANGE) | PSL_VM;
+		}
+		bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe));
+		tf->tf_eflags = eflags;
+		tf->tf_vm86_ds = tf->tf_ds;
+		tf->tf_vm86_es = tf->tf_es;
+		tf->tf_vm86_fs = tf->tf_fs;
+		tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs;
+		tf->tf_ds = _udatasel;
+		tf->tf_es = _udatasel;
+		tf->tf_fs = _udatasel;
+	} else {
+		/*
+		 * Don't allow users to change privileged or reserved flags.
+		 */
+		/*
+		 * XXX do allow users to change the privileged flag PSL_RF.
+		 * The cpu sets PSL_RF in tf_eflags for faults.  Debuggers
+		 * should sometimes set it there too.  tf_eflags is kept in
+		 * the signal context during signal handling and there is no
+		 * other place to remember it, so the PSL_RF bit may be
+		 * corrupted by the signal handler without us knowing.
+		 * Corruption of the PSL_RF bit at worst causes one more or
+		 * one less debugger trap, so allowing it is fairly harmless.
+		 */
+		if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
+			printf("freebsd4_sigreturn: eflags = 0x%x\n", eflags);
+	    		return (EINVAL);
+		}
+
+		/*
+		 * Don't allow users to load a valid privileged %cs.  Let the
+		 * hardware check for invalid selectors, excess privilege in
+		 * other selectors, invalid %eip's and invalid %esp's.
+		 */
+		cs = ucp->uc_mcontext.mc_cs;
+		if (!CS_SECURE(cs)) {
+			printf("freebsd4_sigreturn: cs = 0x%x\n", cs);
+			trapsignal(p, SIGBUS, T_PROTFLT);
+			return (EINVAL);
+		}
+
+		bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs));
+	}
+
+	PROC_LOCK(p);
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+	if (ucp->uc_mcontext.mc_onstack & 1)
+		p->p_sigstk.ss_flags |= SS_ONSTACK;
+	else
+		p->p_sigstk.ss_flags &= ~SS_ONSTACK;
+#endif
+
+	p->p_sigmask = ucp->uc_sigmask;
+	SIG_CANTMASK(p->p_sigmask);
+	signotify(p);
+	PROC_UNLOCK(p);
+	return (EJUSTRETURN);
+}
+#endif	/* COMPAT_FREEBSD4 */
+
+/*
+ * MPSAFE
+ */
+int
 sigreturn(td, uap)
 	struct thread *td;
 	struct sigreturn_args /* {
@@ -859,16 +1103,13 @@
 	struct bios_smap *smap;
 
 	bzero(physmap, sizeof(physmap));
+	basemem = 0;
 
 	/*
-	 * Perform "base memory" related probes & setup
+	 * map page 1 R/W into the kernel page table so we can use it
+	 * as a buffer.  The kernel will unmap this page later.
 	 */
-#error "basemem = fetch from loader metadata"
-	if (basemem > 640) {
-		printf("Preposterous BIOS basemem of %uK, truncating to 640K\n",
-			basemem);
-		basemem = 640;
-	}
+	pmap_kenter(KERNBASE + (1 << PAGE_SHIFT), 1);
 
 	/*
 	 * get memory map with INT 15:E820
@@ -923,6 +1164,72 @@
 	} #error "while not end of smap table from loader"
 
 	/*
+	 * Perform "base memory" related probes & setup
+	 */
+	for (i = 0; i <= physmap_idx; i += 2) {
+		if (physmap[i] == 0x00000000) {
+			basemem = physmap[i + 1] / 1024;
+			break;
+		}
+	}
+
+	/* Fall back to the old compatibility function for base memory */
+#error "basemem = fetch from loader metadata"
+
+	if (basemem > 640) {
+		printf("Preposterous BIOS basemem of %uK, truncating to 640K\n",
+			basemem);
+		basemem = 640;
+	}
+
+	/*
+	 * XXX if biosbasemem is now < 640, there is a `hole'
+	 * between the end of base memory and the start of
+	 * ISA memory.  The hole may be empty or it may
+	 * contain BIOS code or data.  Map it read/write so
+	 * that the BIOS can write to it.  (Memory from 0 to
+	 * the physical end of the kernel is mapped read-only
+	 * to begin with and then parts of it are remapped.
+	 * The parts that aren't remapped form holes that
+	 * remain read-only and are unused by the kernel.
+	 * The base memory area is below the physical end of
+	 * the kernel and right now forms a read-only hole.
+	 * The part of it from PAGE_SIZE to
+	 * (trunc_page(biosbasemem * 1024) - 1) will be
+	 * remapped and used by the kernel later.)
+	 *
+	 * This code is similar to the code used in
+	 * pmap_mapdev, but since no memory needs to be
+	 * allocated we simply change the mapping.
+	 */
+	for (pa = trunc_page(basemem * 1024);
+	     pa < ISA_HOLE_START; pa += PAGE_SIZE)
+		pmap_kenter(KERNBASE + pa, pa);
+
+	/*
+	 * if basemem != 640, map pages r/w into vm86 page table so
+	 * that the bios can scribble on it.
+	 */
+	pte = (pt_entry_t *)vm86paddr;
+	for (i = basemem / 4; i < 160; i++)
+		pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U;
+
+	if (physmap[1] != 0)
+		goto physmap_done;
+
+	/*
+	 * If we failed above, try memory map with INT 15:E801
+	 */
+#error get smap from loader
+	else {
+		/*
+		 * Prefer the RTC value for extended memory.
+		 */
+		extmem = rtcin(RTC_EXTLO) + (rtcin(RTC_EXTHI) << 8);
+	}
+
+physmap_done:
+	/*
 	 * Now, physmap contains a map of physical memory.
 	 */
 
@@ -1638,24 +1945,24 @@
 	struct pcb *pcb;
 
 	if (td == NULL) {
-		dbregs->dr0 = rdr0();
-		dbregs->dr1 = rdr1();
-		dbregs->dr2 = rdr2();
-		dbregs->dr3 = rdr3();
-		dbregs->dr4 = rdr4();
-		dbregs->dr5 = rdr5();
-		dbregs->dr6 = rdr6();
-		dbregs->dr7 = rdr7();
+		dbregs->dr[0] = rdr0();
+		dbregs->dr[1] = rdr1();
+		dbregs->dr[2] = rdr2();
+		dbregs->dr[3] = rdr3();
+		dbregs->dr[4] = rdr4();
+		dbregs->dr[5] = rdr5();
+		dbregs->dr[6] = rdr6();
+		dbregs->dr[7] = rdr7();
 	} else {
 		pcb = td->td_pcb;
-		dbregs->dr0 = pcb->pcb_dr0;
-		dbregs->dr1 = pcb->pcb_dr1;
-		dbregs->dr2 = pcb->pcb_dr2;
-		dbregs->dr3 = pcb->pcb_dr3;
-		dbregs->dr4 = 0;
-		dbregs->dr5 = 0;
-		dbregs->dr6 = pcb->pcb_dr6;
-		dbregs->dr7 = pcb->pcb_dr7;
+		dbregs->dr[0] = pcb->pcb_dr0;
+		dbregs->dr[1] = pcb->pcb_dr1;
+		dbregs->dr[2] = pcb->pcb_dr2;
+		dbregs->dr[3] = pcb->pcb_dr3;
+		dbregs->dr[4] = 0;
+		dbregs->dr[5] = 0;
+		dbregs->dr[6] = pcb->pcb_dr6;
+		dbregs->dr[7] = pcb->pcb_dr7;
 	}
 	return (0);
 }
@@ -1668,14 +1975,14 @@
 	u_int32_t mask1, mask2;
 
 	if (td == NULL) {
-		load_dr0(dbregs->dr0);
-		load_dr1(dbregs->dr1);
-		load_dr2(dbregs->dr2);
-		load_dr3(dbregs->dr3);
-		load_dr4(dbregs->dr4);
-		load_dr5(dbregs->dr5);
-		load_dr6(dbregs->dr6);
-		load_dr7(dbregs->dr7);
+		load_dr0(dbregs->dr[0]);
+		load_dr1(dbregs->dr[1]);
+		load_dr2(dbregs->dr[2]);
+		load_dr3(dbregs->dr[3]);
+		load_dr4(dbregs->dr[4]);
+		load_dr5(dbregs->dr[5]);
+		load_dr6(dbregs->dr[6]);
+		load_dr7(dbregs->dr[7]);
 	} else {
 		/*
 		 * Don't let an illegal value for dr7 get set.	Specifically,
@@ -1685,7 +1992,7 @@
 		 */
 		for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8; 
 		     i++, mask1 <<= 2, mask2 <<= 2)
-			if ((dbregs->dr7 & mask1) == mask2)
+			if ((dbregs->dr[7] & mask1) == mask2)
 				return (EINVAL);
 		
 		pcb = td->td_pcb;
@@ -1706,37 +2013,37 @@
 		 */
 
 		if (suser(td) != 0) {
-			if (dbregs->dr7 & 0x3) {
+			if (dbregs->dr[7] & 0x3) {
 				/* dr0 is enabled */
-				if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
+				if (dbregs->dr[0] >= VM_MAXUSER_ADDRESS)
 					return (EINVAL);
 			}
 			
-			if (dbregs->dr7 & (0x3<<2)) {
+			if (dbregs->dr[7] & (0x3<<2)) {
 				/* dr1 is enabled */
-				if (dbregs->dr1 >= VM_MAXUSER_ADDRESS)
+				if (dbregs->dr[1] >= VM_MAXUSER_ADDRESS)
 					return (EINVAL);
 			}
 			
-			if (dbregs->dr7 & (0x3<<4)) {
+			if (dbregs->dr[7] & (0x3<<4)) {
 				/* dr2 is enabled */
-				if (dbregs->dr2 >= VM_MAXUSER_ADDRESS)
+				if (dbregs->dr[2] >= VM_MAXUSER_ADDRESS)
 					return (EINVAL);
 			}
 			
-			if (dbregs->dr7 & (0x3<<6)) {
+			if (dbregs->dr[7] & (0x3<<6)) {
 				/* dr3 is enabled */
-				if (dbregs->dr3 >= VM_MAXUSER_ADDRESS)
+				if (dbregs->dr[3] >= VM_MAXUSER_ADDRESS)
 					return (EINVAL);
 			}
 		}
 
-		pcb->pcb_dr0 = dbregs->dr0;
-		pcb->pcb_dr1 = dbregs->dr1;
-		pcb->pcb_dr2 = dbregs->dr2;
-		pcb->pcb_dr3 = dbregs->dr3;
-		pcb->pcb_dr6 = dbregs->dr6;
-		pcb->pcb_dr7 = dbregs->dr7;
+		pcb->pcb_dr0 = dbregs->dr[0];
+		pcb->pcb_dr1 = dbregs->dr[1];
+		pcb->pcb_dr2 = dbregs->dr[2];
+		pcb->pcb_dr3 = dbregs->dr[3];
+		pcb->pcb_dr6 = dbregs->dr[6];
+		pcb->pcb_dr7 = dbregs->dr[7];
 
 		pcb->pcb_flags |= PCB_DBREGS;
 	}

==== //depot/projects/hammer/sys/x86_64/x86_64/trap.c#13 (text+ko) ====

@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)trap.c	7.4 (Berkeley) 5/13/91
- * $FreeBSD: src/sys/i386/i386/trap.c,v 1.235 2002/10/09 02:33:35 julian Exp $
+ * $FreeBSD: src/sys/i386/i386/trap.c,v 1.236 2002/10/24 23:09:48 julian Exp $
  */
 
 /*
@@ -799,44 +799,8 @@
 	td->td_frame = &frame;
 	if (td->td_ucred != p->p_ucred) 
 		cred_update_thread(td);
-	if (p->p_flag & P_KSES) {
-		/*
-		 * First check that we shouldn't just abort.
-		 * But check if we are the single thread first!
-		 * XXX p_singlethread not locked, but should be safe.
-		 */
-		if ((p->p_flag & P_WEXIT) && (p->p_singlethread != td)) {
-			PROC_LOCK(p);
-			mtx_lock_spin(&sched_lock);
-			thread_exit();
-			/* NOTREACHED */
-		}
-
-		/*
-		 * If we are doing a syscall in a KSE environment,
-		 * note where our mailbox is. There is always the
-		 * possibility that we could do this lazily (in sleep()),

>>> TRUNCATED FOR MAIL (1000 lines) <<<

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?200210290251.g9T2p3oS055576>