CVS commit: src/sys/dev/pci

2016-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 16 07:24:52 UTC 2016

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
Add three workarounds for PCH_{LPT,SPT}.


To generate a diff of this commit:
cvs rdiff -u -r1.444 -r1.445 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/if_wmreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.444 src/sys/dev/pci/if_wm.c:1.445
--- src/sys/dev/pci/if_wm.c:1.444	Mon Nov 14 05:38:39 2016
+++ src/sys/dev/pci/if_wm.c	Wed Nov 16 07:24:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.444 2016/11/14 05:38:39 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.445 2016/11/16 07:24:52 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.444 2016/11/14 05:38:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.445 2016/11/16 07:24:52 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -862,6 +862,7 @@ static void	wm_set_mdio_slow_mode_hv(str
 static void	wm_configure_k1_ich8lan(struct wm_softc *, int);
 static void	wm_reset_init_script_82575(struct wm_softc *);
 static void	wm_reset_mdicnfg_82580(struct wm_softc *);
+static int	wm_platform_pm_pch_lpt(struct wm_softc *, bool);
 static void	wm_pll_workaround_i210(struct wm_softc *);
 
 CFATTACH_DECL3_NEW(wm, sizeof(struct wm_softc),
@@ -7507,6 +7508,7 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
 		__func__));
 
 	if (icr & ICR_LSC) {
+		uint32_t reg;
 		uint32_t status = CSR_READ(sc, WMREG_STATUS);
 
 		if ((sc->sc_type == WM_T_ICH8) && ((status & STATUS_LU) == 0))
@@ -7575,6 +7577,44 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
 HV_MUX_DATA_CTRL_GEN_TO_MAC);
 			}
 		}
