Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jul 2005 19:45:51 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 79723 for review
Message-ID:  <200507071945.j67Jjpnu086451@repoman.freebsd.org>

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

Change 79723 by jhb@jhb_slimer on 2005/07/07 19:45:15

	IFC @79722.  Merge back several patches from jhb_proc and the
	p{read,write}v stuff from jhb_ktrace.

Affected files ...

.. //depot/projects/smpng/sys/alpha/osf1/osf1_misc.c#38 integrate
.. //depot/projects/smpng/sys/amd64/amd64/apic_vector.S#7 integrate
.. //depot/projects/smpng/sys/amd64/amd64/dump_machdep.c#3 integrate
.. //depot/projects/smpng/sys/amd64/amd64/exception.S#14 integrate
.. //depot/projects/smpng/sys/amd64/amd64/machdep.c#42 integrate
.. //depot/projects/smpng/sys/amd64/amd64/mp_machdep.c#22 integrate
.. //depot/projects/smpng/sys/amd64/amd64/trap.c#29 integrate
.. //depot/projects/smpng/sys/amd64/conf/NOTES#18 integrate
.. //depot/projects/smpng/sys/amd64/ia32/ia32_reg.c#1 branch
.. //depot/projects/smpng/sys/amd64/include/_types.h#5 integrate
.. //depot/projects/smpng/sys/amd64/include/pmap.h#18 integrate
.. //depot/projects/smpng/sys/amd64/isa/clock.c#14 integrate
.. //depot/projects/smpng/sys/cam/cam_periph.c#19 integrate
.. //depot/projects/smpng/sys/cam/cam_queue.c#5 integrate
.. //depot/projects/smpng/sys/cam/cam_sim.c#5 integrate
.. //depot/projects/smpng/sys/cam/cam_xpt.c#31 integrate
.. //depot/projects/smpng/sys/cam/cam_xpt_periph.h#3 integrate
.. //depot/projects/smpng/sys/cam/scsi/scsi_low.c#13 integrate
.. //depot/projects/smpng/sys/cam/scsi/scsi_sa.c#24 integrate
.. //depot/projects/smpng/sys/cam/scsi/scsi_ses.c#13 integrate
.. //depot/projects/smpng/sys/cam/scsi/scsi_targ_bh.c#9 integrate
.. //depot/projects/smpng/sys/cam/scsi/scsi_target.c#19 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_misc.c#22 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_proto.h#18 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_syscall.h#18 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_syscalls.c#18 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_sysent.c#18 integrate
.. //depot/projects/smpng/sys/compat/freebsd32/syscalls.master#18 integrate
.. //depot/projects/smpng/sys/compat/ia32/ia32_reg.h#1 branch
.. //depot/projects/smpng/sys/compat/linux/linux_misc.c#58 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_ipc.c#7 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#40 integrate
.. //depot/projects/smpng/sys/compat/svr4/svr4_socket.c#9 integrate
.. //depot/projects/smpng/sys/conf/files.amd64#33 integrate
.. //depot/projects/smpng/sys/conf/files.ia64#50 integrate
.. //depot/projects/smpng/sys/conf/newvers.sh#17 integrate
.. //depot/projects/smpng/sys/conf/options#102 integrate
.. //depot/projects/smpng/sys/conf/options.amd64#13 integrate
.. //depot/projects/smpng/sys/conf/options.i386#49 integrate
.. //depot/projects/smpng/sys/conf/options.pc98#48 integrate
.. //depot/projects/smpng/sys/ddb/db_command.c#22 integrate
.. //depot/projects/smpng/sys/ddb/ddb.h#15 integrate
.. //depot/projects/smpng/sys/dev/ath/if_ath.c#28 integrate
.. //depot/projects/smpng/sys/dev/ath/if_athvar.h#17 integrate
.. //depot/projects/smpng/sys/dev/ep/if_ep.c#22 integrate
.. //depot/projects/smpng/sys/dev/ep/if_ep_isa.c#13 integrate
.. //depot/projects/smpng/sys/dev/ep/if_ep_mca.c#9 integrate
.. //depot/projects/smpng/sys/dev/ep/if_ep_pccard.c#20 integrate
.. //depot/projects/smpng/sys/dev/ep/if_epvar.h#10 integrate
.. //depot/projects/smpng/sys/dev/fatm/if_fatm.c#14 integrate
.. //depot/projects/smpng/sys/dev/hatm/if_hatm.c#17 integrate
.. //depot/projects/smpng/sys/dev/hatm/if_hatm_ioctl.c#8 integrate
.. //depot/projects/smpng/sys/dev/hatm/if_hatm_tx.c#11 integrate
.. //depot/projects/smpng/sys/dev/hwpmc/hwpmc_logging.c#2 integrate
.. //depot/projects/smpng/sys/dev/hwpmc/hwpmc_mod.c#3 integrate
.. //depot/projects/smpng/sys/dev/hwpmc/hwpmc_x86.c#2 integrate
.. //depot/projects/smpng/sys/dev/ipw/if_ipw.c#3 integrate
.. //depot/projects/smpng/sys/dev/iwi/if_iwi.c#4 integrate
.. //depot/projects/smpng/sys/dev/patm/if_patm_attach.c#9 integrate
.. //depot/projects/smpng/sys/dev/patm/if_patm_tx.c#8 integrate
.. //depot/projects/smpng/sys/dev/pccard/card_if.m#14 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccard.c#35 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccard_cis.c#19 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccarddevs#46 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccardvar.h#22 integrate
.. //depot/projects/smpng/sys/dev/ral/if_ral.c#4 integrate
.. //depot/projects/smpng/sys/dev/re/if_re.c#23 integrate
.. //depot/projects/smpng/sys/dev/sn/if_sn.c#20 integrate
.. //depot/projects/smpng/sys/dev/sn/if_sn_isa.c#6 integrate
.. //depot/projects/smpng/sys/dev/sn/if_sn_pccard.c#15 integrate
.. //depot/projects/smpng/sys/dev/sn/if_snvar.h#5 integrate
.. //depot/projects/smpng/sys/dev/usb/if_ural.c#3 integrate
.. //depot/projects/smpng/sys/dev/usb/uplcom.c#20 integrate
.. //depot/projects/smpng/sys/dev/usb/usbdevs#76 integrate
.. //depot/projects/smpng/sys/fs/procfs/procfs_dbregs.c#15 integrate
.. //depot/projects/smpng/sys/fs/procfs/procfs_fpregs.c#15 integrate
.. //depot/projects/smpng/sys/fs/procfs/procfs_ioctl.c#12 integrate
.. //depot/projects/smpng/sys/fs/procfs/procfs_map.c#9 integrate
.. //depot/projects/smpng/sys/fs/procfs/procfs_regs.c#15 integrate
.. //depot/projects/smpng/sys/fs/pseudofs/pseudofs_vncache.c#23 integrate
.. //depot/projects/smpng/sys/i386/conf/NOTES#103 integrate
.. //depot/projects/smpng/sys/i386/i386/dump_machdep.c#7 integrate
.. //depot/projects/smpng/sys/i386/i386/identcpu.c#36 integrate
.. //depot/projects/smpng/sys/i386/i386/initcpu.c#25 integrate
.. //depot/projects/smpng/sys/i386/i386/machdep.c#96 integrate
.. //depot/projects/smpng/sys/i386/i386/mp_machdep.c#84 integrate
.. //depot/projects/smpng/sys/i386/i386/pmap.c#83 integrate
.. //depot/projects/smpng/sys/i386/i386/ptrace_machdep.c#2 integrate
.. //depot/projects/smpng/sys/i386/i386/trap.c#80 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_isc.c#6 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_misc.c#21 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_sysi86.c#10 integrate
.. //depot/projects/smpng/sys/i386/ibcs2/ibcs2_xenix.c#12 integrate
.. //depot/projects/smpng/sys/i386/include/_types.h#9 integrate
.. //depot/projects/smpng/sys/i386/include/md_var.h#29 integrate
.. //depot/projects/smpng/sys/i386/include/pmap.h#27 integrate
.. //depot/projects/smpng/sys/i386/isa/clock.c#43 integrate
.. //depot/projects/smpng/sys/i386/isa/npx.c#48 integrate
.. //depot/projects/smpng/sys/i386/linux/linux_ptrace.c#12 integrate
.. //depot/projects/smpng/sys/ia64/ia32/ia32_reg.c#1 branch
.. //depot/projects/smpng/sys/ia64/ia64/db_interface.c#20 integrate
.. //depot/projects/smpng/sys/ia64/ia64/dump_machdep.c#8 integrate
.. //depot/projects/smpng/sys/ia64/ia64/machdep.c#94 integrate
.. //depot/projects/smpng/sys/ia64/include/db_machdep.h#10 integrate
.. //depot/projects/smpng/sys/ia64/include/md_var.h#20 integrate
.. //depot/projects/smpng/sys/kern/imgact_elf.c#44 integrate
.. //depot/projects/smpng/sys/kern/init_main.c#55 integrate
.. //depot/projects/smpng/sys/kern/init_sysent.c#57 integrate
.. //depot/projects/smpng/sys/kern/kern_clock.c#41 integrate
.. //depot/projects/smpng/sys/kern/kern_event.c#41 integrate
.. //depot/projects/smpng/sys/kern/kern_exec.c#87 integrate
.. //depot/projects/smpng/sys/kern/kern_fork.c#95 integrate
.. //depot/projects/smpng/sys/kern/subr_kdb.c#10 integrate
.. //depot/projects/smpng/sys/kern/subr_smp.c#41 integrate
.. //depot/projects/smpng/sys/kern/sys_generic.c#42 integrate
.. //depot/projects/smpng/sys/kern/sys_pipe.c#52 integrate
.. //depot/projects/smpng/sys/kern/sys_process.c#44 integrate
.. //depot/projects/smpng/sys/kern/syscalls.c#57 integrate
.. //depot/projects/smpng/sys/kern/syscalls.master#59 integrate
.. //depot/projects/smpng/sys/kern/tty.c#60 integrate
.. //depot/projects/smpng/sys/kern/uipc_socket.c#70 integrate
.. //depot/projects/smpng/sys/kern/uipc_socket2.c#44 integrate
.. //depot/projects/smpng/sys/kern/uipc_syscalls.c#69 integrate
.. //depot/projects/smpng/sys/kern/vfs_aio.c#58 integrate
.. //depot/projects/smpng/sys/kern/vfs_subr.c#105 integrate
.. //depot/projects/smpng/sys/modules/Makefile#99 integrate
.. //depot/projects/smpng/sys/net/bpf.c#52 integrate
.. //depot/projects/smpng/sys/net/bridge.c#38 integrate
.. //depot/projects/smpng/sys/net/bridgestp.c#2 integrate
.. //depot/projects/smpng/sys/net/bsd_comp.c#10 integrate
.. //depot/projects/smpng/sys/net/if.c#68 integrate
.. //depot/projects/smpng/sys/net/if_bridge.c#3 integrate
.. //depot/projects/smpng/sys/net/if_bridgevar.h#2 integrate
.. //depot/projects/smpng/sys/net/if_ppp.c#33 integrate
.. //depot/projects/smpng/sys/net/ppp_tty.c#19 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_freebsd.h#5 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_input.c#19 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_ioctl.c#17 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_ioctl.h#7 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_node.c#18 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_node.h#13 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_output.c#16 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_proto.c#12 integrate
.. //depot/projects/smpng/sys/net80211/ieee80211_var.h#12 integrate
.. //depot/projects/smpng/sys/netatalk/ddp_output.c#10 integrate
.. //depot/projects/smpng/sys/netgraph/netgraph.h#19 integrate
.. //depot/projects/smpng/sys/netgraph/ng_base.c#36 integrate
.. //depot/projects/smpng/sys/netgraph/ng_pppoe.c#27 integrate
.. //depot/projects/smpng/sys/netgraph/ng_socket.c#31 integrate
.. //depot/projects/smpng/sys/netgraph/ng_socketvar.h#4 integrate
.. //depot/projects/smpng/sys/netinet/ip_carp.c#8 integrate
.. //depot/projects/smpng/sys/netinet/ip_fw2.c#55 integrate
.. //depot/projects/smpng/sys/netinet/ip_output.c#73 integrate
.. //depot/projects/smpng/sys/netinet/ip_var.h#29 integrate
.. //depot/projects/smpng/sys/netinet/tcp_input.c#74 integrate
.. //depot/projects/smpng/sys/netinet/tcp_subr.c#69 integrate
.. //depot/projects/smpng/sys/netinet6/ip6_var.h#15 integrate
.. //depot/projects/smpng/sys/pc98/cbus/clock.c#2 integrate
.. //depot/projects/smpng/sys/pc98/conf/NOTES#40 integrate
.. //depot/projects/smpng/sys/pc98/pc98/machdep.c#2 integrate
.. //depot/projects/smpng/sys/pci/if_ti.c#46 integrate
.. //depot/projects/smpng/sys/security/mac/mac_net.c#13 integrate
.. //depot/projects/smpng/sys/security/mac/mac_socket.c#4 integrate
.. //depot/projects/smpng/sys/security/mac_biba/mac_biba.c#35 integrate
.. //depot/projects/smpng/sys/security/mac_lomac/mac_lomac.c#26 integrate
.. //depot/projects/smpng/sys/security/mac_mls/mac_mls.c#33 integrate
.. //depot/projects/smpng/sys/security/mac_stub/mac_stub.c#13 integrate
.. //depot/projects/smpng/sys/security/mac_test/mac_test.c#31 integrate
.. //depot/projects/smpng/sys/sys/event.h#18 integrate
.. //depot/projects/smpng/sys/sys/iconv.h#10 integrate
.. //depot/projects/smpng/sys/sys/kerneldump.h#6 integrate
.. //depot/projects/smpng/sys/sys/mac.h#32 integrate
.. //depot/projects/smpng/sys/sys/mac_policy.h#31 integrate
.. //depot/projects/smpng/sys/sys/mount.h#41 integrate
.. //depot/projects/smpng/sys/sys/pmc.h#3 integrate
.. //depot/projects/smpng/sys/sys/pmckern.h#3 integrate
.. //depot/projects/smpng/sys/sys/pmclog.h#2 integrate
.. //depot/projects/smpng/sys/sys/ptrace.h#15 integrate
.. //depot/projects/smpng/sys/sys/syscall.h#56 integrate
.. //depot/projects/smpng/sys/sys/syscall.mk#56 integrate
.. //depot/projects/smpng/sys/sys/syscallsubr.h#22 integrate
.. //depot/projects/smpng/sys/sys/sysproto.h#58 integrate
.. //depot/projects/smpng/sys/sys/uio.h#22 integrate
.. //depot/projects/smpng/sys/sys/vnode.h#64 integrate

