svn commit: r277210 - in projects/ifnet: contrib/compiler-rt/lib/sanitizer_common contrib/elftoolchain/elfcopy contrib/ntp/ntpd sys/amd64/conf sys/arm/broadcom/bcm2835 sys/arm/ti/cpsw sys/boot/comm...

Gleb Smirnoff glebius at FreeBSD.org
Thu Jan 15 06:14:48 UTC 2015


Author: glebius
Date: Thu Jan 15 06:14:42 2015
New Revision: 277210
URL: https://svnweb.freebsd.org/changeset/base/277210

Log:
  Merge head.

Added:
  projects/ifnet/sys/amd64/conf/MINIMAL
     - copied unchanged from r277209, head/sys/amd64/conf/MINIMAL
Modified:
  projects/ifnet/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
  projects/ifnet/contrib/elftoolchain/elfcopy/sections.c
  projects/ifnet/contrib/ntp/ntpd/ntp_io.c
  projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
  projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h
  projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
  projects/ifnet/sys/arm/ti/cpsw/if_cpsw.c
  projects/ifnet/sys/boot/common/load_elf_obj.c
  projects/ifnet/sys/boot/fdt/dts/arm/beaglebone-black.dts
  projects/ifnet/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
  projects/ifnet/sys/fs/devfs/devfs_devs.c
  projects/ifnet/sys/kern/kern_conf.c
  projects/ifnet/sys/kern/uipc_mbuf.c
  projects/ifnet/sys/sys/mbuf.h
  projects/ifnet/sys/sys/module.h
  projects/ifnet/usr.sbin/kldxref/kldxref.c
Directory Properties:
  projects/ifnet/   (props changed)
  projects/ifnet/contrib/compiler-rt/   (props changed)
  projects/ifnet/contrib/elftoolchain/   (props changed)
  projects/ifnet/contrib/ntp/   (props changed)
  projects/ifnet/sys/   (props changed)
  projects/ifnet/sys/boot/   (props changed)
  projects/ifnet/sys/cddl/contrib/opensolaris/   (props changed)

Modified: projects/ifnet/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
==============================================================================
--- projects/ifnet/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc	Thu Jan 15 06:14:42 2015	(r277210)
@@ -97,7 +97,6 @@
 # include <sys/link_elf.h>
 # include <netinet/ip_mroute.h>
 # include <netinet/in.h>
-# include <netinet/ip_compat.h>
 # include <net/ethernet.h>
 # include <net/ppp_defs.h>
 # include <glob.h>

Modified: projects/ifnet/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- projects/ifnet/contrib/elftoolchain/elfcopy/sections.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/contrib/elftoolchain/elfcopy/sections.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -777,6 +777,8 @@ resync_sections(struct elfcopy *ecp)
 			continue;
 
 		/* Align section offset. */