+		/*
+		 * I217 Packet Loss issue:
+		 * ensure that FEXTNVM4 Beacon Duration is set correctly
+		 * on power up.
+		 * Set the Beacon Duration for I217 to 8 usec
+		 */
+		if ((sc->sc_type == WM_T_PCH_LPT)
+		|| (sc->sc_type == WM_T_PCH_SPT)) {
+			reg = CSR_READ(sc, WMREG_FEXTNVM4);
+			reg &= ~FEXTNVM4_BEACON_DURATION;
+			reg |= FEXTNVM4_BEACON_DURATION_8US;
+			CSR_WRITE(sc, WMREG_FEXTNVM4, reg);
+		}
+
+		/* XXX Work-around I218 hang issue */
+		/* e1000_k1_workaround_lpt_lp() */
+
+		if ((sc->sc_type == WM_T_PCH_LPT)
+		|| (sc->sc_type == WM_T_PCH_SPT)) {
+			/*
+			 * Set platform power management values for Latency
+			 * Tolerance Reporting (LTR)
+			 */
+			wm_platform_pm_pch_lpt(sc,
+((sc->sc_mii.mii_media_status & IFM_ACTIVE)
+!= 0));
+		}
+
+		/* FEXTNVM6 K1-off workaround */
+		if (sc->sc_type == WM_T_PCH_SPT) {
+			reg = CSR_READ(sc, WMREG_FEXTNVM6);
+			if (CSR_READ(sc, WMREG_PCIEANACFG)
+			& FEXTNVM6_K1_OFF_ENABLE)
+reg |= FEXTNVM6_K1_OFF_ENABLE;
+			else
+reg &= ~FEXTNVM6_K1_OFF_ENABLE;
+			CSR_WRITE(sc, WMREG_FEXTNVM6, reg);
+		}
 	} else if (icr & ICR_RXSEQ) {
 		DPRINTF(WM_DEBUG_LINK, ("%s: LINK Receive sequence error\n",
 			device_xname(sc->sc_dev)));
@@ -12525,6 +12565,90 @@ wm_reset_mdicnfg_82580(struct wm_softc *
 	CSR_WRITE(sc, WMREG_MDICNFG, reg);
 }
 
+static int
+wm_platform_pm_pch_lpt(struct wm_softc *sc, bool link)
+{
+	uint32_t reg = __SHIFTIN(link, LTRV_NONSNOOP_REQ)
+	| __SHIFTIN(link, LTRV_SNOOP_REQ) | LTRV_SEND;
+	uint32_t rxa;
+	uint16_t scale = 0, lat_enc = 0;
+	int64_t lat_ns, value;
+	
+	DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+		device_xname(sc->sc_dev), __func__));
+
+	if (link) {
+		pcireg_t preg;
+		uint16_t max_snoop, max_nosnoop, max_ltr_enc;
+
+		rxa = CSR_READ(sc, WMREG_PBA) & PBA_RXA_MASK;
+
+		/*
+		 * Determine the maximum latency tolerated by the device.
+		 *
+		 * Per the PCIe spec, the tolerated latencies are encoded as
+		 * a 3-bit encoded scale (only 0-5 are valid) multiplied by
+		 * a 10-bit value (0-1023) to provide a range from 1 ns to
+		 * 2^25*(2^10-1) ns.  The scale is encoded as 0=2^0ns,
+		 * 1=2^5ns, 2=2^10ns,...5=2^25ns.
+		 */
+		lat_ns = ((int64_t)rxa * 1024 -
+		(2 * (int64_t)sc->sc_ethercom.ec_if.if_mtu)) * 8 * 1000;
+		if (lat_ns < 0)
+			lat_ns = 0;
+		else {
+			uint32_t status;
+			uint16_t speed;
+
+			status = CSR_READ(sc, WMREG_STATUS);
+			switch (__SHIFTOUT(status, STATUS_SPEED)) {
+			case STATUS_SPEED_10:
+speed = 10;
+break;
+			case STATUS_SPEED_100:
+speed = 100;
+break;
+			case STATUS_SPEED_1000:
+speed = 1000;
+break;
+			default:
+printf("%s: Unknown speed (status = %08x)\n",
+device_xname(sc->sc_dev), status);
+return -1;
+			}
+			lat_ns /= speed;
+		}
+		value = lat_ns;
+
+		while (value > LTRV_VALUE) {
+			scale ++;
+			value = howmany(value, __BIT(5));
+		}
+		if (scale > LTRV_SCALE_MAX) {
+			printf("%s: Invalid LTR latency scale %d\n",
+			device_xname(sc->sc_dev), scale);
+			return -1;
+		}
+		lat_enc = (uint16_t)(__SHIFTIN(scale, 

CVS commit: src/sys/dev/pci

2016-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Nov 16 07:24:52 UTC 2016

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
Add three workarounds for PCH_{LPT,SPT}.


To generate a diff of this commit:
cvs rdiff -u -r1.444 -r1.445 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/pci/if_wmreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/x86/x86

2016-11-15 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Nov 16 07:13:01 UTC 2016

Modified Files:
src/sys/arch/x86/x86: intr.c

Log Message:
avoid a failure of interrupt affinity when the interrupt is pending.

pointed out and reviewed by ozaki-r@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/x86/x86/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/x86/x86

2016-11-15 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Nov 16 07:13:01 UTC 2016

Modified Files:
src/sys/arch/x86/x86: intr.c

Log Message:
avoid a failure of interrupt affinity when the interrupt is pending.

pointed out and reviewed by ozaki-r@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/x86/x86/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.94 src/sys/arch/x86/x86/intr.c:1.95
--- src/sys/arch/x86/x86/intr.c:1.94	Mon Jul 11 23:09:34 2016
+++ src/sys/arch/x86/x86/intr.c	Wed Nov 16 07:13:01 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.94 2016/07/11 23:09:34 knakahara Exp $	*/
+/*	$NetBSD: intr.c,v 1.95 2016/11/16 07:13:01 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.94 2016/07/11 23:09:34 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.95 2016/11/16 07:13:01 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -210,6 +210,8 @@ static void intr_calculatemasks(struct c
 static SIMPLEQ_HEAD(, intrsource) io_interrupt_sources =
 	SIMPLEQ_HEAD_INITIALIZER(io_interrupt_sources);
 
+static kmutex_t intr_distribute_lock;
+
 #if NIOAPIC > 0 || NACPICA > 0
 static int intr_scan_bus(int, int, intr_handle_t *);
 #if NPCI > 0
@@ -273,6 +275,8 @@ intr_default_setup(void)
 	 * Eventually might want to check if it's actually there.
 	 */
 	i8259_default_setup();
+
+	mutex_init(_distribute_lock, MUTEX_DEFAULT, IPL_NONE);
 }
 
 /*
@@ -1876,6 +1880,7 @@ intr_set_affinity(struct intrsource *isp
 	int err;
 	int pin;
 
+	KASSERT(mutex_owned(_distribute_lock));
 	KASSERT(mutex_owned(_lock));
 
 	/* XXX
@@ -1921,12 +1926,8 @@ intr_set_affinity(struct intrsource *isp
 
 	pin = isp->is_pin;
 	(*pic->pic_hwmask)(pic, pin); /* for ci_ipending check */
-	if (oldci->ci_ipending & (1 << oldslot)) {
-		(*pic->pic_hwunmask)(pic, pin);
-		DPRINTF(("pin %d on cpuid %ld has pending interrupts.\n",
-			pin, oldci->ci_cpuid));
-		return EBUSY;
-	}
+	while(oldci->ci_ipending & (1 << oldslot))
+		(void)kpause("intrdist", false, 1, _lock);
 
 	kpreempt_disable();
 
@@ -2116,6 +2117,7 @@ intr_distribute_locked(struct intrhand *
 	struct intrsource *isp;
 	int slot;
 
+	KASSERT(mutex_owned(_distribute_lock));
 	KASSERT(mutex_owned(_lock));
 
 	if (ih == NULL)
@@ -2140,9 +2142,11 @@ interrupt_distribute(void *cookie, const
 	int error;
 	struct intrhand *ih = cookie;
 
+	mutex_enter(_distribute_lock);
 	mutex_enter(_lock);
 	error = intr_distribute_locked(ih, newset, oldset);
 	mutex_exit(_lock);
+	mutex_exit(_distribute_lock);
 
 	return error;
 }
@@ -2157,6 +2161,7 @@ interrupt_distribute_handler(const char 
 	int error;
 	struct intrhand *ih;
 
+	mutex_enter(_distribute_lock);
 	mutex_enter(_lock);
 
 	ih = intr_get_handler(intrid);
@@ -2168,6 +2173,7 @@ interrupt_distribute_handler(const char 
 
  out:
 	mutex_exit(_lock);
+	mutex_exit(_distribute_lock);
 	return error;
 }
 



CVS commit: src/usr.bin/w

2016-11-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 16 02:03:30 UTC 2016

Modified Files:
src/usr.bin/w: w.c

Log Message:
if there is more than one : it is not an X display, it is a v6 address


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/w/w.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/w/w.c
diff -u src/usr.bin/w/w.c:1.82 src/usr.bin/w/w.c:1.83
--- src/usr.bin/w/w.c:1.82	Mon Dec 22 10:24:14 2014
+++ src/usr.bin/w/w.c	Tue Nov 15 21:03:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $	*/
+/*	$NetBSD: w.c,v 1.83 2016/11/16 02:03:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)w.c	8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $");
+__RCSID("$NetBSD: w.c,v 1.83 2016/11/16 02:03:30 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -621,27 +621,38 @@ static void
 fixhost(struct entry *ep)
 {
 	char host_buf[sizeof(ep->host)];
-	char *p, *x;
+	char *p, *x, *m;
 	struct hostent *hp;
-	struct in_addr l;
+	union {
+		struct in_addr l4;
+		struct in6_addr l6;
+	} l;
 
 	strlcpy(host_buf, *ep->host ? ep->host : "-", sizeof(host_buf));
 	p = host_buf;
 
 	/*
-	 * XXX: Historical behavior, ':' in hostname means X display number,
-	 * IPv6 not handled.
+	 * One ':' in hostname means X display number, more is IPv6.
 	 */
 	for (x = p; x < _buf[sizeof(host_buf)]; x++)
 		if (*x == '\0' || *x == ':')
 			break;
 	if (x == p + sizeof(host_buf) || *x != ':')
-		x = NULL;
-	else
-		*x++ = '\0';
-
-	if (!nflag && inet_aton(p, ) &&
-	(hp = gethostbyaddr((char *), sizeof(l), AF_INET))) {
+		m = x = NULL;
+	else {
+		for (m = x + 1; m < _buf[sizeof(host_buf)]; m++)
+			if (*m == '\0' || *m == ':')
+break;
+		if (m == p + sizeof(host_buf) || *m != ':') {
+			*x++ = '\0';
+			m = NULL;
+		} else
+			x = NULL;
+	}
+	int af = m ? AF_INET6 : AF_INET;
+	size_t alen = m ? sizeof(l.l6) : sizeof(l.l4);
+	if (!nflag && inet_pton(af, p, ) &&
+	(hp = gethostbyaddr((char *), alen, af))) {
 		if (domain[0] != '\0') {
 			p = hp->h_name;
 			p += strlen(hp->h_name);



CVS commit: src/usr.bin/w

2016-11-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 16 02:03:30 UTC 2016

Modified Files:
src/usr.bin/w: w.c

Log Message:
if there is more than one : it is not an X display, it is a v6 address


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/w/w.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/distrib/sets/lists/modules

2016-11-15 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Nov 16 00:50:13 UTC 2016

Modified Files:
src/distrib/sets/lists/modules: mi

Log Message:
Update sets lists for new bufq_* modules


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/distrib/sets/lists/modules/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.100 src/distrib/sets/lists/modules/mi:1.101
--- src/distrib/sets/lists/modules/mi:1.100	Wed Nov  2 00:12:41 2016
+++ src/distrib/sets/lists/modules/mi	Wed Nov 16 00:50:12 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.100 2016/11/02 00:12:41 pgoyette Exp $
+# $NetBSD: mi,v 1.101 2016/11/16 00:50:12 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -30,6 +30,14 @@
 ./@MODULEDIR@/bpf/bpf.kmod			base-kernel-modules	kmod
 ./@MODULEDIR@/bpf_filter			base-kernel-modules	kmod
 ./@MODULEDIR@/bpf_filter/bpf_filter.kmod	base-kernel-modules	kmod
+./@MODULEDIR@/bufq_disksort			base-kernel-modules	kmod
+./@MODULEDIR@/bufq_disksort/bufq_disksort.kmod	base-kernel-modules	kmod
+./@MODULEDIR@/bufq_fcfsbase-kernel-modules	kmod
+./@MODULEDIR@/bufq_fcfs/bufq_fcfs.kmod		base-kernel-modules	kmod
+./@MODULEDIR@/bufq_priocscan			base-kernel-modules	kmod
+./@MODULEDIR@/bufq_priocscan/bufq_priocscan.kmod base-kernel-modules	kmod
+./@MODULEDIR@/bufq_readprio			base-kernel-modules	kmod
+./@MODULEDIR@/bufq_readprio/bufq_readprio.kmod	base-kernel-modules	kmod
 ./@MODULEDIR@/cacbase-obsolete		obsolete
 ./@MODULEDIR@/cac/cac.kmod			base-obsolete		obsolete
 ./@MODULEDIR@/cac_pcibase-obsolete		obsolete



CVS commit: src/distrib/sets/lists/modules

2016-11-15 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Nov 16 00:50:13 UTC 2016

Modified Files:
src/distrib/sets/lists/modules: mi

Log Message:
Update sets lists for new bufq_* modules


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/distrib/sets/lists/modules/mi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/modules

2016-11-15 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Nov 16 00:49:27 UTC 2016

Modified Files:
src/sys/modules: Makefile
Added Files:
src/sys/modules/bufq_disksort: Makefile
src/sys/modules/bufq_fcfs: Makefile
src/sys/modules/bufq_priocscan: Makefile
src/sys/modules/bufq_readprio: Makefile

Log Message:
Build the newly-created bufq_* modules


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_disksort/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_fcfs/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_priocscan/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_readprio/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.182 src/sys/modules/Makefile:1.183
--- src/sys/modules/Makefile:1.182	Wed Nov  2 00:12:00 2016
+++ src/sys/modules/Makefile	Wed Nov 16 00:49:27 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.182 2016/11/02 00:12:00 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.183 2016/11/16 00:49:27 pgoyette Exp $
 
 .include 
 
@@ -11,6 +11,10 @@ SUBDIR+=	aio
 SUBDIR+=	blowfish
 SUBDIR+=	bpf
 SUBDIR+=	bpf_filter
+SUBDIR+=	bufq_disksort
+SUBDIR+=	bufq_fcfs
+SUBDIR+=	bufq_priocscan
+SUBDIR+=	bufq_readprio
 SUBDIR+=	camellia
 SUBDIR+=	cast128
 SUBDIR+=	ccd

Added files:

Index: src/sys/modules/bufq_disksort/Makefile
diff -u /dev/null src/sys/modules/bufq_disksort/Makefile:1.1
--- /dev/null	Wed Nov 16 00:49:28 2016
+++ src/sys/modules/bufq_disksort/Makefile	Wed Nov 16 00:49:27 2016
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2016/11/16 00:49:27 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH:  ${S}/kern
+
+KMOD=		bufq_disksort
+SRCS=		bufq_disksort.c
+
+.include 

Index: src/sys/modules/bufq_fcfs/Makefile
diff -u /dev/null src/sys/modules/bufq_fcfs/Makefile:1.1
--- /dev/null	Wed Nov 16 00:49:28 2016
+++ src/sys/modules/bufq_fcfs/Makefile	Wed Nov 16 00:49:27 2016
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2016/11/16 00:49:27 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH:  ${S}/kern
+
+KMOD=		bufq_fcfs
+SRCS=		bufq_fcfs.c
+
+.include 

Index: src/sys/modules/bufq_priocscan/Makefile
diff -u /dev/null src/sys/modules/bufq_priocscan/Makefile:1.1
--- /dev/null	Wed Nov 16 00:49:28 2016
+++ src/sys/modules/bufq_priocscan/Makefile	Wed Nov 16 00:49:27 2016
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2016/11/16 00:49:27 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH:  ${S}/kern
+
+KMOD=		bufq_priocscan
+SRCS=		bufq_priocscan.c
+
+.include 

Index: src/sys/modules/bufq_readprio/Makefile
diff -u /dev/null src/sys/modules/bufq_readprio/Makefile:1.1
--- /dev/null	Wed Nov 16 00:49:28 2016
+++ src/sys/modules/bufq_readprio/Makefile	Wed Nov 16 00:49:27 2016
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile,v 1.1 2016/11/16 00:49:27 pgoyette Exp $
+
+.include "../Makefile.inc"
+
+.PATH:  ${S}/kern
+
+KMOD=		bufq_readprio
+SRCS=		bufq_readprio.c
+
+.include 



CVS commit: src/sys/modules

2016-11-15 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Nov 16 00:49:27 UTC 2016

Modified Files:
src/sys/modules: Makefile
Added Files:
src/sys/modules/bufq_disksort: Makefile
src/sys/modules/bufq_fcfs: Makefile
src/sys/modules/bufq_priocscan: Makefile
src/sys/modules/bufq_readprio: Makefile

Log Message:
Build the newly-created bufq_* modules


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_disksort/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_fcfs/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_priocscan/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/bufq_readprio/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2016-11-15 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Nov 16 00:46:46 UTC 2016

Modified Files:
src/sys/kern: bufq_disksort.c bufq_fcfs.c bufq_priocscan.c
bufq_readprio.c init_main.c subr_bufq.c
src/sys/sys: bufq.h bufq_impl.h

Log Message:
Modularize the various bufq strategies


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/bufq_disksort.c
cvs rdiff -u -r1.10 -r1.11 src/sys/kern/bufq_fcfs.c
cvs rdiff -u -r1.18 -r1.19 src/sys/kern/bufq_priocscan.c
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/bufq_readprio.c
cvs rdiff -u -r1.484 -r1.485 src/sys/kern/init_main.c
cvs rdiff -u -r1.21 -r1.22 src/sys/kern/subr_bufq.c
cvs rdiff -u -r1.10 -r1.11 src/sys/sys/bufq.h
cvs rdiff -u -r1.9 -r1.10 src/sys/sys/bufq_impl.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/bufq_disksort.c
diff -u src/sys/kern/bufq_disksort.c:1.11 src/sys/kern/bufq_disksort.c:1.12
--- src/sys/kern/bufq_disksort.c:1.11	Mon Jan 19 14:54:28 2009
+++ src/sys/kern/bufq_disksort.c	Wed Nov 16 00:46:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bufq_disksort.c,v 1.11 2009/01/19 14:54:28 yamt Exp $	*/
+/*	$NetBSD: bufq_disksort.c,v 1.12 2016/11/16 00:46:46 pgoyette Exp $	*/
 /*	NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp 	*/
 
 /*-
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.11 2009/01/19 14:54:28 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.12 2016/11/16 00:46:46 pgoyette Exp $");
 
 #include 
 #include 
@@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: bufq_disksor
 #include 
 #include 
 #include 
+#include 
 
 /*
  * Seek sort for disks.
@@ -227,3 +228,19 @@ bufq_disksort_init(struct bufq_state *bu
 	bufq->bq_fini = bufq_disksort_fini;
 	TAILQ_INIT(>bq_head);
 }
+
+MODULE(MODULE_CLASS_MISC, bufq_disksort, NULL);
+
+static int
+bufq_disksort_modcmd(modcmd_t cmd, void *opaque)
+{
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		return bufq_register(_strat_disksort);
+	case MODULE_CMD_FINI:
+		return bufq_unregister(_strat_disksort);
+	default:
+		return ENOTTY;
+	}
+}

Index: src/sys/kern/bufq_fcfs.c
diff -u src/sys/kern/bufq_fcfs.c:1.10 src/sys/kern/bufq_fcfs.c:1.11
--- src/sys/kern/bufq_fcfs.c:1.10	Mon Jan 19 14:54:28 2009
+++ src/sys/kern/bufq_fcfs.c	Wed Nov 16 00:46:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bufq_fcfs.c,v 1.10 2009/01/19 14:54:28 yamt Exp $	*/
+/*	$NetBSD: bufq_fcfs.c,v 1.11 2016/11/16 00:46:46 pgoyette Exp $	*/
 /*	NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp 	*/
 
 /*-
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.10 2009/01/19 14:54:28 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.11 2016/11/16 00:46:46 pgoyette Exp $");
 
 #include 
 #include 
@@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,
 #include 
 #include 
 #include 
+#include 
 
 /*
  * First-come first-served sort for disks.
@@ -151,3 +152,19 @@ bufq_fcfs_init(struct bufq_state *bufq)
 	fcfs = (struct bufq_fcfs *)bufq->bq_private;
 	TAILQ_INIT(>bq_head);
 }
+
+MODULE(MODULE_CLASS_MISC, bufq_fcfs, NULL);
+
+static int
+bufq_fcfs_modcmd(modcmd_t cmd, void *opaque)
+{
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		return bufq_register(_strat_fcfs);
+	case MODULE_CMD_FINI:
+		return bufq_unregister(_strat_fcfs);
+	default:
+		return ENOTTY;
+	}
+}

Index: src/sys/kern/bufq_priocscan.c
diff -u src/sys/kern/bufq_priocscan.c:1.18 src/sys/kern/bufq_priocscan.c:1.19
--- src/sys/kern/bufq_priocscan.c:1.18	Tue Jan 28 12:50:54 2014
+++ src/sys/kern/bufq_priocscan.c	Wed Nov 16 00:46:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bufq_priocscan.c,v 1.18 2014/01/28 12:50:54 martin Exp $	*/
+/*	$NetBSD: bufq_priocscan.c,v 1.19 2016/11/16 00:46:46 pgoyette Exp $	*/
 
 /*-
  * Copyright (c)2004,2005,2006,2008,2009,2011,2012 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.18 2014/01/28 12:50:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.19 2016/11/16 00:46:46 pgoyette Exp $");
 
 #include 
 #include 
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: bufq_priocsc
 #include 
 #include 
 #include 
+#include 
 
 #undef	PRIOCSCAN_USE_GLOBAL_POSITION
 
@@ -442,3 +443,19 @@ bufq_priocscan_init(struct bufq_state *b
 		cscan_init(cq, sortby);
 	}
 }
+
+MODULE(MODULE_CLASS_MISC, bufq_priocscan, NULL);
+
+static int
+bufq_priocscan_modcmd(modcmd_t cmd, void *opaque)
+{
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		return bufq_register(_strat_priocscan);
+	case MODULE_CMD_FINI:
+		return bufq_unregister(_strat_priocscan);
+	default:
+		return ENOTTY;
+	}
+}

Index: src/sys/kern/bufq_readprio.c
diff -u src/sys/kern/bufq_readprio.c:1.13 src/sys/kern/bufq_readprio.c:1.14
--- src/sys/kern/bufq_readprio.c:1.13	Mon Jan 19 14:54:28 2009
+++ src/sys/kern/bufq_readprio.c	Wed Nov 16 00:46:46 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bufq_readprio.c,v 1.13 2009/01/19 

CVS commit: src/sys

2016-11-15 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Nov 16 00:46:46 UTC 2016

Modified Files:
src/sys/kern: bufq_disksort.c bufq_fcfs.c bufq_priocscan.c
bufq_readprio.c init_main.c subr_bufq.c
src/sys/sys: bufq.h bufq_impl.h

Log Message:
Modularize the various bufq strategies


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/bufq_disksort.c
cvs rdiff -u -r1.10 -r1.11 src/sys/kern/bufq_fcfs.c
cvs rdiff -u -r1.18 -r1.19 src/sys/kern/bufq_priocscan.c
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/bufq_readprio.c
cvs rdiff -u -r1.484 -r1.485 src/sys/kern/init_main.c
cvs rdiff -u -r1.21 -r1.22 src/sys/kern/subr_bufq.c
cvs rdiff -u -r1.10 -r1.11 src/sys/sys/bufq.h
cvs rdiff -u -r1.9 -r1.10 src/sys/sys/bufq_impl.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/etc/mtree

2016-11-15 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Tue Nov 15 22:31:07 UTC 2016

Modified Files:
src/etc/mtree: Makefile

Log Message:
An awk file is not a directory.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/etc/mtree/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/mtree/Makefile
diff -u src/etc/mtree/Makefile:1.35 src/etc/mtree/Makefile:1.36
--- src/etc/mtree/Makefile:1.35	Thu Jun  9 04:26:07 2016
+++ src/etc/mtree/Makefile	Tue Nov 15 22:31:07 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.35 2016/06/09 04:26:07 christos Exp $
+#	$NetBSD: Makefile,v 1.36 2016/11/15 22:31:07 matt Exp $
 
 .include 
 
@@ -58,7 +58,7 @@ NetBSD.dist.xcompat: NetBSD.dist.xcompat
 
 NetBSD.dist.tests.compat: NetBSD.dist.tests mkcompattree.awk 
 	${MKCREATE}
-	${TOOL_AWK} -f ${.ALLSRC:M*.awk}/mkcompattree.awk \
+	${TOOL_AWK} -f ${.ALLSRC:M*.awk} \
 	-v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} -v S="usr/tests" \
 		${.ALLSRC:M*.tests} > ${.TARGET}
 



CVS commit: src/etc/mtree

2016-11-15 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Tue Nov 15 22:31:07 UTC 2016

Modified Files:
src/etc/mtree: Makefile

Log Message:
An awk file is not a directory.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/etc/mtree/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/netinet

2016-11-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Nov 15 22:23:09 UTC 2016

Modified Files:
src/sys/netinet: tcp_input.c

Log Message:
apply a #ifdef INET6 so the previous compiles without INET6.


To generate a diff of this commit:
cvs rdiff -u -r1.348 -r1.349 src/sys/netinet/tcp_input.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/netinet

2016-11-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Nov 15 22:23:09 UTC 2016

Modified Files:
src/sys/netinet: tcp_input.c

Log Message:
apply a #ifdef INET6 so the previous compiles without INET6.


To generate a diff of this commit:
cvs rdiff -u -r1.348 -r1.349 src/sys/netinet/tcp_input.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.348 src/sys/netinet/tcp_input.c:1.349
--- src/sys/netinet/tcp_input.c:1.348	Tue Nov 15 20:50:28 2016
+++ src/sys/netinet/tcp_input.c	Tue Nov 15 22:23:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.348 2016/11/15 20:50:28 mlelstv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.349 2016/11/15 22:23:09 mrg Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.348 2016/11/15 20:50:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.349 2016/11/15 22:23:09 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1357,7 +1357,9 @@ tcp_input(struct mbuf *m, ...)
 			return;
 		}
 		ip = mtod(m, struct ip *);
+#ifdef INET6
 		ip6 = mtod(m, struct ip6_hdr *);
+#endif
 		th = (struct tcphdr *)(mtod(m, char *) + toff);
 	}
 	KASSERT(TCP_HDR_ALIGNED_P(th));



CVS commit: src/tests/kernel

2016-11-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 15 21:50:38 UTC 2016

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Add vfork1 test in t_ptrace_wait* and vfork2 in t_ptrace_wait{4,6,id,pid}

These tests are exact clones for fork1 and fork2, however testing vfork(2).

vfork1:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_VFORK.

vfork2:
Verify that vfork(2) is not intercepted by ptrace(2) with empty
EVENT_MASK.

vfork1 is supposed to test currently unimplemented PTRACE_VFORK option in
EVENT_MASK, marked as failure and linked with PR kern/51630.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/kernel/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/kernel

2016-11-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 15 21:50:38 UTC 2016

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Add vfork1 test in t_ptrace_wait* and vfork2 in t_ptrace_wait{4,6,id,pid}

These tests are exact clones for fork1 and fork2, however testing vfork(2).

vfork1:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_VFORK.

vfork2:
Verify that vfork(2) is not intercepted by ptrace(2) with empty
EVENT_MASK.

vfork1 is supposed to test currently unimplemented PTRACE_VFORK option in
EVENT_MASK, marked as failure and linked with PR kern/51630.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/kernel/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/kernel/t_ptrace_wait.c
diff -u src/tests/kernel/t_ptrace_wait.c:1.17 src/tests/kernel/t_ptrace_wait.c:1.18
--- src/tests/kernel/t_ptrace_wait.c:1.17	Tue Nov 15 20:59:11 2016
+++ src/tests/kernel/t_ptrace_wait.c	Tue Nov 15 21:50:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.17 2016/11/15 20:59:11 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.18 2016/11/15 21:50:38 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.17 2016/11/15 20:59:11 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.18 2016/11/15 21:50:38 kamil Exp $");
 
 #include 
 #include 
@@ -1800,6 +1800,216 @@ ATF_TC_BODY(fork2, tc)
 }
 
 #if defined(TWAIT_HAVE_PID)
+ATF_TC(vfork1);
+ATF_TC_HEAD(vfork1, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK "
+	"set to PTRACE_VFORK");
+}
+
+ATF_TC_BODY(vfork1, tc)
+{
+	const int exitval = 5;
+	const int exitval2 = 15;
+	const int sigval = SIGSTOP;
+	pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	ptrace_state_t state;
+	const int slen = sizeof(state);
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+
+	/*
+	 * ptrace(2) command PT_SET_EVENT_MASK: option PTRACE_VFORK unsupported
+	 */
+#ifndef PTRACE_VFORK
+#define PTRACE_VFORK 0
+#endif
+	atf_tc_expect_fail("PR kern/51630");
+
+	printf("Before forking process PID=%d\n", getpid());
+	child = atf_utils_fork();
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		FORKEE_ASSERT((child2 = vfork()) != 1);
+
+		if (child2 == 0)
+			_exit(exitval2);
+
+		FORKEE_REQUIRE_SUCCESS
+		(wpid = TWAIT_GENERIC(child2, , 0), child2);
+
+		forkee_status_exited(status, exitval2);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = PTRACE_VFORK;
+	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK);
+
+	child2 = state.pe_other_pid;
+	printf("Reported PTRACE_VFORK event with forkee %d\n", child2);
+
+	printf("Before calling %s() for the forkee %d of the child %d\n",
+	TWAIT_FNAME, child2, child);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, , 0),
+	child2);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, , slen) != -1);
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK);
+	ATF_REQUIRE_EQ(state.pe_other_pid, child);
+
+	printf("Before resuming the forkee process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the forkee - expected exited\n",
+	TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, , 0),
+	child2);
+
+	validate_status_exited(status, exitval2);
+
+	printf("Before calling %s() for the forkee - expected no process\n",
+	TWAIT_FNAME);
+	