Differences ...

==== //depot/projects/smpng/sys/alpha/osf1/osf1_misc.c#38 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/alpha/osf1/osf1_misc.c,v 1.55 2005/04/01 20:00:10 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/alpha/osf1/osf1_misc.c,v 1.56 2005/07/07 19:16:30 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1256,7 +1256,7 @@
 	struct thread *td;
 	struct osf1_usleep_thread_args *uap;
 {
-	int error, s, timo;
+	int error, timo;
 	struct osf1_timeval time;
 	struct timeval difftv, endtv, sleeptv, tv;
 
@@ -1274,19 +1274,15 @@
 
 	if (timo == 0)
 		timo = 1;
-	s = splclock();
 	microtime(&tv);
-	splx(s);
 
 	tsleep(td, PUSER|PCATCH, "OSF/1", timo);
 
 	if (uap->slept != NULL) {
-		s = splclock();
 		microtime(&endtv);
-		timersub(&time, &endtv, &difftv);
-		splx(s);
-		if (tv.tv_sec < 0 || tv.tv_usec < 0)
-			tv.tv_sec = tv.tv_usec = 0;
+		timersub(&endtv, &tv, &difftv);
+		if (difftv.tv_sec < 0 || difftv.tv_usec < 0)
+			difftv.tv_sec = difftv.tv_usec = 0;
 		TV_CP(difftv, time)
 		error = copyout(&time, uap->slept, sizeof time);
 	}

==== //depot/projects/smpng/sys/amd64/amd64/apic_vector.S#7 (text+ko) ====

@@ -28,7 +28,7 @@
  * SUCH DAMAGE.
  *
  *	from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD: src/sys/amd64/amd64/apic_vector.S,v 1.102 2005/02/28 23:37:35 peter Exp $
+ * $FreeBSD: src/sys/amd64/amd64/apic_vector.S,v 1.103 2005/06/30 05:33:26 peter Exp $
  */
 
 /*
@@ -148,7 +148,7 @@
 	movq	lapic, %rdx
 	movl	$0, LA_EOI(%rdx)	/* End Of Interrupt to APIC */
 
-	FAKE_MCOUNT(TF_EIP(%esp))
+	FAKE_MCOUNT(TF_RIP(%rsp))
 
 	call	lapic_handle_timer
 	MEXITCOUNT

==== //depot/projects/smpng/sys/amd64/amd64/dump_machdep.c#3 (text+ko) ====

@@ -1,40 +1,31 @@
 /*-
- * Copyright (c) 2002 Poul-Henning Kamp
- * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * Copyright (c) 2002 Marcel Moolenaar
  * All rights reserved.
  *
- * This software was developed for the FreeBSD Project by Poul-Henning Kamp
- * and NAI Labs, the Security Research Division of Network Associates, Inc.
- * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
- * DARPA CHATS research program.
- *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
+ *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. The names of the authors may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/dump_machdep.c,v 1.9 2003/07/25 21:15:44 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/dump_machdep.c,v 1.11 2005/07/02 19:57:30 marcel Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -44,92 +35,336 @@
 #include <sys/kerneldump.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
+#include <machine/elf.h>
 #include <machine/md_var.h>
 
 CTASSERT(sizeof(struct kerneldumpheader) == 512);
 
+/*
+ * Don't touch the first SIZEOF_METADATA bytes on the dump device. This
+ * is to protect us from metadata and to protect metadata from us.
+ */
+#define	SIZEOF_METADATA		(64*1024)
+
+#define	MD_ALIGN(x)	(((off_t)(x) + PAGE_MASK) & ~PAGE_MASK)
+#define	DEV_ALIGN(x)	(((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1))
+
+struct md_pa {
+	vm_paddr_t md_start;
+	vm_paddr_t md_size;
+};
+
+typedef int callback_t(struct md_pa *, int, void *);
+
 static struct kerneldumpheader kdh;
+static off_t dumplo, fileofs;
 
-void
-dumpsys(struct dumperinfo *di)
+/* Handle buffered writes. */
+static char buffer[DEV_BSIZE];
+static size_t fragsz;
+
+/* 20 phys_avail entry pairs correspond to 10 md_pa's */
+static struct md_pa dump_map[10];
+
+static void
+md_pa_init(void)
+{
+	int n, idx;
+
+	bzero(dump_map, sizeof(dump_map));
+	for (n = 0; n < sizeof(dump_map) / sizeof(dump_map[0]); n++) {
+		idx = n * 2;
+		if (dump_avail[idx] == 0 && dump_avail[idx + 1] == 0)
+			break;
+		dump_map[n].md_start = dump_avail[idx];
+		dump_map[n].md_size = dump_avail[idx + 1] - dump_avail[idx];
+	}
+}
+
+static struct md_pa *
+md_pa_first(void)
+{
+
+	return (&dump_map[0]);
+}
+
+static struct md_pa *
+md_pa_next(struct md_pa *mdp)
 {
-	off_t dumplo;
-	vm_offset_t a, addr;
-	u_int count, left, u;
-	void *va;
-	int i, mb;
-	int c;
+
+	mdp++;
+	if (mdp->md_size == 0)
+		mdp = NULL;
+	return (mdp);
+}
 
-	printf("Dumping %ld MB\n", Maxmem / (1024*1024 / PAGE_SIZE));
+/* XXX should be MI */
+static void
+mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
+    uint32_t blksz)
+{
 
-	/* Fill in the kernel dump header */
-	strcpy(kdh.magic, KERNELDUMPMAGIC);
-	strcpy(kdh.architecture, "amd64");
-	kdh.version = htod32(KERNELDUMPVERSION);
-	kdh.architectureversion = htod32(KERNELDUMP_I386_VERSION);
-	kdh.dumplength = htod64(Maxmem * (off_t)PAGE_SIZE);
-	kdh.dumptime = htod64(time_second);
-	kdh.blocksize = htod32(di->blocksize);
-	strncpy(kdh.hostname, hostname, sizeof kdh.hostname);
-	strncpy(kdh.versionstring, version, sizeof kdh.versionstring);
+	bzero(kdh, sizeof(*kdh));
+	strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
+	strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
+	kdh->version = htod32(KERNELDUMPVERSION);
+	kdh->architectureversion = htod32(archver);
+	kdh->dumplength = htod64(dumplen);
+	kdh->dumptime = htod64(time_second);
+	kdh->blocksize = htod32(blksz);
+	strncpy(kdh->hostname, hostname, sizeof(kdh->hostname));
+	strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
 	if (panicstr != NULL)
-		strncpy(kdh.panicstring, panicstr, sizeof kdh.panicstring);
-	kdh.parity = kerneldump_parity(&kdh);
+		strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
+	kdh->parity = kerneldump_parity(kdh);
+}
+
+static int
+buf_write(struct dumperinfo *di, char *ptr, size_t sz)
+{
+	size_t len;
+	int error;
 
-	/*
-	 * Check if we will have enough room to save the coredump.
-	 * The partition size needed is the sum of:
-	 * Memory to save + header + trailer + Room to leave untouched
-	 * at partition head. (an arbitrary amount).
-	 */
-	if (di->mediasize <  
-	    Maxmem * (off_t)PAGE_SIZE + sizeof kdh * 2 + 64*1024) {
-		printf("\nDump failed. Partition too small.\n");
-		return;
+	while (sz) {
+		len = DEV_BSIZE - fragsz;
+		if (len > sz)
+			len = sz;
+		bcopy(ptr, buffer + fragsz, len);
+		fragsz += len;
+		ptr += len;
+		sz -= len;
+		if (fragsz == DEV_BSIZE) {
+			error = di->dumper(di->priv, buffer, 0, dumplo,
+			    DEV_BSIZE);
+			if (error)
+				return error;
+			dumplo += DEV_BSIZE;
+			fragsz = 0;
+		}
 	}
-	dumplo = di->mediaoffset + di->mediasize - Maxmem * (off_t)PAGE_SIZE;
-	dumplo -= sizeof kdh * 2;
-	i = di->dumper(di->priv, &kdh, 0, dumplo, sizeof kdh);
-	if (i)
-		printf("\nDump failed writing header (%d)\n", i);
-	dumplo += sizeof kdh;
-	i = 0;
-	addr = 0;
+
+	return (0);
+}
+
+static int
+buf_flush(struct dumperinfo *di)
+{
+	int error;
+
+	if (fragsz == 0)
+		return (0);
+
+	error = di->dumper(di->priv, buffer, 0, dumplo, DEV_BSIZE);
+	dumplo += DEV_BSIZE;
+	fragsz = 0;
+	return (error);
+}
+
+#define PG2MB(pgs) ((pgs + (1 << 8) - 1) >> 8)
+
+static int
+cb_dumpdata(struct md_pa *mdp, int seqnr, void *arg)
+{
+	struct dumperinfo *di = (struct dumperinfo*)arg;
+	vm_paddr_t a, pa;
+	void *va;
+	uint64_t pgs;
+	size_t counter, sz, chunk;
+	int i, c, error, twiddle;
+
+	error = 0;	/* catch case in which chunk size is 0 */
+	counter = 0;	/* Update twiddle every 16MB */
+	twiddle = 0;
 	va = 0;
-	mb = 0;
-	for (count = 0; count < Maxmem;) {
-		left = Maxmem - count;
-		if (left > MAXDUMPPGS)
-			left = MAXDUMPPGS;
-		for (u = 0; u < left; u++) {
-			a = addr + u * PAGE_SIZE;
-			if (!is_physical_memory(a))
-				a = 0;
-			va = pmap_kenter_temporary(trunc_page(a), u);
+	pgs = mdp->md_size / PAGE_SIZE;
+	pa = mdp->md_start;
+
+	printf("  chunk %d: %ldMB (%ld pages)", seqnr, PG2MB(pgs), pgs);
+
+	while (pgs) {
+		chunk = pgs;
+		if (chunk > MAXDUMPPGS)
+			chunk = MAXDUMPPGS;
+		sz = chunk << PAGE_SHIFT;
+		counter += sz;
+		if (counter >> 24) {
+			printf(" %ld", PG2MB(pgs));
+			counter &= (1<<24) - 1;
 		}
-		i = count / (16*1024*1024 / PAGE_SIZE);
-		if (i != mb) {
-			printf(" %d", count / (1024 * 1024 / PAGE_SIZE));
-			mb = i;
+		for (i = 0; i < chunk; i++) {
+			a = pa + i * PAGE_SIZE;
+			va = pmap_kenter_temporary(trunc_page(a), i);
 		}
-		i = di->dumper(di->priv, va, 0, dumplo, left * PAGE_SIZE);
-		if (i)
+		error = di->dumper(di->priv, va, 0, dumplo, sz);
+		if (error)
 			break;
-		count += left;
-		dumplo += left * PAGE_SIZE;
-		addr += left * PAGE_SIZE;
-		if ((c = cncheckc()) == 0x03) {
-			printf("\nDump aborted.\n");
-			return;
-		} else if (c != -1)
-			printf("[CTRL-C to abort] ");
+		dumplo += sz;
+		pgs -= chunk;
+		pa += sz;
+
+		/* Check for user abort. */
+		c = cncheckc();
+		if (c == 0x03)
+			return (ECANCELED);
+		if (c != -1)
+			printf(" (CTRL-C to abort) ");
+	}
+	printf(" ... %s\n", (error) ? "fail" : "ok");
+	return (error);
+}
+
+static int
+cb_dumphdr(struct md_pa *mdp, int seqnr, void *arg)
+{
+	struct dumperinfo *di = (struct dumperinfo*)arg;
+	Elf_Phdr phdr;
+	uint64_t size;
+	int error;
+
+	size = mdp->md_size;
+	bzero(&phdr, sizeof(phdr));
+	phdr.p_type = PT_LOAD;
+	phdr.p_flags = PF_R;			/* XXX */
+	phdr.p_offset = fileofs;
+	phdr.p_vaddr = mdp->md_start;
+	phdr.p_paddr = mdp->md_start;
+	phdr.p_filesz = size;
+	phdr.p_memsz = size;
+	phdr.p_align = PAGE_SIZE;
+
+	error = buf_write(di, (char*)&phdr, sizeof(phdr));
+	fileofs += phdr.p_filesz;
+	return (error);
+}
+
+static int
+cb_size(struct md_pa *mdp, int seqnr, void *arg)
+{
+	uint64_t *sz = (uint64_t*)arg;
+
+	*sz += (uint64_t)mdp->md_size;
+	return (0);
+}
+
+static int
+foreach_chunk(callback_t cb, void *arg)
+{
+	struct md_pa *mdp;
+	int error, seqnr;
+
+	seqnr = 0;
+	mdp = md_pa_first();
+	while (mdp != NULL) {
+		error = (*cb)(mdp, seqnr++, arg);
+		if (error)
+			return (-error);
+		mdp = md_pa_next(mdp);
+	}
+	return (seqnr);
+}
+
+void
+dumpsys(struct dumperinfo *di)
+{
+	Elf_Ehdr ehdr;
+	uint64_t dumpsize;
+	off_t hdrgap;
+	size_t hdrsz;
+	int error;
+
+	bzero(&ehdr, sizeof(ehdr));
+	ehdr.e_ident[EI_MAG0] = ELFMAG0;
+	ehdr.e_ident[EI_MAG1] = ELFMAG1;
+	ehdr.e_ident[EI_MAG2] = ELFMAG2;
+	ehdr.e_ident[EI_MAG3] = ELFMAG3;
+	ehdr.e_ident[EI_CLASS] = ELF_CLASS;
+#if BYTE_ORDER == LITTLE_ENDIAN
+	ehdr.e_ident[EI_DATA] = ELFDATA2LSB;
+#else
+	ehdr.e_ident[EI_DATA] = ELFDATA2MSB;
+#endif
+	ehdr.e_ident[EI_VERSION] = EV_CURRENT;
+	ehdr.e_ident[EI_OSABI] = ELFOSABI_STANDALONE;	/* XXX big picture? */
+	ehdr.e_type = ET_CORE;
+	ehdr.e_machine = EM_X86_64;
+	ehdr.e_phoff = sizeof(ehdr);
+	ehdr.e_flags = 0;
+	ehdr.e_ehsize = sizeof(ehdr);
+	ehdr.e_phentsize = sizeof(Elf_Phdr);
+	ehdr.e_shentsize = sizeof(Elf_Shdr);
+
+	md_pa_init();
+
+	/* Calculate dump size. */
+	dumpsize = 0L;
+	ehdr.e_phnum = foreach_chunk(cb_size, &dumpsize);
+	hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
+	fileofs = MD_ALIGN(hdrsz);
+	dumpsize += fileofs;
+	hdrgap = fileofs - DEV_ALIGN(hdrsz);
+
+	/* Determine dump offset on device. */
+	if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) {
+		error = ENOSPC;
+		goto fail;
 	}
-	if (i) 
-		printf("\nDump failed writing data (%d)\n", i);
-	i = di->dumper(di->priv, &kdh, 0, dumplo, sizeof kdh);
-	if (i)
-		printf("\nDump failed writing trailer (%d)\n", i);
-	di->dumper(di->priv, NULL, 0, 0, 0);  /* tell them we are done */
+	dumplo = di->mediaoffset + di->mediasize - dumpsize;
+	dumplo -= sizeof(kdh) * 2;
+
+	mkdumpheader(&kdh, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize);
+
+	printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
+	    ehdr.e_phnum);
+
+	/* Dump leader */
+	error = di->dumper(di->priv, &kdh, 0, dumplo, sizeof(kdh));
+	if (error)
+		goto fail;
+	dumplo += sizeof(kdh);
+
+	/* Dump ELF header */
+	error = buf_write(di, (char*)&ehdr, sizeof(ehdr));
+	if (error)
+		goto fail;
+
+	/* Dump program headers */
+	error = foreach_chunk(cb_dumphdr, di);
+	if (error < 0)
+		goto fail;
+	buf_flush(di);
+
+	/*
+	 * All headers are written using blocked I/O, so we know the
+	 * current offset is (still) block aligned. Skip the alignement
+	 * in the file to have the segment contents aligned at page
+	 * boundary. We cannot use MD_ALIGN on dumplo, because we don't
+	 * care and may very well be unaligned within the dump device.
+	 */
+	dumplo += hdrgap;
+
+	/* Dump memory chunks (updates dumplo) */
+	error = foreach_chunk(cb_dumpdata, di);
+	if (error < 0)
+		goto fail;
+
+	/* Dump trailer */
+	error = di->dumper(di->priv, &kdh, 0, dumplo, sizeof(kdh));
+	if (error)
+		goto fail;
+
+	/* Signal completion, signoff and exit stage left. */
+	di->dumper(di->priv, NULL, 0, 0, 0);
 	printf("\nDump complete\n");
 	return;
+
+ fail:
+	if (error < 0)
+		error = -error;
+
+	if (error == ECANCELED)
+		printf("\nDump aborted\n");
+	else if (error == ENOSPC)
+		printf("\nDump failed. Partition too small.\n");
+	else
+		printf("\n** DUMP FAILED (ERROR %d) **\n", error);
 }

==== //depot/projects/smpng/sys/amd64/amd64/exception.S#14 (text+ko) ====

@@ -27,7 +27,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/amd64/exception.S,v 1.124 2005/06/24 00:38:36 peter Exp $
+ * $FreeBSD: src/sys/amd64/amd64/exception.S,v 1.125 2005/06/30 00:26:54 peter Exp $
  */
 
 #include "opt_atpic.h"
@@ -126,8 +126,6 @@
 	TRAP_ERR(T_SEGNPFLT)
 IDTVEC(stk)
 	TRAP_ERR(T_STKFLT)
-IDTVEC(prot)
-	TRAP_ERR(T_PROTFLT)
 IDTVEC(align)
 	TRAP_ERR(T_ALIGNFLT)
 
@@ -203,7 +201,8 @@
 	testb	$SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */
 	jz	1f			/* already running with kernel GS.base */
 	swapgs
-1:	movq	%rdi,TF_RDI(%rsp)	/* free up a GP register */
+1:
+	movq	%rdi,TF_RDI(%rsp)	/* free up a GP register */
 	movq	%cr2,%rdi		/* preserve %cr2 before ..  */
 	movq	%rdi,TF_ADDR(%rsp)	/* enabling interrupts. */
 	testl	$PSL_I,TF_RFLAGS(%rsp)
@@ -211,6 +210,30 @@
 	sti
 	jmp	alltraps_pushregs_no_rdi
 
+	/*
+	 * We have to special-case this one.  If we get a trap in doreti() at
+	 * the iretq stage, we'll reenter with the wrong gs state.  We'll have
+	 * to do a special the swapgs in this case even coming from the kernel.
+	 * XXX linux has a trap handler for their equivalent of load_gs().
+	 */
+IDTVEC(prot)
+	subq	$TF_ERR,%rsp
+	movq	$T_PROTFLT,TF_TRAPNO(%rsp)
+	movq	$0,TF_ADDR(%rsp)
+	movq	%rdi,TF_RDI(%rsp)	/* free up a GP register */
+	leaq	doreti_iret(%rip),%rdi
+	cmpq	%rdi,TF_RIP(%rsp)
+	je	2f			/* kernel but with user gsbase!! */
+	testb	$SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */
+	jz	1f			/* already running with kernel GS.base */
+2:
+	swapgs
+1:
+	testl	$PSL_I,TF_RFLAGS(%rsp)
+	jz	alltraps_pushregs_no_rdi
+	sti
+	jmp	alltraps_pushregs_no_rdi
+
 /*
  * Fast syscall entry point.  We enter here with just our new %cs/%ss set,
  * and the new privilige level.  We are still running on the old user stack

==== //depot/projects/smpng/sys/amd64/amd64/machdep.c#42 (text+ko) ====

@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.637 2005/06/24 00:45:01 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.638 2005/06/29 22:28:45 peter Exp $");
 
 #include "opt_atalk.h"
 #include "opt_atpic.h"
@@ -159,9 +159,11 @@
 long realmem = 0;
 
 vm_paddr_t phys_avail[20];
+vm_paddr_t dump_avail[20];
 
 /* must be 2 less so 0 0 can signal end of chunks */
-#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(vm_offset_t)) - 2)
+#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(phys_avail[0])) - 2)
+#define DUMP_AVAIL_ARRAY_END ((sizeof(dump_avail) / sizeof(dump_avail[0])) - 2)
 
 struct kva_md_info kmi;
 
@@ -864,7 +866,7 @@
 static void
 getmemsize(caddr_t kmdp, u_int64_t first)
 {
-	int i, physmap_idx, pa_indx;
+	int i, physmap_idx, pa_indx, da_indx;
 	vm_paddr_t pa, physmap[PHYSMAP_SIZE];
 	u_long physmem_tunable;
 	pt_entry_t *pte;
@@ -978,8 +980,10 @@
 	 */
 	physmap[0] = PAGE_SIZE;		/* mask off page 0 */
 	pa_indx = 0;
+	da_indx = 1;
 	phys_avail[pa_indx++] = physmap[0];
 	phys_avail[pa_indx] = physmap[0];
+	dump_avail[da_indx] = physmap[0];
 	pte = CMAP1;
 
 	/*
@@ -1000,22 +1004,23 @@
 		if (physmap[i + 1] < end)
 			end = trunc_page(physmap[i + 1]);
 		for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) {
-			int tmp, page_bad;
+			int tmp, page_bad, full;
 			int *ptr = (int *)CADDR1;
 
+			full = FALSE;
 			/*
 			 * block out kernel memory as not available.
 			 */
 			if (pa >= 0x100000 && pa < first)
-				continue;
+				goto do_dump_avail;
 
- 			/*
- 			 * block out dcons buffer
- 			 */
- 			if (dcons_addr > 0
- 			    && pa >= trunc_page(dcons_addr)
- 			    && pa < dcons_addr + dcons_size)
- 				continue;
+			/*
+			 * block out dcons buffer
+			 */
+			if (dcons_addr > 0
+			    && pa >= trunc_page(dcons_addr)
+			    && pa < dcons_addr + dcons_size)
+				goto do_dump_avail;
 
 			page_bad = FALSE;
 
@@ -1079,12 +1084,28 @@
 					printf(
 		"Too many holes in the physical address space, giving up\n");
 					pa_indx--;
-					break;
+					full = TRUE;
+					goto do_dump_avail;
 				}
 				phys_avail[pa_indx++] = pa;	/* start */
 				phys_avail[pa_indx] = pa + PAGE_SIZE; /* end */
 			}
 			physmem++;
+do_dump_avail:
+			if (dump_avail[da_indx] == pa) {
+				dump_avail[da_indx] += PAGE_SIZE;
+			} else {
+				da_indx++;
+				if (da_indx == DUMP_AVAIL_ARRAY_END) {
+					da_indx--;
+					goto do_next;
+				}
+				dump_avail[da_indx++] = pa; /* start */
+				dump_avail[da_indx] = pa + PAGE_SIZE; /* end */
+			}
+do_next:
+			if (full)
+				break;
 		}
 	}
 	*pte = 0;