+		if (s->align == 0)
+			s->align = 1;
 		if (off <= s->off) {
 			if (!s->loadable)
 				s->off = roundup(off, s->align);

Modified: projects/ifnet/contrib/ntp/ntpd/ntp_io.c
==============================================================================
--- projects/ifnet/contrib/ntp/ntpd/ntp_io.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/contrib/ntp/ntpd/ntp_io.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -1176,12 +1176,13 @@ set_wildcard_reuse(int family, int on)
 
 #ifdef INCLUDE_IPV6_SUPPORT
 static isc_boolean_t
-is_anycast(struct sockaddr *sa, char *name)
+is_not_bindable(struct sockaddr *sa, char *name)
 {
-#if defined(SIOCGIFAFLAG_IN6) && defined(IN6_IFF_ANYCAST)
+#if defined(SIOCGIFAFLAG_IN6) && \
+	   (defined(IN6_IFF_ANYCAST) || defined(IN6_IFF_NOTREADY))
 	struct in6_ifreq ifr6;
 	int fd;
-	u_int32_t flags6;
+	u_int32_t flags6, exclude = 0;
 
 	if (sa->sa_family != AF_INET6)
 		return ISC_FALSE;
@@ -1197,9 +1198,15 @@ is_anycast(struct sockaddr *sa, char *na
 	}
 	close(fd);
 	flags6 = ifr6.ifr_ifru.ifru_flags6;
-	if ((flags6 & IN6_IFF_ANYCAST) != 0)
+#if defined(IN6_IFF_ANYCAST)
+	exclude |= IN6_IFF_ANYCAST;
+#endif /* !IN6_IFF_ANYCAST */
+#if defined(IN6_IFF_NOTREADY)
+	exclude |= IN6_IFF_NOTREADY;
+#endif /* !IN6_IFF_NOTREADY */
+	if ((flags6 & exclude) != 0)
 		return ISC_TRUE;
-#endif /* !SIOCGIFAFLAG_IN6 || !IN6_IFF_ANYCAST */
+#endif /* !SIOCGIFAFLAG_IN6 || !(IN6_IFF_ANYCAST && IN6_IFF_NOTREADY) */
 	return ISC_FALSE;
 }
 #endif /* !INCLUDE_IPV6_SUPPORT */
@@ -1344,7 +1351,7 @@ update_interfaces(
 			continue;
 
 #ifdef INCLUDE_IPV6_SUPPORT
-		if (is_anycast((struct sockaddr *)&interface.sin, isc_if.name))
+		if (is_not_bindable((struct sockaddr *)&interface.sin, isc_if.name))
 			continue;
 #endif /* !INCLUDE_IPV6_SUPPORT */
 

Copied: projects/ifnet/sys/amd64/conf/MINIMAL (from r277209, head/sys/amd64/conf/MINIMAL)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ifnet/sys/amd64/conf/MINIMAL	Thu Jan 15 06:14:42 2015	(r277210, copy of r277209, head/sys/amd64/conf/MINIMAL)
@@ -0,0 +1,145 @@
+#
+# MINIMAL -- Mostly Minimal kernel configuration file for FreeBSD/amd64
+#
+# Many definitions of minimal are possible. The one this file follows is
+# GENERIC, minus all functionality that can be replaced by loading kernel
+# modules.
+#
+# Exceptions:
+# o While UFS is buildable as a module, the current module lacks
+#   some features (ACL, GJOURNAL) that GENERIC includes.
+# o acpi as a module has been reported flakey and not well tested, so
+#   is included in the kernel.
+# o random is included due to uncertaty...
+# o Many networking things are included
+#
+# For now, please run changes to these list past imp at freebsd.org
+#
+# For more information on this file, please read the config(5) manual page,
+# and/or the handbook section on Kernel Configuration Files:
+#
+#    http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD$
+
+cpu		HAMMER
+ident		MINIMAL
+
+makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
+makeoptions	WITH_CTF=1		# Run ctfconvert(1) for DTrace support
+
+options 	SCHED_ULE		# ULE scheduler
+options 	PREEMPTION		# Enable kernel thread preemption
+options 	INET			# InterNETworking
+options 	INET6			# IPv6 communications protocols
+options 	TCP_OFFLOAD		# TCP offload
+options 	SCTP			# Stream Control Transmission Protocol
+options 	FFS			# Berkeley Fast Filesystem
+options 	SOFTUPDATES		# Enable FFS soft updates support
+options 	UFS_ACL			# Support for access control lists
+options 	UFS_DIRHASH		# Improve performance on big directories
+options 	UFS_GJOURNAL		# Enable gjournal-based UFS journaling
+options 	QUOTA			# Enable disk quotas for UFS
+options 	MD_ROOT			# MD is a potential root device
+options 	COMPAT_FREEBSD32	# Compatible with i386 binaries
+options 	COMPAT_FREEBSD4		# Compatible with FreeBSD4
+options 	COMPAT_FREEBSD5		# Compatible with FreeBSD5
+options 	COMPAT_FREEBSD6		# Compatible with FreeBSD6
+options 	COMPAT_FREEBSD7		# Compatible with FreeBSD7
+options 	COMPAT_FREEBSD9		# Compatible with FreeBSD9
+options 	COMPAT_FREEBSD10	# Compatible with FreeBSD10
+options 	SCSI_DELAY=5000		# Delay (in ms) before probing SCSI
+options 	KTRACE			# ktrace(1) support
+options 	STACK			# stack(9) support
+options 	SYSVSHM			# SYSV-style shared memory
+options 	SYSVMSG			# SYSV-style message queues
+options 	SYSVSEM			# SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
+options 	PRINTF_BUFR_SIZE=128	# Prevent printf output being interspersed.
+options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
+options 	HWPMC_HOOKS		# Necessary kernel hooks for hwpmc(4)
+options 	AUDIT			# Security event auditing
+options 	CAPABILITY_MODE		# Capsicum capability mode
+options 	CAPABILITIES		# Capsicum capabilities
+options 	MAC			# TrustedBSD MAC Framework
+options 	KDTRACE_FRAME		# Ensure frames are compiled in
+options 	KDTRACE_HOOKS		# Kernel DTrace hooks
+options 	DDB_CTF			# Kernel ELF linker loads CTF data
+options 	INCLUDE_CONFIG_FILE	# Include this file in kernel
+
+# Debugging support.  Always need this:
+options 	KDB			# Enable kernel debugger support.
+options 	KDB_TRACE		# Print a stack trace for a panic.
+# For full debugger support use (turn off in stable branch):
+options 	DDB			# Support DDB.
+options 	GDB			# Support remote GDB.
+options 	DEADLKRES		# Enable the deadlock resolver
+options 	INVARIANTS		# Enable calls of extra sanity checking
+options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
+options 	WITNESS			# Enable checks to detect deadlocks and cycles
+options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
+options 	MALLOC_DEBUG_MAXZONES=8	# Separate malloc(9) zones
+
+# Make an SMP-capable kernel by default
+options 	SMP			# Symmetric MultiProcessor Kernel
+
+# CPU frequency control
+device		cpufreq
+
+# Bus support.
+device		acpi
+options 	ACPI_DMAR
+device		pci
+
+# atkbdc0 controls both the keyboard and the PS/2 mouse
+device		atkbdc			# AT keyboard controller
+device		atkbd			# AT keyboard
+device		psm			# PS/2 mouse
+
+device		kbdmux			# keyboard multiplexer
+
+device		vga			# VGA video card driver
+options 	VESA			# Add support for VESA BIOS Extensions (VBE)
+
+device		splash			# Splash screen and screen saver support
+
+# syscons is the default console driver, resembling an SCO console
+device		sc
+options 	SC_PIXEL_MODE		# add support for the raster text mode
+
+# vt is the new video console driver
+device		vt
+device		vt_vga
+device		vt_efifb
+
+device		agp			# support several AGP chipsets
+
+# Pseudo devices.
+device		loop			# Network loopback
+device		random			# Entropy device
+device		padlock_rng		# VIA Padlock RNG
+device		rdrand_rng		# Intel Bull Mountain RNG
+device		ether			# Ethernet support
+device		vlan			# 802.1Q VLAN support
+device		tun			# Packet tunnel.
+device		gif			# IPv6 and IPv4 tunneling
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device		bpf			# Berkeley packet filter
+
+# Xen HVM Guest Optimizations
+# NOTE: XENHVM depends on xenpci.  They must be added or removed together.
+options 	XENHVM			# Xen HVM kernel infrastructure
+device		xenpci			# Xen HVM Hypervisor services driver

Modified: projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
==============================================================================
--- projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bsc.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -252,6 +252,7 @@ bcm_bsc_attach(device_t dev)
 	}
 	if (i == nitems(bcm_bsc_pins)) {
 		device_printf(dev, "only bsc0 and bsc1 are supported\n");
+		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
 		return (ENXIO);
 	}
 
@@ -262,6 +263,7 @@ bcm_bsc_attach(device_t dev)
 	gpio = devclass_get_device(devclass_find("gpio"), 0);
 	if (!gpio) {
 		device_printf(dev, "cannot find gpio0\n");
+		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
 		return (ENXIO);
 	}
 	bcm_gpio_set_alternate(gpio, bcm_bsc_pins[i].sda, BCM_GPIO_ALT0);

Modified: projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h
==============================================================================
--- projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h	Thu Jan 15 06:14:42 2015	(r277210)
@@ -58,9 +58,9 @@ struct bcm_bsc_softc {
 #define	BCM_I2C_ERROR		0x04
 
 #define	BCM_BSC_WRITE(_sc, _off, _val)		\
-    bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val)
+    bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, _off, _val)
 #define	BCM_BSC_READ(_sc, _off)			\