re: CVS commit: src/sys/compat/netbsd32

2016-11-15 Thread matthew green
> > i didn't look closely, but note that netbsd 5.0 had different
> > time_t -- it was only 32 bits.
> >
> > please check the compat50 and earlier code works fine with this.
> 
> I've checked that i386 binaries from 5.2.2 work on amd64.

perfect, thanks!


.mrg.


CVS commit: src/sys/netinet6

2016-11-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Nov 15 21:17:07 UTC 2016

Modified Files:
src/sys/netinet6: nd6_nbr.c

Log Message:
nd6_dad_duplicated takes the lock itself. Move it out of the critical
section.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/netinet6/nd6_nbr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/netinet6

2016-11-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Nov 15 21:17:07 UTC 2016

Modified Files:
src/sys/netinet6: nd6_nbr.c

Log Message:
nd6_dad_duplicated takes the lock itself. Move it out of the critical
section.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/netinet6/nd6_nbr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/nd6_nbr.c
diff -u src/sys/netinet6/nd6_nbr.c:1.129 src/sys/netinet6/nd6_nbr.c:1.130
--- src/sys/netinet6/nd6_nbr.c:1.129	Mon Oct 31 04:16:25 2016
+++ src/sys/netinet6/nd6_nbr.c	Tue Nov 15 21:17:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6_nbr.c,v 1.129 2016/10/31 04:16:25 ozaki-r Exp $	*/
+/*	$NetBSD: nd6_nbr.c,v 1.130 2016/11/15 21:17:07 mlelstv Exp $	*/
 /*	$KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.129 2016/10/31 04:16:25 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.130 2016/11/15 21:17:07 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1229,6 +1229,7 @@ nd6_dad_timer(struct ifaddr *ifa)
 {
 	struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
 	struct dadq *dp;
+	int duplicate = 0;
 
 #ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
@@ -1286,10 +1287,6 @@ nd6_dad_timer(struct ifaddr *ifa)
 		 * We have transmitted sufficient number of DAD packets.
 		 * See what we've got.
 		 */