==== //depot/projects/smpng/sys/amd64/amd64/mp_machdep.c#22 (text+ko) ====

@@ -25,9 +25,10 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/mp_machdep.c,v 1.259 2005/06/09 18:23:54 ups Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/mp_machdep.c,v 1.260 2005/06/29 23:23:16 peter Exp $");
 
 #include "opt_cpu.h"
+#include "opt_kdb.h"
 #include "opt_kstack_pages.h"
 #include "opt_mp_watchdog.h"
 #include "opt_sched.h"

==== //depot/projects/smpng/sys/amd64/amd64/trap.c#29 (text+ko) ====

@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.288 2005/06/25 22:14:42 ups Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.289 2005/06/29 23:23:16 peter Exp $");
 
 /*
  * AMD64 Trap and System call handling
@@ -48,6 +48,7 @@
 #include "opt_cpu.h"
 #include "opt_hwpmc_hooks.h"
 #include "opt_isa.h"
+#include "opt_kdb.h"
 #include "opt_ktrace.h"
 
 #include <sys/param.h>

==== //depot/projects/smpng/sys/amd64/conf/NOTES#18 (text+ko) ====

@@ -4,7 +4,7 @@
 # This file contains machine dependent kernel configuration notes.  For
 # machine independent notes, look in /sys/conf/NOTES.
 #
-# $FreeBSD: src/sys/amd64/conf/NOTES,v 1.35 2005/06/14 14:21:25 ups Exp $
+# $FreeBSD: src/sys/amd64/conf/NOTES,v 1.36 2005/06/30 05:33:25 peter Exp $
 #
 
 #
@@ -15,7 +15,7 @@
 
 #
 # We want LINT to cover profiling as well.
-#XXX#profile         2
+profile         2
 
 
 #####################################################################
@@ -202,6 +202,9 @@
 #!options 	ACPI_NO_SEMAPHORES
 #!options 	ACPICA_PEDANTIC
 
+# The cpufreq(4) driver provides support for non-ACPI CPU frequency control
+device		cpufreq
+
 # Direct Rendering modules for 3D acceleration.
 device		drm		# DRM core module required by DRM drivers
 device		mach64drm	# ATI Rage Pro, Rage Mobility P/M, Rage XL
@@ -225,15 +228,19 @@
 
 #XXX#	still calls MD i386 kvtop function instead of vtophys etc
 #XXX#device		ed
+#XXX#options 		ED_3C503
+#XXX#options 		ED_HPP
+#XXX#options 		ED_SIC
 #XXX#device		lnc
 
-#XXX#device	ath
-#XXX#device	ath_hal		# Atheros HAL (includes binary component)
-device		wlan		# 802.11 layer
+device		ath
+device		ath_hal		# Atheros HAL (includes binary component)
+device		ath_rate_onoe	# Onoe rate control for ath driver
+#device		ath_rate_amrr	# AMRR rate control for ath driver
+#device		ath_rate_sample	# SampleRate rate control for the ath driver
+#device		wlan		# 802.11 layer
 
 #
-# ATA raid adapters
-#
 #XXX this stores pointers in a 32bit field that is defined by the hardware
 #device	pst
 
@@ -269,6 +276,11 @@
 device		aacp	# SCSI Passthrough interface (optional, CAM required)
 
 #
+# Highpoint RocketRAID 182x.  This is really just software RAID on a
+# Marvell SATA chip.
+#device		hptmv	# Broken, i386-only binary.
+
+#
 # IBM (now Adaptec) ServeRAID controllers
 device		ips
 
@@ -305,6 +317,10 @@
 device		digi_Xe
 device		digi_Xem
 device		digi_Xr
+# Parallel (8255 PPI) basic I/O (mode 0) port (e.g. Advantech PCL-724)
+device		pbio

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



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