-    bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off)
+    bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, _off)
 
 #define	BCM_BSC_LOCK(_sc)			\
     mtx_lock(&(_sc)->sc_mtx)

Modified: projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
==============================================================================
--- projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -64,8 +64,6 @@ __FBSDID("$FreeBSD$");
 #define MHZ2HZ(freq) ((freq) * (1000 * 1000))
 #define OFFSET2MVOLT(val) (1200 + ((val) * 25))
 #define MVOLT2OFFSET(val) (((val) - 1200) / 25)
-#define RAW2K(temp) (((temp) + 273150) / 1000)
-#define K2RAW(temp) (((temp) * 1000) - 273150)
 
 #define DEFAULT_ARM_FREQUENCY	 700
 #define DEFAULT_CORE_FREQUENCY	 250
@@ -77,6 +75,7 @@ __FBSDID("$FreeBSD$");
 #define MSG_ERROR	  -999999999
 #define MHZSTEP			 100
 #define HZSTEP	   (MHZ2HZ(MHZSTEP))
+#define	TZ_ZEROC		2732
 
 #define VC_LOCK(sc) do {			\
 		sema_wait(&vc_sema);		\
@@ -1215,7 +1214,7 @@ sysctl_bcm2835_devcpu_temperature(SYSCTL
 		return (EIO);
 
 	/* 1/1000 celsius (raw) to 1/10 kelvin */
-	val = RAW2K(val) * 10;
+	val = val / 100 + TZ_ZEROC;
 
 	err = sysctl_handle_int(oidp, &val, 0, req);
 	if (err || !req->newptr) /* error || read request */

Modified: projects/ifnet/sys/arm/ti/cpsw/if_cpsw.c
==============================================================================
--- projects/ifnet/sys/arm/ti/cpsw/if_cpsw.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/arm/ti/cpsw/if_cpsw.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -396,9 +396,9 @@ cpsw_dump_slot(struct cpsw_softc *sc, st
 	printf("\n");
 	if (slot->mbuf) {
 		printf("  Ether:  %14D\n",
-		    (char *)(slot->mbuf->m_hdr.mh_data), " ");
+		    (char *)(slot->mbuf->m_data), " ");
 		printf("  Packet: %16D\n",
-		    (char *)(slot->mbuf->m_hdr.mh_data) + 14, " ");
+		    (char *)(slot->mbuf->m_data) + 14, " ");
 	}
 }
 
@@ -611,7 +611,7 @@ cpsw_attach(device_t dev)
 
 	/* Allocate the null mbuf and pre-sync it. */
 	sc->null_mbuf = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
-	memset(sc->null_mbuf->m_hdr.mh_data, 0, sc->null_mbuf->m_ext.ext_size);
+	memset(sc->null_mbuf->m_data, 0, sc->null_mbuf->m_ext.ext_size);
 	bus_dmamap_create(sc->mbuf_dtag, 0, &sc->null_mbuf_dmamap);
 	bus_dmamap_load_mbuf_sg(sc->mbuf_dtag, sc->null_mbuf_dmamap,
 	    sc->null_mbuf, segs, &nsegs, BUS_DMA_NOWAIT);
@@ -1292,8 +1292,8 @@ cpsw_rx_dequeue(struct cpsw_softc *sc)
 		/* Set up mbuf */
 		/* TODO: track SOP/EOP bits to assemble a full mbuf
 		   out of received fragments. */
-		slot->mbuf->m_hdr.mh_data += bd.bufoff;
-		slot->mbuf->m_hdr.mh_len = bd.pktlen - 4;
+		slot->mbuf->m_data += bd.bufoff;
+		slot->mbuf->m_len = bd.pktlen - 4;
 		slot->mbuf->m_pkthdr.len = bd.pktlen - 4;
 		slot->mbuf->m_flags |= M_PKTHDR;
 		slot->mbuf->m_pkthdr.rcvif = ifp;
