CVS commit: src/usr.bin/config

2017-11-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 18 01:11:05 UTC 2017

Modified Files:
src/usr.bin/config: main.c

Log Message:
avoid creating infinite loops.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/config/main.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/config/main.c
diff -u src/usr.bin/config/main.c:1.92 src/usr.bin/config/main.c:1.93
--- src/usr.bin/config/main.c:1.92	Thu Nov 16 12:08:07 2017
+++ src/usr.bin/config/main.c	Fri Nov 17 20:11:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.92 2017/11/16 17:08:07 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.93 2017/11/18 01:11:05 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: main.c,v 1.92 2017/11/16 17:08:07 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.93 2017/11/18 01:11:05 christos Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include 
@@ -1878,6 +1878,20 @@ is_orphan_loop(const struct devbase *d, 
 }
 
 static void
+addlevelparent(struct devbase *d, struct devbase *parent)
+{
+	struct devbase *p;
+
+	if (d->d_levelparent)
+		return;
+
+	for (p = parent; p != NULL; p = p->d_levelparent)
+		if (d == p)
+			return;
+	d->d_levelparent = p;
+}
+
+static void
 do_kill_orphans(struct devbase *d, struct attr *at, struct devbase *parent,
 int state)
 {
@@ -1888,8 +1902,7 @@ do_kill_orphans(struct devbase *d, struc
 	struct pspec *p;
 	int active = 0;
 
-	if (d->d_levelparent == NULL)
-		d->d_levelparent = parent;
+	addlevelparent(d, parent);
 
 	/*
 	 * A pseudo-device will always attach at root, and if it has an



CVS commit: src/sys/arch/arm/vexpress

2017-11-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 18 00:25:43 UTC 2017

Modified Files:
src/sys/arch/arm/vexpress: vexpress_platform.c

Log Message:
Fix clcd node path for newer dtb


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/vexpress/vexpress_platform.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/arm/vexpress/vexpress_platform.c
diff -u src/sys/arch/arm/vexpress/vexpress_platform.c:1.4 src/sys/arch/arm/vexpress/vexpress_platform.c:1.5
--- src/sys/arch/arm/vexpress/vexpress_platform.c:1.4	Sun Oct 22 20:35:32 2017
+++ src/sys/arch/arm/vexpress/vexpress_platform.c	Sat Nov 18 00:25:43 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vexpress_platform.c,v 1.4 2017/10/22 20:35:32 skrll Exp $ */
+/* $NetBSD: vexpress_platform.c,v 1.5 2017/11/18 00:25:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "opt_fdt_arm.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vexpress_platform.c,v 1.4 2017/10/22 20:35:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vexpress_platform.c,v 1.5 2017/11/18 00:25:43 jmcneill Exp $");
 
 #include 
 #include 
@@ -58,7 +58,7 @@ __KERNEL_RCSID(0, "$NetBSD: vexpress_pla
 #include 
 
 #define	VEXPRESS_CLCD_NODE_PATH	\
-	"/smb@0800/motherboard/iofpga@3,/clcd@1f"
+	"/smb@800/motherboard/iofpga@3,/clcd@1f"
 #define	VEXPRESS_REF_FREQ	2400
 
 extern struct bus_space armv7_generic_bs_tag;



CVS commit: [netbsd-8] src/doc

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:47:52 UTC 2017

Modified Files:
src/doc [netbsd-8]: CHANGES-8.0

Log Message:
352-357


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.76 -r1.1.2.77 src/doc/CHANGES-8.0

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

Modified files:

Index: src/doc/CHANGES-8.0
diff -u src/doc/CHANGES-8.0:1.1.2.76 src/doc/CHANGES-8.0:1.1.2.77
--- src/doc/CHANGES-8.0:1.1.2.76	Fri Nov 17 15:08:35 2017
+++ src/doc/CHANGES-8.0	Fri Nov 17 20:47:51 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.76 2017/11/17 15:08:35 martin Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.77 2017/11/17 20:47:51 snj Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -6766,3 +6766,59 @@ sys/arch/arm/cortex/a9_mpsubr.S			1.52
 	Ensure CNTVOFF is 0 before dropping out of Hyp mode.
 	[skrll, ticket #351]
 
+sys/external/bsd/ipf/netinet/ip_state.c		1.9-1.10
+
+	Stop a kernel panic when altering the ipf state table size
+	at runtime due to unallocated memory.
+	[sborrill, ticket #352]
+
+sys/net/if_llatbl.c1.22
+sys/net/if_llatbl.h1.13
+sys/netinet/if_arp.c1.254
+sys/netinet/in.c1.208
+sys/netinet/in.c1.209
+sys/netinet6/in6.c1.249
+sys/netinet6/in6.c1.250
+sys/netinet6/nd6.c1.237
+
+	Fix a deadlock on route update.
+	[ozaki-r, ticket #353]
+
+sys/netinet6/in6_ifattach.c			1.113
+sys/netinet6/nd6.c1.238
+
+	Fix race conditions; pserialize was used for sleepable
+	code that required psref instead.
+	[ozaki-r, ticket #354]
+
+bin/sh/parser.c	1.145
+
+	Correct PR bin/52715 in /bin/sh a (mostly harmless) use after
+	free in prompt expansion processing (detected by asan.)
+	[kre, ticket #355]
+
+sys/dev/usb/xhci.c1.76
+
+	Wait 1ms first after reset. Existing Intel xHCI requires 1ms
+	delay to prevent system hang (Errata).
+	[msaitoh, ticket #356]
+
+distrib/sets/lists/debug/mi			1.228
+distrib/sets/lists/tests/mi			1.765
+distrib/sets/lists/tests/mi			1.766
+etc/mtree/NetBSD.dist.tests			1.149
+sys/net/npf/npf_ctl.c1.49
+tests/net/ipsec/Makefile			1.10
+tests/net/ipsec/algorithms.sh			1.6
+tests/net/ipsec/natt_terminator.c		1.1
+tests/net/ipsec/t_ipsec_natt.sh			1.1
+tests/net/net_common.sh1.23
+tests/net/net_common.sh1.24
+usr.sbin/npf/npfctl/npfctl.c			1.54
+
+	- Add ATF tests for IPsec NAT-T
+	- Fix npfclt reload on rump kernels
+	- npfctl(8): Fix showing translated port (ntohs-ed twice wrongly)
+	- tests/net/net_common.sh: Stop using bpfjit
+	[ozaki-r, ticket #357]
+



CVS commit: [netbsd-8] src

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:43:11 UTC 2017

Modified Files:
src/distrib/sets/lists/debug [netbsd-8]: mi
src/distrib/sets/lists/tests [netbsd-8]: mi
src/etc/mtree [netbsd-8]: NetBSD.dist.tests
src/sys/net/npf [netbsd-8]: npf_ctl.c
src/tests/net [netbsd-8]: net_common.sh
src/tests/net/ipsec [netbsd-8]: Makefile algorithms.sh
src/usr.sbin/npf/npfctl [netbsd-8]: npfctl.c
Added Files:
src/tests/net/ipsec [netbsd-8]: natt_terminator.c t_ipsec_natt.sh

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #357):
distrib/sets/lists/debug/mi: 1.228
distrib/sets/lists/tests/mi: 1.765-1.766
etc/mtree/NetBSD.dist.tests: 1.149
sys/net/npf/npf_ctl.c: 1.49
tests/net/ipsec/Makefile: 1.10
tests/net/ipsec/algorithms.sh: 1.6
tests/net/ipsec/natt_terminator.c: 1.1
tests/net/ipsec/t_ipsec_natt.sh: 1.1
tests/net/net_common.sh: 1.23-1.24
usr.sbin/npf/npfctl/npfctl.c: 1.54
Handle esp-udp for NAT-T
--
Fix npfclt reload on rump kernels
It fails because npfctl cannot get an errno when it calls ioctl to the (rump)
kernel; npfctl (libnpf) expects that an errno is returned via proplib,
however, the rump library of npf doesn't so. It happens because of mishandlings
of complicate npf kernel options.
PR kern/52643
--
Fix showing translated port (ntohs-ed twice wrongly)
--
Add test cases of NAT-T (transport mode)
A small C program is added to make a special socket (UDP_ENCAP_ESPINUDP)
and keep it to handle UDP-encapsulated ESP packets.
--
Add net/ipsec debug lib directory
--
Add ./usr/libdata/debug/usr/tests/net/ipsec
--
Stop using bpfjit
Because most architectures don't support it and npf still works without it.


To generate a diff of this commit:
cvs rdiff -u -r1.216.2.4 -r1.216.2.5 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.752.2.5 -r1.752.2.6 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.147.2.1 -r1.147.2.2 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.48 -r1.48.2.1 src/sys/net/npf/npf_ctl.c
cvs rdiff -u -r1.18.2.2 -r1.18.2.3 src/tests/net/net_common.sh
cvs rdiff -u -r1.6.2.1 -r1.6.2.2 src/tests/net/ipsec/Makefile
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/tests/net/ipsec/algorithms.sh
cvs rdiff -u -r0 -r1.1.2.2 src/tests/net/ipsec/natt_terminator.c \
src/tests/net/ipsec/t_ipsec_natt.sh
cvs rdiff -u -r1.53 -r1.53.6.1 src/usr.sbin/npf/npfctl/npfctl.c

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.216.2.4 src/distrib/sets/lists/debug/mi:1.216.2.5
--- src/distrib/sets/lists/debug/mi:1.216.2.4	Mon Oct  2 13:21:41 2017
+++ src/distrib/sets/lists/debug/mi	Fri Nov 17 20:43:10 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.216.2.4 2017/10/02 13:21:41 martin Exp $
+# $NetBSD: mi,v 1.216.2.5 2017/11/17 20:43:10 snj 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
@@ -2276,6 +2276,7 @@
 ./usr/libdata/debug/usr/tests/net/if/t_compat.debug		tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/if_loop/t_pr.debug		tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/in_cksum/in_cksum.debug	tests-net-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/net/ipsec/natt_terminator.debug	tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/mcast/mcast.debug		tests-net-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/net/mcast/t_mcast.debug		tests-obsolete		debug,atf,rump,obsolete
 ./usr/libdata/debug/usr/tests/net/net/t_pktinfo.debug		tests-net-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.752.2.5 src/distrib/sets/lists/tests/mi:1.752.2.6
--- src/distrib/sets/lists/tests/mi:1.752.2.5	Tue Oct 24 08:55:55 2017
+++ src/distrib/sets/lists/tests/mi	Fri Nov 17 20:43:10 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.752.2.5 2017/10/24 08:55:55 snj Exp $
+# $NetBSD: mi,v 1.752.2.6 2017/11/17 20:43:10 snj Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -162,6 +162,7 @@
 ./usr/libdata/debug/usr/tests/net/if	tests-net-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/net/if_looptests-net-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/net/in_cksumtests-net-debug		compattestfile,atf
+./usr/libdata/debug/usr/tests/net/ipsec	tests-net-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/net/mcast	tests-net-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/net/net	tests-net-debug		compattestfile,atf
 ./usr/libdata/debug/usr/tests/net/sys	tests-net-debug		compattestfile,atf
@@ -3316,11 +3317,13 @@
 ./usr/tests/net/ipsectests-net-tests		compattestfile,atf
 

CVS commit: src/usr.bin/systat

2017-11-17 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Nov 17 20:43:08 UTC 2017

Modified Files:
src/usr.bin/systat: main.c

Log Message:
add missing 'b' to the optstring.  alpha-sort the option handling.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/systat/main.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/systat/main.c
diff -u src/usr.bin/systat/main.c:1.51 src/usr.bin/systat/main.c:1.52
--- src/usr.bin/systat/main.c:1.51	Sat Dec  3 03:26:27 2016
+++ src/usr.bin/systat/main.c	Fri Nov 17 20:43:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.51 2016/12/03 03:26:27 mrg Exp $	*/
+/*	$NetBSD: main.c,v 1.52 2017/11/17 20:43:08 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1980, 1992, 1993
@@ -36,7 +36,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: main.c,v 1.51 2016/12/03 03:26:27 mrg Exp $");
+__RCSID("$NetBSD: main.c,v 1.52 2017/11/17 20:43:08 mrg Exp $");
 #endif /* not lint */
 
 #include 
@@ -102,7 +102,7 @@ main(int argc, char **argv)
 	egid = getegid();
 	(void)setegid(getgid());
 
-	while ((ch = getopt(argc, argv, "M:N:nw:t:")) != -1)
+	while ((ch = getopt(argc, argv, "M:N:bnw:t:")) != -1)
 		switch(ch) {
 		case 'M':
 			memf = optarg;
@@ -110,19 +110,19 @@ main(int argc, char **argv)
 		case 'N':
 			nlistf = optarg;
 			break;
+		case 'b':
+			bflag = !bflag;
+			break;
 		case 'n':
 			nflag = !nflag;
 			break;
-		case 'w':
-			if ((naptime = strtod(optarg, NULL)) <= 0)
-errx(1, "interval <= 0.");
-			break;
 		case 't':
 			if ((turns = atoi(optarg)) <= 0)
 errx(1, "turns <= 0.");
 			break;
-		case 'b':
-			bflag = !bflag;
+		case 'w':
+			if ((naptime = strtod(optarg, NULL)) <= 0)
+errx(1, "interval <= 0.");
 			break;
 		case '?':
 		default:



CVS commit: [netbsd-8] src/sys/dev/usb

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:35:57 UTC 2017

Modified Files:
src/sys/dev/usb [netbsd-8]: xhci.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #356):
sys/dev/usb/xhci.c: revision 1.76
Wait 1ms first. Existing Intel xHCI requies 1ms delay to prevent system hang
(Errata).


To generate a diff of this commit:
cvs rdiff -u -r1.72.2.2 -r1.72.2.3 src/sys/dev/usb/xhci.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/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.72.2.2 src/sys/dev/usb/xhci.c:1.72.2.3
--- src/sys/dev/usb/xhci.c:1.72.2.2	Thu Nov  2 21:29:52 2017
+++ src/sys/dev/usb/xhci.c	Fri Nov 17 20:35:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.72.2.2 2017/11/02 21:29:52 snj Exp $	*/
+/*	$NetBSD: xhci.c,v 1.72.2.3 2017/11/17 20:35:57 snj Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.2 2017/11/02 21:29:52 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.72.2.3 2017/11/17 20:35:57 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -689,10 +689,14 @@ xhci_hc_reset(struct xhci_softc * const 
 	usbcmd = XHCI_CMD_HCRST;
 	xhci_op_write_4(sc, XHCI_USBCMD, usbcmd);
 	for (i = 0; i < XHCI_WAIT_HCRST; i++) {
+		/*
+		 * Wait 1ms first. Existing Intel xHCI requies 1ms delay to
+		 * prevent system hang (Errata).
+		 */
+		usb_delay_ms(>sc_bus, 1);
 		usbcmd = xhci_op_read_4(sc, XHCI_USBCMD);
 		if ((usbcmd & XHCI_CMD_HCRST) == 0)
 			break;
-		usb_delay_ms(>sc_bus, 1);
 	}
 	if (i >= XHCI_WAIT_HCRST) {
 		aprint_error_dev(sc->sc_dev, "host controller reset timeout\n");



CVS commit: [netbsd-8] src/bin/sh

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:33:53 UTC 2017

Modified Files:
src/bin/sh [netbsd-8]: parser.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #355):
bin/sh/parser.c: revision 1.145
PR bin/52715
Correct a (relatively harmless) use after free in prompt expansion
processing [detected by asan.]
Relatively harmless: as (while incorrect) the way the data is (was)
used more or less guaranteed that the buffer contents would be
unaltered until well after they are (were) no longer wanted (this
is the expanded prompt string, it is just output (or copied into
libedit internal storage) and forgotten.
This should make no visible difference to anyone (not using asan or
similar.)


To generate a diff of this commit:
cvs rdiff -u -r1.132.2.2 -r1.132.2.3 src/bin/sh/parser.c

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

Modified files:

Index: src/bin/sh/parser.c
diff -u src/bin/sh/parser.c:1.132.2.2 src/bin/sh/parser.c:1.132.2.3
--- src/bin/sh/parser.c:1.132.2.2	Wed Aug  9 05:35:18 2017
+++ src/bin/sh/parser.c	Fri Nov 17 20:33:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: parser.c,v 1.132.2.2 2017/08/09 05:35:18 snj Exp $	*/
+/*	$NetBSD: parser.c,v 1.132.2.3 2017/11/17 20:33:53 snj Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)parser.c	8.7 (Berkeley) 5/16/95";
 #else
-__RCSID("$NetBSD: parser.c,v 1.132.2.2 2017/08/09 05:35:18 snj Exp $");
+__RCSID("$NetBSD: parser.c,v 1.132.2.3 2017/11/17 20:33:53 snj Exp $");
 #endif
 #endif /* not lint */
 
@@ -2227,9 +2227,27 @@ getprompt(void *unused)
  * Expand a string ... used for expanding prompts (PS1...)
  *
  * Never return NULL, always some string (return input string if invalid)
+ *
+ * The internal routine does the work, leaving the result on the
+ * stack (or in a static string, or even the input string) and
+ * handles parser recursion, and cleanup after an error while parsing.
+ *
+ * The visible interface copies the result off the stack (if it is there),
+ * and handles stack management, leaving the stack in the exact same
+ * state it was when expandstr() was called (so it can be used part way
+ * through building a stack data structure - as in when PS2 is being
+ * expanded half way through reading a "command line")
+ *
+ * on error, expandonstack() cleans up the parser state, but then
+ * simply jumps out through expandstr() withut doing any stack cleanup,
+ * which is OK, as the error handler must deal with that anyway.
+ *
+ * The split into two funcs is to avoid problems with setjmp/longjmp
+ * and local variables which could otherwise be optimised into bizarre
+ * behaviour.
  */
-const char *
-expandstr(char *ps, int lineno)
+static const char *
+expandonstack(char *ps, int lineno)
 {
 	union node n;
 	struct jmploc jmploc;
@@ -2238,20 +2256,8 @@ expandstr(char *ps, int lineno)
 	const int save_x = xflag;
 	struct parse_state new_state = init_parse_state;
 	struct parse_state *const saveparser = psp.v_current_parser;
-	struct stackmark smark;
 	const char *result = NULL;
 
-	setstackmark();
-	/*
-	 * At this point we anticipate that there may be a string
-	 * growing on the stack, but we have no idea how big it is.
-	 * However we know that it cannot be bigger than the current
-	 * allocated stack block, so simply reserve the whole thing,
-	 * then we can use the stack without barfing all over what
-	 * is there already...   (the stack mark undoes this later.)
-	 */
-	(void) stalloc(stackblocksize());
-
 	if (!setjmp(jmploc.loc)) {
 		handler = 
 
@@ -2278,7 +2284,6 @@ expandstr(char *ps, int lineno)
 	xflag = save_x;
 	popfilesupto(savetopfile);
 	handler = savehandler;
-	popstackmark();
 
 	if (result != NULL) {
 		INTON;
@@ -2290,3 +2295,71 @@ expandstr(char *ps, int lineno)
 
 	return result;
 }
+
+const char *
+expandstr(char *ps, int lineno)
+{
+	const char *result = NULL;
+	struct stackmark smark;
+	static char *buffer = NULL;	/* storage for prompt, never freed */
+	static size_t bufferlen = 0;
+
+	setstackmark();
+	/*
+	 * At this point we anticipate that there may be a string
+	 * growing on the stack, but we have no idea how big it is.
+	 * However we know that it cannot be bigger than the current
+	 * allocated stack block, so simply reserve the whole thing,
+	 * then we can use the stack without barfing all over what
+	 * is there already...   (the stack mark undoes this later.)
+	 */
+	(void) stalloc(stackblocksize());
+
+	result = expandonstack(ps, lineno);
+
+	if (__predict_true(result == stackblock())) {
+		size_t len = strlen(result) + 1;
+
+		/*
+		 * the result (usual case) is on the stack, which we
+		 * are just about to discard (popstackmark()) so we
+		 * need to move it somewhere safe first.
+		 */
+
+		if (__predict_false(len > bufferlen)) {
+			char *new;
+			size_t newlen = bufferlen;
+
+			if (__predict_false(len > (SIZE_MAX >> 4))) {
+result = 

CVS commit: [netbsd-8] src/sys/netinet6

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:26:19 UTC 2017

Modified Files:
src/sys/netinet6 [netbsd-8]: in6_ifattach.c nd6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #354):
sys/netinet6/in6_ifattach.c: revision 1.113
sys/netinet6/nd6.c: revision 1.238
Use psref instead of pserialize because that code is sleepable
--
Use psref instead of pserialize because that code is sleepable


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.112.6.1 src/sys/netinet6/in6_ifattach.c
cvs rdiff -u -r1.232.2.3 -r1.232.2.4 src/sys/netinet6/nd6.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/in6_ifattach.c
diff -u src/sys/netinet6/in6_ifattach.c:1.112 src/sys/netinet6/in6_ifattach.c:1.112.6.1
--- src/sys/netinet6/in6_ifattach.c:1.112	Thu Feb 23 07:57:10 2017
+++ src/sys/netinet6/in6_ifattach.c	Fri Nov 17 20:26:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_ifattach.c,v 1.112 2017/02/23 07:57:10 ozaki-r Exp $	*/
+/*	$NetBSD: in6_ifattach.c,v 1.112.6.1 2017/11/17 20:26:19 snj Exp $	*/
 /*	$KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.112 2017/02/23 07:57:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.112.6.1 2017/11/17 20:26:19 snj Exp $");
 
 #include 
 #include 
@@ -787,13 +787,15 @@ in6_ifattach(struct ifnet *ifp, struct i
 	 */
 	if (!(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) &&
 	ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) {
-		int s = pserialize_read_enter();
-		ia = in6ifa_ifpforlinklocal(ifp, 0);
+		int bound = curlwp_bind();
+		struct psref psref;
+		ia = in6ifa_ifpforlinklocal_psref(ifp, 0, );
 		if (ia == NULL && in6_ifattach_linklocal(ifp, altifp) != 0) {
 			printf("%s: cannot assign link-local address\n",
 			ifp->if_xname);
 		}
-		pserialize_read_exit(s);
+		ia6_release(ia, );
+		curlwp_bindx(bound);
 	}
 }
 

Index: src/sys/netinet6/nd6.c
diff -u src/sys/netinet6/nd6.c:1.232.2.3 src/sys/netinet6/nd6.c:1.232.2.4
--- src/sys/netinet6/nd6.c:1.232.2.3	Fri Nov 17 20:24:05 2017
+++ src/sys/netinet6/nd6.c	Fri Nov 17 20:26:19 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nd6.c,v 1.232.2.3 2017/11/17 20:24:05 snj Exp $	*/
+/*	$NetBSD: nd6.c,v 1.232.2.4 2017/11/17 20:26:19 snj Exp $	*/
 /*	$KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.232.2.3 2017/11/17 20:24:05 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.232.2.4 2017/11/17 20:26:19 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1446,7 +1446,7 @@ nd6_rtrequest(int req, struct rtentry *r
 
 	switch (req) {
 	case RTM_ADD: {
-		int s;
+		struct psref psref;
 
 		RT_DPRINTF("rt_getkey(rt) = %p\n", rt_getkey(rt));
 		/*
@@ -1554,9 +1554,8 @@ nd6_rtrequest(int req, struct rtentry *r
 		 * check if rt_getkey(rt) is an address assigned
 		 * to the interface.
 		 */
-		s = pserialize_read_enter();
-		ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp,
-		(rt_getkey(rt))->sin6_addr);
+		ifa = (struct ifaddr *)in6ifa_ifpwithaddr_psref(ifp,
+		(rt_getkey(rt))->sin6_addr, );
 		if (ifa != NULL) {
 			if (nd6_useloopback) {
 rt->rt_ifp = lo0ifp;	/* XXX */
@@ -1593,7 +1592,7 @@ nd6_rtrequest(int req, struct rtentry *r
 			}
 		}
 	out:
-		pserialize_read_exit(s);
+		ifa_release(ifa, );
 		/*
 		 * If we have too many cache entries, initiate immediate
 		 * purging for some entries.



CVS commit: [netbsd-8] src/sys

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:24:05 UTC 2017

Modified Files:
src/sys/net [netbsd-8]: if_llatbl.c if_llatbl.h
src/sys/netinet [netbsd-8]: if_arp.c in.c
src/sys/netinet6 [netbsd-8]: in6.c nd6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #353):
sys/net/if_llatbl.c: 1.22
sys/net/if_llatbl.h: 1.13
sys/netinet/if_arp.c: 1.254
sys/netinet/in.c: 1.208-1.209
sys/netinet6/in6.c: 1.249-1.250
sys/netinet6/nd6.c: 1.237
Remove redundant KASSERTMSG
The function is static, has just one caller and the caller does the same check.
--
Fix a deadlock between a route update and lltable
It happens because rtalloc1 is called from lltable with holding
IF_AFDATA_WLOCK.
If a route update is in action, rtalloc1 would wait for its completion with
holding IF_AFDATA_WLOCK. At the same moment, a softint (e.g., arpintr) may try
to take IF_AFDATA_WLOCK and get stuck on it. Unfortunately the stuck softint
prevents the route update from progressing because the route update calls
psref_target_destroy that needs the softint to complete.
A resource allocation graph of the senario looks like this:
route update =(psref_target_destroy)=> softint => IF_AFDATA_WLOCK
=(rt_update_wait)=> route update
Fix the deadlock by pulling rtalloc1 out of the lltable codes inside
IF_AFDATA_WLOCK.
Note that the deadlock happens only if NET_MPSAFE is enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.18.6.1 -r1.18.6.2 src/sys/net/if_llatbl.c
cvs rdiff -u -r1.10.8.1 -r1.10.8.2 src/sys/net/if_llatbl.h
cvs rdiff -u -r1.250.2.2 -r1.250.2.3 src/sys/netinet/if_arp.c
cvs rdiff -u -r1.203.2.1 -r1.203.2.2 src/sys/netinet/in.c
cvs rdiff -u -r1.245.2.1 -r1.245.2.2 src/sys/netinet6/in6.c
cvs rdiff -u -r1.232.2.2 -r1.232.2.3 src/sys/netinet6/nd6.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/net/if_llatbl.c
diff -u src/sys/net/if_llatbl.c:1.18.6.1 src/sys/net/if_llatbl.c:1.18.6.2
--- src/sys/net/if_llatbl.c:1.18.6.1	Fri Jul  7 13:57:26 2017
+++ src/sys/net/if_llatbl.c	Fri Nov 17 20:24:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_llatbl.c,v 1.18.6.1 2017/07/07 13:57:26 martin Exp $	*/
+/*	$NetBSD: if_llatbl.c,v 1.18.6.2 2017/11/17 20:24:05 snj Exp $	*/
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -386,7 +386,7 @@ llentry_alloc(struct ifnet *ifp, struct 
 	(ifp->if_flags & IFF_NOARP) == 0) {
 #endif
 		IF_AFDATA_WLOCK(ifp);
-		la = lla_create(lt, 0, (struct sockaddr *)dst);
+		la = lla_create(lt, 0, (struct sockaddr *)dst, NULL /* XXX */);
 		IF_AFDATA_WUNLOCK(ifp);
 	}
 
@@ -656,7 +656,12 @@ lla_rt_output(const u_char rtm_type, con
 	error = 0;
 
 	switch (rtm_type) {
-	case RTM_ADD:
+	case RTM_ADD: {
+		struct rtentry *rt;
+
+		/* Never call rtalloc1 with IF_AFDATA_WLOCK */
+		rt = rtalloc1(dst, 0);
+
 		/* Add static LLE */
 		IF_AFDATA_WLOCK(ifp);
 		lle = lla_lookup(llt, 0, dst);
@@ -666,15 +671,19 @@ lla_rt_output(const u_char rtm_type, con
 		(lle->la_flags & LLE_STATIC || lle->la_expire == 0)) {
 			LLE_RUNLOCK(lle);
 			IF_AFDATA_WUNLOCK(ifp);
+			if (rt != NULL)
+rt_unref(rt);
 			error = EEXIST;
 			goto out;
 		}
 		if (lle != NULL)
 			LLE_RUNLOCK(lle);
 
-		lle = lla_create(llt, 0, dst);
+		lle = lla_create(llt, 0, dst, rt);
 		if (lle == NULL) {
 			IF_AFDATA_WUNLOCK(ifp);
+			if (rt != NULL)
+rt_unref(rt);
 			error = ENOMEM;
 			goto out;
 		}
@@ -703,6 +712,8 @@ lla_rt_output(const u_char rtm_type, con
 		laflags = lle->la_flags;
 		LLE_WUNLOCK(lle);
 		IF_AFDATA_WUNLOCK(ifp);
+		if (rt != NULL)
+			rt_unref(rt);
 #if defined(INET) && NARP > 0
 		/* gratuitous ARP */
 		if ((laflags & LLE_PUB) && dst->sa_family == AF_INET) {
@@ -721,8 +732,8 @@ lla_rt_output(const u_char rtm_type, con
 #else
 		(void)laflags;
 #endif
-
 		break;
+	}
 
 	case RTM_DELETE:
 		IF_AFDATA_WLOCK(ifp);

Index: src/sys/net/if_llatbl.h
diff -u src/sys/net/if_llatbl.h:1.10.8.1 src/sys/net/if_llatbl.h:1.10.8.2
--- src/sys/net/if_llatbl.h:1.10.8.1	Fri Jul  7 13:57:26 2017
+++ src/sys/net/if_llatbl.h	Fri Nov 17 20:24:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_llatbl.h,v 1.10.8.1 2017/07/07 13:57:26 martin Exp $	*/
+/*	$NetBSD: if_llatbl.h,v 1.10.8.2 2017/11/17 20:24:05 snj Exp $	*/
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -190,7 +190,7 @@ struct llentry {
 typedef	struct llentry *(llt_lookup_t)(struct lltable *, u_int flags,
 const struct sockaddr *l3addr);
 typedef	struct llentry *(llt_create_t)(struct lltable *, u_int flags,
-const struct sockaddr *l3addr);
+const struct sockaddr *l3addr, const struct rtentry *);
 typedef	int (llt_delete_t)(struct lltable *, u_int flags,
 const struct sockaddr *l3addr);
 

CVS commit: [netbsd-8] src/sys/external/bsd/ipf/netinet

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:20:23 UTC 2017

Modified Files:
src/sys/external/bsd/ipf/netinet [netbsd-8]: ip_state.c

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #352):
sys/external/bsd/ipf/netinet/ip_state.c: 1.9-1.10
When growing the state, remember to grow the seed array, otherwise we'll end
up accessing memory we did not allocate.
--
put back the cast.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.4.1 src/sys/external/bsd/ipf/netinet/ip_state.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/external/bsd/ipf/netinet/ip_state.c
diff -u src/sys/external/bsd/ipf/netinet/ip_state.c:1.7 src/sys/external/bsd/ipf/netinet/ip_state.c:1.7.4.1
--- src/sys/external/bsd/ipf/netinet/ip_state.c:1.7	Sun Apr 23 20:47:22 2017
+++ src/sys/external/bsd/ipf/netinet/ip_state.c	Fri Nov 17 20:20:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_state.c,v 1.7 2017/04/23 20:47:22 christos Exp $	*/
+/*	$NetBSD: ip_state.c,v 1.7.4.1 2017/11/17 20:20:22 snj Exp $	*/
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -100,7 +100,7 @@ struct file;
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_state.c,v 1.7 2017/04/23 20:47:22 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_state.c,v 1.7.4.1 2017/11/17 20:20:22 snj Exp $");
 #else
 static const char sccsid[] = "@(#)ip_state.c	1.8 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: ip_state.c,v 1.1.1.2 2012/07/22 13:45:37 darrenr Exp";
@@ -298,6 +298,32 @@ ipf_state_soft_destroy(ipf_main_softc_t 
 	KFREE(softs);
 }
 
+static void *
+ipf_state_seed_alloc(u_int state_size, u_int state_max)
+{
+	u_int i;
+	u_long *state_seed;
+	KMALLOCS(state_seed, u_long *, state_size * sizeof(*state_seed));
+	if (state_seed == NULL)
+		return NULL;
+
+	for (i = 0; i < state_size; i++) {
+		/*
+		 * XXX - ipf_state_seed[X] should be a random number of sorts.
+		 */
+#if !defined(NEED_LOCAL_RAND) && defined(_KERNEL)
+		state_seed[i] = cprng_fast32();
+#else
+		state_seed[i] = ((u_long)state_seed + i) * state_size;
+		state_seed[i] ^= 0xa5a55a5a;
+		state_seed[i] *= (u_long)state_seed;
+		state_seed[i] ^= 0x5a5aa5a5;
+		state_seed[i] *= state_max;
+#endif
+	}
+	return state_seed;
+}
+
 
 /*  */
 /* Function:ipf_state_soft_init */
@@ -328,27 +354,11 @@ ipf_state_soft_init(ipf_main_softc_t *so
 	bzero((char *)softs->ipf_state_table,
 	  softs->ipf_state_size * sizeof(ipstate_t *));
 
-	KMALLOCS(softs->ipf_state_seed, u_long *,
-		 softs->ipf_state_size * sizeof(*softs->ipf_state_seed));
+	softs->ipf_state_seed = ipf_state_seed_alloc(softs->ipf_state_size,
+	softs->ipf_state_max);
 	if (softs->ipf_state_seed == NULL)
 		return -2;
 
-	for (i = 0; i < softs->ipf_state_size; i++) {
-		/*
-		 * XXX - ipf_state_seed[X] should be a random number of sorts.
-		 */
-#if !defined(NEED_LOCAL_RAND) && defined(_KERNEL)
-		softs->ipf_state_seed[i] = cprng_fast32();
-#else
-		softs->ipf_state_seed[i] = ((u_long)softs->ipf_state_seed + i) *
-softs->ipf_state_size;
-		softs->ipf_state_seed[i] ^= 0xa5a55a5a;
-		softs->ipf_state_seed[i] *= (u_long)softs->ipf_state_seed;
-		softs->ipf_state_seed[i] ^= 0x5a5aa5a5;
-		softs->ipf_state_seed[i] *= softs->ipf_state_max;
-#endif
-	}
-
 	KMALLOCS(softs->ipf_state_stats.iss_bucketlen, u_int *,
 		 softs->ipf_state_size * sizeof(u_int));
 	if (softs->ipf_state_stats.iss_bucketlen == NULL)
@@ -5137,6 +5147,7 @@ ipf_state_rehash(ipf_main_softc_t *softc
 {
 	ipf_state_softc_t *softs = softc->ipf_state_soft;
 	ipstate_t **newtab, *is;
+	u_long *newseed;
 	u_int *bucketlens;
 	u_int maxbucket;
 	u_int newsize;
@@ -5163,6 +5174,14 @@ ipf_state_rehash(ipf_main_softc_t *softc
 		return ENOMEM;
 	}
 
+	newseed = ipf_state_seed_alloc(newsize, softs->ipf_state_max);
+	if (newseed == NULL) {
+		KFREES(bucketlens, newsize * sizeof(*bucketlens));
+		KFREES(newtab, newsize * sizeof(*newtab));
+		IPFERROR(100037);
+		return ENOMEM;
+	}
+
 	for (maxbucket = 0, i = newsize; i > 0; i >>= 1)
 		maxbucket++;
 	maxbucket *= 2;
@@ -5178,6 +5197,12 @@ ipf_state_rehash(ipf_main_softc_t *softc
 	}
 	softs->ipf_state_table = newtab;
 
+	if (softs->ipf_state_seed != NULL) {
+		KFREES(softs->ipf_state_seed,
+		   softs->ipf_state_size * sizeof(*softs->ipf_state_seed));
+	}
+	softs->ipf_state_seed = newseed;
+
 	if (softs->ipf_state_stats.iss_bucketlen != NULL) {
 		KFREES(softs->ipf_state_stats.iss_bucketlen,
 		   softs->ipf_state_size * sizeof(u_int));



CVS commit: [netbsd-7] src/doc

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:19:00 UTC 2017

Modified Files:
src/doc [netbsd-7]: CHANGES-7.2

Log Message:
1448


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.53 -r1.1.2.54 src/doc/CHANGES-7.2

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

Modified files:

Index: src/doc/CHANGES-7.2
diff -u src/doc/CHANGES-7.2:1.1.2.53 src/doc/CHANGES-7.2:1.1.2.54
--- src/doc/CHANGES-7.2:1.1.2.53	Sun Nov  5 21:06:42 2017
+++ src/doc/CHANGES-7.2	Fri Nov 17 20:19:00 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.2,v 1.1.2.53 2017/11/05 21:06:42 snj Exp $
+# $NetBSD: CHANGES-7.2,v 1.1.2.54 2017/11/17 20:19:00 snj Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.2
 release:
@@ -4857,3 +4857,11 @@ xsrc/xfree/xc/programs/Xserver/render/re
 	apply fixes for CVEs 2017-12176 to 2017-12187
 	[mrg, ticket #1523]
 
+common/lib/libc/stdlib/_strtol.h		1.11 via patch
+common/lib/libc/stdlib/_strtoul.h		1.11 via patch
+tests/lib/libc/stdlib/t_strtol.c		1.7 via patch
+
+	Fix ISO C compliance: strtol of "0xX" should give the largest
+	valid numeric prefix, which is 0.
+	[joerg, ticket #1448]
+



CVS commit: [netbsd-7] src

2017-11-17 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Nov 17 20:08:29 UTC 2017

Modified Files:
src/common/lib/libc/stdlib [netbsd-7]: _strtol.h _strtoul.h
src/tests/lib/libc/stdlib [netbsd-7]: t_strtol.c

Log Message:
Pull up following revision(s) (requested by joerg in ticket #1448):
common/lib/libc/stdlib/_strtol.h: revision 1.11
common/lib/libc/stdlib/_strtoul.h: revision 1.11
tests/lib/libc/stdlib/t_strtol.c: revision 1.7
Fix ISO C compliance: strtol of "0xX" should give the largest valid
numeric prefix, which is 0.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.6.1 src/common/lib/libc/stdlib/_strtol.h
cvs rdiff -u -r1.7.6.1 -r1.7.6.2 src/common/lib/libc/stdlib/_strtoul.h
cvs rdiff -u -r1.5 -r1.5.22.1 src/tests/lib/libc/stdlib/t_strtol.c

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

Modified files:

Index: src/common/lib/libc/stdlib/_strtol.h
diff -u src/common/lib/libc/stdlib/_strtol.h:1.7 src/common/lib/libc/stdlib/_strtol.h:1.7.6.1
--- src/common/lib/libc/stdlib/_strtol.h:1.7	Fri May 17 12:55:56 2013
+++ src/common/lib/libc/stdlib/_strtol.h	Fri Nov 17 20:08:29 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.7 2013/05/17 12:55:56 joerg Exp $ */
+/* $NetBSD: _strtol.h,v 1.7.6.1 2017/11/17 20:08:29 snj Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -101,7 +101,10 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const
 			c = *s++;
 	}
 	if ((base == 0 || base == 16) &&
-	c == '0' && (*s == 'x' || *s == 'X')) {
+	c == '0' && (*s == 'x' || *s == 'X') &&
+	((s[1] >= '0' && s[1] <= '9') ||
+	 (s[1] >= 'a' && s[1] <= 'f') ||
+	 (s[1] >= 'A' && s[1] <= 'F'))) {
 		c = s[1];
 		s += 2;
 		base = 16;

Index: src/common/lib/libc/stdlib/_strtoul.h
diff -u src/common/lib/libc/stdlib/_strtoul.h:1.7.6.1 src/common/lib/libc/stdlib/_strtoul.h:1.7.6.2
--- src/common/lib/libc/stdlib/_strtoul.h:1.7.6.1	Sun Dec 18 06:23:22 2016
+++ src/common/lib/libc/stdlib/_strtoul.h	Fri Nov 17 20:08:29 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.7.6.1 2016/12/18 06:23:22 snj Exp $ */
+/* $NetBSD: _strtoul.h,v 1.7.6.2 2017/11/17 20:08:29 snj Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -101,7 +101,10 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const
 			c = *s++;
 	}
 	if ((base == 0 || base == 16) &&
-	c == '0' && (*s == 'x' || *s == 'X')) {
+	c == '0' && (*s == 'x' || *s == 'X') &&
+	((s[1] >= '0' && s[1] <= '9') ||
+	 (s[1] >= 'a' && s[1] <= 'f') ||
+	 (s[1] >= 'A' && s[1] <= 'F'))) {
 		c = s[1];
 		s += 2;
 		base = 16;

Index: src/tests/lib/libc/stdlib/t_strtol.c
diff -u src/tests/lib/libc/stdlib/t_strtol.c:1.5 src/tests/lib/libc/stdlib/t_strtol.c:1.5.22.1
--- src/tests/lib/libc/stdlib/t_strtol.c:1.5	Tue Jun 14 02:45:58 2011
+++ src/tests/lib/libc/stdlib/t_strtol.c	Fri Nov 17 20:08:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp $ */
+/*	$NetBSD: t_strtol.c,v 1.5.22.1 2017/11/17 20:08:29 snj Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp $");
+__RCSID("$NetBSD: t_strtol.c,v 1.5.22.1 2017/11/17 20:08:29 snj Exp $");
 
 #include 
 #include 
@@ -59,9 +59,10 @@ check(struct test *t, long int li, long 
 		atf_tc_fail_nonfatal("strtoll(%s, NULL, %d) failed "
 		"(rv = %lld)", t->str, t->base, lli);
 
-	if (t->end != NULL && strcmp(t->end, end) != 0)
-		atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
-		"strtol(%s, , %d)", end, t->str, t->base);
+	if ((t->end != NULL && strcmp(t->end, end) != 0) ||
+	(t->end == NULL && *end != '\0'))
+		atf_tc_fail_nonfatal("invalid end pointer (%p) from "
+		"strtol(%p, , %d)", end, t->str, t->base);
 }
 
 ATF_TC(strtol_base);
@@ -89,15 +90,21 @@ ATF_TC_BODY(strtol_base, tc)
 		{ "12579781",			 123456789, 14, NULL	},
 		{ "AC89BC9",			 123456789, 15, NULL	},
 		{ "75BCD15",			 123456789, 16, NULL	},
-		{ "123456789",			342391,  8, NULL	},
-		{ "0123456789",			342391,  0, NULL	},
+		{ "1234567",			342391,  8, NULL	},
+		{ "01234567",			342391,  0, NULL	},
 		{ "0123456789",			 123456789, 10, NULL	},
-		{ "0x75bcd15",		 123456789,  0, NULL	},
+		{ "0x75bcd15",			 123456789,  0, NULL	},
+		{ " 0xX",			 0,  0, "xX"	},
+		{ " 0xX",			 0, 16, "xX"	},
+		{ " 0XX",			 0,  0, "XX"	},
+		{ " 0XX",			 0, 16, "XX"	},
 	};
 
 	long long int lli;
 	long int li;
-	char *end;
+	long long int ulli;
+	long int uli;
+	char *end, *end2;
 	size_t i;
 
 	for (i = 0; i < __arraycount(t); i++) {
@@ -105,7 +112,20 @@ ATF_TC_BODY(strtol_base, tc)
 		li = strtol(t[i].str, , t[i].base);
 		lli = strtoll(t[i].str, NULL, t[i].base);
 
+		uli = strtoul(t[i].str, , t[i].base);
+		ulli = strtoull(t[i].str, NULL, t[i].base);
+
 		check([i], li, lli, end);
+
+		if (li != uli)
+			atf_tc_fail_nonfatal("strtoul(%s, NULL, %d) failed "
+			

CVS commit: src/external/cddl/osnet/sys/sys

2017-11-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 17 18:18:01 UTC 2017

Modified Files:
src/external/cddl/osnet/sys/sys: kmem.h

Log Message:
our pool code needs either PR_SLEEP or PR_NOWAIT; arrange for that explaining
the current choice :-)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/sys/sys/kmem.h

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

Modified files:

Index: src/external/cddl/osnet/sys/sys/kmem.h
diff -u src/external/cddl/osnet/sys/sys/kmem.h:1.6 src/external/cddl/osnet/sys/sys/kmem.h:1.7
--- src/external/cddl/osnet/sys/sys/kmem.h:1.6	Sat Feb 20 20:46:36 2010
+++ src/external/cddl/osnet/sys/sys/kmem.h	Fri Nov 17 13:18:01 2017
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: kmem.h,v 1.6 2010/02/21 01:46:36 darran Exp $	*/
+/*	$NetBSD: kmem.h,v 1.7 2017/11/17 18:18:01 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@ u_long	kmem_size(void);
 u_long	kmem_used(void);
 void	kmem_reap(void);
 
-void	*calloc(size_t n, size_t s);
+void	*calloc(size_t, size_t);
 
 static inline kmem_cache_t *
 kmem_cache_create(char *name, size_t bufsize, size_t align,
@@ -62,8 +62,29 @@ kmem_cache_create(char *name, size_t buf
 	return pc;
 }
 
+static inline void *
+kmem_cache_alloc(kmem_cache_t *cache, int flags)
+{
+	/*
+	 * This happens when we specify KM_PUSHPAGE by itself.
+	 *
+	 * According to kmem_cache_create(9) KM_PUSHPAGE can be used
+	 * together with KM_SLEEP and in that case the code will not
+	 * cause a deadlock. It does not say if KM_PUSHPAGE can be
+	 * used with KM_NOSLEEP. In our case, we don't have a pool
+	 * of emergency pages, so we prefer to KM_SLEEP instead of
+	 * using KM_NOSLEEP and potentially returning NULL, under the
+	 * assumption that the code wants to use the emergency pool
+	 * because it does not want the allocation to fail. If that
+	 * causes a deadlock we either need to provide an emergency
+	 * pool or handle the failure.
+	 */
+	if (flags == 0)
+		flags |= KM_SLEEP;
+	return pool_cache_get(cache, flags);
+}
+
 #define	kmem_cache_destroy(cache)		pool_cache_destroy(cache)
-#define	kmem_cache_alloc(cache, flags)		pool_cache_get(cache, flags)
 #define	kmem_cache_free(cache, buf)		pool_cache_put(cache, buf)
 #define	kmem_cache_reap_now(cache)		pool_cache_invalidate(cache)
 



CVS commit: src/external/bsd/tre/dist

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:44:01 UTC 2017

Added Files:
src/external/bsd/tre/dist: ChangeLog.old

Log Message:
Add ChangeLog.old, which has been newly added to github repository.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/tre/dist/ChangeLog.old

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

Added files:

Index: src/external/bsd/tre/dist/ChangeLog.old
diff -u /dev/null src/external/bsd/tre/dist/ChangeLog.old:1.1
--- /dev/null	Fri Nov 17 16:44:01 2017
+++ src/external/bsd/tre/dist/ChangeLog.old	Fri Nov 17 16:44:01 2017
@@ -0,0 +1,815 @@
+Fri Dec 10 21:15:14 2004  Ville Laurikari  
+
+	* Released tre-0.7.2.
+
+Sat Dec  4 12:04:29 2004  Ville Laurikari  
+
+	* lib/tre-compile.c (tre_expand_ast): Bugfix.  If a back reference
+	occurred after {m,n} in a regexp, its position was not updated
+	causing incorrect match results.
+
+	* lib/tre-compile.c (tre_make_trans): Bugfix.  If a back reference
+	was immediately followed by $ or ^, it triggered an assertion
+	failure when compiling the regexp.
+
+	* tre/retest.c: Added regression tests to catch the above bugs.
+
+	* lib/tre-compile.c (tre_version): Changed to return a better
+	human-readable string instead of just the version number.
+
+	* src/agrep.c (tre_agrep_handle_file): Bugfix.  The read buffer
+	must be reset when starting to read a new file because the read
+	loop may bail out without reading the full file.
+	
+Sun Nov 21 18:22:26 2004  Ville Laurikari  
+
+	* Released tre-0.7.1.
+
+Sat Nov 20 10:10:12 2004  Ville Laurikari  
+
+	* src/agrep.c: Added the --delimiter-after command line option.
+	It can be used to output the record delimiter after the matching
+	record when a custom delimiter regex has been given instead of
+	before the matching record, which is the default.
+
+	* src/agrep.c: Added the --color (and --colour) command line
+	option.  It highlights the matching part of the text with a color
+	code from the GREP_COLOR environment variable, or red by default.
+
+	* src/agrep.c: Made some changes which hopefully make agrep faster
+	in certain conditions.
+	
+	* win32/tre.def: Added reguexec.
+
+Sun Nov  7 17:26:54 2004  Ville Laurikari  
+
+	* Makefile.am: Fixed to include all files under the python
+	directory to distributions.
+
+	* lib/*: Divided tre-compile.c to several smaller files, to make
+	things easier to maintain.
+
+	* doc/agrep.1.in: Added this man page for agrep.
+
+Fri Sep 10 21:47:23 2004  Ville Laurikari  
+
+	* Released tre-0.7.0.
+	
+Sat Sep  4 14:55:00 2004  Ville Laurikari  
+
+	* lib/tre-compile.c (tre_parse): Added support for the \x1B and
+	\x{263a} extensions for entering 8 bit and wide characters in
+	hexadecimal.
+
+	* tests/retest.c: Added tests for the above.
+
+	* python/{tre-python.c, setup.py.in, example.py}, configure.ac:
+	Added Python language bindings contributed by Nikolai SAOUKH.
+	Thanks!
+
+	* lib/regex.c (tre_have_backrefs, tre_have_approx): Added these
+	functions to query from a compiled regexp whether it uses back
+	references or approximate matching, respectively.
+
+Sun Aug 29 19:30:01 2004  Ville Laurikari  
+
+	* Added the reguexec() function.  It can be used to match regexps
+	over arbitrary data structures, since characters are fed to the
+	matcher loop one by one with a user specified function.  Unless
+	the backtracking matcher is used, the user specified function does
+	not even need to keep the whole string in memory at once.
+
+	* tests/test-str-source.c: Test program for the above.
+
+Tue Aug  3 12:59:15 2004  Ville Laurikari  
+
+	* lib/regex.h: Added the REG_APPROX_MATCHER and
+	REG_BACKTRACKING_MATCHER execution flags to force using the
+	approximate matcher and backtracking matcher, respectively.
+
+	* tests/retest.c: Rewrote to run tests with different pmatch[] and
+	nmatch arguments, different compilation flags and different
+	matcher loops.
+
+	* lib/tre-match-approx.c (tre_tnfa_run_approx): Fixed to work
+	correctly in multibyte mode.  Before the approximate matcher did
+	not find matches if there were characters more than one byte long
+	in the string.
+
+Sun Aug  1 19:42:59 2004  Ville Laurikari  
+
+	* lib/tre-compile.c (tre_parse): Added support for \Q and \E for
+	turning REG_LITERAL on for parts of a regexp.
+
+Mon Jul  5 16:22:11 2004  Ville Laurikari  
+
+	* configure.ac: Fixed to prepend "-lgnugetopt" to LIBS if
+	gnugetopt is needed for getopt_long().
+
+Sat Jul  3 12:47:51 2004  Ville Laurikari  
+
+	* lib/tre-compile.c, lib/regex.h: Added a new compilation flag
+	REG_RIGHT_ASSOC.  It can be used to change concatenation
+	associativity from left associative (the default) to right
+	associative.
+
+	* lib/tre-compile.c (tre_parse): Added support for (?inr-inr)
+	and 

CVS commit: src/doc

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:21:45 UTC 2017

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Update libtre to the latest git source as of 20171117.


To generate a diff of this commit:
cvs rdiff -u -r1.1484 -r1.1485 src/doc/3RDPARTY
cvs rdiff -u -r1.2332 -r1.2333 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1484 src/doc/3RDPARTY:1.1485
--- src/doc/3RDPARTY:1.1484	Thu Nov 16 14:28:19 2017
+++ src/doc/3RDPARTY	Fri Nov 17 16:21:44 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1484 2017/11/16 14:28:19 wiz Exp $
+#	$NetBSD: 3RDPARTY,v 1.1485 2017/11/17 16:21:44 rin Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1569,10 +1569,10 @@ Notes:
 		Need to feed back local changes
 
 Package:	tre
-Version:	0.8.0
+Version:	0.8.0, git source as of 20171117
 Current Vers:	0.8.0
 Maintainer:	http://laurikari.net/tre
-Archive Site:	http://laurikari.net/tre
+Archive Site:	https://github.com/laurikari/tre
 Home Page:	http://laurikari.net/tre
 Mailing List:
 Responsible:	agc, christos

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2332 src/doc/CHANGES:1.2333
--- src/doc/CHANGES:1.2332	Fri Nov 17 07:16:06 2017
+++ src/doc/CHANGES	Fri Nov 17 16:21:44 2017
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2332 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2333 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -84,3 +84,4 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 	acpi(4): Updated ACPICA to 20171110. [christos 2017]
 	sunxinand(4): Add driver for Allwinner NAND Flash Controller.
 		[jmcneill 20171113]
+	libtre: Update to the latest git source. [rin 20171117]



CVS commit: src/external/bsd/tre/lib

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:18:06 UTC 2017

Added Files:
src/external/bsd/tre/lib: tre.pc

Log Message:
Add tre.pc to be installed into /usr/lib/pkgconfig (not yet).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/tre/lib/tre.pc

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

Added files:

Index: src/external/bsd/tre/lib/tre.pc
diff -u /dev/null src/external/bsd/tre/lib/tre.pc:1.1
--- /dev/null	Fri Nov 17 16:18:06 2017
+++ src/external/bsd/tre/lib/tre.pc	Fri Nov 17 16:18:06 2017
@@ -0,0 +1,10 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: TRE
+Description: TRE regexp matching library
+Version: 0.8.0
+Libs: -L${libdir} -ltre   
+Cflags: -I${includedir} 



CVS commit: src/external/bsd/tre/include

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:17:06 UTC 2017

Modified Files:
src/external/bsd/tre/include: config.h tre-config.h

Log Message:
Regen. Actually stop using alloca(3).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/tre/include/config.h
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/tre/include/tre-config.h

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

Modified files:

Index: src/external/bsd/tre/include/config.h
diff -u src/external/bsd/tre/include/config.h:1.2 src/external/bsd/tre/include/config.h:1.3
--- src/external/bsd/tre/include/config.h:1.2	Fri Nov 17 14:37:37 2017
+++ src/external/bsd/tre/include/config.h	Fri Nov 17 16:17:06 2017
@@ -14,7 +14,7 @@
 /* #undef ENABLE_NLS */
 
 /* Define to 1 if you have `alloca', as a function or macro. */
-#define HAVE_ALLOCA 1
+/* #undef HAVE_ALLOCA */
 
 /* Define to 1 if you have  and it should be used (not on Ultrix).
*/
@@ -48,7 +48,7 @@
 #define HAVE_ICONV 1
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_INTTYPES_H 1
+/* #undef HAVE_INTTYPES_H */
 
 /* Define to 1 if you have the `isascii' function. */
 #define HAVE_ISASCII 1
@@ -81,34 +81,34 @@
 #define HAVE_MBSTATE_T 1
 
 /* Define to 1 if you have the `mbtowc' function or macro. */
-#define HAVE_MBTOWC 1
+/* #undef HAVE_MBTOWC */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_MEMORY_H 1
+/* #undef HAVE_MEMORY_H */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_REGEX_H 1
+/* #undef HAVE_REGEX_H */
 
 /* Define to 1 if the system has the type `reg_errcode_t'. */
 /* #undef HAVE_REG_ERRCODE_T */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_STDINT_H 1
+/* #undef HAVE_STDINT_H */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_STDLIB_H 1
+/* #undef HAVE_STDLIB_H */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_STRINGS_H 1
+/* #undef HAVE_STRINGS_H */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_STRING_H 1
+/* #undef HAVE_STRING_H */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_SYS_STAT_H 1
+/* #undef HAVE_SYS_STAT_H */
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_SYS_TYPES_H 1
+/* #undef HAVE_SYS_TYPES_H */
 
 /* Define to 1 if you have the `towlower' function or macro. */
 #define HAVE_TOWLOWER 1
@@ -117,7 +117,7 @@
 #define HAVE_TOWUPPER 1
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_UNISTD_H 1
+/* #undef HAVE_UNISTD_H */
 
 /* Define to 1 if you have the  header file. */
 #define HAVE_WCHAR_H 1
@@ -141,7 +141,7 @@
 #define HAVE_WCSRTOMBS 1
 
 /* Define to 1 if you have the `wcstombs' function or macro. */
-#define HAVE_WCSTOMBS 1
+/* #undef HAVE_WCSTOMBS */
 
 /* Define to 1 if you have the `wctype' function or macro. */
 #define HAVE_WCTYPE 1
@@ -152,17 +152,17 @@
 /* Define to 1 if the system has the type `wint_t'. */
 #define HAVE_WINT_T 1
 
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
 /* Define if you want to disable debug assertions. */
 #define NDEBUG 1
 
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
 /* Name of package */
 #define PACKAGE "tre"
 
 /* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "tre-gene...@lists.laurikari.net"
+#define PACKAGE_BUGREPORT ""
 
 /* Define to the full name of this package. */
 #define PACKAGE_NAME "TRE"
@@ -173,6 +173,9 @@
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "tre"
 
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
 /* Define to the version of this package. */
 #define PACKAGE_VERSION "0.8.0"
 
@@ -207,7 +210,7 @@
 
 /* Define if you want TRE to use alloca() instead of malloc() when allocating
memory needed for regexec operations. */
-#define TRE_USE_ALLOCA 1
+/* #undef TRE_USE_ALLOCA */
 
 /* Define to include the system regex.h from TRE regex.h */
 /* #undef TRE_USE_SYSTEM_REGEX_H */
@@ -234,11 +237,16 @@
 /* #undef WCHAR_MAX */
 
 /* Define if wchar_t is signed */
-#define WCHAR_T_SIGNED 1
+/* #undef WCHAR_T_SIGNED */
 
 /* Define if wchar_t is unsigned */
 /* #undef WCHAR_T_UNSIGNED */
 
+/* Enable large inode numbers on Mac OS X 10.5.  */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
 /* Number of bits in a file offset, on hosts where this is settable. */
 /* #undef _FILE_OFFSET_BITS */
 
@@ -259,3 +267,6 @@
 #ifndef __cplusplus
 /* #undef inline */
 #endif
+
+/* Define to `unsigned int' if  does not define. */
+/* #undef size_t */

Index: src/external/bsd/tre/include/tre-config.h
diff -u src/external/bsd/tre/include/tre-config.h:1.1 src/external/bsd/tre/include/tre-config.h:1.2
--- src/external/bsd/tre/include/tre-config.h:1.1	Sat Nov  5 

CVS commit: src/external/bsd/tre/dist/lib

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:16:19 UTC 2017

Modified Files:
src/external/bsd/tre/dist/lib: regcomp.c regexec.c tre-compile.c

Log Message:
Disable tre_reg*b() when we don't have REG_USEBYTES.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/regcomp.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/tre/dist/lib/regexec.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/tre/dist/lib/tre-compile.c

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

Modified files:

Index: src/external/bsd/tre/dist/lib/regcomp.c
diff -u src/external/bsd/tre/dist/lib/regcomp.c:1.4 src/external/bsd/tre/dist/lib/regcomp.c:1.5
--- src/external/bsd/tre/dist/lib/regcomp.c:1.4	Fri Nov 17 16:14:30 2017
+++ src/external/bsd/tre/dist/lib/regcomp.c	Fri Nov 17 16:16:19 2017
@@ -99,6 +99,7 @@ tre_regncomp(regex_t *preg, const char *
   return ret;
 }
 
+#ifdef REG_USEBYTES
 /* this version takes bytes literally, to be used with raw vectors */
 int
 tre_regncompb(regex_t *preg, const char *regex, size_t n, int cflags)
@@ -123,6 +124,7 @@ tre_regncompb(regex_t *preg, const char 
 
   return ret;
 }
+#endif /* REG_USEBYTES */
 
 int
 tre_regcomp(regex_t *preg, const char *regex, int cflags)
@@ -130,6 +132,7 @@ tre_regcomp(regex_t *preg, const char *r
   return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
 }
 
+#ifdef REG_USEBYTES
 int
 tre_regcompb(regex_t *preg, const char *regex, int cflags)
 {
@@ -151,6 +154,7 @@ tre_regcompb(regex_t *preg, const char *
   xfree(wregex);
   return ret;
 }
+#endif /* REG_USEBYTES */
 
 
 #ifdef TRE_WCHAR

Index: src/external/bsd/tre/dist/lib/regexec.c
diff -u src/external/bsd/tre/dist/lib/regexec.c:1.8 src/external/bsd/tre/dist/lib/regexec.c:1.9
--- src/external/bsd/tre/dist/lib/regexec.c:1.8	Fri Nov 17 16:14:30 2017
+++ src/external/bsd/tre/dist/lib/regexec.c	Fri Nov 17 16:16:19 2017
@@ -227,6 +227,7 @@ tre_regexec(const regex_t *preg, const c
 	return ret;
 }
 
+#ifdef REG_USEBYTES
 int
 tre_regexecb(const regex_t *preg, const char *str,
 size_t nmatch, regmatch_t pmatch[], int eflags)
@@ -244,6 +245,7 @@ tre_regnexecb(const regex_t *preg, const
 
   return tre_match(tnfa, str, len, STR_BYTE, nmatch, pmatch, eflags);
 }
+#endif /* REG_USEBYTES */
 
 
 #ifdef TRE_WCHAR
@@ -364,6 +366,7 @@ tre_regaexec(const regex_t *preg, const 
   return tre_reganexec(preg, str, (unsigned)-1, match, params, eflags);
 }
 
+#ifdef REG_USEBYTES
 int
 tre_regaexecb(const regex_t *preg, const char *str,
   regamatch_t *match, regaparams_t params, int eflags)
@@ -373,6 +376,7 @@ tre_regaexecb(const regex_t *preg, const
   return tre_match_approx(tnfa, str, (unsigned)-1, STR_BYTE,
   match, params, eflags);
 }
+#endif /* REG_USEBYTES */
 
 #ifdef TRE_WCHAR
 

Index: src/external/bsd/tre/dist/lib/tre-compile.c
diff -u src/external/bsd/tre/dist/lib/tre-compile.c:1.3 src/external/bsd/tre/dist/lib/tre-compile.c:1.4
--- src/external/bsd/tre/dist/lib/tre-compile.c:1.3	Fri Nov 17 16:14:30 2017
+++ src/external/bsd/tre/dist/lib/tre-compile.c	Fri Nov 17 16:16:19 2017
@@ -1891,7 +1891,11 @@ tre_compile(regex_t *preg, const tre_cha
   parse_ctx.cflags = cflags;
   parse_ctx.max_backref = -1;
   /* workaround for PR#14408: use 8-bit optimizations in 8-bit mode */
+#ifdef REG_USEBYTES
   parse_ctx.cur_max = (cflags & REG_USEBYTES) ? 1 : TRE_MB_CUR_MAX;
+#else
+  parse_ctx.cur_max = TRE_MB_CUR_MAX;
+#endif
   DPRINT(("tre_compile: parsing '%.*" STRF "'\n", (int)n, regex));
   errcode = tre_parse(_ctx);
   if (errcode != REG_OK)



CVS commit: src/external/bsd/tre/dist

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:14:31 UTC 2017

Modified Files:
src/external/bsd/tre/dist: configure.ac
src/external/bsd/tre/dist/lib: regcomp.c regexec.c tre-compile.c
tre-internal.h tre-match-approx.c tre-match-backtrack.c
tre-match-parallel.c tre-match-utils.h tre-parse.c tre-parse.h
tre-stack.h tre.h
Removed Files:
src/external/bsd/tre/dist: ABOUT-NLS ChangeLog INSTALL Makefile.in
README aclocal.m4 config.h.in configure

Log Message:
Merge tre as of 20171117.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r0 src/external/bsd/tre/dist/ABOUT-NLS \
src/external/bsd/tre/dist/ChangeLog src/external/bsd/tre/dist/INSTALL \
src/external/bsd/tre/dist/Makefile.in src/external/bsd/tre/dist/README \
src/external/bsd/tre/dist/aclocal.m4 \
src/external/bsd/tre/dist/config.h.in src/external/bsd/tre/dist/configure
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/tre/dist/configure.ac
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/tre/dist/lib/regcomp.c \
src/external/bsd/tre/dist/lib/tre-parse.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/tre/dist/lib/regexec.c
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/tre/dist/lib/tre-compile.c \
src/external/bsd/tre/dist/lib/tre-internal.h \
src/external/bsd/tre/dist/lib/tre-match-approx.c \
src/external/bsd/tre/dist/lib/tre-match-parallel.c \
src/external/bsd/tre/dist/lib/tre-match-utils.h \
src/external/bsd/tre/dist/lib/tre-parse.h \
src/external/bsd/tre/dist/lib/tre-stack.h
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/tre-match-backtrack.c \
src/external/bsd/tre/dist/lib/tre.h

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

Modified files:

Index: src/external/bsd/tre/dist/configure.ac
diff -u src/external/bsd/tre/dist/configure.ac:1.2 src/external/bsd/tre/dist/configure.ac:1.3
--- src/external/bsd/tre/dist/configure.ac:1.2	Fri Nov 17 14:37:37 2017
+++ src/external/bsd/tre/dist/configure.ac	Fri Nov 17 16:14:30 2017
@@ -1,9 +1,9 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(TRE, 0.8.0, [tre-gene...@lists.laurikari.net])
+AC_INIT(TRE, 0.8.0)
 AC_CONFIG_SRCDIR([lib/regcomp.c])
 AC_CONFIG_AUX_DIR(utils)
 AC_CANONICAL_TARGET
-AM_INIT_AUTOMAKE(1.9.0)
+AM_INIT_AUTOMAKE([foreign])
 AC_PREREQ(2.59)
 AM_GNU_GETTEXT_VERSION(0.17)
 

Index: src/external/bsd/tre/dist/lib/regcomp.c
diff -u src/external/bsd/tre/dist/lib/regcomp.c:1.3 src/external/bsd/tre/dist/lib/regcomp.c:1.4
--- src/external/bsd/tre/dist/lib/regcomp.c:1.3	Sat Nov  5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/regcomp.c	Fri Nov 17 16:14:30 2017
@@ -99,12 +99,59 @@ tre_regncomp(regex_t *preg, const char *
   return ret;
 }
 
+/* this version takes bytes literally, to be used with raw vectors */
+int
+tre_regncompb(regex_t *preg, const char *regex, size_t n, int cflags)
+{
+  int ret;
+#if TRE_WCHAR /* wide chars = we need to convert it all to the wide format */
+  tre_char_t *wregex;
+  size_t i;
+
+  wregex = xmalloc(sizeof(tre_char_t) * n);
+  if (wregex == NULL)
+return REG_ESPACE;
+
+  for (i = 0; i < n; i++)
+wregex[i] = (tre_char_t) ((unsigned char) regex[i]);
+
+  ret = tre_compile(preg, wregex, n, cflags | REG_USEBYTES);
+  xfree(wregex);
+#else /* !TRE_WCHAR */
+  ret = tre_compile(preg, (const tre_char_t *)regex, n, cflags | REG_USEBYTES);
+#endif /* !TRE_WCHAR */
+
+  return ret;
+}
+
 int
 tre_regcomp(regex_t *preg, const char *regex, int cflags)
 {
   return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
 }
 
+int
+tre_regcompb(regex_t *preg, const char *regex, int cflags)
+{
+  int ret;
+  tre_char_t *wregex;
+  size_t wlen, n = strlen(regex);
+  unsigned int i;
+  const unsigned char *str = (const unsigned char *)regex;
+  tre_char_t *wstr;
+
+  wregex = xmalloc(sizeof(tre_char_t) * (n + 1));
+  if (wregex == NULL) return REG_ESPACE;
+  wstr = wregex;
+
+  for (i = 0; i < n; i++) *(wstr++) = *(str++);
+  wlen = n;
+  wregex[wlen] = L'\0';
+  ret = tre_compile(preg, wregex, wlen, cflags | REG_USEBYTES);
+  xfree(wregex);
+  return ret;
+}
+
 
 #ifdef TRE_WCHAR
 int
Index: src/external/bsd/tre/dist/lib/tre-parse.c
diff -u src/external/bsd/tre/dist/lib/tre-parse.c:1.3 src/external/bsd/tre/dist/lib/tre-parse.c:1.4
--- src/external/bsd/tre/dist/lib/tre-parse.c:1.3	Sat Nov  5 22:39:13 2011
+++ src/external/bsd/tre/dist/lib/tre-parse.c	Fri Nov 17 16:14:30 2017
@@ -133,7 +133,7 @@ tre_expand_ctype(tre_mem_t mem, tre_ctyp
   DPRINT(("  expanding class to character ranges\n"));
   for (j = 0; (j < 256) && (status == REG_OK); j++)
 {
-  c = j;
+  c = (tre_cint_t) j;
   if (tre_isctype(c, class)
 	  || ((cflags & REG_ICASE)
 	  && (tre_isctype(tre_tolower(c), class)
@@ -346,7 +346,7 @@ tre_parse_bracket_items(tre_parse_ctx_t 
 		  if (!class)
 		status = REG_ECTYPE;
 		  

CVS import: src/external/bsd/tre/dist

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:11:13 UTC 2017

Update of /cvsroot/src/external/bsd/tre/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv15967

Log Message:
Import tre from https://github.com/laurikari/tre as of 10171117:

- tre_reg*b() functions are added, that take bytes literally.
- minor bug fixes

Status:

Vendor Tag: LAURIKARI
Release Tags:   tre-20171117

U src/external/bsd/tre/dist/AUTHORS
U src/external/bsd/tre/dist/LICENSE
U src/external/bsd/tre/dist/Makefile.am
U src/external/bsd/tre/dist/NEWS
N src/external/bsd/tre/dist/README.md
U src/external/bsd/tre/dist/THANKS
U src/external/bsd/tre/dist/TODO
C src/external/bsd/tre/dist/configure.ac
U src/external/bsd/tre/dist/tre.pc.in
U src/external/bsd/tre/dist/tre.spec.in
U src/external/bsd/tre/dist/doc/Makefile.am
U src/external/bsd/tre/dist/doc/agrep.1.in
U src/external/bsd/tre/dist/doc/default.css
U src/external/bsd/tre/dist/doc/tre-api.html
U src/external/bsd/tre/dist/doc/tre-syntax.html
N src/external/bsd/tre/dist/include/tre/tre-config.h
N src/external/bsd/tre/dist/include/tre/tre.h
U src/external/bsd/tre/dist/lib/Makefile.am
U src/external/bsd/tre/dist/lib/README
C src/external/bsd/tre/dist/lib/regcomp.c
U src/external/bsd/tre/dist/lib/regerror.c
U src/external/bsd/tre/dist/lib/regex.h
C src/external/bsd/tre/dist/lib/regexec.c
U src/external/bsd/tre/dist/lib/tre-ast.c
U src/external/bsd/tre/dist/lib/tre-ast.h
C src/external/bsd/tre/dist/lib/tre-compile.c
U src/external/bsd/tre/dist/lib/tre-compile.h
U src/external/bsd/tre/dist/lib/tre-config.h.in
N src/external/bsd/tre/dist/lib/tre-filter.c
N src/external/bsd/tre/dist/lib/tre-filter.h
C src/external/bsd/tre/dist/lib/tre-internal.h
C src/external/bsd/tre/dist/lib/tre-match-approx.c
C src/external/bsd/tre/dist/lib/tre-match-backtrack.c
C src/external/bsd/tre/dist/lib/tre-match-parallel.c
C src/external/bsd/tre/dist/lib/tre-match-utils.h
U src/external/bsd/tre/dist/lib/tre-mem.c
U src/external/bsd/tre/dist/lib/tre-mem.h
C src/external/bsd/tre/dist/lib/tre-parse.c
C src/external/bsd/tre/dist/lib/tre-parse.h
U src/external/bsd/tre/dist/lib/tre-stack.c
C src/external/bsd/tre/dist/lib/tre-stack.h
C src/external/bsd/tre/dist/lib/tre.h
U src/external/bsd/tre/dist/lib/xmalloc.c
U src/external/bsd/tre/dist/lib/xmalloc.h
U src/external/bsd/tre/dist/m4/Makefile.am
U src/external/bsd/tre/dist/m4/ac_libtool_tags.m4
U src/external/bsd/tre/dist/m4/ax_check_funcs_comp.m4
U src/external/bsd/tre/dist/m4/ax_check_sign.m4
U src/external/bsd/tre/dist/m4/ax_decl_wchar_max.m4
U src/external/bsd/tre/dist/m4/vl_prog_cc_warnings.m4
U src/external/bsd/tre/dist/po/LINGUAS
U src/external/bsd/tre/dist/po/Makevars
U src/external/bsd/tre/dist/po/POTFILES.in
U src/external/bsd/tre/dist/po/fi.po
U src/external/bsd/tre/dist/po/sv.po
U src/external/bsd/tre/dist/python/example.py
U src/external/bsd/tre/dist/python/setup.py
N src/external/bsd/tre/dist/python/setup.py.in
U src/external/bsd/tre/dist/python/tre-python.c
U src/external/bsd/tre/dist/src/Makefile.am
U src/external/bsd/tre/dist/src/agrep.c
U src/external/bsd/tre/dist/tests/Makefile.am
U src/external/bsd/tre/dist/tests/bench.c
N src/external/bsd/tre/dist/tests/build-on-hosts.sh
N src/external/bsd/tre/dist/tests/build-run.sh
U src/external/bsd/tre/dist/tests/build-tests.sh
U src/external/bsd/tre/dist/tests/randtest.c
U src/external/bsd/tre/dist/tests/retest.c
U src/external/bsd/tre/dist/tests/test-str-source.c
U src/external/bsd/tre/dist/tests/agrep/Makefile.am
U src/external/bsd/tre/dist/tests/agrep/basic.args
U src/external/bsd/tre/dist/tests/agrep/basic.input
U src/external/bsd/tre/dist/tests/agrep/basic.ok
U src/external/bsd/tre/dist/tests/agrep/delimiters.args
U src/external/bsd/tre/dist/tests/agrep/delimiters.input
U src/external/bsd/tre/dist/tests/agrep/delimiters.ok
U src/external/bsd/tre/dist/tests/agrep/exitstatus.args
U src/external/bsd/tre/dist/tests/agrep/exitstatus.input
U src/external/bsd/tre/dist/tests/agrep/exitstatus.ok
U src/external/bsd/tre/dist/tests/agrep/records.args
U src/external/bsd/tre/dist/tests/agrep/records.input
U src/external/bsd/tre/dist/tests/agrep/records.ok
U src/external/bsd/tre/dist/tests/agrep/run-tests.sh
N src/external/bsd/tre/dist/tests/build-hosts/ahma
N src/external/bsd/tre/dist/tests/build-hosts/earthquake
N src/external/bsd/tre/dist/tests/build-hosts/hemuli
N src/external/bsd/tre/dist/tests/build-hosts/jolly
U src/external/bsd/tre/dist/utils/Makefile.am
U src/external/bsd/tre/dist/utils/autogen.sh
N src/external/bsd/tre/dist/utils/build-release.sh
U src/external/bsd/tre/dist/utils/build-rpm.sh
N src/external/bsd/tre/dist/utils/build-sources.sh
N src/external/bsd/tre/dist/utils/replace-vars.sh
N src/external/bsd/tre/dist/vcbuild/tre.vcxproj
N src/external/bsd/tre/dist/vcbuild/tre.vcxproj.filters
U src/external/bsd/tre/dist/win32/config.h
N src/external/bsd/tre/dist/win32/retest.vcproj
U src/external/bsd/tre/dist/win32/tre-config.h
N src/external/bsd/tre/dist/win32/tre

CVS commit: src/external/bsd/tre

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 16:08:20 UTC 2017

Added Files:
src/external/bsd/tre: tre2netbsd

Log Message:
Add tre2netbsd script based on nvi2netbsd.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/tre/tre2netbsd

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

Added files:

Index: src/external/bsd/tre/tre2netbsd
diff -u /dev/null src/external/bsd/tre/tre2netbsd:1.1
--- /dev/null	Fri Nov 17 16:08:20 2017
+++ src/external/bsd/tre/tre2netbsd	Fri Nov 17 16:08:20 2017
@@ -0,0 +1,87 @@
+#! /bin/sh
+#
+#	$NetBSD: tre2netbsd,v 1.1 2017/11/17 16:08:20 rin Exp $
+#
+# Copyright (c) 2000 The NetBSD Foundation, Inc.
+# 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# based on nvi2netbsd,
+# itself based on bind2netbsd by Bernd Ernesti and changes by Simon Burge
+#
+# Rough instructions for importing new tre release from their git repository:
+#
+#	$ cd /some/where/temporary
+#	$ git clone https://github.com/laurikari/tre.git
+#	$ sh /usr/src/external/bsd/tre/tre2netbsd tre `pwd`
+#	$ cd src/external/bsd/tre/dist
+#	$ cvs import src/external/bsd/tre/dist LAURIKARI tre-mmdd
+#	>>> if any conflicts, merge, fix and commit them.
+#	>>> check out src/external/bsd/tre/dist.
+#	$ cd checked-out-directory
+#	>>> next step requires autoconf, automake, gettext, and libtool.
+#	$ utils/autogen.sh
+#	$ ./configure --prefix=/usr --without-alloca
+#	>>> merge newly generated files:
+#	>>> 	config.h	 into /usr/src/external/bsd/tre/include
+#	>>> 	lib/tre-config.h into /usr/src/external/bsd/tre/include
+#	>>> 	tre.pc		 into /usr/src/external/bsd/tre/lib
+
+prog="$(basename "$0")"
+r="$1"
+d="$2"/src/external/bsd/tre/dist
+
+if [ $# -ne 2 ]; then echo "${prog} src dest"; exit 1; fi
+
+case "$d" in
+	/*)
+		;;
+	*)
+		d="`/bin/pwd`/$d"
+		;;
+esac
+
+case "$r" in
+	/*)
+		;;
+	*)
+		r="`/bin/pwd`/$r"
+		;;
+esac
+
+echo preparing directory "$d"
+rm -rf "$d"
+mkdir -p "$d"
+
+### Copy the files and directories
+echo copying "$r" to "$d"
+cd "$r"
+pax -rw * "$d"
+
+echo removing unneeded directories and files
+
+### Remove unneeded files
+cd "$d"
+rm -fr `find . -name '.git*'`
+
+exit 0



CVS commit: [netbsd-8] src/doc

2017-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 17 15:08:35 UTC 2017

Modified Files:
src/doc [netbsd-8]: CHANGES-8.0

Log Message:
Tickets #309, #337 and #351


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.75 -r1.1.2.76 src/doc/CHANGES-8.0

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

Modified files:

Index: src/doc/CHANGES-8.0
diff -u src/doc/CHANGES-8.0:1.1.2.75 src/doc/CHANGES-8.0:1.1.2.76
--- src/doc/CHANGES-8.0:1.1.2.75	Wed Nov  8 22:26:58 2017
+++ src/doc/CHANGES-8.0	Fri Nov 17 15:08:35 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.0,v 1.1.2.75 2017/11/08 22:26:58 snj Exp $
+# $NetBSD: CHANGES-8.0,v 1.1.2.76 2017/11/17 15:08:35 martin Exp $
 
 A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04
 until the 8.0 release:
@@ -6747,3 +6747,22 @@ sys/netinet6/raw_ip6.c1.158
 	back to the normal path.  PR kern/52659
 	[ozaki-r, ticket #350]
 
+sys/kern/vfs_vnode.c1.99-1.100
+sys/sys/vnode_impl.h1.17
+
+	Change the VSTATE_ASSERT_UNLOCKED code by pushing the potential lock
+	handling into the backend and doing an optimistic (unlocked) check
+	first. Always taking the vnode interlock makes this assertion
+	otherwise very heavy for multi-processor machines.
+	[hannken, ticket #309]
+
+bin/sh/jobs.c	1.91 via patch
+
+	Fix job table handling for PR bin/52640 and PR bin/52641.
+	[kre, ticket #337]
+
+sys/arch/arm/cortex/a9_mpsubr.S			1.52
+
+	Ensure CNTVOFF is 0 before dropping out of Hyp mode.
+	[skrll, ticket #351]
+



CVS commit: [netbsd-8] src/sys/arch/arm/cortex

2017-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 17 15:07:16 UTC 2017

Modified Files:
src/sys/arch/arm/cortex [netbsd-8]: a9_mpsubr.S

Log Message:
Pull up following revision(s) (requested by skrll in ticket #351):
sys/arch/arm/cortex/a9_mpsubr.S: revision 1.52
Ensure CNTVOFF is 0 before dropping out of Hyp mode


To generate a diff of this commit:
cvs rdiff -u -r1.47.8.1 -r1.47.8.2 src/sys/arch/arm/cortex/a9_mpsubr.S

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/arm/cortex/a9_mpsubr.S
diff -u src/sys/arch/arm/cortex/a9_mpsubr.S:1.47.8.1 src/sys/arch/arm/cortex/a9_mpsubr.S:1.47.8.2
--- src/sys/arch/arm/cortex/a9_mpsubr.S:1.47.8.1	Thu Jul  6 05:28:43 2017
+++ src/sys/arch/arm/cortex/a9_mpsubr.S	Fri Nov 17 15:07:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: a9_mpsubr.S,v 1.47.8.1 2017/07/06 05:28:43 martin Exp $	*/
+/*	$NetBSD: a9_mpsubr.S,v 1.47.8.2 2017/11/17 15:07:16 martin Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -354,6 +354,10 @@ cortex_init:
 	teq	r0, #(PSR_HYP32_MODE)	/* Hyp Mode? */
 	bne	1f
 
+	/* Set CNTVOFF to 0 */
+	mov	r0, #0
+	mcrr	p15, 4, r0, r0, c14
+
 	/* Ensure that IRQ, and FIQ will be disabled after eret */
 	mrs	r0, cpsr
 	bic	r0, r0, #(PSR_MODE)



CVS commit: [netbsd-8] src/bin/sh

2017-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 17 14:56:52 UTC 2017

Modified Files:
src/bin/sh [netbsd-8]: jobs.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #337):
bin/sh/jobs.c: revision 1.91 (patch)

PR bin/52640  PR bin/52641

Don't delete jobs from the jobs table merely because they finished,
if they are not the job we are waiting upon.   (bin/52640 part 1)

In a sub-shell environment, don't allow wait to find jobs from the
parent shell that had already exited (before the sub-shell was
created) and return status for them as if they are our children.
(bin/52640 part 2)

Don't have the "jobs" command also be an implicit "wait" command
in non-interactive shells.  (bin/52641)

Use WCONTINUED (when it exists) so we can report on stopped jobs that
"mysteriously" move back to running state without the user issuing
a "bg" command (eg: kill -CONT )   Previously they would keep
being reported as stopped until they exited.
When a job is detected as having changed status just as we're
issuing a "jobs" command (i.e.: the change occurred between the last
prompt and the jobs command being entered) don't report it twice,
once from the status change, and then again in the jobs command
output.   Once is enough (keep the jobs output, suppress the other).

Apply some sanity to the way jobs_invalid is processed - ignore it
in getjob() instead of just ignoring it most of the time there, and
instead always check it before calling getjob() in situations where
we can handle only children of the current shell.  This allows the
(totally broken) save/clear/restore of jobs_invalid in jobscmd() to
be done away with (previously an error while in the clear state would
have left jobs_invalid incorrectly cleared - shouldn't have mattered
since jobs_invalid => subshell => error causes exit, but better to be safe).

Add/improve the DEBUG more tracing.


To generate a diff of this commit:
cvs rdiff -u -r1.85.2.1 -r1.85.2.2 src/bin/sh/jobs.c

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

Modified files:

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.85.2.1 src/bin/sh/jobs.c:1.85.2.2
--- src/bin/sh/jobs.c:1.85.2.1	Sun Jul 23 14:58:14 2017
+++ src/bin/sh/jobs.c	Fri Nov 17 14:56:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.85.2.1 2017/07/23 14:58:14 snj Exp $	*/
+/*	$NetBSD: jobs.c,v 1.85.2.2 2017/11/17 14:56:52 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.85.2.1 2017/07/23 14:58:14 snj Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.85.2.2 2017/11/17 14:56:52 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -82,6 +82,14 @@ __RCSID("$NetBSD: jobs.c,v 1.85.2.1 2017
 #include "mystring.h"
 
 
+#ifndef	WCONTINUED
+#define	WCONTINUED 0		/* So we can compile on old systems */
+#endif
+#ifndef	WIFCONTINUED
+#define	WIFCONTINUED(x)	(0)		/* ditto */
+#endif
+
+
 static struct job *jobtab;		/* array of jobs */
 static int njobs;			/* size of array */
 static int jobs_invalid;		/* set in child */
@@ -98,6 +106,7 @@ STATIC struct job *getjob(const char *, 
 STATIC int dowait(int, struct job *);
 #define WBLOCK	1
 #define WNOFREE 2
+#define WSILENT 4
 STATIC int waitproc(int, struct job *, int *);
 STATIC void cmdtxt(union node *);
 STATIC void cmdlist(union node *, int);
@@ -246,6 +255,8 @@ do_fgcmd(const char *arg_ptr)
 	int i;
 	int status;
 
+	if (jobs_invalid)
+		error("No current jobs");
 	jp = getjob(arg_ptr, 0);
 	if (jp->jobctl == 0)
 		error("job not created under job control");
@@ -338,6 +349,8 @@ bgcmd(int argc, char **argv)
 	int i;
 
 	nextopt("");
+	if (jobs_invalid)
+		error("No current jobs");
 	do {
 		jp = getjob(*argptr, 0);
 		if (jp->jobctl == 0)
@@ -467,7 +480,7 @@ showjob(struct output *out, struct job *
 fmtstr(s + col, 16, "Done");
 		} else {
 #if JOBS
-			if (WIFSTOPPED(ps->status)) 
+			if (WIFSTOPPED(ps->status))
 st = WSTOPSIG(ps->status);
 			else /* WIFSIGNALED(ps->status) */
 #endif
@@ -511,22 +524,21 @@ int
 jobscmd(int argc, char **argv)
 {
 	int mode, m;
-	int sv = jobs_invalid;
 
-	jobs_invalid = 0;
 	mode = 0;
 	while ((m = nextopt("lp")))
 		if (m == 'l')
 			mode = SHOW_PID;
 		else
 			mode = SHOW_PGID;
+	if (!iflag)
+		mode |= SHOW_NO_FREE;
 	if (*argptr)
 		do
 			showjob(out1, getjob(*argptr,0), mode);
 		while (*++argptr);
 	else
 		showjobs(out1, mode);
-	jobs_invalid = sv;
 	return 0;
 }
 
@@ -550,8 +562,8 @@ showjobs(struct output *out, int mode)
 	CTRACE(DBG_JOBS, ("showjobs(%x) called\n", mode));
 
 	/* If not even one one job changed, there is nothing to do */
-	gotpid = dowait(0, NULL);
-	while (dowait(0, NULL) > 0)
+	gotpid = dowait(WSILENT, NULL);
+	while (dowait(WSILENT, NULL) > 0)
 		continue;
 #ifdef JOBS
 	/*
@@ -617,11 +629,20 @@ waitcmd(int argc, char **argv)
 
 	nextopt("");
 
+	/*
+	 * If we have forked, and not yet created 

CVS commit: src/external/bsd/tre

2017-11-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 17 14:37:37 UTC 2017

Modified Files:
src/external/bsd/tre: Makefile.inc
src/external/bsd/tre/dist: configure.ac
src/external/bsd/tre/include: config.h

Log Message:
Specify TRE_REGEX_T_FIELD in CPPFLAGS when we want ABI compatible with libc,
in a similar manner to TRE_SYSTEM_REGEX_H_PATH and TRE_USE_SYSTEM_REGEX_H.

No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/tre/Makefile.inc
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/tre/dist/configure.ac
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/tre/include/config.h

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

Modified files:

Index: src/external/bsd/tre/Makefile.inc
diff -u src/external/bsd/tre/Makefile.inc:1.2 src/external/bsd/tre/Makefile.inc:1.3
--- src/external/bsd/tre/Makefile.inc:1.2	Sat Nov  5 22:39:12 2011
+++ src/external/bsd/tre/Makefile.inc	Fri Nov 17 14:37:37 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.2 2011/11/05 22:39:12 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.3 2017/11/17 14:37:37 rin Exp $
 #	@(#)Makefile.inc	8.1 (Berkeley) 6/4/93
 
 # regex sources
@@ -8,6 +8,6 @@ CPPFLAGS+=	-I${TREDIST}/lib -I${.CURDIR}
 CPPFLAGS+=	-DHAVE_CONFIG_H=1
 CPPFLAGS+=	-DTRE_SYSTEM_REGEX_H_PATH=\"${NETBSDSRCDIR}/include/regex.h\"
 CPPFLAGS+=	-DTRE_USE_SYSTEM_REGEX_H=1
-
+CPPFLAGS+=	-DTRE_REGEX_T_FIELD=re_g
 
 WARNS=	4

Index: src/external/bsd/tre/dist/configure.ac
diff -u src/external/bsd/tre/dist/configure.ac:1.1.1.1 src/external/bsd/tre/dist/configure.ac:1.2
--- src/external/bsd/tre/dist/configure.ac:1.1.1.1	Thu Feb 25 07:33:18 2010
+++ src/external/bsd/tre/dist/configure.ac	Fri Nov 17 14:37:37 2017
@@ -254,13 +254,18 @@ if test "$tre_system_abi" = "yes"; then
 [ Define to include the system regex.h from TRE regex.h ])
   AC_DEFINE_UNQUOTED(TRE_SYSTEM_REGEX_H_PATH, "$tre_system_regex_h",
 [ Define to the absolute path to the system regex.h ])
-  AC_DEFINE_UNQUOTED(TRE_REGEX_T_FIELD, $tre_regex_t_field,
-[ Define to a field in the regex_t struct where TRE should store a
-  pointer to the internal tre_tnfa_t structure ])
+  AC_DEFINE_UNQUOTED(TRE_REGEX_T_FIELD, $tre_regex_t_field)
 else
   AC_DEFINE(TRE_REGEX_T_FIELD, value)
 fi
 
+AH_VERBATIM(TRE_REGEX_T_FIELD,
+[/* Define to a field in the regex_t struct where TRE should store a pointer to
+   the internal tre_tnfa_t structure */
+#ifndef TRE_REGEX_T_FIELD
+#undef TRE_REGEX_T_FIELD
+#endif])
+
 AC_CHECK_FUNCS([isascii isblank])
 
 AC_CHECK_HEADERS([getopt.h])

Index: src/external/bsd/tre/include/config.h
diff -u src/external/bsd/tre/include/config.h:1.1 src/external/bsd/tre/include/config.h:1.2
--- src/external/bsd/tre/include/config.h:1.1	Sat Nov  5 22:39:13 2011
+++ src/external/bsd/tre/include/config.h	Fri Nov 17 14:37:37 2017
@@ -198,7 +198,9 @@
 
 /* Define to a field in the regex_t struct where TRE should store a pointer to
the internal tre_tnfa_t structure */
-#define TRE_REGEX_T_FIELD re_g
+#ifndef TRE_REGEX_T_FIELD
+#define TRE_REGEX_T_FIELD value
+#endif
 
 /* Define to the absolute path to the system regex.h */
 /* #undef TRE_SYSTEM_REGEX_H_PATH */



CVS commit: [netbsd-8] src/sys

2017-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 17 14:34:02 UTC 2017

Modified Files:
src/sys/kern [netbsd-8]: vfs_vnode.c
src/sys/sys [netbsd-8]: vnode_impl.h

Log Message:
Pull up following revision(s) (requested by hannken in ticket #309):
sys/sys/vnode_impl.h: revision 1.17
sys/kern/vfs_vnode.c: revision 1.99, 1.100

Change the VSTATE_ASSERT_UNLOCKED code by pushing the potential lock
handling into the backend and doing an optimistic (unlocked) check
first. Always taking the vnode interlock makes this assertion otherwise
very heavy for multi-processor machines.
-
Fix non-DIAGNOSTICS build by adjusting _vstate_assert here too.


To generate a diff of this commit:
cvs rdiff -u -r1.93.2.2 -r1.93.2.3 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.13.6.2 -r1.13.6.3 src/sys/sys/vnode_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/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.93.2.2 src/sys/kern/vfs_vnode.c:1.93.2.3
--- src/sys/kern/vfs_vnode.c:1.93.2.2	Fri Aug 25 05:46:46 2017
+++ src/sys/kern/vfs_vnode.c	Fri Nov 17 14:34:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.93.2.2 2017/08/25 05:46:46 snj Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.93.2.3 2017/11/17 14:34:02 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.93.2.2 2017/08/25 05:46:46 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.93.2.3 2017/11/17 14:34:02 martin Exp $");
 
 #include 
 #include 
@@ -242,17 +242,34 @@ extern struct vfsops	dead_vfsops;
 	vstate_assert_wait_stable((vp), __func__, __LINE__)
 
 void
-_vstate_assert(vnode_t *vp, enum vnode_state state, const char *func, int line)
+_vstate_assert(vnode_t *vp, enum vnode_state state, const char *func, int line,
+bool has_lock)
 {
 	vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
 
+	if (!has_lock) {
+		/*
+		 * Prevent predictive loads from the CPU, but check the state
+		 * without loooking first.
+		 */
+		membar_enter();
+		if (state == VS_ACTIVE && vp->v_usecount > 0 &&
+		(vip->vi_state == VS_LOADED || vip->vi_state == VS_BLOCKED))
+			return;
+		if (vip->vi_state == state)
+			return;
+		mutex_enter((vp)->v_interlock);
+	}
+
 	KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
 
-	if (state == VS_ACTIVE && vp->v_usecount > 0 &&
-	(vip->vi_state == VS_LOADED || vip->vi_state == VS_BLOCKED))
-		return;
-	if (vip->vi_state == state)
+	if ((state == VS_ACTIVE && vp->v_usecount > 0 &&
+	(vip->vi_state == VS_LOADED || vip->vi_state == VS_BLOCKED)) ||
+	vip->vi_state == state) {
+		if (!has_lock)
+			mutex_exit((vp)->v_interlock);
 		return;
+	}
 	vnpanic(vp, "state is %s, usecount %d, expected %s at %s:%d",
 	vstate_name(vip->vi_state), vp->v_usecount,
 	vstate_name(state), func, line);
@@ -329,7 +346,8 @@ vstate_assert_change(vnode_t *vp, enum v
 #define VSTATE_WAIT_STABLE(vp) \
 	vstate_wait_stable((vp))
 void
-_vstate_assert(vnode_t *vp, enum vnode_state state, const char *func, int line)
+_vstate_assert(vnode_t *vp, enum vnode_state state, const char *func, int line,
+bool has_lock)
 {
 
 }

Index: src/sys/sys/vnode_impl.h
diff -u src/sys/sys/vnode_impl.h:1.13.6.2 src/sys/sys/vnode_impl.h:1.13.6.3
--- src/sys/sys/vnode_impl.h:1.13.6.2	Fri Aug 25 05:46:46 2017
+++ src/sys/sys/vnode_impl.h	Fri Nov 17 14:34:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnode_impl.h,v 1.13.6.2 2017/08/25 05:46:46 snj Exp $	*/
+/*	$NetBSD: vnode_impl.h,v 1.13.6.3 2017/11/17 14:34:02 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -88,20 +88,14 @@ typedef struct vnode_impl vnode_impl_t;
 /*
  * Vnode state assertion.
  */
-void _vstate_assert(vnode_t *, enum vnode_state, const char *, int );
+void _vstate_assert(vnode_t *, enum vnode_state, const char *, int, bool);
 
 #if defined(DIAGNOSTIC) 
 
 #define VSTATE_ASSERT(vp, state) \
-	do { \
-		_vstate_assert((vp), (state), __func__, __LINE__); \
-	} while (/*CONSTCOND*/ 0)
+	_vstate_assert((vp), (state), __func__, __LINE__, true)
 #define VSTATE_ASSERT_UNLOCKED(vp, state) \
-	do { \
-		mutex_enter((vp)->v_interlock); \
-		_vstate_assert((vp), (state), __func__, __LINE__); \
-		mutex_exit((vp)->v_interlock); \
-	} while (/*CONSTCOND*/ 0)
+	_vstate_assert((vp), (state), __func__, __LINE__, false)
 
 #else /* defined(DIAGNOSTIC) */
 



CVS commit: src/sys/dev/usb

2017-11-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 17 13:27:09 UTC 2017

Modified Files:
src/sys/dev/usb: if_urtwn.c

Log Message:
PR/52702 Malicious USB devices attaching as urtwn(4) can corrupt kernel memory

Patch from PR slighly updated by me


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/usb/if_urtwn.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/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.54 src/sys/dev/usb/if_urtwn.c:1.55
--- src/sys/dev/usb/if_urtwn.c:1.54	Tue Oct 31 00:57:14 2017
+++ src/sys/dev/usb/if_urtwn.c	Fri Nov 17 13:27:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.54 2017/10/31 00:57:14 khorben Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.55 2017/11/17 13:27:09 skrll Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.54 2017/10/31 00:57:14 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.55 2017/11/17 13:27:09 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -590,8 +590,8 @@ static int
 urtwn_open_pipes(struct urtwn_softc *sc)
 {
 	/* Bulk-out endpoints addresses (from highest to lowest prio). */
-	static uint8_t epaddr[3];
-	static uint8_t rxepaddr[3];
+	static uint8_t epaddr[R92C_MAX_EPOUT];
+	static uint8_t rxepaddr[R92C_MAX_EPIN];
 	usb_interface_descriptor_t *id;
 	usb_endpoint_descriptor_t *ed;
 	size_t i, ntx = 0, nrx = 0;
@@ -603,26 +603,32 @@ urtwn_open_pipes(struct urtwn_softc *sc)
 	id = usbd_get_interface_descriptor(sc->sc_iface);
 	for (i = 0; i < id->bNumEndpoints; i++) {
 		ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
-		if (ed != NULL &&
-		UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK &&
-		UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT) {
-			epaddr[ntx] = ed->bEndpointAddress;
+		if (ed == NULL || UE_GET_XFERTYPE(ed->bmAttributes) != UE_BULK) {
+			continue;
+		}
+		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT) {
+			if (ntx < sizeof(epaddr))
+epaddr[ntx] = ed->bEndpointAddress;
 			ntx++;
 		}
-		if (ed != NULL &&
-		UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK &&
-		UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) {
-			rxepaddr[nrx] = ed->bEndpointAddress;
+		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) {
+			if (nrx < sizeof(rxepaddr))
+rxepaddr[nrx] = ed->bEndpointAddress;
 			nrx++;
 		}
 	}
-	DPRINTFN(DBG_INIT, ("%s: %s: found %zd bulk-out pipes\n",
-	device_xname(sc->sc_dev), __func__, ntx));
+	if (nrx == 0 || nrx > R92C_MAX_EPIN) {
+		aprint_error_dev(sc->sc_dev,
+		"%zd: invalid number of Rx bulk pipes\n", nrx);
+		return EIO;
+	}
 	if (ntx == 0 || ntx > R92C_MAX_EPOUT) {
 		aprint_error_dev(sc->sc_dev,
 		"%zd: invalid number of Tx bulk pipes\n", ntx);
 		return EIO;
 	}
+	DPRINTFN(DBG_INIT, ("%s: %s: found %zd/%zd bulk-in/out pipes\n",
+	device_xname(sc->sc_dev), __func__, nrx, ntx));
 	sc->rx_npipe = nrx;
 	sc->tx_npipe = ntx;
 



CVS commit: src/sys/dev/usb

2017-11-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 17 13:08:48 UTC 2017

Modified Files:
src/sys/dev/usb: if_run.c if_runvar.h

Log Message:
Use a #define instead of a magic number


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/usb/if_run.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/if_runvar.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/usb/if_run.c
diff -u src/sys/dev/usb/if_run.c:1.23 src/sys/dev/usb/if_run.c:1.24
--- src/sys/dev/usb/if_run.c:1.23	Fri Nov 17 12:55:16 2017
+++ src/sys/dev/usb/if_run.c	Fri Nov 17 13:08:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_run.c,v 1.23 2017/11/17 12:55:16 skrll Exp $	*/
+/*	$NetBSD: if_run.c,v 1.24 2017/11/17 13:08:48 skrll Exp $	*/
 /*	$OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.23 2017/11/17 12:55:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.24 2017/11/17 13:08:48 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -599,13 +599,13 @@ run_attach(device_t parent, device_t sel
 		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) {
 			sc->rxq.pipe_no = ed->bEndpointAddress;
 			nrx++;
-		} else if (ntx < 4) {
+		} else if (ntx < RUN_MAXEPOUT) {
 			sc->txq[ntx].pipe_no = ed->bEndpointAddress;
 			ntx++;
 		}
 	}
 	/* make sure we've got them all */
-	if (nrx < 1 || ntx < 4) {
+	if (nrx < 1 || ntx < RUN_MAXEPOUT) {
 		aprint_error_dev(sc->sc_dev, "missing endpoint\n");
 		return;
 	}

Index: src/sys/dev/usb/if_runvar.h
diff -u src/sys/dev/usb/if_runvar.h:1.3 src/sys/dev/usb/if_runvar.h:1.4
--- src/sys/dev/usb/if_runvar.h:1.3	Fri Sep 16 09:25:30 2016
+++ src/sys/dev/usb/if_runvar.h	Fri Nov 17 13:08:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_runvar.h,v 1.3 2016/09/16 09:25:30 mlelstv Exp $	*/
+/*	$NetBSD: if_runvar.h,v 1.4 2017/11/17 13:08:48 skrll Exp $	*/
 /*	$OpenBSD: if_runvar.h,v 1.8 2010/02/08 18:46:47 damien Exp $	*/
 
 /*-
@@ -132,6 +132,8 @@ struct run_node {
 	uint8_t			ctl_ridx[IEEE80211_RATE_MAXSIZE];
 };
 
+#define	RUN_MAXEPOUT	4
+
 struct run_softc {
 	device_t			sc_dev;
 	struct ethercom			sc_ec;
@@ -191,7 +193,7 @@ struct run_softc {
 	callout_t			calib_to;
 
 	struct run_rx_ring		rxq;
-	struct run_tx_ring		txq[4];
+	struct run_tx_ring		txq[RUN_MAXEPOUT];
 	struct run_host_cmd_ring	cmdq;
 	uint8_tqfullmsk;
 	intsc_tx_timer;



CVS commit: src/sys/dev/usb

2017-11-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 17 12:55:17 UTC 2017

Modified Files:
src/sys/dev/usb: if_run.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/usb/if_run.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/dev/usb/if_run.c
diff -u src/sys/dev/usb/if_run.c:1.22 src/sys/dev/usb/if_run.c:1.23
--- src/sys/dev/usb/if_run.c:1.22	Thu May  4 14:07:34 2017
+++ src/sys/dev/usb/if_run.c	Fri Nov 17 12:55:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_run.c,v 1.22 2017/05/04 14:07:34 hauke Exp $	*/
+/*	$NetBSD: if_run.c,v 1.23 2017/11/17 12:55:16 skrll Exp $	*/
 /*	$OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.22 2017/05/04 14:07:34 hauke Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.23 2017/11/17 12:55:16 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -494,12 +494,12 @@ static const struct {
 	RT3572_DEF_RF
 },rt3593_def_rf[] = {
 	RT3593_DEF_RF
-},rt5390_def_rf[] = {   
-	RT5390_DEF_RF   
-},rt5392_def_rf[] = {   
-	RT5392_DEF_RF   
-},rt5592_def_rf[] = {   
-	RT5592_DEF_RF   
+},rt5390_def_rf[] = {
+	RT5390_DEF_RF
+},rt5392_def_rf[] = {
+	RT5392_DEF_RF
+},rt5592_def_rf[] = {
+	RT5592_DEF_RF
 },rt5592_2ghz_def_rf[] = {
 	RT5592_2GHZ_DEF_RF
 },rt5592_5ghz_def_rf[] = {
@@ -2485,13 +2485,13 @@ run_tx(struct run_softc *sc, struct mbuf
 	txd->flags = RT2860_TX_QSEL_EDCA;
 	txd->len = htole16(xferlen);
 
-	/* 
+	/*
 	 * Ether both are true or both are false, the header
 	 * are nicely aligned to 32-bit. So, no L2 padding.
-	 */ 
+	 */
 	if (IEEE80211_HAS_ADDR4(wh) == IEEE80211_QOS_HAS_SEQ(wh))
 		pad = 0;
-	else
+	else
 		pad = 2;
 
 	/* setup TX Wireless Information */
@@ -3630,8 +3630,8 @@ run_set_chan(struct run_softc *sc, struc
 	usbd_delay_ms(sc->sc_udev, 10);
 
 	/* Perform IQ calibration. */
-	if (sc->mac_ver >= 0x5392) 
-		run_iq_calib(sc, chan); 
+	if (sc->mac_ver >= 0x5392)
+		run_iq_calib(sc, chan);
 
 	return 0;
 }
@@ -3639,7 +3639,7 @@ run_set_chan(struct run_softc *sc, struc
 static void
 run_updateprot(struct run_softc *sc)
 {
-	struct ieee80211com *ic = >sc_ic; 
+	struct ieee80211com *ic = >sc_ic;
 	uint32_t tmp;
 
 	tmp = RT2860_RTSTH_EN | RT2860_PROT_NAV_SHORT | RT2860_TXOP_ALLOW_ALL;
@@ -3816,7 +3816,7 @@ run_rssi2dbm(struct run_softc *sc, uint8
 	return -12 - delta - rssi;
 }
 
-static void 
+static void
 run_rt5390_bbp_init(struct run_softc *sc)
 {
 	u_int i;
@@ -3839,26 +3839,26 @@ run_rt5390_bbp_init(struct run_softc *sc
 		for (i = 0; i < (int)__arraycount(rt5592_bbp_r196); i++) {
 			run_bbp_write(sc, 195, i + 0x80);
 			run_bbp_write(sc, 196, rt5592_bbp_r196[i]);
-		}   
-	} else {
+		}
+	} else {
 		for (i = 0; i < (int)__arraycount(rt5390_def_bbp); i++) {
 			run_bbp_write(sc, rt5390_def_bbp[i].reg,
 			rt5390_def_bbp[i].val);
-		} 
-	}  
+		}
+	}
 	if (sc->mac_ver == 0x5392) {
-		run_bbp_write(sc, 88, 0x90); 
-		run_bbp_write(sc, 95, 0x9a); 
-		run_bbp_write(sc, 98, 0x12); 
+		run_bbp_write(sc, 88, 0x90);
+		run_bbp_write(sc, 95, 0x9a);
+		run_bbp_write(sc, 98, 0x12);
 		run_bbp_write(sc, 106, 0x12);
 		run_bbp_write(sc, 134, 0xd0);
 		run_bbp_write(sc, 135, 0xf6);
 		run_bbp_write(sc, 148, 0x84);
-	} 
-  
+	}
+
 	run_bbp_read(sc, 152, );
 	run_bbp_write(sc, 152, bbp | 0x80);
-	
+
 	/* Fix BBP254 for RT5592C. */
 	if (sc->mac_ver == 0x5592 && sc->mac_rev >= 0x0221) {
 		run_bbp_read(sc, 254, );
@@ -4312,14 +4312,14 @@ run_rt3070_rf_setup(struct run_softc *sc
 	}
 }
 
-static void 
+static void
 run_rt3593_rf_setup(struct run_softc *sc)
 {
 	uint8_t bbp, rf;
 
 	if (sc->mac_rev >= 0x0211) {
 		/* Enable DC filter. */
-		run_bbp_write(sc, 103, 0xc0); 
+		run_bbp_write(sc, 103, 0xc0);
 	}
 	run_write(sc, RT2860_TX_SW_CFG1, 0);
 	if (sc->mac_rev < 0x0211) {
@@ -4327,22 +4327,22 @@ run_rt3593_rf_setup(struct run_softc *sc
 		sc->patch_dac ? 0x2c : 0x0f);
 	} else
 		run_write(sc, RT2860_TX_SW_CFG2, 0);
-	
+
 	run_rt3070_rf_read(sc, 50, );
 	run_rt3070_rf_write(sc, 50, rf & ~RT3593_TX_LO2);
 
 	run_rt3070_rf_read(sc, 51, );
 	rf = (rf & ~(RT3593_TX_LO1 | 0x0c)) |
-	((sc->txmixgain_2ghz & 0x07) << 2); 
+	((sc->txmixgain_2ghz & 0x07) << 2);
 	run_rt3070_rf_write(sc, 51, rf);
-	
+
 	run_rt3070_rf_read(sc, 38, );
 	run_rt3070_rf_write(sc, 38, rf & ~RT5390_RX_LO1);
-	
+
 	run_rt3070_rf_read(sc, 39, );
 	run_rt3070_rf_write(sc, 39, rf & ~RT5390_RX_LO2);
 
-	run_rt3070_rf_read(sc, 1, ); 
+	run_rt3070_rf_read(sc, 1, );
 	run_rt3070_rf_write(sc, 1, rf & ~(RT3070_RF_BLOCK | RT3070_PLL_PD));
 
 	run_rt3070_rf_read(sc, 30, );
@@ -4353,7 +4353,7 @@ run_rt3593_rf_setup(struct run_softc *sc
 	run_bbp_read(sc, 105, );
 	if (sc->nrxchains > 1)
 		run_bbp_write(sc, 105, bbp | RT5390_MLD);
-	
+
 	/* Avoid data lost and CRC error. */
 	run_bbp_read(sc, 4, );
 	

CVS commit: src/sys

2017-11-17 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Nov 17 09:26:36 UTC 2017

Modified Files:
src/sys/kern: subr_localcount.c
src/sys/sys: localcount.h

Log Message:
Implement a debugging facility (overflow/underflow detection) for localcount

We cannot get an accurate count from a localcount instance because it consists
of per-cpu counters and we have no way to sum them up atomically. So we cannot
detect counter overflow/underflow as we can do on a normal refcount.

The facility adds an atomic counter to each localcount instance to enable the
validations. The counter ups and downs in synchronization with the per-CPU
counters. The counter is used iff both DEBUG and LOCKDEBUG are enabled in the
kernel.

Discussed on tech-kern@


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/kern/subr_localcount.c
cvs rdiff -u -r1.4 -r1.5 src/sys/sys/localcount.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/subr_localcount.c
diff -u src/sys/kern/subr_localcount.c:1.6 src/sys/kern/subr_localcount.c:1.7
--- src/sys/kern/subr_localcount.c:1.6	Mon Jun 12 21:08:34 2017
+++ src/sys/kern/subr_localcount.c	Fri Nov 17 09:26:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_localcount.c,v 1.6 2017/06/12 21:08:34 riastradh Exp $	*/
+/*	$NetBSD: subr_localcount.c,v 1.7 2017/11/17 09:26:36 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_localcount.c,v 1.6 2017/06/12 21:08:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_localcount.c,v 1.7 2017/11/17 09:26:36 ozaki-r Exp $");
 
 #include 
 #include 
@@ -54,6 +54,9 @@ __KERNEL_RCSID(0, "$NetBSD: subr_localco
 #include 
 #include 
 #include 
+#if defined(DEBUG) && defined(LOCKDEBUG)
+#include 
+#endif
 
 static void localcount_xc(void *, void *);
 
@@ -209,6 +212,10 @@ localcount_acquire(struct localcount *lc
 
 	KASSERT(lc->lc_totalp == NULL);
 	localcount_adjust(lc, +1);
+#if defined(DEBUG) && defined(LOCKDEBUG)
+	if (atomic_inc_32_nv(>lc_refcnt) == 0)
+		panic("counter overflow");
+#endif
 }
 
 /*
@@ -253,5 +260,26 @@ localcount_release(struct localcount *lc
 	}
 
 	localcount_adjust(lc, -1);
+#if defined(DEBUG) && defined(LOCKDEBUG)
+	if (atomic_dec_32_nv(>lc_refcnt) == UINT_MAX)
+		panic("counter underflow");
+#endif
  out:	kpreempt_enable();
 }
+
+/*
+ * localcount_debug_refcnt(lc)
+ *
+ *	Return a total reference count of lc.  It returns a correct value
+ *	only if DEBUG and LOCKDEBUG enabled.  Otherwise always return 0.
+ */
+uint32_t
+localcount_debug_refcnt(const struct localcount *lc)
+{
+
+#if defined(DEBUG) && defined(LOCKDEBUG)
+	return lc->lc_refcnt;
+#else
+	return 0;
+#endif
+}

Index: src/sys/sys/localcount.h
diff -u src/sys/sys/localcount.h:1.4 src/sys/sys/localcount.h:1.5
--- src/sys/sys/localcount.h:1.4	Fri Jun  2 00:32:12 2017
+++ src/sys/sys/localcount.h	Fri Nov 17 09:26:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: localcount.h,v 1.4 2017/06/02 00:32:12 chs Exp $	*/
+/*	$NetBSD: localcount.h,v 1.5 2017/11/17 09:26:36 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -43,8 +43,9 @@ struct kmutex;
 struct percpu;
 
 struct localcount {
-	int64_t		*lc_totalp;
-	struct percpu	*lc_percpu; /* int64_t */
+	int64_t			*lc_totalp;
+	struct percpu		*lc_percpu; /* int64_t */
+	volatile uint32_t	lc_refcnt; /* only for debugging */
 };
 
 void	localcount_init(struct localcount *);
@@ -55,4 +56,7 @@ void	localcount_acquire(struct localcoun
 void	localcount_release(struct localcount *, struct kcondvar *,
 	struct kmutex *);
 
+uint32_t
+	localcount_debug_refcnt(const struct localcount *);
+
 #endif	/* _SYS_LOCALCOUNT_H */



CVS commit: src/sys

2017-11-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 17 08:22:03 UTC 2017

Modified Files:
src/sys/dev/usb: ehci.c motg.c ohci.c uhci.c xhci.c
src/sys/external/bsd/dwc2: dwc2.c

Log Message:
s/PR_NOWAIT/PR_WAITOK/ in HCD allocx (allocate xfer) method


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/usb/motg.c
cvs rdiff -u -r1.275 -r1.276 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.278 -r1.279 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.46 -r1.47 src/sys/external/bsd/dwc2/dwc2.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/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.256 src/sys/dev/usb/ehci.c:1.257
--- src/sys/dev/usb/ehci.c:1.256	Sat Oct 28 00:37:12 2017
+++ src/sys/dev/usb/ehci.c	Fri Nov 17 08:22:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.256 2017/10/28 00:37:12 pgoyette Exp $ */
+/*	$NetBSD: ehci.c,v 1.257 2017/11/17 08:22:02 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.256 2017/10/28 00:37:12 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.257 2017/11/17 08:22:02 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -1516,7 +1516,7 @@ ehci_allocx(struct usbd_bus *bus, unsign
 	struct ehci_softc *sc = EHCI_BUS2SC(bus);
 	struct usbd_xfer *xfer;
 
-	xfer = pool_cache_get(sc->sc_xferpool, PR_NOWAIT);
+	xfer = pool_cache_get(sc->sc_xferpool, PR_WAITOK);
 	if (xfer != NULL) {
 		memset(xfer, 0, sizeof(struct ehci_xfer));
 #ifdef DIAGNOSTIC

Index: src/sys/dev/usb/motg.c
diff -u src/sys/dev/usb/motg.c:1.18 src/sys/dev/usb/motg.c:1.19
--- src/sys/dev/usb/motg.c:1.18	Sat Oct 28 00:37:12 2017
+++ src/sys/dev/usb/motg.c	Fri Nov 17 08:22:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: motg.c,v 1.18 2017/10/28 00:37:12 pgoyette Exp $	*/
+/*	$NetBSD: motg.c,v 1.19 2017/11/17 08:22:02 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.18 2017/10/28 00:37:12 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.19 2017/11/17 08:22:02 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_motg.h"
@@ -752,7 +752,7 @@ motg_allocx(struct usbd_bus *bus, unsign
 	struct motg_softc *sc = MOTG_BUS2SC(bus);
 	struct usbd_xfer *xfer;
 
-	xfer = pool_cache_get(sc->sc_xferpool, PR_NOWAIT);
+	xfer = pool_cache_get(sc->sc_xferpool, PR_WAITOK);
 	if (xfer != NULL) {
 		memset(xfer, 0, sizeof(struct motg_xfer));
 #ifdef DIAGNOSTIC

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.275 src/sys/dev/usb/ohci.c:1.276
--- src/sys/dev/usb/ohci.c:1.275	Sat Oct 28 07:36:02 2017
+++ src/sys/dev/usb/ohci.c	Fri Nov 17 08:22:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.275 2017/10/28 07:36:02 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.276 2017/11/17 08:22:02 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.275 2017/10/28 07:36:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.276 2017/11/17 08:22:02 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1069,7 +1069,7 @@ ohci_allocx(struct usbd_bus *bus, unsign
 	ohci_softc_t *sc = OHCI_BUS2SC(bus);
 	struct usbd_xfer *xfer;
 
-	xfer = pool_cache_get(sc->sc_xferpool, PR_NOWAIT);
+	xfer = pool_cache_get(sc->sc_xferpool, PR_WAITOK);
 	if (xfer != NULL) {
 		memset(xfer, 0, sizeof(struct ohci_xfer));
 #ifdef DIAGNOSTIC

Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.278 src/sys/dev/usb/uhci.c:1.279
--- src/sys/dev/usb/uhci.c:1.278	Thu Nov 16 21:54:51 2017
+++ src/sys/dev/usb/uhci.c	Fri Nov 17 08:22:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhci.c,v 1.278 2017/11/16 21:54:51 christos Exp $	*/
+/*	$NetBSD: uhci.c,v 1.279 2017/11/17 08:22:02 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.278 2017/11/16 21:54:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.279 2017/11/17 08:22:02 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -657,7 +657,7 @@ uhci_allocx(struct usbd_bus *bus, unsign
 	struct uhci_softc *sc = UHCI_BUS2SC(bus);
 	struct usbd_xfer *xfer;
 
-	xfer = pool_cache_get(sc->sc_xferpool, PR_NOWAIT);
+	xfer = pool_cache_get(sc->sc_xferpool, PR_WAITOK);
 	if (xfer != NULL) {
 		memset(xfer, 0, sizeof(struct uhci_xfer));
 

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.76 src/sys/dev/usb/xhci.c:1.77
--- src/sys/dev/usb/xhci.c:1.76	Thu Nov  9 10:03:46 2017
+++ src/sys/dev/usb/xhci.c	Fri Nov 17 08:22:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.76 2017/11/09 10:03:46 msaitoh Exp $	*/
+/*	$NetBSD: