Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Apr 2014 20:44:27 +0000 (UTC)
From:      Mark Murray <markm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r265105 - in projects/random_number_generator: . contrib/libstdc++/include/bits lib/libc/locale share/man/man4 share/mk sys/amd64/include sys/amd64/vmm sys/arm/conf sys/arm/xilinx sys/d...
Message-ID:  <201404292044.s3TKiRn4030471@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markm
Date: Tue Apr 29 20:44:27 2014
New Revision: 265105
URL: http://svnweb.freebsd.org/changeset/base/265105

Log:
  MFC - tracking commit.
  Merging r265087 through r265104.

Added:
  projects/random_number_generator/sys/arm/xilinx/zy7_mp.c
     - copied unchanged from r265104, head/sys/arm/xilinx/zy7_mp.c
Modified:
  projects/random_number_generator/Makefile
  projects/random_number_generator/contrib/libstdc++/include/bits/stl_multimap.h
  projects/random_number_generator/lib/libc/locale/utf8.c
  projects/random_number_generator/share/man/man4/proto.4
  projects/random_number_generator/share/mk/bsd.opts.mk
  projects/random_number_generator/sys/amd64/include/vmm.h   (contents, props changed)
  projects/random_number_generator/sys/amd64/vmm/vmm.c
  projects/random_number_generator/sys/arm/conf/ZEDBOARD
  projects/random_number_generator/sys/arm/xilinx/files.zynq7
  projects/random_number_generator/sys/arm/xilinx/std.zynq7
  projects/random_number_generator/sys/dev/drm2/i915/i915_gem.c
  projects/random_number_generator/sys/kern/subr_witness.c
  projects/random_number_generator/sys/mips/beri/beri_machdep.c
  projects/random_number_generator/sys/net/route.c
  projects/random_number_generator/sys/net/route.h
  projects/random_number_generator/sys/net/rtsock.c
  projects/random_number_generator/sys/netinet/in.c
  projects/random_number_generator/sys/vm/vm_phys.c
  projects/random_number_generator/tests/sys/netinet/fibs_test.sh
  projects/random_number_generator/usr.bin/netstat/mroute.c
  projects/random_number_generator/usr.sbin/bhyve/bhyverun.c
Directory Properties:
  projects/random_number_generator/   (props changed)
  projects/random_number_generator/contrib/libstdc++/   (props changed)
  projects/random_number_generator/lib/libc/   (props changed)
  projects/random_number_generator/share/man/man4/   (props changed)
  projects/random_number_generator/sys/   (props changed)
  projects/random_number_generator/sys/amd64/vmm/   (props changed)
  projects/random_number_generator/usr.sbin/bhyve/   (props changed)

Modified: projects/random_number_generator/Makefile
==============================================================================
--- projects/random_number_generator/Makefile	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/Makefile	Tue Apr 29 20:44:27 2014	(r265105)
@@ -238,8 +238,17 @@ tinderbox toolchains kernel-toolchains: 
 ${TGTS}:
 	${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
 
-# Set a reasonable default
-.MAIN:	all
+# The historic default "all" target creates files which may cause stale
+# or (in the cross build case) unlinkable results. Fail with an error
+# when no target is given. The users can explicitly specify "all"
+# if they want the historic behavior.
+.MAIN:	_guard
+
+_guard:
+	@echo
+	@echo "Explicit target required (use \"all\" for historic behavior)"
+	@echo
+	@false
 
 STARTTIME!= LC_ALL=C date
 CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s ; echo

Modified: projects/random_number_generator/contrib/libstdc++/include/bits/stl_multimap.h
==============================================================================
--- projects/random_number_generator/contrib/libstdc++/include/bits/stl_multimap.h	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/contrib/libstdc++/include/bits/stl_multimap.h	Tue Apr 29 20:44:27 2014	(r265105)
@@ -185,7 +185,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GL
       template <typename _InputIterator>
         multimap(_InputIterator __first, _InputIterator __last)
 	: _M_t()
-        { _M_t._M_insert_unique(__first, __last); }
+        { _M_t._M_insert_equal(__first, __last); }
 
       /**
        *  @brief  Builds a %multimap from a range.

Modified: projects/random_number_generator/lib/libc/locale/utf8.c
==============================================================================
--- projects/random_number_generator/lib/libc/locale/utf8.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/lib/libc/locale/utf8.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -203,6 +203,14 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, 
 		errno = EILSEQ;
 		return ((size_t)-1);
 	}
+	if ((wch >= 0xd800 && wch <= 0xdfff) ||
+	    wch == 0xfffe || wch == 0xffff) {
+		/*
+		 * Malformed input; invalid code points.
+		 */
+		errno = EILSEQ;
+		return ((size_t)-1);
+	}
 	if (pwc != NULL)
 		*pwc = wch;
 	us->want = 0;

Modified: projects/random_number_generator/share/man/man4/proto.4
==============================================================================
--- projects/random_number_generator/share/man/man4/proto.4	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/share/man/man4/proto.4	Tue Apr 29 20:44:27 2014	(r265105)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 21, 2014
+.Dd April 29, 2014
 .Dt PROTO 4
 .Os
 .\"
@@ -34,7 +34,19 @@
 .Nd Driver for prototyping and H/W diagnostics
 .\"
 .Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following line in your
+kernel configuration file:
+.Bd -ragged -offset indent
 .Cd "device proto"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+proto_load="YES"
+.Ed
 .\"
 .Sh DESCRIPTION
 The
@@ -43,7 +55,7 @@ device driver attaches to PCI devices wh
 present and creates device special files for all resources associated
 with the device.
 The driver itself has no knowledge of the device it attaches to.
-Programs can open these device special files and peform register-level
+Programs can open these device special files and perform register-level
 reads and writes.
 As such, the
 .Nm
@@ -51,7 +63,7 @@ device driver is nothing but a conduit o
 programs and the hardware device.
 .Pp
 Examples for why this is useful include hardware diagnostics and prototyping.
-In both these use cases, it's far more convenient to develop and run the
+In both these use cases, it is far more convenient to develop and run the
 logic in user space.
 Especially hardware diagnostics requires a somewhat user-friendly interface
 and adequate reporting.
@@ -108,8 +120,9 @@ Since interrupts cannot be handled by th
 into signals and delivered to the program that has registered for interrupts.
 .Pp
 In order to test the transmission or reception of data, some means of doing
-direct memory access (DMA) by the device must be possible. This too much be
-under the control of the program. The details of how a program can setup and
+direct memory access (DMA) by the device must be possible.
+This too must be under the control of the program.
+The details of how a program can set up and
 initiate DMA still need to be fleshed out.
 .Pp
 Support for non-PCI devices has not been implemented yet.

Modified: projects/random_number_generator/share/mk/bsd.opts.mk
==============================================================================
--- projects/random_number_generator/share/mk/bsd.opts.mk	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/share/mk/bsd.opts.mk	Tue Apr 29 20:44:27 2014	(r265105)
@@ -56,6 +56,7 @@ __DEFAULT_YES_OPTIONS = \
     MAN \
     MANCOMPRESS \
     NIS \
+    NLS \
     OPENSSH \
     PROFILE \
     SSP \
@@ -149,7 +150,6 @@ __DEFAULT_YES_OPTIONS = \
     NDIS \
     NETCAT \
     NETGRAPH \
-    NLS \
     NLS_CATALOGS \
     NS_CACHING \
     NTP \