-		int duplicate;
-
-		duplicate = 0;
-
 		if (dp->dad_na_icount) {
 			/*
 			 * the check is in nd6_dad_na_input(),
@@ -1306,7 +1303,6 @@ nd6_dad_timer(struct ifaddr *ifa)
 		if (duplicate) {
 			/* (*dp) will be freed in nd6_dad_duplicated() */
 			dp = NULL;
-			nd6_dad_duplicated(ifa);
 		} else {
 			/*
 			 * We are done with DAD.  No NA came, no NS came.
@@ -1329,6 +1325,10 @@ nd6_dad_timer(struct ifaddr *ifa)
 
 done:
 	mutex_exit(_dad_lock);
+
+	if (duplicate)
+		nd6_dad_duplicated(ifa);
+
 #ifndef NET_MPSAFE
 	KERNEL_UNLOCK_ONE(NULL);
 	mutex_exit(softnet_lock);



CVS commit: src/tests/kernel

2016-11-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 15 20:59:12 UTC 2016

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Add new test fork2 in t_ptrace_wait*

Verify that fork(2) is not intercepted by ptrace(2) with empty EVENT_MASK.

This test works with all wait(2)-like functions.

Debugger receives only SIGCHLD from tracee, when its the child of tracee
exits. Tracer notes nothing about fork(2) events.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/kernel/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/kernel/t_ptrace_wait.c
diff -u src/tests/kernel/t_ptrace_wait.c:1.16 src/tests/kernel/t_ptrace_wait.c:1.17
--- src/tests/kernel/t_ptrace_wait.c:1.16	Tue Nov 15 19:30:28 2016
+++ src/tests/kernel/t_ptrace_wait.c	Tue Nov 15 20:59:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.16 2016/11/15 19:30:28 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.17 2016/11/15 20:59:11 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.16 2016/11/15 19:30:28 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.17 2016/11/15 20:59:11 kamil Exp $");
 
 #include 
 #include 
@@ -1721,6 +1721,84 @@ ATF_TC_BODY(fork1, tc)
 }
 #endif
 
+ATF_TC(fork2);
+ATF_TC_HEAD(fork2, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Verify that fork(2) is not intercepted by ptrace(2) with empty "
+	"EVENT_MASK");
+}
+
+ATF_TC_BODY(fork2, tc)
+{
+	const int exitval = 5;
+	const int exitval2 = 15;
+	const int sigval = SIGSTOP;
+	pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+
+	printf("Before forking process PID=%d\n", getpid());
+	child = atf_utils_fork();
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		FORKEE_ASSERT((child2 = fork()) != 1);
+
+		if (child2 == 0)
+			_exit(exitval2);
+
+		FORKEE_REQUIRE_SUCCESS
+		(wpid = TWAIT_GENERIC(child2, , 0), child2);
+
+		forkee_status_exited(status, exitval2);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Set empty EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = 0;
+	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected stopped "
+	"SIGCHLD\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, SIGCHLD);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected exited\n",
+	TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_exited(status, exitval);
+
+	printf("Before calling %s() for the child - expected no process\n",
+	TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
+}
+
 #if defined(TWAIT_HAVE_PID)
 #define ATF_TP_ADD_TC_HAVE_PID(a,b)	ATF_TP_ADD_TC(a,b)
 #else
@@ -1748,6 +1826,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, eventmask2);
 
 	ATF_TP_ADD_TC_HAVE_PID(tp, fork1);
+	ATF_TP_ADD_TC(tp, fork2);
 
 	return atf_no_error();
 }



CVS commit: src/tests/kernel

2016-11-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 15 20:59:12 UTC 2016

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Add new test fork2 in t_ptrace_wait*

Verify that fork(2) is not intercepted by ptrace(2) with empty EVENT_MASK.

This test works with all wait(2)-like functions.

Debugger receives only SIGCHLD from tracee, when its the child of tracee
exits. Tracer notes nothing about fork(2) events.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/kernel/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2016-11-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Nov 15 20:50:29 UTC 2016

Modified Files:
src/sys/netinet: tcp_input.c udp_usrreq.c
src/sys/netinet6: icmp6.c udp6_usrreq.c

Log Message:
Enforce alignment requirements that are violated in some cases.
For machines that don't need strict alignment (i386,amd64,vax,m68k) this
is a no-op.

Fixes PR kern/50766 but should be improved.


To generate a diff of this commit:
cvs rdiff -u -r1.347 -r1.348 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.227 -r1.228 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.200 -r1.201 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.124 -r1.125 src/sys/netinet6/udp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys

2016-11-15 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Nov 15 20:50:29 UTC 2016

Modified Files:
src/sys/netinet: tcp_input.c udp_usrreq.c
src/sys/netinet6: icmp6.c udp6_usrreq.c

Log Message:
Enforce alignment requirements that are violated in some cases.
For machines that don't need strict alignment (i386,amd64,vax,m68k) this
is a no-op.

Fixes PR kern/50766 but should be improved.


To generate a diff of this commit:
cvs rdiff -u -r1.347 -r1.348 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.227 -r1.228 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.200 -r1.201 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.124 -r1.125 src/sys/netinet6/udp6_usrreq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.347 src/sys/netinet/tcp_input.c:1.348
--- src/sys/netinet/tcp_input.c:1.347	Fri Jun 10 13:31:44 2016
+++ src/sys/netinet/tcp_input.c	Tue Nov 15 20:50:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.347 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.348 2016/11/15 20:50:28 mlelstv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.347 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.348 2016/11/15 20:50:28 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1346,7 +1346,20 @@ tcp_input(struct mbuf *m, ...)
 		m_freem(m);
 		return;
 	}
-
+	/*
+ * Enforce alignment requirements that are violated in
+	 * some cases, see kern/50766 for details.
+	 */
+	if (TCP_HDR_ALIGNED_P(th) == 0) {
+		m = m_copyup(m, toff + sizeof(struct tcphdr), 0);
+		if (m == NULL) {
+			TCP_STATINC(TCP_STAT_RCVSHORT);
+			return;
+		}
+		ip = mtod(m, struct ip *);
+		ip6 = mtod(m, struct ip6_hdr *);
+		th = (struct tcphdr *)(mtod(m, char *) + toff);
+	}
 	KASSERT(TCP_HDR_ALIGNED_P(th));
 
 	/*

Index: src/sys/netinet/udp_usrreq.c
diff -u src/sys/netinet/udp_usrreq.c:1.227 src/sys/netinet/udp_usrreq.c:1.228
--- src/sys/netinet/udp_usrreq.c:1.227	Wed Oct 19 01:13:01 2016
+++ src/sys/netinet/udp_usrreq.c	Tue Nov 15 20:50:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp_usrreq.c,v 1.227 2016/10/19 01:13:01 ozaki-r Exp $	*/
+/*	$NetBSD: udp_usrreq.c,v 1.228 2016/11/15 20:50:28 mlelstv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.227 2016/10/19 01:13:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.228 2016/11/15 20:50:28 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -355,6 +355,19 @@ udp_input(struct mbuf *m, ...)
 		UDP_STATINC(UDP_STAT_HDROPS);
 		return;
 	}
+	/*
+	 * Enforce alignment requirements that are violated in
+	 * some cases, see kern/50766 for details.
+	 */
+	if (UDP_HDR_ALIGNED_P(uh) == 0) {
+		m = m_copyup(m, iphlen + sizeof(struct udphdr), 0);
+		if (m == NULL) {
+			UDP_STATINC(UDP_STAT_HDROPS);
+			return;
+		}
+		ip = mtod(m, struct ip *);
+		uh = (struct udphdr *)(mtod(m, char *) + iphlen);
+	}
 	KASSERT(UDP_HDR_ALIGNED_P(uh));
 
 	/* destination port of 0 is illegal, based on RFC768. */

Index: src/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.200 src/sys/netinet6/icmp6.c:1.201
--- src/sys/netinet6/icmp6.c:1.200	Mon Oct 31 04:16:25 2016
+++ src/sys/netinet6/icmp6.c	Tue Nov 15 20:50:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.200 2016/10/31 04:16:25 ozaki-r Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.201 2016/11/15 20:50:28 mlelstv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.200 2016/10/31 04:16:25 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.201 2016/11/15 20:50:28 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -482,6 +482,20 @@ icmp6_input(struct mbuf **mp, int *offp,
 		icmp6_ifstat_inc(rcvif, ifs6_in_error);
 		goto freeit;
 	}
+	/*
+	 * Enforce alignment requirements that are violated in
+	 * some cases, see kern/50766 for details.
+	 */
+	if (IP6_HDR_ALIGNED_P(icmp6) == 0) {
+		m = m_copyup(m, off + sizeof(struct icmp6_hdr), 0);
+		if (m == NULL) {
+			ICMP6_STATINC(ICMP6_STAT_TOOSHORT);
+			icmp6_ifstat_inc(rcvif, ifs6_in_error);
+			goto freeit;
+		}
+		ip6 = mtod(m, struct ip6_hdr *);
+		icmp6 = (struct icmp6_hdr *)(ip6 + 1);
+	}
 	KASSERT(IP6_HDR_ALIGNED_P(icmp6));
 
 	/*

Index: src/sys/netinet6/udp6_usrreq.c
diff -u src/sys/netinet6/udp6_usrreq.c:1.124 src/sys/netinet6/udp6_usrreq.c:1.125
--- src/sys/netinet6/udp6_usrreq.c:1.124	Fri Jul 15 07:40:09 2016
+++ src/sys/netinet6/udp6_usrreq.c	Tue Nov 15 20:50:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp6_usrreq.c,v 1.124 2016/07/15 07:40:09 ozaki-r Exp $	*/
+/*	$NetBSD: udp6_usrreq.c,v 1.125 2016/11/15 20:50:28 mlelstv Exp $	*/
 /*	$KAME: 

CVS commit: src/tests/kernel

2016-11-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 15 19:30:28 UTC 2016

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Add new test fork1 in t_ptrace_wait{4,6,id,pid}

Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_FORK.

In this test tracee calls fork(2) and this event is noted by tracer, both
for forker and forkee with PT_GET_PROCESS_STATE reporting pe_report_event
equal to PTRACE_FORK and pe_other_pid as forkee for forker and forker for
forkee.

The fork(2) event in the current implementation stops forker and forkee
with the SIGTRAP signal.

Exited forkee stops forker with the SIGCHLD signal.

Sponsored by .


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/kernel/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/kernel/t_ptrace_wait.c
diff -u src/tests/kernel/t_ptrace_wait.c:1.15 src/tests/kernel/t_ptrace_wait.c:1.16
--- src/tests/kernel/t_ptrace_wait.c:1.15	Tue Nov 15 02:53:32 2016
+++ src/tests/kernel/t_ptrace_wait.c	Tue Nov 15 19:30:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.15 2016/11/15 02:53:32 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.16 2016/11/15 19:30:28 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.15 2016/11/15 02:53:32 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.16 2016/11/15 19:30:28 kamil Exp $");
 
 #include 
 #include 
@@ -1598,6 +1598,130 @@ ATF_TC_BODY(eventmask2, tc)
 }
 
 #if defined(TWAIT_HAVE_PID)
+ATF_TC(fork1);
+ATF_TC_HEAD(fork1, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK "
+	"set to PTRACE_FORK");
+}
+
+ATF_TC_BODY(fork1, tc)
+{
+	const int exitval = 5;
+	const int exitval2 = 15;
+	const int sigval = SIGSTOP;
+	pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	ptrace_state_t state;
+	const int slen = sizeof(state);
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+
+	printf("Before forking process PID=%d\n", getpid());
+	child = atf_utils_fork();
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		FORKEE_ASSERT((child2 = fork()) != 1);
+
+		if (child2 == 0)
+			_exit(exitval2);
+
+		FORKEE_REQUIRE_SUCCESS
+		(wpid = TWAIT_GENERIC(child2, , 0), child2);
+
+		forkee_status_exited(status, exitval2);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = PTRACE_FORK;
+	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
+
+	child2 = state.pe_other_pid;
+	printf("Reported PTRACE_FORK event with forkee %d\n", child2);
+
+	printf("Before calling %s() for the forkee %d of the child %d\n",
+	TWAIT_FNAME, child2, child);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, , 0),
+	child2);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, , slen) != -1);
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
+	ATF_REQUIRE_EQ(state.pe_other_pid, child);
+
+	printf("Before resuming the forkee process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	"without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the forkee - expected exited\n",
+	TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, , 0),
+	child2);
+
+	validate_status_exited(status, exitval2);
+
+	printf("Before calling %s() for the forkee - expected no process\n",
+	TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD,
+	wpid = TWAIT_GENERIC(child2, , 0));
+
+	printf("Before calling %s() for the child - expected stopped "
+	"SIGCHLD\n", 

CVS commit: src/tests/kernel

2016-11-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Nov 15 19:30:28 UTC 2016

Modified Files:
src/tests/kernel: t_ptrace_wait.c

Log Message:
Add new test fork1 in t_ptrace_wait{4,6,id,pid}

Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_FORK.

In this test tracee calls fork(2) and this event is noted by tracer, both
for forker and forkee with PT_GET_PROCESS_STATE reporting pe_report_event
equal to PTRACE_FORK and pe_other_pid as forkee for forker and forker for
forkee.

The fork(2) event in the current implementation stops forker and forkee
with the SIGTRAP signal.

Exited forkee stops forker with the SIGCHLD signal.

Sponsored by .


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/kernel/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/xen/x86

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 17:01:12 UTC 2016

Modified Files:
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
Mmh, apparently I didn't properly test my previous change since it does not
compile anymore


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.66 src/sys/arch/xen/x86/x86_xpmap.c:1.67
--- src/sys/arch/xen/x86/x86_xpmap.c:1.66	Tue Nov 15 15:37:20 2016
+++ src/sys/arch/xen/x86/x86_xpmap.c	Tue Nov 15 17:01:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.66 2016/11/15 15:37:20 maxv Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.67 2016/11/15 17:01:12 maxv Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert 
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.66 2016/11/15 15:37:20 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.67 2016/11/15 17:01:12 maxv Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -799,7 +799,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	avail += PAGE_SIZE;
 
 	addr = ((u_long)pdtpe) - KERNBASE;
-	bt_pgd[L4_SLOT_KERNBASE] = bt_cpu_pgd[L4_SLOT_KERNBASE] =
+	bt_pgd[pl4_pi(KERNTEXTOFF)] = bt_cpu_pgd[pl4_pi(KERNTEXTOFF)] =
 	xpmap_ptom_masked(addr) | PG_k | PG_V | PG_RW;
 #else
 	pdtpe = bt_pgd;
@@ -812,7 +812,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	avail += PAGE_SIZE;
 
 	addr = ((u_long)pde) - KERNBASE;
-	pdtpe[L3_SLOT_KERNBASE] =
+	pdtpe[pl3_pi(KERNTEXTOFF)] =
 	xpmap_ptom_masked(addr) | PG_k | PG_V | PG_RW;
 #elif defined(PAE)
 	/* Our PAE-style level 2: 5 contigous pages (4 L2 + 1 shadow) */



CVS commit: src/sys/arch/xen/x86

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 17:01:12 UTC 2016

Modified Files:
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
Mmh, apparently I didn't properly test my previous change since it does not
compile anymore


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/xen/x86

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 15:37:20 UTC 2016

Modified Files:
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
Keep simplifying that stuff. Also, replace plX_pi(KERNTEXTOFF) by
LX_SLOT_KERNBASE: the base address is KERNBASE, and we just start mapping
from KERNTEXTOFF. For symmetry with the normal amd64, does not change
anything.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.65 src/sys/arch/xen/x86/x86_xpmap.c:1.66
--- src/sys/arch/xen/x86/x86_xpmap.c:1.65	Fri Nov 11 11:34:51 2016
+++ src/sys/arch/xen/x86/x86_xpmap.c	Tue Nov 15 15:37:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.65 2016/11/11 11:34:51 maxv Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.66 2016/11/15 15:37:20 maxv Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert 
@@ -38,7 +38,6 @@
  * 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.
- *
  */
 
 /*
@@ -66,9 +65,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.65 2016/11/11 11:34:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.66 2016/11/15 15:37:20 maxv Exp $");
 
 #include "opt_xen.h"
 #include "opt_ddb.h"
@@ -90,20 +88,15 @@ __KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,
 
 #undef	XENDEBUG
 /* #define XENDEBUG_SYNC */
-/* #define XENDEBUG_LOW */
 
 #ifdef XENDEBUG
 #define	XENPRINTF(x) printf x
-#define	XENPRINTK(x) printk x
 #define	XENPRINTK2(x) /* printk x */
 static char XBUF[256];
 #else
 #define	XENPRINTF(x)
-#define	XENPRINTK(x)
 #define	XENPRINTK2(x)
 #endif
-#define	PRINTF(x) printf x
-#define	PRINTK(x) printk x
 
 volatile shared_info_t *HYPERVISOR_shared_info;
 /* Xen requires the start_info struct to be page aligned */
@@ -120,7 +113,7 @@ extern volatile struct xencons_interface
 extern struct xenstore_domain_interface *xenstore_interface; /* XXX */
 
 static void xen_bt_set_readonly(vaddr_t);
-static void xen_bootstrap_tables(vaddr_t, vaddr_t, size_t, size_t, int);
+static void xen_bootstrap_tables(vaddr_t, vaddr_t, size_t, size_t, bool);
 
 vaddr_t xen_locore(void);
 
@@ -180,7 +173,8 @@ static int xpq_idx_array[MAXCPUS];
 
 #ifdef i386
 extern union descriptor tmpgdt[];
-#endif /* i386 */
+#endif
+
 void
 xpq_flush_queue(void)
 {
@@ -581,7 +575,7 @@ xpq_debug_dump(void)
 
 #ifdef PAE
 /*
- * For PAE, we consider a single contigous L2 "superpage" of 4 pages, all of
+ * For PAE, we consider a single contiguous L2 "superpage" of 4 pages, all of
  * them mapped by the L3 page. We also need a shadow page for L3[3].
  */
 static const int l2_4_count = 6;
@@ -643,15 +637,15 @@ xen_locore(void)
 #ifdef __x86_64__
 	count = TABLE_L2_ENTRIES;
 #else
-	count = (mapsize + (NBPD_L2 -1)) >> L2_SHIFT;
+	count = (mapsize + (NBPD_L2 - 1)) >> L2_SHIFT;
 #endif
 
 	/*
 	 * Now compute how many L2 pages we need exactly. This is useful only
 	 * on i386, since the initial count for amd64 is already enough.
 	 */
-	while (mapsize + (count + l2_4_count) * PAGE_SIZE + KERNTEXTOFF >
-	(count << L2_SHIFT) + KERNBASE) {
+	while (KERNTEXTOFF + mapsize + (count + l2_4_count) * PAGE_SIZE >
+	KERNBASE + (count << L2_SHIFT)) {
 		count++;
 	}
 
@@ -682,20 +676,23 @@ bootstrap_again:
 		bootstrap_tables = init_tables +
 		((count + l2_4_count) * PAGE_SIZE);
 
-	/* Make sure we have enough to map the bootstrap tables. */
+	/*
+	 * Make sure the number of L2 pages we have is enough to map everything
+	 * from KERNBASE to the bootstrap tables themselves.
+	 */
 	if (bootstrap_tables + ((oldcount + l2_4_count) * PAGE_SIZE) > 
-	(oldcount << L2_SHIFT) + KERNBASE) {
+	KERNBASE + (oldcount << L2_SHIFT)) {
 		oldcount++;
 		goto bootstrap_again;
 	}
 
 	/* Create temporary tables */
 	xen_bootstrap_tables(init_tables, bootstrap_tables,
-	xen_start_info.nr_pt_frames, oldcount, 0);
+	xen_start_info.nr_pt_frames, oldcount, false);
 
 	/* Create final tables */
 	xen_bootstrap_tables(bootstrap_tables, init_tables,
-	oldcount + l2_4_count, count, 1);
+	oldcount + l2_4_count, count, true);
 
 	/* Zero out free space after tables */
 	memset((void *)(init_tables + ((count + l2_4_count) * PAGE_SIZE)), 0,
@@ -715,7 +712,7 @@ bootstrap_again:
  */
 static void
 xen_bootstrap_tables(vaddr_t old_pgd, vaddr_t new_pgd, size_t old_count,
-size_t new_count, int final)
+size_t new_count, bool final)
 {
 	pd_entry_t *pdtpe, *pde, *pte;
 	pd_entry_t *bt_pgd;
@@ -736,7 +733,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va
 	pg_nx = (descs[3] & CPUID_NOX) ? PG_NX : 0;
 
 	/*
-	 * Size of RW area after the 

CVS commit: src/sys/arch/xen/x86

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 15:37:20 UTC 2016

Modified Files:
src/sys/arch/xen/x86: x86_xpmap.c

Log Message:
Keep simplifying that stuff. Also, replace plX_pi(KERNTEXTOFF) by
LX_SLOT_KERNBASE: the base address is KERNBASE, and we just start mapping
from KERNTEXTOFF. For symmetry with the normal amd64, does not change
anything.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/xen/x86/x86_xpmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/amd64/amd64

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 15:26:59 UTC 2016

Modified Files:
src/sys/arch/amd64/amd64: machdep.c

Log Message:
I actually came across the solution to this issue in the Intel SDM for a
totally unrelated reason a few weeks ago. The reason we need a particular
module_map on amd64 is because gcc makes us use RIP-relative addressing.

The offset field of the associated opcodes is a 32bit signed displacement,
which means we can access only up to 2GB around the current instruction.
And given that kernel_map is too far away from the kernel .text, it is not
RIP-addressable. Hence the module_map embedded into the bootstrap memory,
which is right above the kernel image.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/arch/amd64/amd64/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.231 src/sys/arch/amd64/amd64/machdep.c:1.232
--- src/sys/arch/amd64/amd64/machdep.c:1.231	Tue Nov 15 15:00:56 2016
+++ src/sys/arch/amd64/amd64/machdep.c	Tue Nov 15 15:26:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.231 2016/11/15 15:00:56 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.232 2016/11/15 15:26:59 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.231 2016/11/15 15:00:56 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.232 2016/11/15 15:26:59 maxv Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -377,12 +377,14 @@ cpu_startup(void)
 	/*
 	 * Create the module map.
 	 *
-	 * XXX: the module map is taken as what is left of the bootstrap memory
-	 * created in locore.S, which is not big enough if we want to load many
-	 * modules dynamically. We really should be using kernel_map instead.
+	 * The kernel uses RIP-relative addressing with a maximum offset of
+	 * 2GB. The problem is, kernel_map is too far away in memory from
+	 * the kernel .text. So we cannot use it, and have to create a
+	 * special module_map.
 	 *
-	 * But the modules must be located above the kernel image, and that
-	 * wouldn't be guaranteed if we were using kernel_map.
+	 * The module map is taken as what is left of the bootstrap memory
+	 * created in locore.S. This memory is right above the kernel
+	 * image, so this is the best place to put our modules.
 	 */
 	uvm_map_setup(_map_store, module_start, module_end, 0);
 	module_map_store.pmap = pmap_kernel();



CVS commit: src/sys/arch/amd64/amd64

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 15:26:59 UTC 2016

Modified Files:
src/sys/arch/amd64/amd64: machdep.c

Log Message:
I actually came across the solution to this issue in the Intel SDM for a
totally unrelated reason a few weeks ago. The reason we need a particular
module_map on amd64 is because gcc makes us use RIP-relative addressing.

The offset field of the associated opcodes is a 32bit signed displacement,
which means we can access only up to 2GB around the current instruction.
And given that kernel_map is too far away from the kernel .text, it is not
RIP-addressable. Hence the module_map embedded into the bootstrap memory,
which is right above the kernel image.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/arch/amd64/amd64/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 15:00:56 UTC 2016

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/i386/i386: machdep.c
src/sys/arch/x86/x86: x86_machdep.c

Log Message:
Initialize kern_end in amd64 instead of x86.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.763 -r1.764 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/x86/x86/x86_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.230 src/sys/arch/amd64/amd64/machdep.c:1.231
--- src/sys/arch/amd64/amd64/machdep.c:1.230	Sat Aug 27 16:17:16 2016
+++ src/sys/arch/amd64/amd64/machdep.c	Tue Nov 15 15:00:56 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.230 2016/08/27 16:17:16 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.231 2016/11/15 15:00:56 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.230 2016/08/27 16:17:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.231 2016/11/15 15:00:56 maxv Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1540,7 +1540,9 @@ init_x86_64(paddr_t first_avail)
 	int x;
 #ifndef XEN
 	int ist;
-#endif /* !XEN */
+#endif
+
+	KASSERT(first_avail % PAGE_SIZE == 0);
 
 #ifdef XEN
 	KASSERT(HYPERVISOR_shared_info != NULL);
@@ -1609,11 +1611,13 @@ init_x86_64(paddr_t first_avail)
 	 */
 	pmap_bootstrap(VM_MIN_KERNEL_ADDRESS);
 
+	/* End of the virtual space we have created so far. */
+	kern_end = KERNBASE + first_avail;
+
 #ifndef XEN
 	/* Internalize the physical pages into the VM system. */
 	init_x86_vm(first_avail);
 #else	/* XEN */
-	kern_end = KERNBASE + first_avail;
 	physmem = xen_start_info.nr_pages;
 
 	uvm_page_physload(atop(avail_start),

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.763 src/sys/arch/i386/i386/machdep.c:1.764
--- src/sys/arch/i386/i386/machdep.c:1.763	Fri Nov 11 11:34:51 2016
+++ src/sys/arch/i386/i386/machdep.c	Tue Nov 15 15:00:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.763 2016/11/11 11:34:51 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.764 2016/11/15 15:00:55 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.763 2016/11/11 11:34:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.764 2016/11/15 15:00:55 maxv Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -1141,6 +1141,8 @@ init386(paddr_t first_avail)
 	extern u_char biostramp_image[];
 #endif
 
+	KASSERT(first_avail % PAGE_SIZE == 0);
+
 #ifdef XEN
 	XENPRINTK(("HYPERVISOR_shared_info %p (%x)\n", HYPERVISOR_shared_info,
 	xen_start_info.shared_info));

Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.75 src/sys/arch/x86/x86/x86_machdep.c:1.76
--- src/sys/arch/x86/x86/x86_machdep.c:1.75	Mon Aug  1 16:07:39 2016
+++ src/sys/arch/x86/x86/x86_machdep.c	Tue Nov 15 15:00:56 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.75 2016/08/01 16:07:39 maxv Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.76 2016/11/15 15:00:56 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.75 2016/08/01 16:07:39 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.76 2016/11/15 15:00:56 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -849,14 +849,10 @@ init_x86_vm(paddr_t pa_kend)
 			x86_freelists[i].freelist = VM_FREELIST_DEFAULT;
 	}
 
-	/* Make sure the end of the space used by the kernel is rounded. */
-	pa_kend = round_page(pa_kend);
-
 #ifdef amd64
 	extern vaddr_t kern_end;
 	extern vaddr_t module_start, module_end;
 
-	kern_end = KERNBASE + pa_kend;
 	module_start = kern_end;
 	module_end = KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2;
 #endif



CVS commit: src/sys/arch

2016-11-15 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Nov 15 15:00:56 UTC 2016

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/arch/i386/i386: machdep.c
src/sys/arch/x86/x86: x86_machdep.c

Log Message:
Initialize kern_end in amd64 instead of x86.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.763 -r1.764 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/x86/x86/x86_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2016-11-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Nov 15 12:59:33 UTC 2016

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests

Log Message:
Fix librefuse falout Hi pho


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.699 -r1.700 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.132 -r1.133 src/etc/mtree/NetBSD.dist.tests

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2016-11-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Nov 15 12:59:33 UTC 2016

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests

Log Message:
Fix librefuse falout Hi pho


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.699 -r1.700 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.132 -r1.133 src/etc/mtree/NetBSD.dist.tests

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.176 src/distrib/sets/lists/debug/mi:1.177
--- src/distrib/sets/lists/debug/mi:1.176	Fri Nov 11 15:30:44 2016
+++ src/distrib/sets/lists/debug/mi	Tue Nov 15 12:59:33 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.176 2016/11/11 15:30:44 njoly Exp $
+# $NetBSD: mi,v 1.177 2016/11/15 12:59:33 skrll Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2175,6 +2175,7 @@
 ./usr/libdata/debug/usr/tests/lib/libpthread/t_timedmutex.debug		tests-lib-tests		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/librt/t_sched.debug			tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/librt/t_sem.debug			tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/librefuse/t_refuse_opt.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/librumpclient/h_exec.debug			tests-lib-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/lib/librumpclient/h_execthr.debug			tests-lib-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/lib/librumpclient/h_ution.debug			tests-obsolete		obsolete

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.699 src/distrib/sets/lists/tests/mi:1.700
--- src/distrib/sets/lists/tests/mi:1.699	Fri Nov 11 15:30:44 2016
+++ src/distrib/sets/lists/tests/mi	Tue Nov 15 12:59:33 2016
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.699 2016/11/11 15:30:44 njoly Exp $
+# $NetBSD: mi,v 1.700 2016/11/15 12:59:33 skrll Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -129,6 +129,7 @@
 ./usr/libdata/debug/usr/tests/lib/libpthreadtests-lib-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libpthread/dlopen			tests-lib-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/librt	tests-lib-debug		compattestfile,atf
+./usr/libdata/debug/usr/tests/lib/librefusetests-lib-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/librumpclienttests-lib-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/librumphijacktests-lib-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libskeytests-lib-debug		compattestfile,atf
@@ -3019,6 +3020,9 @@
 ./usr/tests/lib/librt/Kyuafile			tests-lib-tests		compattestfile,atf,kyua
 ./usr/tests/lib/librt/t_sched			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/librt/t_sem			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/librefuse			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/librefuse/Atffile		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/librefuse/t_refuse_opt		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/librumpclienttests-lib-tests		compattestfile,atf
 ./usr/tests/lib/librumpclient/Atffile			tests-lib-tests		atf,rump
 ./usr/tests/lib/librumpclient/Kyuafile			tests-lib-tests		atf,rump,kyua

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.132 src/etc/mtree/NetBSD.dist.tests:1.133
--- src/etc/mtree/NetBSD.dist.tests:1.132	Sat Oct 22 14:13:39 2016
+++ src/etc/mtree/NetBSD.dist.tests	Tue Nov 15 12:59:33 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.132 2016/10/22 14:13:39 abhinav Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.133 2016/11/15 12:59:33 skrll Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -116,6 +116,7 @@
 ./usr/libdata/debug/usr/tests/lib/libprop
 ./usr/libdata/debug/usr/tests/lib/libpthread
 ./usr/libdata/debug/usr/tests/lib/libpthread/dlopen
+./usr/libdata/debug/usr/tests/lib/librefuse
 ./usr/libdata/debug/usr/tests/lib/librt
 ./usr/libdata/debug/usr/tests/lib/librumpclient
 ./usr/libdata/debug/usr/tests/lib/librumphijack
@@ -300,6 +301,7 @@
 ./usr/tests/lib/libprop
 ./usr/tests/lib/libpthread
 ./usr/tests/lib/libpthread/dlopen
+./usr/tests/lib/librefuse
 ./usr/tests/lib/librt
 ./usr/tests/lib/librumpclient
 ./usr/tests/lib/librumphijack



Re: CVS commit: src/tests/lib/librefuse

2016-11-15 Thread Christos Zoulas
In article <20161115100522.627f9f...@cvs.netbsd.org>,
Martin Husemann  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  martin
>Date:  Tue Nov 15 10:05:22 UTC 2016
>
>Modified Files:
>   src/tests/lib/librefuse: t_refuse_opt.c
>
>Log Message:
>Evil hack to make register_t known and fix the build - XXX not sure this
>is the proper fix.

You just need to #define _KERNTYPES in the beginning of the file, no need
to include 

christos



Re: CVS commit: src/sys/compat/netbsd32

2016-11-15 Thread Rin Okuyama

Hi,

On 2016/11/13 1:06, Michael van Elst wrote:

Module Name:src
Committed By:   mlelstv
Date:   Sat Nov 12 16:06:04 UTC 2016

Modified Files:
src/sys/compat/netbsd32: netbsd32_ioctl.c netbsd32_ioctl.h

Log Message:
Fix netbsd32 emulation for clockctl_ntp_adjtime.

The ioctl args reference a timex structure that needs to be
transformed to 64bit layout and back.

The 32bit ioctl definition was wrong for mips, as register_t is 64bit
for N32 abi.


After this commit, non-NTP kernel fails to build:

  netbsd32_ioctl.o: In function `netbsd32_do_clockctl_ntp_adjtime':
  xxx/../../../../compat/netbsd32/netbsd32_ioctl.c:938: undefined reference to 
`ntp_adjtime1'
  xxx/../../../../compat/netbsd32/netbsd32_ioctl.c:943: undefined reference to 
`ntp_timestatus'
  *** [netbsd] Error code 1

This results in build failure for most ARM environments:

  http://releng.netbsd.org/builds/HEAD/201611140950Z/

I think that NTP stuff should be protected by "#ifdef NTP".
Can I commit the attached patch?

Thanks,
Rin
===
--- src/sys/compat/netbsd32/netbsd32_ioctl.c.orig   2016-11-15 
18:41:41.050970773 +0900
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c2016-11-15 19:06:19.965189392 
+0900
@@ -422,6 +422,7 @@
p->tp = NETBSD32PTR64(s32p->tp);
 }
 
+#ifdef NTP

 static inline void
 netbsd32_to_clockctl_ntp_adjtime(
 const struct netbsd32_clockctl_ntp_adjtime *s32p,
@@ -432,6 +433,7 @@
p->tp = NETBSD32PTR64(s32p->tp);
p->retval = s32p->retval;
 }
+#endif
 
 static inline void

 netbsd32_to_ksyms_gsymbol(
@@ -842,6 +844,7 @@
NETBSD32PTR32(s32p->tp, p->tp);
 }
 
+#ifdef NTP

 static inline void
 netbsd32_from_clockctl_ntp_adjtime(
 const struct clockctl_ntp_adjtime *p,
@@ -852,6 +855,7 @@
NETBSD32PTR32(s32p->tp, p->tp);
s32p->retval = p->retval;
 }
+#endif
 
 static inline void

 netbsd32_from_ksyms_gsymbol(
@@ -922,6 +926,7 @@
NETBSD32PTR32(s32p->locators, p->locators);
 }
 
+#ifdef NTP

 static int
 netbsd32_do_clockctl_ntp_adjtime(struct clockctl_ntp_adjtime *args)
 {
@@ -944,6 +949,7 @@
 
 	return error;

 }
+#endif
 
 /*

  * main ioctl syscall.
@@ -1314,6 +1320,7 @@
case CLOCKCTL_CLOCK_SETTIME32:
IOCTL_STRUCT_CONV_TO(CLOCKCTL_CLOCK_SETTIME,
clockctl_clock_settime);
+#ifdef NTP
case CLOCKCTL_NTP_ADJTIME32:
{
size = IOCPARM_LEN(CLOCKCTL_NTP_ADJTIME);
@@ -1335,6 +1342,7 @@
 
 			break;

}
+#endif
 
 	case KIOCGSYMBOL32:

IOCTL_STRUCT_CONV_TO(KIOCGSYMBOL, ksyms_gsymbol);


Re: CVS commit: src/sys/compat/netbsd32

2016-11-15 Thread Rin Okuyama

On 2016/11/15 19:26, Martin Husemann wrote:

On Tue, Nov 15, 2016 at 07:23:09PM +0900, Rin Okuyama wrote:

This results in build failure for most ARM environments:

  http://releng.netbsd.org/builds/HEAD/201611140950Z/

I think that NTP stuff should be protected by "#ifdef NTP".
Can I commit the attached patch?


Sounds good, but don't you need to add #include "opt_ntp.h" to
netbsd32_ioctl.c ?


Thank you so much! I added this. Otherwise, NTP kernel gets
broken this time...

Thanks,
Rin


CVS commit: src/sys/compat/netbsd32

2016-11-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Nov 15 10:57:57 UTC 2016

Modified Files:
src/sys/compat/netbsd32: netbsd32_ioctl.c

Log Message:
Protect NPT stuff by "#ifdef NTP". Fix non-NTP kernel.
Approved by martin.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/compat/netbsd32/netbsd32_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_ioctl.c
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.c:1.85 src/sys/compat/netbsd32/netbsd32_ioctl.c:1.86
--- src/sys/compat/netbsd32/netbsd32_ioctl.c:1.85	Sat Nov 12 16:06:04 2016
+++ src/sys/compat/netbsd32/netbsd32_ioctl.c	Tue Nov 15 10:57:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.c,v 1.85 2016/11/12 16:06:04 mlelstv Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.c,v 1.86 2016/11/15 10:57:57 rin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -31,7 +31,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.85 2016/11/12 16:06:04 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ioctl.c,v 1.86 2016/11/15 10:57:57 rin Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_ntp.h"
+#endif
 
 #include 
 #include 
@@ -422,6 +426,7 @@ netbsd32_to_clockctl_clock_settime(
 	p->tp = NETBSD32PTR64(s32p->tp);
 }
 
+#ifdef NTP
 static inline void
 netbsd32_to_clockctl_ntp_adjtime(
 const struct netbsd32_clockctl_ntp_adjtime *s32p,
@@ -432,6 +437,7 @@ netbsd32_to_clockctl_ntp_adjtime(
 	p->tp = NETBSD32PTR64(s32p->tp);
 	p->retval = s32p->retval;
 }
+#endif
 
 static inline void
 netbsd32_to_ksyms_gsymbol(
@@ -842,6 +848,7 @@ netbsd32_from_clockctl_clock_settime(
 	NETBSD32PTR32(s32p->tp, p->tp);
 }
 
+#ifdef NTP
 static inline void
 netbsd32_from_clockctl_ntp_adjtime(
 const struct clockctl_ntp_adjtime *p,
@@ -852,6 +859,7 @@ netbsd32_from_clockctl_ntp_adjtime(
 	NETBSD32PTR32(s32p->tp, p->tp);
 	s32p->retval = p->retval;
 }
+#endif
 
 static inline void
 netbsd32_from_ksyms_gsymbol(
@@ -922,6 +930,7 @@ netbsd32_from_devrescanargs(
 	NETBSD32PTR32(s32p->locators, p->locators);
 }
 
+#ifdef NTP
 static int
 netbsd32_do_clockctl_ntp_adjtime(struct clockctl_ntp_adjtime *args)
 {
@@ -944,6 +953,7 @@ netbsd32_do_clockctl_ntp_adjtime(struct 
 
 	return error;
 }
+#endif
 
 /*
  * main ioctl syscall.
@@ -1314,6 +1324,7 @@ netbsd32_ioctl(struct lwp *l, const stru
 	case CLOCKCTL_CLOCK_SETTIME32:
 		IOCTL_STRUCT_CONV_TO(CLOCKCTL_CLOCK_SETTIME,
 		clockctl_clock_settime);
+#ifdef NTP
 	case CLOCKCTL_NTP_ADJTIME32:
 		{
 			size = IOCPARM_LEN(CLOCKCTL_NTP_ADJTIME);
@@ -1335,6 +1346,7 @@ netbsd32_ioctl(struct lwp *l, const stru
 
 			break;
 		}
+#endif
 
 	case KIOCGSYMBOL32:
 		IOCTL_STRUCT_CONV_TO(KIOCGSYMBOL, ksyms_gsymbol);



CVS commit: src/sys/compat/netbsd32

2016-11-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Nov 15 10:57:57 UTC 2016

Modified Files:
src/sys/compat/netbsd32: netbsd32_ioctl.c

Log Message:
Protect NPT stuff by "#ifdef NTP". Fix non-NTP kernel.
Approved by martin.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/compat/netbsd32/netbsd32_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/compat/netbsd32

2016-11-15 Thread Martin Husemann
On Tue, Nov 15, 2016 at 07:23:09PM +0900, Rin Okuyama wrote:
> This results in build failure for most ARM environments:
> 
>   http://releng.netbsd.org/builds/HEAD/201611140950Z/
> 
> I think that NTP stuff should be protected by "#ifdef NTP".
> Can I commit the attached patch?

Sounds good, but don't you need to add #include "opt_ntp.h" to 
netbsd32_ioctl.c ?

Martin


CVS commit: src/tests/lib/librefuse

2016-11-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 15 10:05:22 UTC 2016

Modified Files:
src/tests/lib/librefuse: t_refuse_opt.c

Log Message:
Evil hack to make register_t known and fix the build - XXX not sure this
is the proper fix.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/librefuse/t_refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/librefuse/t_refuse_opt.c
diff -u src/tests/lib/librefuse/t_refuse_opt.c:1.4 src/tests/lib/librefuse/t_refuse_opt.c:1.5
--- src/tests/lib/librefuse/t_refuse_opt.c:1.4	Tue Nov 15 00:37:18 2016
+++ src/tests/lib/librefuse/t_refuse_opt.c	Tue Nov 15 10:05:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_refuse_opt.c,v 1.4 2016/11/15 00:37:18 pho Exp $ */
+/*	$NetBSD: t_refuse_opt.c,v 1.5 2016/11/15 10:05:22 martin Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -26,7 +26,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_refuse_opt.c,v 1.4 2016/11/15 00:37:18 pho Exp $");
+__RCSID("$NetBSD: t_refuse_opt.c,v 1.5 2016/11/15 10:05:22 martin Exp $");
+
+#define _KERNTYPES
+#include 
 
 #include 
 



CVS commit: src/tests/lib/librefuse

2016-11-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 15 10:05:22 UTC 2016

Modified Files:
src/tests/lib/librefuse: t_refuse_opt.c

Log Message:
Evil hack to make register_t known and fix the build - XXX not sure this
is the proper fix.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/librefuse/t_refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/compat/netbsd32

2016-11-15 Thread Rin Okuyama

On 2016/11/15 8:16, matthew green wrote:

"Rin Okuyama" writes:

Module Name:src
Committed By:   rin
Date:   Sun Nov 13 13:59:45 UTC 2016

Modified Files:
src/sys/compat/netbsd32: netbsd32_conv.h

Log Message:
correct wrong casting. some are considered harmless, but
- tv_sec in netbsd32_timeval is netbsd32_time_t (aka netbsd32_int64_t)
  rather than time_t (int64_t)
- tv_sec in netbsd32_timespec is netbsd32_time_t rather than
  netbsd32_long (y2038 problem)
approved by martin


i didn't look closely, but note that netbsd 5.0 had different
time_t -- it was only 32 bits.

please check the compat50 and earlier code works fine with this.


I've checked that i386 binaries from 5.2.2 work on amd64. The point is
that netbsd32_time{val,spec}50 are converted into/from time{val,spec}.
Not time{val,spec}50. Function names netbsd32_{to,from}_time{val,spec}50
may be misleading, although they conform to the naming rules...

Thanks,
Rin


CVS commit: src/sys/rump/net/lib/libsockin

2016-11-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Nov 15 09:04:30 UTC 2016

Modified Files:
src/sys/rump/net/lib/libsockin: sockin.c

Log Message:
Fix build of usr.sbin/puffs/rump_nfs

XXX a better fix should be to separate nfs codes and let rump_nfs link only
XXX one that doesn't depend on rt_delete_matched_entries (and rtrequest).


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/rump/net/lib/libsockin/sockin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/net/lib/libsockin/sockin.c
diff -u src/sys/rump/net/lib/libsockin/sockin.c:1.63 src/sys/rump/net/lib/libsockin/sockin.c:1.64
--- src/sys/rump/net/lib/libsockin/sockin.c:1.63	Tue Jan 26 23:12:19 2016
+++ src/sys/rump/net/lib/libsockin/sockin.c	Tue Nov 15 09:04:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sockin.c,v 1.63 2016/01/26 23:12:19 pooka Exp $	*/
+/*	$NetBSD: sockin.c,v 1.64 2016/11/15 09:04:30 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2008, 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.63 2016/01/26 23:12:19 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.64 2016/11/15 09:04:30 ozaki-r Exp $");
 
 #include 
 #include 
@@ -707,3 +707,4 @@ sockin_unavailable(void)
 __strong_alias(rtrequest,sockin_unavailable);
 __strong_alias(ifunit,sockin_unavailable);
 __strong_alias(ifreq_setaddr,sockin_unavailable);
+__strong_alias(rt_delete_matched_entries,sockin_unavailable);



CVS commit: src/sys/rump/net/lib/libsockin

2016-11-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Nov 15 09:04:30 UTC 2016

Modified Files:
src/sys/rump/net/lib/libsockin: sockin.c

Log Message:
Fix build of usr.sbin/puffs/rump_nfs

XXX a better fix should be to separate nfs codes and let rump_nfs link only
XXX one that doesn't depend on rt_delete_matched_entries (and rtrequest).


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/rump/net/lib/libsockin/sockin.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.