@@ -1461,7 +1461,7 @@ cpsw_tx_enqueue(struct cpsw_softc *sc)
 			bus_dmamap_unload(sc->mbuf_dtag, slot->dmamap);
 			if (padlen > 0) /* May as well add padding. */
 				m_append(slot->mbuf, padlen,
-				    sc->null_mbuf->m_hdr.mh_data);
+				    sc->null_mbuf->m_data);
 			m0 = m_defrag(slot->mbuf, M_NOWAIT);
 			if (m0 == NULL) {
 				if_printf(sc->ifp,

Modified: projects/ifnet/sys/boot/common/load_elf_obj.c
==============================================================================
--- projects/ifnet/sys/boot/common/load_elf_obj.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/boot/common/load_elf_obj.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -416,6 +416,7 @@ __elfN(obj_parse_modmetadata)(struct pre
 			modcnt++;
 			break;
 		case MDT_MODULE:
+		case MDT_PNP_INFO:
 			break;
 		default:
 			printf("unknown type %d\n", md.md_type);

Modified: projects/ifnet/sys/boot/fdt/dts/arm/beaglebone-black.dts
==============================================================================
--- projects/ifnet/sys/boot/fdt/dts/arm/beaglebone-black.dts	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/boot/fdt/dts/arm/beaglebone-black.dts	Thu Jan 15 06:14:42 2015	(r277210)
@@ -144,10 +144,9 @@
 			status = "okay";
 			non-removable;
 		};
-
  
 		i2c at 44e0b000 {
-			pmic at 24 {
+			pmic at 48 {
 				compatible = "ti,am335x-pmic";
 				reg = <0x48>;
 			};

Modified: projects/ifnet/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
==============================================================================
--- projects/ifnet/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -440,7 +440,7 @@ trim_map_vdev_commit(spa_t *spa, zio_t *
 	if (tm == NULL)
 		return;
 
-	timelimit = gethrtime() - trim_timeout * NANOSEC;
+	timelimit = gethrtime() - (hrtime_t)trim_timeout * NANOSEC;
 	if (vd->vdev_isl2cache) {
 		txgsafe = UINT64_MAX;
 		txgtarget = UINT64_MAX;

Modified: projects/ifnet/sys/fs/devfs/devfs_devs.c
==============================================================================
--- projects/ifnet/sys/fs/devfs/devfs_devs.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/fs/devfs/devfs_devs.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -137,6 +137,12 @@ devfs_alloc(int flags)
 	vfs_timestamp(&ts);
 	cdev->si_atime = cdev->si_mtime = cdev->si_ctime = ts;
 	cdev->si_cred = NULL;
+	/*
+	 * Avoid race with dev_rel() by setting the initial
+	 * reference count to 1. This last reference is taken
+	 * by the destroy_dev() function.
+	 */
+	cdev->si_refcount = 1;
 
 	return (cdev);
 }

Modified: projects/ifnet/sys/kern/kern_conf.c
==============================================================================
--- projects/ifnet/sys/kern/kern_conf.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/kern/kern_conf.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -1048,8 +1048,6 @@ destroy_devl(struct cdev *dev)
 	/* Remove name marking */
 	dev->si_flags &= ~SI_NAMED;
 
-	dev->si_refcount++;	/* Avoid race with dev_rel() */
-
 	/* If we are a child, remove us from the parents list */
 	if (dev->si_flags & SI_CHILD) {
 		LIST_REMOVE(dev, si_siblings);

Modified: projects/ifnet/sys/kern/uipc_mbuf.c
==============================================================================
--- projects/ifnet/sys/kern/uipc_mbuf.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/kern/uipc_mbuf.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -88,11 +88,38 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, m_defrag
  * Ensure the correct size of various mbuf parameters.  It could be off due
  * to compiler-induced padding and alignment artifacts.
  */
-CTASSERT(sizeof(struct mbuf) == MSIZE);
 CTASSERT(MSIZE - offsetof(struct mbuf, m_dat) == MLEN);
 CTASSERT(MSIZE - offsetof(struct mbuf, m_pktdat) == MHLEN);
 
 /*
+ * mbuf data storage should be 64-bit aligned regardless of architectural
+ * pointer size; check this is the case with and without a packet header.
+ */
+CTASSERT(offsetof(struct mbuf, m_dat) % 8 == 0);
+CTASSERT(offsetof(struct mbuf, m_pktdat) % 8 == 0);
+
+/*
+ * While the specific values here don't matter too much (i.e., +/- a few
+ * words), we do want to ensure that changes to these values are carefully
+ * reasoned about and properly documented.  This is especially the case as
+ * network-protocol and device-driver modules encode these layouts, and must
+ * be recompiled if the structures change.  Check these values at compile time
+ * against the ones documented in comments in mbuf.h.
+ *
+ * NB: Possibly they should be documented there via #define's and not just
+ * comments.
+ */
+#if defined(__LP64__)
+CTASSERT(offsetof(struct mbuf, m_dat) == 32);
+CTASSERT(sizeof(struct pkthdr) == 56);
+CTASSERT(sizeof(struct struct_m_ext) == 48);
+#else
+CTASSERT(offsetof(struct mbuf, m_dat) == 24);
+CTASSERT(sizeof(struct pkthdr) == 48);
+CTASSERT(sizeof(struct struct_m_ext) == 28);
+#endif
+
+/*
  * m_get2() allocates minimum mbuf that would fit "size" argument.
  */
 struct mbuf *

Modified: projects/ifnet/sys/sys/mbuf.h
==============================================================================
--- projects/ifnet/sys/sys/mbuf.h	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/sys/mbuf.h	Thu Jan 15 06:14:42 2015	(r277210)
@@ -60,9 +60,15 @@
  * MLEN is data length in a normal mbuf.
  * MHLEN is data length in an mbuf with pktheader.
  * MINCLSIZE is a smallest amount of data that should be put into cluster.
+ *
+ * Compile-time assertions in uipc_mbuf.c test these values to ensure that
+ * they are sensible.
  */
-#define	MLEN		((int)(MSIZE - sizeof(struct m_hdr)))
-#define	MHLEN		((int)(MLEN - sizeof(struct pkthdr)))
+struct mbuf;
+#define	MHSIZE		offsetof(struct mbuf, M_dat.M_databuf)
+#define	MPKTHSIZE	offsetof(struct mbuf, M_dat.MH.MH_dat.MH_databuf)
+#define	MLEN		((int)(MSIZE - MHSIZE))
+#define	MHLEN		((int)(MSIZE - MPKTHSIZE))
 #define	MINCLSIZE	(MHLEN + 1)
 
 #ifdef _KERNEL
@@ -126,6 +132,8 @@ struct m_tag {
  * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set.
  * Size ILP32: 48
  *	 LP64: 56
+ * Compile-time assertions in uipc_mbuf.c test these values to ensure that
+ * they are correct.
  */
 struct pkthdr {
 	struct ifnet	*rcvif;		/* rcv interface */
@@ -174,8 +182,10 @@ struct pkthdr {
  * set.
  * Size ILP32: 28
  *	 LP64: 48
+ * Compile-time assertions in uipc_mbuf.c test these values to ensure that
+ * they are correct.
  */
-struct m_ext {
+struct struct_m_ext {
 	volatile u_int	*ext_cnt;	/* pointer to ref count info */
 	caddr_t		 ext_buf;	/* start of buffer */
 	uint32_t	 ext_size;	/* size of buffer, for ext_free */
@@ -192,28 +202,55 @@ struct m_ext {
  * purposes.
  */
 struct mbuf {
-	struct m_hdr	m_hdr;
+	/*
+	 * Header present at the beginning of every mbuf.
+	 * Size ILP32: 24
+	 *      LP64: 32
+	 * Compile-time assertions in uipc_mbuf.c test these values to ensure
+	 * that they are correct.
+	 */
+	union {
+		struct mbuf		*m;
+		SLIST_ENTRY(mbuf)	slist;
+		STAILQ_ENTRY(mbuf)	stailq;
+	}		 mu_next;	/* next buffer in chain */
+	union {
+		struct mbuf		*m;
+		SLIST_ENTRY(mbuf)	slist;
+		STAILQ_ENTRY(mbuf)	stailq;
+	}		 mu_nextpkt;	/* next chain in queue/record */
+	caddr_t		 m_data;	/* location of data */
+	int32_t		 m_len;		/* amount of data in this mbuf */
+	uint32_t	 m_type:8,	/* type of data in this mbuf */
+			 m_flags:24;	/* flags; see below */
+#if !defined(__LP64__)
+	uint32_t	 m_pad;		/* pad for 64bit alignment */
+#endif
+
+	/*
+	 * A set of optional headers (packet header, external storage header)
+	 * and internal data storage.  Historically, these arrays were sized
+	 * to MHLEN (space left after a packet header) and MLEN (space left
+	 * after only a regular mbuf header); they are now variable size in
+	 * order to support future work on variable-size mbufs.
+	 */
 	union {
 		struct {
 			struct pkthdr	MH_pkthdr;	/* M_PKTHDR set */
 			union {
-				struct m_ext	MH_ext;	/* M_EXT set */
-				char		MH_databuf[MHLEN];
+				struct struct_m_ext	MH_ext;	/* M_EXT set */
+				char		MH_databuf[0];
 			} MH_dat;
 		} MH;
-		char	M_databuf[MLEN];		/* !M_PKTHDR, !M_EXT */
+		char	M_databuf[0];			/* !M_PKTHDR, !M_EXT */
 	} M_dat;
 };
-#define	m_next		m_hdr.mh_next.m
-#define	m_slist		m_hdr.mh_next.slist
-#define	m_stailq	m_hdr.mh_next.stailq
-#define	m_len		m_hdr.mh_len
-#define	m_data		m_hdr.mh_data
-#define	m_type		m_hdr.mh_type
-#define	m_flags		m_hdr.mh_flags
-#define	m_nextpkt	m_hdr.mh_nextpkt.m
-#define	m_slistpkt	m_hdr.mh_nextpkt.slist
-#define	m_stailqpkt	m_hdr.mh_nextpkt.stailq
+#define	m_next		mu_next.m
+#define	m_slist		mu_next.slist
+#define	m_stailq	mu_next.stailq
+#define	m_nextpkt	mu_nextpkt.m
+#define	m_slistpkt	mu_nextpkt.slist
+#define	m_stailqpkt	mu_nextpkt.stailq
 #define	m_pkthdr	M_dat.MH.MH_pkthdr
 #define	m_ext		M_dat.MH.MH_dat.MH_ext
 #define	m_pktdat	M_dat.MH.MH_dat.MH_databuf

Modified: projects/ifnet/sys/sys/module.h
==============================================================================
--- projects/ifnet/sys/sys/module.h	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/sys/sys/module.h	Thu Jan 15 06:14:42 2015	(r277210)
@@ -35,6 +35,7 @@
 #define	MDT_DEPEND	1		/* argument is a module name */
 #define	MDT_MODULE	2		/* module declaration */
 #define	MDT_VERSION	3		/* module version(s) */
+#define	MDT_PNP_INFO	4		/* Plug and play hints record */
 
 #define	MDT_STRUCT_VERSION	1	/* version of metadata structure */
 #define	MDT_SETNAME	"modmetadata_set"

Modified: projects/ifnet/usr.sbin/kldxref/kldxref.c
==============================================================================
--- projects/ifnet/usr.sbin/kldxref/kldxref.c	Thu Jan 15 02:22:52 2015	(r277209)
+++ projects/ifnet/usr.sbin/kldxref/kldxref.c	Thu Jan 15 06:14:42 2015	(r277210)
@@ -172,6 +172,10 @@ parse_entry(struct mod_metadata *md, con
 			record_string(kldname);
 		}
 		break;
+	case MDT_PNP_INFO:
+		if (dflag) {
+			printf("  pnp info for bus %s\n", cval);
+		}
 	default:
 		warnx("unknown metadata record %d in file %s", md->md_type, kldname);
 	}


More information about the svn-src-projects mailing list