Modified: projects/random_number_generator/sys/amd64/include/vmm.h
==============================================================================
--- projects/random_number_generator/sys/amd64/include/vmm.h	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/amd64/include/vmm.h	Tue Apr 29 20:44:27 2014	(r265105)
@@ -325,7 +325,7 @@ enum vm_exitcode {
 	VM_EXITCODE_PAGING,
 	VM_EXITCODE_INST_EMUL,
 	VM_EXITCODE_SPINUP_AP,
-	VM_EXITCODE_SPINDOWN_CPU,
+	VM_EXITCODE_DEPRECATED1,	/* used to be SPINDOWN_CPU */
 	VM_EXITCODE_RENDEZVOUS,
 	VM_EXITCODE_IOAPIC_EOI,
 	VM_EXITCODE_SUSPENDED,

Modified: projects/random_number_generator/sys/amd64/vmm/vmm.c
==============================================================================
--- projects/random_number_generator/sys/amd64/vmm/vmm.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/amd64/vmm/vmm.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -191,8 +191,6 @@ static int vmm_ipinum;
 SYSCTL_INT(_hw_vmm, OID_AUTO, ipinum, CTLFLAG_RD, &vmm_ipinum, 0,
     "IPI vector used for vcpu notifications");
 
-static void vm_deactivate_cpu(struct vm *vm, int vcpuid);
-
 static void
 vcpu_cleanup(struct vm *vm, int i)
 {
@@ -1006,60 +1004,47 @@ vm_handle_rendezvous(struct vm *vm, int 
 static int
 vm_handle_hlt(struct vm *vm, int vcpuid, bool intr_disabled, bool *retu)
 {
-	struct vm_exit *vmexit;
 	struct vcpu *vcpu;
-	int t, timo, spindown;
+	const char *wmesg;
+	int t;
 
 	vcpu = &vm->vcpu[vcpuid];
-	spindown = 0;
 
 	vcpu_lock(vcpu);
+	while (1) {
+		/*
+		 * Do a final check for pending NMI or interrupts before
+		 * really putting this thread to sleep. Also check for
+		 * software events that would cause this vcpu to wakeup.
+		 *
+		 * These interrupts/events could have happened after the
+		 * vcpu returned from VMRUN() and before it acquired the
+		 * vcpu lock above.
+		 */
+		if (vm->rendezvous_func != NULL || vm->suspend)
+			break;
+		if (vm_nmi_pending(vm, vcpuid))
+			break;
+		if (!intr_disabled) {
+			if (vm_extint_pending(vm, vcpuid) ||
+			    vlapic_pending_intr(vcpu->vlapic, NULL)) {
+				break;
+			}
+		}
+
+		if (vlapic_enabled(vcpu->vlapic))
+			wmesg = "vmidle";
+		else
+			wmesg = "vmhalt";
 
-	/*
-	 * Do a final check for pending NMI or interrupts before
-	 * really putting this thread to sleep.
-	 *
-	 * These interrupts could have happened any time after we
-	 * returned from VMRUN() and before we grabbed the vcpu lock.
-	 */
-	if (vm->rendezvous_func == NULL &&
-	    !vm_nmi_pending(vm, vcpuid) &&
-	    (intr_disabled || !vlapic_pending_intr(vcpu->vlapic, NULL))) {
 		t = ticks;
 		vcpu_require_state_locked(vcpu, VCPU_SLEEPING);
-		if (vlapic_enabled(vcpu->vlapic)) {
-			/*
-			 * XXX msleep_spin() is not interruptible so use the
-			 * 'timo' to put an upper bound on the sleep time.
-			 */
-			timo = hz;
-			msleep_spin(vcpu, &vcpu->mtx, "vmidle", timo);
-		} else {
-			/*
-			 * Spindown the vcpu if the APIC is disabled and it
-			 * had entered the halted state, but never spin
-			 * down the BSP.
-			 */
-			if (vcpuid != 0)
-				spindown = 1;
-		}
+		msleep_spin(vcpu, &vcpu->mtx, wmesg, 0);
 		vcpu_require_state_locked(vcpu, VCPU_FROZEN);
 		vmm_stat_incr(vm, vcpuid, VCPU_IDLE_TICKS, ticks - t);
 	}
 	vcpu_unlock(vcpu);
 
-	/*
-	 * Since 'vm_deactivate_cpu()' grabs a sleep mutex we must call it
-	 * outside the confines of the vcpu spinlock.
-	 */
-	if (spindown) {
-		*retu = true;
-		vmexit = vm_exitinfo(vm, vcpuid);
-		vmexit->exitcode = VM_EXITCODE_SPINDOWN_CPU;
-		vm_deactivate_cpu(vm, vcpuid);
-		VCPU_CTR0(vm, vcpuid, "spinning down cpu");
-	}
-
 	return (0);
 }
 
@@ -1673,30 +1658,6 @@ vm_activate_cpu(struct vm *vm, int vcpui
 	CPU_SET_ATOMIC(vcpuid, &vm->active_cpus);
 }
 
-static void
-vm_deactivate_cpu(struct vm *vm, int vcpuid)
-{
-
-	KASSERT(vcpuid >= 0 && vcpuid < VM_MAXCPU,
-	    ("vm_deactivate_cpu: invalid vcpuid %d", vcpuid));
-	KASSERT(CPU_ISSET(vcpuid, &vm->active_cpus),
-	    ("vm_deactivate_cpu: vcpuid %d is not active", vcpuid));
-
-	VCPU_CTR0(vm, vcpuid, "deactivated");
-	CPU_CLR_ATOMIC(vcpuid, &vm->active_cpus);
-
-	/*
-	 * If a vcpu rendezvous is in progress then it could be blocked
-	 * on 'vcpuid' - unblock it before disappearing forever.
-	 */
-	mtx_lock(&vm->rendezvous_mtx);
-	if (vm->rendezvous_func != NULL) {
-		VCPU_CTR0(vm, vcpuid, "unblock rendezvous after deactivation");
-		wakeup(&vm->rendezvous_func);
-	}
-	mtx_unlock(&vm->rendezvous_mtx);
-}
-
 cpuset_t
 vm_active_cpus(struct vm *vm)
 {

Modified: projects/random_number_generator/sys/arm/conf/ZEDBOARD
==============================================================================
--- projects/random_number_generator/sys/arm/conf/ZEDBOARD	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/arm/conf/ZEDBOARD	Tue Apr 29 20:44:27 2014	(r265105)
@@ -56,6 +56,7 @@ options 	SYSVSEM			# SYSV-style semaphor
 options 	_KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
 options 	FREEBSD_BOOT_LOADER
 options 	VFP			# vfp/neon
+options 	SMP			# Symmetric MultiProcessor Kernel
 
 # Debugging
 makeoptions	DEBUG=-g

Modified: projects/random_number_generator/sys/arm/xilinx/files.zynq7
==============================================================================
--- projects/random_number_generator/sys/arm/xilinx/files.zynq7	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/arm/xilinx/files.zynq7	Tue Apr 29 20:44:27 2014	(r265105)
@@ -21,6 +21,7 @@ arm/xilinx/zy7_l2cache.c			standard
 arm/xilinx/zy7_bus_space.c			standard
 arm/xilinx/zy7_slcr.c				standard
 arm/xilinx/zy7_devcfg.c				standard
+arm/xilinx/zy7_mp.c				optional smp
 
 dev/cadence/if_cgem.c				optional if_cgem
 dev/sdhci/sdhci_fdt.c				optional sdhci

Modified: projects/random_number_generator/sys/arm/xilinx/std.zynq7
==============================================================================
--- projects/random_number_generator/sys/arm/xilinx/std.zynq7	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/arm/xilinx/std.zynq7	Tue Apr 29 20:44:27 2014	(r265105)
@@ -20,3 +20,5 @@ makeoptions	KERNVIRTADDR=0xc0100000
 
 options		ARM_L2_PIPT
 
+options		IPI_IRQ_START=0
+options		IPI_IRQ_END=15

Copied: projects/random_number_generator/sys/arm/xilinx/zy7_mp.c (from r265104, head/sys/arm/xilinx/zy7_mp.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/random_number_generator/sys/arm/xilinx/zy7_mp.c	Tue Apr 29 20:44:27 2014	(r265105, copy of r265104, head/sys/arm/xilinx/zy7_mp.c)
@@ -0,0 +1,99 @@
+/*-
+ * Copyright (c) 2013 Thomas Skibo.  All rights reserved.
+ *
+ * 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.
+ *
+ * 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$");
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/smp.h>
+
+#include <machine/smp.h>
+#include <machine/fdt.h>
+#include <machine/intr.h>
+
+#include <arm/xilinx/zy7_reg.h>
+
+#define	ZYNQ7_CPU1_ENTRY	0xfffffff0
+
+void
+platform_mp_init_secondary(void)
+{
+
+	gic_init_secondary();
+}
+
+void
+platform_mp_setmaxid(void)
+{
+
+	mp_maxid = 1;
+}
+
+int
+platform_mp_probe(void)
+{
+
+	mp_ncpus = 2;
+	return (1);
+}
+
+void    
+platform_mp_start_ap(void)
+{
+	bus_space_handle_t ocm_handle;
+
+	/* Map in magic location to give entry address to CPU1. */
+	if (bus_space_map(fdtbus_bs_tag, ZYNQ7_CPU1_ENTRY, 4,
+	    0, &ocm_handle) != 0)
+		panic("platform_mp_start_ap: Couldn't map OCM\n");
+
+	/* Write start address for CPU1. */
+	bus_space_write_4(fdtbus_bs_tag, ocm_handle, 0,
+	    pmap_kextract((vm_offset_t)mpentry));
+
+	/*
+	 * The SCU is enabled by the BOOTROM but I think the second CPU doesn't
+	 * turn on filtering until after the wake-up below. I think that's why
+	 * things don't work if I don't put these cache ops here.  Also, the
+	 * magic location, 0xfffffff0, isn't in the SCU's filtering range so it
+	 * needs a write-back too.
+	 */
+	cpu_idcache_wbinv_all();
+	cpu_l2cache_wbinv_all();
+
+	/* Wake up CPU1. */
+	armv7_sev();
+
+	bus_space_unmap(fdtbus_bs_tag, ocm_handle, 4);
+}
+
+void
+platform_ipi_send(cpuset_t cpus, u_int ipi)
+{
+
+	pic_ipi_send(cpus, ipi);
+}

Modified: projects/random_number_generator/sys/dev/drm2/i915/i915_gem.c
==============================================================================
--- projects/random_number_generator/sys/dev/drm2/i915/i915_gem.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/dev/drm2/i915/i915_gem.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -1431,6 +1431,7 @@ retry:
 	m = vm_phys_fictitious_to_vm_page(dev->agp->base + obj->gtt_offset +
 	    offset);
 	if (m == NULL) {
+		VM_OBJECT_WUNLOCK(vm_obj);
 		cause = 60;
 		ret = -EFAULT;
 		goto unlock;
@@ -1450,7 +1451,6 @@ retry:
 		DRM_UNLOCK(dev);
 		VM_OBJECT_WUNLOCK(vm_obj);
 		VM_WAIT;
-		VM_OBJECT_WLOCK(vm_obj);
 		goto retry;
 	}
 	m->valid = VM_PAGE_BITS_ALL;

Modified: projects/random_number_generator/sys/kern/subr_witness.c
==============================================================================
--- projects/random_number_generator/sys/kern/subr_witness.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/kern/subr_witness.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -135,7 +135,7 @@ __FBSDID("$FreeBSD$");
 #define	WITNESS_COUNT 		1536
 #define	WITNESS_CHILDCOUNT 	(WITNESS_COUNT * 4)
 #define	WITNESS_HASH_SIZE	251	/* Prime, gives load factor < 2 */
-#define	WITNESS_PENDLIST	1024
+#define	WITNESS_PENDLIST	(1024 + MAXCPU)
 
 /* Allocate 256 KB of stack data space */
 #define	WITNESS_LO_DATA_COUNT	2048

Modified: projects/random_number_generator/sys/mips/beri/beri_machdep.c
==============================================================================
--- projects/random_number_generator/sys/mips/beri/beri_machdep.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/mips/beri/beri_machdep.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -132,6 +132,46 @@ platform_reset(void)
 		__asm__ __volatile("wait");
 }
 
+#ifdef FDT
+/* Parse cmd line args as env - copied from xlp_machdep. */
+/* XXX-BZ this should really be centrally provided for all (boot) code. */
+static void
+_parse_bootargs(char *cmdline)
+{
+	char *n, *v;
+
+	while ((v = strsep(&cmdline, " \n")) != NULL) {
+		if (*v == '\0')
+			continue;
+		if (*v == '-') {
+			while (*v != '\0') {
+				v++;
+				switch (*v) {
+				case 'a': boothowto |= RB_ASKNAME; break;
+				/* Someone should simulate that ;-) */
+				case 'C': boothowto |= RB_CDROM; break;
+				case 'd': boothowto |= RB_KDB; break;
+				case 'D': boothowto |= RB_MULTIPLE; break;
+				case 'm': boothowto |= RB_MUTE; break;
+				case 'g': boothowto |= RB_GDB; break;
+				case 'h': boothowto |= RB_SERIAL; break;
+				case 'p': boothowto |= RB_PAUSE; break;
+				case 'r': boothowto |= RB_DFLTROOT; break;
+				case 's': boothowto |= RB_SINGLE; break;
+				case 'v': boothowto |= RB_VERBOSE; break;
+				}
+			}
+		} else {
+			n = strsep(&v, "=");
+			if (v == NULL)
+				setenv(n, "1");
+			else
+				setenv(n, v);
+		}
+	}
+}
+#endif
+
 void
 platform_start(__register_t a0, __register_t a1,  __register_t a2, 
     __register_t a3)
@@ -144,7 +184,9 @@ platform_start(__register_t a0, __regist
 	char **envp = (char **)a2;
 	long memsize;
 #ifdef FDT
+	char buf[2048];		/* early stack supposedly big enough */
 	vm_offset_t dtbp;
+	phandle_t chosen;
 	void *kmdp;
 #endif
 	int i;
@@ -201,7 +243,6 @@ platform_start(__register_t a0, __regist
 		while (1);
 	if (OF_init((void *)dtbp) != 0)
 		while (1);
-#endif
 
 	/*
 	 * Configure more boot-time parameters passed in by loader.
@@ -210,6 +251,14 @@ platform_start(__register_t a0, __regist
 	kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
 
 	/*
+	 * Get bootargs from FDT if specified.
+	 */
+	chosen = OF_finddevice("/chosen");
+	if (OF_getprop(chosen, "bootargs", buf, sizeof(buf)) != -1)
+		_parse_bootargs(buf);
+#endif
+
+	/*
 	 * XXXRW: We have no way to compare wallclock time to cycle rate on
 	 * BERI, so for now assume we run at the MALTA default (100MHz).
 	 */

Modified: projects/random_number_generator/sys/net/route.c
==============================================================================
--- projects/random_number_generator/sys/net/route.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/net/route.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -142,6 +142,7 @@ static VNET_DEFINE(uma_zone_t, rtzone);	
 
 static int rtrequest1_fib_change(struct radix_node_head *, struct rt_addrinfo *,
     struct rtentry **, u_int);
+static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *);
 
 /*
  * handler for net.my_fibnum
@@ -1401,6 +1402,8 @@ rtrequest1_fib(int req, struct rt_addrin
 		if (ifa->ifa_rtrequest)
 			ifa->ifa_rtrequest(req, rt, info);
 
+		rt_setmetrics(info, rt);
+
 		/*
 		 * actually return a resultant rtentry and
 		 * give the caller a single reference.
@@ -1431,7 +1434,6 @@ bad:
 #undef ifpaddr
 #undef flags
 
-#define	senderr(e) { error = e; goto bad; }
 static int
 rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info,
     struct rtentry **ret_nrt, u_int fibnum)
@@ -1476,7 +1478,7 @@ rtrequest1_fib_change(struct radix_node_
 			free_ifa = 1;
 
 		if (error != 0)
-			senderr(error);
+			goto bad;
 	}
 
 	/* Check if outgoing interface has changed */
@@ -1489,7 +1491,7 @@ rtrequest1_fib_change(struct radix_node_
 	if (info->rti_info[RTAX_GATEWAY] != NULL) {
 		error = rt_setgate(rt, rt_key(rt), info->rti_info[RTAX_GATEWAY]);
 		if (error != 0)
-			senderr(error);
+			goto bad;
 
 		rt->rt_flags &= ~RTF_GATEWAY;
 		rt->rt_flags |= (RTF_GATEWAY & info->rti_flags);
@@ -1507,6 +1509,8 @@ rtrequest1_fib_change(struct radix_node_
 	if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest != NULL)
 	       rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, info);
 
+	rt_setmetrics(info, rt);
+
 	if (ret_nrt) {
 		*ret_nrt = rt;
 		RT_ADDREF(rt);
@@ -1517,8 +1521,20 @@ bad:
 		ifa_free(info->rti_ifa);
 	return (error);
 }
-#undef senderr
 
+static void
+rt_setmetrics(const struct rt_addrinfo *info, struct rtentry *rt)
+{
+
+	if (info->rti_mflags & RTV_MTU)
+		rt->rt_mtu = info->rti_rmx->rmx_mtu;
+	if (info->rti_mflags & RTV_WEIGHT)
+		rt->rt_weight = info->rti_rmx->rmx_weight;
+	/* Kernel -> userland timebase conversion. */
+	if (info->rti_mflags & RTV_EXPIRE)
+		rt->rt_expire = info->rti_rmx->rmx_expire ?
+		    info->rti_rmx->rmx_expire - time_second + time_uptime : 0;
+}
 
 int
 rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate)

Modified: projects/random_number_generator/sys/net/route.h
==============================================================================
--- projects/random_number_generator/sys/net/route.h	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/net/route.h	Tue Apr 29 20:44:27 2014	(r265105)
@@ -261,6 +261,8 @@ struct rt_addrinfo {
 	int	rti_flags;
 	struct	ifaddr *rti_ifa;
 	struct	ifnet *rti_ifp;
+	u_long	rti_mflags;
+	struct	rt_metrics *rti_rmx;
 };
 
 /*

Modified: projects/random_number_generator/sys/net/rtsock.c
==============================================================================
--- projects/random_number_generator/sys/net/rtsock.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/net/rtsock.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -160,7 +160,6 @@ static int	sysctl_dumpentry(struct radix
 static int	sysctl_iflist(int af, struct walkarg *w);
 static int	sysctl_ifmalist(int af, struct walkarg *w);
 static int	route_output(struct mbuf *m, struct socket *so);
-static void	rt_setmetrics(const struct rt_msghdr *rtm, struct rtentry *rt);
 static void	rt_getmetrics(const struct rtentry *rt, struct rt_metrics *out);
 static void	rt_dispatch(struct mbuf *, sa_family_t);
 
@@ -532,7 +531,6 @@ route_output(struct mbuf *m, struct sock
 	sa_family_t saf = AF_UNSPEC;
 	struct rawcb *rp = NULL;
 	struct walkarg w;
-	char msgbuf[512];
 
 	fibnum = so->so_fibnum;
 
@@ -549,20 +547,12 @@ route_output(struct mbuf *m, struct sock
 
 	/*
 	 * Most of current messages are in range 200-240 bytes,
-	 * minimize possible failures by using on-stack buffer
-	 * which should fit for most messages.
-	 * However, use stable memory if we need to handle
-	 * something large.
+	 * minimize possible re-allocation on reply using larger size
+	 * buffer aligned on 1k boundaty.
 	 */
-	if (len < sizeof(msgbuf)) {
-		alloc_len = sizeof(msgbuf);
-		rtm = (struct rt_msghdr *)msgbuf;
-	} else {
-		alloc_len = roundup2(len, 1024);
-		rtm = malloc(alloc_len, M_TEMP, M_NOWAIT);
-		if (rtm == NULL)
-			senderr(ENOBUFS);
-	}
+	alloc_len = roundup2(len, 1024);
+	if ((rtm = malloc(alloc_len, M_TEMP, M_NOWAIT)) == NULL)
+		senderr(ENOBUFS);
 
 	m_copydata(m, 0, len, (caddr_t)rtm);
 	bzero(&info, sizeof(info));
@@ -570,8 +560,7 @@ route_output(struct mbuf *m, struct sock
 
 	if (rtm->rtm_version != RTM_VERSION) {
 		/* Do not touch message since format is unknown */
-		if ((char *)rtm != msgbuf)
-			free(rtm, M_TEMP);
+		free(rtm, M_TEMP);
 		rtm = NULL;
 		senderr(EPROTONOSUPPORT);
 	}
@@ -584,6 +573,10 @@ route_output(struct mbuf *m, struct sock
 
 	rtm->rtm_pid = curproc->p_pid;
 	info.rti_addrs = rtm->rtm_addrs;
+
+	info.rti_mflags = rtm->rtm_inits;
+	info.rti_rmx = &rtm->rtm_rmx;
+
 	/*
 	 * rt_xaddrs() performs s6_addr[2] := sin6_scope_id for AF_INET6
 	 * link-local address because rtrequest requires addresses with
@@ -670,7 +663,6 @@ route_output(struct mbuf *m, struct sock
 			rti_need_deembed = (V_deembed_scopeid) ? 1 : 0;
 #endif
 			RT_LOCK(saved_nrt);
-			rt_setmetrics(rtm, saved_nrt);
 			rtm->rtm_index = saved_nrt->rt_ifp->if_index;
 			RT_REMREF(saved_nrt);
 			RT_UNLOCK(saved_nrt);
@@ -859,7 +851,7 @@ flush:
 	 */
 	if ((so->so_options & SO_USELOOPBACK) == 0) {
 		if (V_route_cb.any_count <= 1) {
-			if (rtm != NULL && (char *)rtm != msgbuf)
+			if (rtm != NULL)
 				free(rtm, M_TEMP);
 			m_freem(m);
 			return (error);
@@ -897,8 +889,7 @@ flush:
 		} else if (m->m_pkthdr.len > rtm->rtm_msglen)
 			m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len);
 
-		if ((char *)rtm != msgbuf)
-			free(rtm, M_TEMP);
+		free(rtm, M_TEMP);
 	}
 	if (m != NULL) {
 		M_SETFIB(m, fibnum);
@@ -920,20 +911,6 @@ flush:
 }
 
 static void
-rt_setmetrics(const struct rt_msghdr *rtm, struct rtentry *rt)
-{
-
-	if (rtm->rtm_inits & RTV_MTU)
-		rt->rt_mtu = rtm->rtm_rmx.rmx_mtu;
-	if (rtm->rtm_inits & RTV_WEIGHT)
-		rt->rt_weight = rtm->rtm_rmx.rmx_weight;
-	/* Kernel -> userland timebase conversion. */
-	if (rtm->rtm_inits & RTV_EXPIRE)
-		rt->rt_expire = rtm->rtm_rmx.rmx_expire ?
-		    rtm->rtm_rmx.rmx_expire - time_second + time_uptime : 0;
-}
-
-static void
 rt_getmetrics(const struct rtentry *rt, struct rt_metrics *out)
 {
 

Modified: projects/random_number_generator/sys/netinet/in.c
==============================================================================
--- projects/random_number_generator/sys/netinet/in.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/netinet/in.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -696,11 +696,9 @@ in_scrubprefix(struct in_ifaddr *target,
 {
 	struct in_ifaddr *ia;
 	struct in_addr prefix, mask, p, m;
-	int error = 0, fibnum;
+	int error = 0;
 	struct sockaddr_in prefix0, mask0;
 
-	fibnum = rt_add_addr_allfibs ? RT_ALL_FIBS : target->ia_ifp->if_fib;
-
 	/*
 	 * Remove the loopback route to the interface address.
 	 */
@@ -712,6 +710,8 @@ in_scrubprefix(struct in_ifaddr *target,
 		eia = in_localip_more(target);
 
 		if (eia != NULL) {
+			int fibnum = target->ia_ifp->if_fib;
+
 			error = ifa_switch_loopback_route((struct ifaddr *)eia,
 			    (struct sockaddr *)&target->ia_addr, fibnum);
 			ifa_free(&eia->ia_ifa);
@@ -736,6 +736,10 @@ in_scrubprefix(struct in_ifaddr *target,
 	}
 
 	if ((target->ia_flags & IFA_ROUTE) == 0) {
+		int fibnum;
+		
+		fibnum = rt_add_addr_allfibs ? RT_ALL_FIBS :
+			target->ia_ifp->if_fib;
 		rt_addrmsg(RTM_DELETE, &target->ia_ifa, fibnum);
 		return (0);
 	}

Modified: projects/random_number_generator/sys/vm/vm_phys.c
==============================================================================
--- projects/random_number_generator/sys/vm/vm_phys.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/sys/vm/vm_phys.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -551,7 +551,9 @@ vm_phys_fictitious_reg_range(vm_paddr_t 
 
 #ifdef VM_PHYSSEG_DENSE
 	pi = atop(start);
-	if (pi >= first_page && atop(end) < vm_page_array_size) {
+	if (pi >= first_page && pi < vm_page_array_size + first_page) {
+		if (atop(end) >= vm_page_array_size + first_page)
+			return (EINVAL);
 		fp = &vm_page_array[pi - first_page];
 		malloced = FALSE;
 	} else

Modified: projects/random_number_generator/tests/sys/netinet/fibs_test.sh
==============================================================================
--- projects/random_number_generator/tests/sys/netinet/fibs_test.sh	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/tests/sys/netinet/fibs_test.sh	Tue Apr 29 20:44:27 2014	(r265105)
@@ -213,6 +213,98 @@ default_route_with_multiple_fibs_on_same
 }
 
 
+# Regression test for PR kern/189089
+# Create two tap interfaces and assign them both the same IP address but with
+# different netmasks, and both on the default FIB.  Then remove one's IP
+# address.  Hopefully the machine won't panic.
+atf_test_case same_ip_multiple_ifaces_fib0 cleanup
+same_ip_multiple_ifaces_fib0_head()
+{
+	atf_set "descr" "Can remove an IP alias from an interface when the same IP is also assigned to another interface."
+	atf_set "require.user" "root"
+	atf_set "require.config" "fibs"
+}
+same_ip_multiple_ifaces_fib0_body()
+{
+	ADDR="192.0.2.2"
+	MASK0="24"
+	MASK1="32"
+
+	# Unlike most of the tests in this file, this is applicable regardless
+	# of net.add_addr_allfibs
+
+	# Setup the interfaces, then remove one alias.  It should not panic.
+	setup_tap 0 ${ADDR} ${MASK0}
+	TAP0=${TAP}
+	setup_tap 0 ${ADDR} ${MASK1}
+	TAP1=${TAP}
+	ifconfig ${TAP1} -alias ${ADDR}
+
+	# Do it again, in the opposite order.  It should not panic.
+	setup_tap 0 ${ADDR} ${MASK0}
+	TAP0=${TAP}
+	setup_tap 0 ${ADDR} ${MASK1}
+	TAP1=${TAP}
+	ifconfig ${TAP0} -alias ${ADDR}
+}
+same_ip_multiple_ifaces_fib0_cleanup()
+{
+	cleanup_tap
+}
+
+# Regression test for PR kern/189088
+# Test that removing an IP address works even if the same IP is assigned to a
+# different interface, on a different FIB.  Tests the same code that whose
+# panic was regressed by same_ip_multiple_ifaces_fib0.  
+# Create two tap interfaces and assign them both the same IP address but with
+# different netmasks, and on different FIBs.  Then remove one's IP
+# address.  Hopefully the machine won't panic.  Also, the IP's hostroute should
+# dissappear from the correct fib.
+atf_test_case same_ip_multiple_ifaces cleanup
+same_ip_multiple_ifaces_head()
+{
+	atf_set "descr" "Can remove an IP alias from an interface when the same IP is also assigned to another interface, on non-default FIBs."
+	atf_set "require.user" "root"
+	atf_set "require.config" "fibs"
+}
+same_ip_multiple_ifaces_body()
+{
+	atf_expect_fail "kern/189088 Assigning the same IP to multiple interfaces in different FIBs creates a host route for only one"
+	ADDR="192.0.2.2"
+	MASK0="24"
+	MASK1="32"
+
+	# Unlike most of the tests in this file, this is applicable regardless
+	# of net.add_addr_allfibs
+	get_fibs 2
+
+	# Setup the interfaces, then remove one alias.  It should not panic.
+	setup_tap ${FIB0} ${ADDR} ${MASK0}
+	TAP0=${TAP}
+	setup_tap ${FIB1} ${ADDR} ${MASK1}
+	TAP1=${TAP}
+	ifconfig ${TAP1} -alias ${ADDR}
+	atf_check -o not-match:"^${ADDR}[[:space:]]" \
+		setfib ${FIB1} netstat -rn -f inet
+
+	# Do it again, in the opposite order.  It should not panic.
+	setup_tap ${FIB0} ${ADDR} ${MASK0}
+	TAP0=${TAP}
+	setup_tap ${FIB1} ${ADDR} ${MASK1}
+	TAP1=${TAP}
+	ifconfig ${TAP0} -alias ${ADDR}
+	atf_check -o not-match:"^${ADDR}[[:space:]]" \
+		setfib ${FIB0} netstat -rn -f inet
+}
+same_ip_multiple_ifaces_cleanup()
+{
+	# Due to PR kern/189088, we must destroy the interfaces in LIFO order
+	# in order for the routes to be correctly cleaned up.
+	for TAPD in `tail -r "tap_devices_to_cleanup"`; do
+		ifconfig ${TAPD} destroy
+	done
+}
+
 # Regression test for kern/187550
 atf_test_case subnet_route_with_multiple_fibs_on_same_subnet cleanup
 subnet_route_with_multiple_fibs_on_same_subnet_head()
@@ -309,6 +401,8 @@ atf_init_test_cases()
 	atf_add_test_case arpresolve_checks_interface_fib
 	atf_add_test_case loopback_and_network_routes_on_nondefault_fib
 	atf_add_test_case default_route_with_multiple_fibs_on_same_subnet
+	atf_add_test_case same_ip_multiple_ifaces_fib0
+	atf_add_test_case same_ip_multiple_ifaces
 	atf_add_test_case subnet_route_with_multiple_fibs_on_same_subnet
 	atf_add_test_case udp_dontroute
 }

Modified: projects/random_number_generator/usr.bin/netstat/mroute.c
==============================================================================
--- projects/random_number_generator/usr.bin/netstat/mroute.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/usr.bin/netstat/mroute.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -236,16 +236,7 @@ mroutepr()
 	 * functionality was deprecated, as PIM does not use it.
 	 */
 	maxvif = 0;
-
-	kresolve_list(mrl);
-	pmfchashtbl = mrl[N_MFCHASHTBL].n_value;
-	pmfctablesize = mrl[N_MFCTABLESIZE].n_value;
-	pviftbl = mrl[N_VIFTABLE].n_value;
-
-	if (pmfchashtbl == 0 || pmfctablesize == 0 || pviftbl == 0) {
-		fprintf(stderr, "No IPv4 MROUTING kernel support.\n");
-		return;
-	}
+	pmfchashtbl = pmfctablesize = pviftbl = 0;
 
 	len = sizeof(viftable);
 	if (live) {
@@ -254,8 +245,19 @@ mroutepr()
 			warn("sysctl: net.inet.ip.viftable");
 			return;
 		}
-	} else
+	} else {
+		kresolve_list(mrl);
+		pmfchashtbl = mrl[N_MFCHASHTBL].n_value;
+		pmfctablesize = mrl[N_MFCTABLESIZE].n_value;
+		pviftbl = mrl[N_VIFTABLE].n_value;
+
+		if (pmfchashtbl == 0 || pmfctablesize == 0 || pviftbl == 0) {
+			fprintf(stderr, "No IPv4 MROUTING kernel support.\n");
+			return;
+		}
+
 		kread(pviftbl, (char *)viftable, sizeof(viftable));
+	}
 
 	banner_printed = 0;
 	for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {

Modified: projects/random_number_generator/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- projects/random_number_generator/usr.sbin/bhyve/bhyverun.c	Tue Apr 29 19:48:11 2014	(r265104)
+++ projects/random_number_generator/usr.sbin/bhyve/bhyverun.c	Tue Apr 29 20:44:27 2014	(r265105)
@@ -114,6 +114,7 @@ struct bhyvestats {
         uint64_t        cpu_switch_rotate;
         uint64_t        cpu_switch_direct;
         int             io_reset;
+	int		io_poweroff;
 } stats;
 
 struct mt_vmm_info {
@@ -237,13 +238,6 @@ fbsdrun_deletecpu(struct vmctx *ctx, int
 }
 
 static int
-vmexit_catch_reset(void)
-{
-        stats.io_reset++;
-        return (VMEXIT_RESET);
-}
-
-static int
 vmexit_catch_inout(void)
 {
 	return (VMEXIT_ABORT);
@@ -293,8 +287,10 @@ vmexit_inout(struct vmctx *ctx, struct v
 	case INOUT_OK:
 		return (VMEXIT_CONTINUE);
 	case INOUT_RESET:
+		stats.io_reset++;
 		return (VMEXIT_RESET);
 	case INOUT_POWEROFF:
+		stats.io_poweroff++;
 		return (VMEXIT_POWEROFF);
 	default:
 		fprintf(stderr, "Unhandled %s%c 0x%04x\n",
@@ -365,17 +361,6 @@ vmexit_spinup_ap(struct vmctx *ctx, stru
 }
 
 static int
-vmexit_spindown_cpu(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
-{
-	int lastcpu;
-
-	lastcpu = fbsdrun_deletecpu(ctx, *pvcpu);
-	if (!lastcpu)
-		pthread_exit(NULL);
-	return (vmexit_catch_reset());
-}
-
-static int
 vmexit_vmx(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
 
@@ -501,7 +486,6 @@ static vmexit_handler_t handler[VM_EXITC
 	[VM_EXITCODE_MTRAP]  = vmexit_mtrap,
 	[VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
 	[VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap,
-	[VM_EXITCODE_SPINDOWN_CPU] = vmexit_spindown_cpu,
 	[VM_EXITCODE_SUSPENDED] = vmexit_suspend
 };
 



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