CVS commit: src/bin/test

2016-05-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri May 27 05:50:07 UTC 2016

Modified Files:
src/bin/test: test.1

Log Message:
usage nit


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/bin/test/test.1

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

Modified files:

Index: src/bin/test/test.1
diff -u src/bin/test/test.1:1.28 src/bin/test/test.1:1.29
--- src/bin/test/test.1:1.28	Sun Dec 16 17:57:49 2012
+++ src/bin/test/test.1	Fri May 27 05:50:07 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: test.1,v 1.28 2012/12/16 17:57:49 wiz Exp $
+.\"	$NetBSD: test.1,v 1.29 2016/05/27 05:50:07 dholland Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -275,7 +275,7 @@ True if either
 .Ar expression1
 or
 .Ar expression2
-are true.
+is true.
 .It Cm \&( Ar expression Cm \&)
 True if
 .Ar expression



CVS commit: src/sys/arch/powerpc/pic

2016-05-26 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu May 26 17:38:06 UTC 2016

Modified Files:
src/sys/arch/powerpc/pic: intr.c ipi_openpic.c pic_openpic.c

Log Message:
treat IPIs like regular interrupts at IPL_HIGH
should fix port-powerpc/44387
tested by chuq


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/pic/intr.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/powerpc/pic/ipi_openpic.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/powerpc/pic/pic_openpic.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/powerpc/pic/intr.c
diff -u src/sys/arch/powerpc/pic/intr.c:1.23 src/sys/arch/powerpc/pic/intr.c:1.24
--- src/sys/arch/powerpc/pic/intr.c:1.23	Fri Aug 31 13:12:52 2012
+++ src/sys/arch/powerpc/pic/intr.c	Thu May 26 17:38:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.23 2012/08/31 13:12:52 macallan Exp $ */
+/*	$NetBSD: intr.c,v 1.24 2016/05/26 17:38:05 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.23 2012/08/31 13:12:52 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.24 2016/05/26 17:38:05 macallan Exp $");
 
 #include "opt_interrupt.h"
 #include "opt_multiprocessor.h"
@@ -548,18 +548,8 @@ pic_handle_intr(void *cookie)
 	const int pcpl = ci->ci_cpl;
 
 	do {
-#ifdef MULTIPROCESSOR
-		/* THIS IS WRONG XXX */
-		if (picirq == ipiops.ppc_ipi_vector) {
-			ci->ci_cpl = IPL_HIGH;
-			ipi_intr(NULL);
-			ci->ci_cpl = pcpl;
-			pic->pic_ack_irq(pic, picirq);
-			continue;
-		}
-#endif
-
 		const int virq = virq_map[picirq + pic->pic_intrbase];
+
 		KASSERT(virq != 0);
 		KASSERT(picirq < pic->pic_numintrs);
 		imask_t v_imen = PIC_VIRQ_TO_MASK(virq);

Index: src/sys/arch/powerpc/pic/ipi_openpic.c
diff -u src/sys/arch/powerpc/pic/ipi_openpic.c:1.7 src/sys/arch/powerpc/pic/ipi_openpic.c:1.8
--- src/sys/arch/powerpc/pic/ipi_openpic.c:1.7	Wed Feb  1 09:54:03 2012
+++ src/sys/arch/powerpc/pic/ipi_openpic.c	Thu May 26 17:38:05 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: ipi_openpic.c,v 1.7 2012/02/01 09:54:03 matt Exp $ */
+/* $NetBSD: ipi_openpic.c,v 1.8 2016/05/26 17:38:05 macallan Exp $ */
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipi_openpic.c,v 1.7 2012/02/01 09:54:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipi_openpic.c,v 1.8 2016/05/26 17:38:05 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 #include 
@@ -103,15 +103,7 @@ openpic_send_ipi(cpuid_t target, uint32_
 static void
 openpic_establish_ipi(int type, int level, void *ih_args)
 {
-/*
- * XXX
- * for now we catch IPIs early in pic_handle_intr() so no need to do anything
- * here
- */
-#if 0
-	intr_establish(ipiops.ppc_ipi_vector, type, level, ppcipi_intr,
-	ih_args);
-#endif
+	intr_establish(ipiops.ppc_ipi_vector, type, level, ipi_intr, ih_args);
 }
 
 #endif /*MULTIPROCESSOR*/

Index: src/sys/arch/powerpc/pic/pic_openpic.c
diff -u src/sys/arch/powerpc/pic/pic_openpic.c:1.8 src/sys/arch/powerpc/pic/pic_openpic.c:1.9
--- src/sys/arch/powerpc/pic/pic_openpic.c:1.8	Wed Feb  1 09:54:03 2012
+++ src/sys/arch/powerpc/pic/pic_openpic.c	Thu May 26 17:38:05 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_openpic.c,v 1.8 2012/02/01 09:54:03 matt Exp $ */
+/*	$NetBSD: pic_openpic.c,v 1.9 2016/05/26 17:38:05 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_openpic.c,v 1.8 2012/02/01 09:54:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_openpic.c,v 1.9 2016/05/26 17:38:05 macallan Exp $");
 
 #include 
 #include 
@@ -67,7 +67,7 @@ setup_openpic(void *addr, int passthroug
 	"Supports %d CPUs and %d interrupt sources.\n",
 	x & 0xff, ((x & 0x1f00) >> 8) + 1, ((x & 0x07ff) >> 16) + 1);
 
-	pic->pic_numintrs = ((x & 0x07ff) >> 16) + 1;
+	pic->pic_numintrs = ((x & 0x07ff) >> 16) + 2; /* one more slot for IPI */
 	pic->pic_cookie = addr;
 	pic->pic_enable_irq = opic_enable_irq;
 	pic->pic_reenable_irq = opic_enable_irq;



CVS commit: src/doc

2016-05-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 26 16:55:08 UTC 2016

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
new bind


To generate a diff of this commit:
cvs rdiff -u -r1.1331 -r1.1332 src/doc/3RDPARTY
cvs rdiff -u -r1.2165 -r1.2166 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.1331 src/doc/3RDPARTY:1.1332
--- src/doc/3RDPARTY:1.1331	Tue May 24 13:11:14 2016
+++ src/doc/3RDPARTY	Thu May 26 12:55:08 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1331 2016/05/24 17:11:14 salazar Exp $
+#	$NetBSD: 3RDPARTY,v 1.1332 2016/05/26 16:55:08 christos Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -114,8 +114,8 @@ Notes:
 bc includes dc, both of which are in the NetBSD tree.
 
 Package:	bind [named and utils]
-Version:	9.10.3-P4
-Current Vers:	9.10.3-P4
+Version:	9.10.4-P1
+Current Vers:	9.10.4-P1
 Maintainer:	Paul Vixie <vi...@vix.com>
 Archive Site:	ftp://ftp.isc.org/isc/bind9/
 Home Page:	http://www.isc.org/software/bind/

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2165 src/doc/CHANGES:1.2166
--- src/doc/CHANGES:1.2165	Tue May 24 13:11:14 2016
+++ src/doc/CHANGES	Thu May 26 12:55:08 2016
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2165 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2166 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -309,3 +309,4 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 	x86: Use processor-specific features to optimize memory access time to
 		the kernel image on amd64 and i386. [maxv 20160515]
 	arm: Add support for i.MX7 SoC. [ryo 20160517]
+	bind: Import version 9.10.4-P1. [christos 20160526]



CVS commit: src/external/bsd/bind

2016-05-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 26 16:50:01 UTC 2016

Modified Files:
src/external/bsd/bind: bind2netbsd
src/external/bsd/bind/dist: CHANGES Makefile.in README acconfig.h
config.h.in configure configure.in isc-config.sh.1 srcid version
src/external/bsd/bind/dist/bin/check: named-checkconf.8
named-checkconf.c named-checkzone.8 named-checkzone.c
src/external/bsd/bind/dist/bin/confgen: ddns-confgen.8 rndc-confgen.8
src/external/bsd/bind/dist/bin/delv: delv.c
src/external/bsd/bind/dist/bin/dig: dig.1 dig.c dighost.c host.1
nslookup.1
src/external/bsd/bind/dist/bin/dnssec: dnssec-dsfromkey.8
dnssec-importkey.8 dnssec-keyfromlabel.8 dnssec-keygen.8
dnssec-revoke.8 dnssec-revoke.c dnssec-settime.8 dnssec-settime.c
dnssec-signzone.8 dnssec-signzone.c dnssec-verify.8
src/external/bsd/bind/dist/bin/named: bind9.xsl.h client.c config.c
control.c controlconf.c lwdgrbn.c lwresd.8 main.c named.8
named.conf.5 named.conf.docbook named.conf.html query.c server.c
statschannel.c xfrout.c zoneconf.c
src/external/bsd/bind/dist/bin/named/include/named: log.h query.h
server.h
src/external/bsd/bind/dist/bin/named/unix: os.c
src/external/bsd/bind/dist/bin/named/unix/include/named: os.h
src/external/bsd/bind/dist/bin/named/win32: os.c
src/external/bsd/bind/dist/bin/named/win32/include/named: os.h
src/external/bsd/bind/dist/bin/nsupdate: nsupdate.1 nsupdate.c
src/external/bsd/bind/dist/bin/python: dnssec-checkds.8
dnssec-checkds.docbook
src/external/bsd/bind/dist/bin/rndc: rndc.8 rndc.conf.5
src/external/bsd/bind/dist/bin/tests: db_test.c nsecify.c rbt_test.c
wire_test.c
src/external/bsd/bind/dist/bin/tests/atomic: t_atomic.c
src/external/bsd/bind/dist/bin/tools: arpaname.1 genrandom.8
isc-hmac-fixup.8 named-journalprint.8 nsec3hash.8
src/external/bsd/bind/dist/bin/win32/BINDInstall: BINDInstallDlg.h
src/external/bsd/bind/dist/contrib/dlz/modules/wildcard:
dlz_wildcard_dynamic.c
src/external/bsd/bind/dist/contrib/perftcpdns: perftcpdns.c
src/external/bsd/bind/dist/contrib/query-loc-0.4.0: loc.c loc.h
src/external/bsd/bind/dist/contrib/sdb/ldap: zone2ldap.c
src/external/bsd/bind/dist/doc/arm: Bv9ARM.ch04.html Bv9ARM.ch06.html
Bv9ARM.ch07.html Bv9ARM.ch08.html Bv9ARM.ch09.html Bv9ARM.html
Bv9ARM.pdf man.arpaname.html man.ddns-confgen.html man.delv.html
man.dig.html man.dnssec-checkds.html man.dnssec-coverage.html
man.dnssec-dsfromkey.html man.dnssec-importkey.html
man.dnssec-keyfromlabel.html man.dnssec-keygen.html
man.dnssec-revoke.html man.dnssec-settime.html
man.dnssec-signzone.html man.dnssec-verify.html man.genrandom.html
man.host.html man.isc-hmac-fixup.html man.named-checkconf.html
man.named-checkzone.html man.named-journalprint.html
man.named-rrchecker.html man.named.html man.nsec3hash.html
man.nsupdate.html man.rndc-confgen.html man.rndc.conf.html
man.rndc.html
src/external/bsd/bind/dist/doc/misc: options
src/external/bsd/bind/dist/lib/bind9: check.c
src/external/bsd/bind/dist/lib/dns: acache.c api cache.c client.c db.c
dst_api.c dst_openssl.h forward.c gen.c journal.c master.c
message.c name.c openssl_link.c openssldh_link.c openssldsa_link.c
opensslrsa_link.c rbt.c rbtdb.c rcode.c rdata.c resolver.c rootns.c
tkey.c update.c view.c xfrin.c zone.c
src/external/bsd/bind/dist/lib/dns/include/dns: db.h dbiterator.h
forward.h message.h name.h rbt.h view.h
src/external/bsd/bind/dist/lib/dns/rdata/any_255: tsig_250.c
src/external/bsd/bind/dist/lib/dns/rdata/ch_3: a_1.c
src/external/bsd/bind/dist/lib/dns/rdata/generic: afsdb_18.c cname_5.c
dlv_32769.c dlv_32769.h dname_39.c dnskey_48.c dnskey_48.h ds_43.c
hip_55.c ipseckey_45.c key_25.c key_25.h mb_7.c md_3.c mf_4.c
mg_8.c minfo_14.c mr_9.c mx_15.c ns_2.c nsec3_50.c nsec_47.c
nxt_30.c opt_41.c ptr_12.c rp_17.c rrsig_46.c rt_21.c sig_24.c
soa_6.c spf_99.c tkey_249.c txt_16.c
src/external/bsd/bind/dist/lib/dns/rdata/in_1: a6_38.c kx_36.c
nsap-ptr_23.c px_26.c srv_33.c
src/external/bsd/bind/dist/lib/dns/tests: Makefile.in dnstest.h
rdata_test.c
src/external/bsd/bind/dist/lib/irs: resconf.c
src/external/bsd/bind/dist/lib/isc: base32.c base64.c buffer.c
commandline.c hash.c hex.c httpd.c md5.c mem.c netaddr.c result.c
sockaddr.c stats.c string.c task.c

CVS commit: src/sys

2016-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May 26 11:09:55 UTC 2016

Modified Files:
src/sys/kern: vfs_vnode.c
src/sys/sys: vnode.h

Log Message:
Use vnode state to replace VI_MARKER, VI_CHANGING, VI_XLOCK and VI_CLEAN.

Presented on tech-kern@


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.261 -r1.262 src/sys/sys/vnode.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.51 src/sys/kern/vfs_vnode.c:1.52
--- src/sys/kern/vfs_vnode.c:1.51	Thu May 26 11:08:44 2016
+++ src/sys/kern/vfs_vnode.c	Thu May 26 11:09:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.51 2016/05/26 11:08:44 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.52 2016/05/26 11:09:55 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -92,6 +92,49 @@
  *	or cleaned via vclean(9), which calls VOP_RECLAIM(9) to disassociate
  *	underlying file system from the vnode, and finally destroyed.
  *
+ * Vnode state
+ *
+ *	Vnode is always in one of six states:
+ *	- MARKER	This is a marker vnode to help list traversal.  It
+ *			will never change its state.
+ *	- LOADING	Vnode is associating underlying file system and not
+ *			yet ready to use.
+ *	- ACTIVE	Vnode has associated underlying file system and is
+ *			ready to use.
+ *	- BLOCKED	Vnode is active but cannot get new references.
+ *	- RECLAIMING	Vnode is disassociating from the underlying file
+ *			system.
+ *	- RECLAIMED	Vnode has disassociated from underlying file system
+ *			and is dead.
+ *
+ *	Valid state changes are:
+ *	LOADING -> ACTIVE
+ *			Vnode has been initialised in vcache_get() or
+ *			vcache_new() and is ready to use.
+ *	ACTIVE -> RECLAIMING
+ *			Vnode starts disassociation from underlying file
+ *			system in vclean().
+ *	RECLAIMING -> RECLAIMED
+ *			Vnode finished disassociation from underlying file
+ *			system in vclean().
+ *	ACTIVE -> BLOCKED
+ *			Either vcache_rekey*() is changing the vnode key or
+ *			vrelel() is about to call VOP_INACTIVE().
+ *	BLOCKED -> ACTIVE
+ *			The block condition is over.
+ *	LOADING -> RECLAIMED
+ *			Either vcache_get() or vcache_new() failed to
+ *			associate the underlying file system or vcache_rekey*()
+ *			drops a vnode used as placeholder.
+ *
+ *	Of these states LOADING, BLOCKED and RECLAIMING are intermediate
+ *	and it is possible to wait for state change.
+ *
+ *	State is protected with v_interlock with one exception:
+ *	to change from LOADING both v_interlock and vcache.lock must be held
+ *	so it is possible to check "state == LOADING" without holding
+ *	v_interlock.  See vcache_get() for details.
+ *
  * Reference counting
  *
  *	Vnode is considered active, if reference count (vnode_t::v_usecount)
@@ -109,14 +152,10 @@
  *	Changing the usecount from a non-zero value to a non-zero value can
  *	safely be done using atomic operations, without the interlock held.
  *
- *	Note: if VI_CLEAN is set, vnode_t::v_interlock will be released while
- *	mntvnode_lock is still held.
- *
- *	See PR 41374.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.51 2016/05/26 11:08:44 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.52 2016/05/26 11:09:55 hannken Exp $");
 
 #define _VFS_VNODE_PRIVATE
 
@@ -146,7 +185,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
 
 /* Flags to vrelel. */
 #define	VRELEL_ASYNC_RELE	0x0001	/* Always defer to vrele thread. */
-#define	VRELEL_CHANGING_SET	0x0002	/* VI_CHANGING set by caller. */
 
 enum vcache_state {
 	VN_MARKER,	/* Stable, used as marker. Will not change. */
@@ -162,10 +200,9 @@ struct vcache_key {
 	size_t vk_key_len;
 };
 struct vcache_node {
-	struct vnode vn_data;
+	struct vnode vn_vnode;
 	enum vcache_state vn_state;
 	SLIST_ENTRY(vcache_node) vn_hash;
-	struct vnode *vn_vnode;
 	struct vcache_key vn_key;
 };
 
@@ -211,7 +248,6 @@ static void		vdrain_thread(void *);
 static void		vrele_thread(void *);
 static void		vnpanic(vnode_t *, const char *, ...)
 __printflike(2, 3);
-static void		vwait(vnode_t *, int);
 
 /* Routines having to do with the management of the vnode table. */
 extern struct mount	*dead_rootmount;
@@ -253,7 +289,7 @@ vstate_name(enum vcache_state state)
 #define VSTATE_ASSERT(vp, state) \
 	vstate_assert((vp), (state), __func__, __LINE__)
 
-static void __unused
+static void
 vstate_assert(vnode_t *vp, enum vcache_state state, const char *func, int line)
 {
 	struct vcache_node *node = VP_TO_VN(vp);
@@ -266,7 +302,7 @@ vstate_assert(vnode_t *vp, enum vcache_s
 	vstate_name(node->vn_state), vstate_name(state), func, line);
 }
 
-static enum vcache_state __unused
+static enum vcache_state
 vstate_assert_get(vnode_t *vp, const char *func, int line)
 {
 	struct vcache_node *node = VP_TO_VN(vp);
@@ -279,7 +315,7 @@ vstate_assert_get(vnode_t *vp, const cha
 	return 

CVS commit: src/sys/kern

2016-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May 26 11:08:44 UTC 2016

Modified Files:
src/sys/kern: vfs_vnode.c

Log Message:
Add vnode state and supporting operations and diagnostics.

Presented on tech-kern@


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/kern/vfs_vnode.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/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.50 src/sys/kern/vfs_vnode.c:1.51
--- src/sys/kern/vfs_vnode.c:1.50	Thu May 26 11:07:33 2016
+++ src/sys/kern/vfs_vnode.c	Thu May 26 11:08:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.50 2016/05/26 11:07:33 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.51 2016/05/26 11:08:44 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -116,7 +116,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.50 2016/05/26 11:07:33 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.51 2016/05/26 11:08:44 hannken Exp $");
 
 #define _VFS_VNODE_PRIVATE
 
@@ -148,6 +148,14 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
 #define	VRELEL_ASYNC_RELE	0x0001	/* Always defer to vrele thread. */
 #define	VRELEL_CHANGING_SET	0x0002	/* VI_CHANGING set by caller. */
 
+enum vcache_state {
+	VN_MARKER,	/* Stable, used as marker. Will not change. */
+	VN_LOADING,	/* Intermediate, initialising the fs node. */
+	VN_ACTIVE,	/* Stable, valid fs node attached. */
+	VN_BLOCKED,	/* Intermediate, active, no new references allowed. */
+	VN_RECLAIMING,	/* Intermediate, detaching the fs node. */
+	VN_RECLAIMED	/* Stable, no fs node attached. */
+};
 struct vcache_key {
 	struct mount *vk_mount;
 	const void *vk_key;
@@ -155,6 +163,7 @@ struct vcache_key {
 };
 struct vcache_node {
 	struct vnode vn_data;
+	enum vcache_state vn_state;
 	SLIST_ENTRY(vcache_node) vn_hash;
 	struct vnode *vn_vnode;
 	struct vcache_key vn_key;
@@ -185,6 +194,7 @@ static int		vrele_gen		__cacheline_align
 SLIST_HEAD(hashhead, vcache_node);
 static struct {
 	kmutex_t	lock;
+	kcondvar_t	cv;
 	u_long		hashmask;
 	struct hashhead	*hashtab;
 	pool_cache_t	pool;
@@ -208,6 +218,145 @@ extern struct mount	*dead_rootmount;
 extern int		(**dead_vnodeop_p)(void *);
 extern struct vfsops	dead_vfsops;
 
+/* Vnode state operations and diagnostics. */
+
+static const char *
+vstate_name(enum vcache_state state)
+{
+
+	switch (state) {
+	case VN_MARKER:
+		return "MARKER";
+	case VN_LOADING:
+		return "LOADING";
+	case VN_ACTIVE:
+		return "ACTIVE";
+	case VN_BLOCKED:
+		return "BLOCKED";
+	case VN_RECLAIMING:
+		return "RECLAIMING";
+	case VN_RECLAIMED:
+		return "RECLAIMED";
+	default:
+		return "ILLEGAL";
+	}
+}
+
+#if defined(DIAGNOSTIC)
+
+#define VSTATE_GET(vp) \
+	vstate_assert_get((vp), __func__, __LINE__)
+#define VSTATE_CHANGE(vp, from, to) \
+	vstate_assert_change((vp), (from), (to), __func__, __LINE__)
+#define VSTATE_WAIT_STABLE(vp) \
+	vstate_assert_wait_stable((vp), __func__, __LINE__)
+#define VSTATE_ASSERT(vp, state) \
+	vstate_assert((vp), (state), __func__, __LINE__)
+
+static void __unused
+vstate_assert(vnode_t *vp, enum vcache_state state, const char *func, int line)
+{
+	struct vcache_node *node = VP_TO_VN(vp);
+
+	KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
+
+	if (__predict_true(node->vn_state == state))
+		return;
+	vnpanic(vp, "state is %s, expected %s at %s:%d",
+	vstate_name(node->vn_state), vstate_name(state), func, line);
+}
+
+static enum vcache_state __unused
+vstate_assert_get(vnode_t *vp, const char *func, int line)
+{
+	struct vcache_node *node = VP_TO_VN(vp);
+
+	KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
+	if (node->vn_state == VN_MARKER)
+		vnpanic(vp, "state is %s at %s:%d",
+		vstate_name(node->vn_state), func, line);
+
+	return node->vn_state;
+}
+
+static void __unused
+vstate_assert_wait_stable(vnode_t *vp, const char *func, int line)
+{
+	struct vcache_node *node = VP_TO_VN(vp);
+
+	KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
+	if (node->vn_state == VN_MARKER)
+		vnpanic(vp, "state is %s at %s:%d",
+		vstate_name(node->vn_state), func, line);
+
+	while (node->vn_state != VN_ACTIVE && node->vn_state != VN_RECLAIMED)
+		cv_wait(>v_cv, vp->v_interlock);
+
+	if (node->vn_state == VN_MARKER)
+		vnpanic(vp, "state is %s at %s:%d",
+		vstate_name(node->vn_state), func, line);
+}
+
+static void __unused
+vstate_assert_change(vnode_t *vp, enum vcache_state from, enum vcache_state to,
+const char *func, int line)
+{
+	struct vcache_node *node = VP_TO_VN(vp);
+
+	KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line);
+	if (from == VN_LOADING)
+		KASSERTMSG(mutex_owned(), "at %s:%d", func, line);
+
+	if (from == VN_MARKER)
+		vnpanic(vp, "from is %s at %s:%d",
+		vstate_name(from), func, line);
+	if (to == VN_MARKER)
+		vnpanic(vp, "to is %s at %s:%d",
+		vstate_name(to), func, 

CVS commit: src/sys

2016-05-26 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May 26 11:07:33 UTC 2016

Modified Files:
src/sys/kern: vfs_subr.c vfs_vnode.c
src/sys/sys: vnode.h

Log Message:
Merge the vnode and its corresponding vcache_node into one
vcache_node structure.

Print the vcache_node part in vprint() and vfs_vnode_print().

Presented on tech-kern@


To generate a diff of this commit:
cvs rdiff -u -r1.448 -r1.449 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.260 -r1.261 src/sys/sys/vnode.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_subr.c
diff -u src/sys/kern/vfs_subr.c:1.448 src/sys/kern/vfs_subr.c:1.449
--- src/sys/kern/vfs_subr.c:1.448	Mon Aug 24 22:50:32 2015
+++ src/sys/kern/vfs_subr.c	Thu May 26 11:07:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_subr.c,v 1.448 2015/08/24 22:50:32 pooka Exp $	*/
+/*	$NetBSD: vfs_subr.c,v 1.449 2016/05/26 11:07:33 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.448 2015/08/24 22:50:32 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.449 2016/05/26 11:07:33 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -76,6 +76,8 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v
 #include "opt_compat_43.h"
 #endif
 
+#define _VFS_VNODE_PRIVATE	/* for vcache_print(). */
+
 #include 
 #include 
 #include 
@@ -1085,6 +1087,7 @@ vprint(const char *label, struct vnode *
 	ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type,
 	vp->v_usecount, vp->v_writecount, vp->v_holdcnt,
 	vp->v_freelisthd, vp->v_mount, vp->v_data, >v_lock);
+	vcache_print(vp, "\t", printf);
 	if (vp->v_data != NULL) {
 		printf("\t");
 		VOP_PRINT(vp);
@@ -1481,6 +1484,8 @@ vfs_vnode_print(struct vnode *vp, int fu
 
 	(*pr)("v_lock %p\n", >v_lock);
 
+	vcache_print(vp, "", pr);
+
 	if (full) {
 		struct buf *bp;
 

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.49 src/sys/kern/vfs_vnode.c:1.50
--- src/sys/kern/vfs_vnode.c:1.49	Thu May 19 14:50:18 2016
+++ src/sys/kern/vfs_vnode.c	Thu May 26 11:07:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.49 2016/05/19 14:50:18 hannken Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.50 2016/05/26 11:07:33 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -116,7 +116,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.49 2016/05/19 14:50:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.50 2016/05/26 11:07:33 hannken Exp $");
 
 #define _VFS_VNODE_PRIVATE
 
@@ -154,14 +154,16 @@ struct vcache_key {
 	size_t vk_key_len;
 };
 struct vcache_node {
+	struct vnode vn_data;
 	SLIST_ENTRY(vcache_node) vn_hash;
 	struct vnode *vn_vnode;
 	struct vcache_key vn_key;
 };
 
-u_int			numvnodes		__cacheline_aligned;
+#define VN_TO_VP(node)	((vnode_t *)(node))
+#define VP_TO_VN(vp)	((struct vcache_node *)(vp))
 
-static pool_cache_t	vnode_cache		__read_mostly;
+u_int			numvnodes		__cacheline_aligned;
 
 /*
  * There are two free lists: one is for vnodes which have no buffer/page
@@ -189,14 +191,14 @@ static struct {
 }			vcache			__cacheline_aligned;
 
 static int		cleanvnode(void);
+static struct vcache_node *vcache_alloc(void);
+static void		vcache_free(struct vcache_node *);
 static void		vcache_init(void);
 static void		vcache_reinit(void);
 static void		vclean(vnode_t *);
 static void		vrelel(vnode_t *, int);
 static void		vdrain_thread(void *);
 static void		vrele_thread(void *);
-static vnode_t *	vnalloc(struct mount *);
-static void		vnfree(vnode_t *);
 static void		vnpanic(vnode_t *, const char *, ...)
 __printflike(2, 3);
 static void		vwait(vnode_t *, int);
@@ -211,10 +213,6 @@ vfs_vnode_sysinit(void)
 {
 	int error __diagused;
 
-	vnode_cache = pool_cache_init(sizeof(vnode_t), 0, 0, 0, "vnodepl",
-	NULL, IPL_NONE, NULL, NULL, NULL);
-	KASSERT(vnode_cache != NULL);
-
 	dead_rootmount = vfs_mountalloc(_vfsops, NULL);
 	KASSERT(dead_rootmount != NULL);
 	dead_rootmount->mnt_iflag = IMNT_MPSAFE;
@@ -243,8 +241,18 @@ vfs_vnode_sysinit(void)
 vnode_t *
 vnalloc_marker(struct mount *mp)
 {
+	struct vcache_node *node;
+	vnode_t *vp;
+
+	node = pool_cache_get(vcache.pool, PR_WAITOK);
+	memset(node, 0, sizeof(*node));
+	vp = VN_TO_VP(node);
+	uvm_obj_init(>v_uobj, _vnodeops, true, 0);
+	vp->v_mount = mp;
+	vp->v_type = VBAD;
+	vp->v_iflag = VI_MARKER;
 
-	return vnalloc(mp);
+	return vp;
 }
 
 /*
@@ -253,9 +261,12 @@ vnalloc_marker(struct mount *mp)
 void
 vnfree_marker(vnode_t *vp)
 {
+	struct vcache_node *node;
 
+	node = VP_TO_VN(vp);
 	KASSERT(ISSET(vp->v_iflag, VI_MARKER));
-	vnfree(vp);
+	uvm_obj_destroy(>v_uobj, true);
+	pool_cache_put(vcache.pool, node);
 }
 
 /*
@@ -269,69 +280,6 @@ vnis_marker(vnode_t *vp)
 }
 
 /*
- * Allocate a new, uninitialized vnode.  If 'mp' is 

CVS commit: src/sys/arch/sparc64/conf

2016-05-26 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Thu May 26 10:38:07 UTC 2016

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add more CardBus devices.


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.188 src/sys/arch/sparc64/conf/GENERIC:1.189
--- src/sys/arch/sparc64/conf/GENERIC:1.188	Thu May 26 04:26:05 2016
+++ src/sys/arch/sparc64/conf/GENERIC	Thu May 26 10:38:07 2016
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.188 2016/05/26 04:26:05 nakayama Exp $
+# $NetBSD: GENERIC,v 1.189 2016/05/26 10:38:07 nakayama Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.188 $"
+#ident		"GENERIC-$Revision: 1.189 $"
 
 maxusers	64
 
@@ -773,7 +773,9 @@ pseudo-device	stf			# 6to4 IPv6 over IPv
 
 # CardBus network interfaces
 #ath*	at cardbus? function ?	# Atheros 5210/5211/5212 802.11
+#athn*	at cardbus? function ?	# Atheros AR9k (802.11a/g/n) UT
 #atw*	at cardbus? function ?	# ADMtek ADM8211 (802.11) UT
+#bwi*	at cardbus? function ?	# Broadcom BCM43xx wireless
 #ex*	at cardbus? function ?	# 3Com 3C575TX
 #fxp*	at cardbus? function ?	# Intel i8255x UT
 #ral*	at cardbus? function ?	# Ralink Technology RT25x0 802.11a/b/g UT
@@ -787,6 +789,9 @@ pseudo-device	stf			# 6to4 IPv6 over IPv
 #ohci*	at cardbus? function ?	# Open Host Controller
 #uhci*	at cardbus? function ?	# Universal Host Controller (Intel) UT
 
+# CardBus IEEE1394 controllers
+#fwohci* at cardbus? function ?	# IEEE1394 Open Host Controller UT
+
 ## PCMCIA cards; UT marks untested.
 
 # PCMCIA serial interfaces



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

2016-05-26 Thread Patrick Welche
Module Name:src
Committed By:   prlw1
Date:   Thu May 26 09:09:47 UTC 2016

Modified Files:
src/external/bsd/dhcpcd/dist: dhcp.c dhcp.h

Log Message:
Handle truncated DHCP messages, provided only the BOOTP vendor area
is truncated.  [3fd740f3ed]
OK from roy@


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/dhcp.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/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.41 src/external/bsd/dhcpcd/dist/dhcp.c:1.42
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.41	Mon May  9 20:28:08 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Thu May 26 09:09:47 2016
@@ -1,5 +1,5 @@
 #include 
- __RCSID("$NetBSD: dhcp.c,v 1.41 2016/05/09 20:28:08 martin Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.42 2016/05/26 09:09:47 prlw1 Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1087,9 +1087,12 @@ make_message(struct bootp **bootpm, cons
 	*p++ = DHO_END;
 	len = (size_t)(p - (uint8_t *)bootp);
 
-	/* Pad out to the BOOTP minimum message length.
-	 * Some DHCP servers incorrectly require this. */
-	while (len < BOOTP_MESSAGE_LENTH_MIN) {
+	/* Pad out to the BOOTP message length.
+	 * Even if we send a DHCP packet with a variable length vendor area,
+	 * some servers / relay agents don't like packets smaller than
+	 * a BOOTP message which is fine because that's stipulated
+	 * in RFC1542 section 2.1. */
+	while (len < sizeof(*bootp)) {
 		*p++ = DHO_PAD;
 		len++;
 	}
@@ -3139,14 +3142,26 @@ dhcp_handlepacket(void *arg)
 			"%s: server %s is not destination",
 			ifp->name, inet_ntoa(from));
 		}
-
+		/*
+		 * DHCP has a variable option area rather than a fixed
+		 * vendor area.
+		 * Because DHCP uses the BOOTP protocol it should
+		 * still send BOOTP sized packets to be RFC compliant.
+		 * However some servers send a truncated vendor area.
+		 * dhcpcd can work fine without the vendor area being sent.
+		 */
 		bytes = get_udp_data(, buf);
-		if (bytes < sizeof(struct bootp)) {
+		if (bytes < offsetof(struct bootp, vend)) {
 			logger(ifp->ctx, LOG_ERR,
 			"%s: truncated packet (%zu) from %s",
 			ifp->name, bytes, inet_ntoa(from));
 			continue;
 		}
+		/* But to make our IS_DHCP macro easy, ensure the vendor
+		 * area has at least 4 octets. */
+		while (bytes < offsetof(struct bootp, vend) + 4)
+			bootp[bytes++] = '\0';
+
 		dhcp_handledhcp(ifp, (struct bootp *)bootp, bytes, );
 		if (state->raw_fd == -1)
 			break;

Index: src/external/bsd/dhcpcd/dist/dhcp.h
diff -u src/external/bsd/dhcpcd/dist/dhcp.h:1.15 src/external/bsd/dhcpcd/dist/dhcp.h:1.16
--- src/external/bsd/dhcpcd/dist/dhcp.h:1.15	Mon May  9 10:15:59 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.h	Thu May 26 09:09:47 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp.h,v 1.15 2016/05/09 10:15:59 roy Exp $ */
+/* $NetBSD: dhcp.h,v 1.16 2016/05/26 09:09:47 prlw1 Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -133,9 +133,6 @@ enum FQDN {
 	FQDN_BOTH   = 0x31
 };
 
-/* Some crappy DHCP servers require the BOOTP minimum length */
-#define BOOTP_MESSAGE_LENTH_MIN 300
-
 /* Don't import common.h as that defines __unused which causes problems
  * on some Linux systems which define it as part of a structure */
 #if __GNUC__ > 2 || defined(__INTEL_COMPILER)



CVS commit: xsrc/external/mit/glu/dist/include/GL

2016-05-26 Thread Manuel Bouyer
Module Name:xsrc
Committed By:   bouyer
Date:   Thu May 26 07:59:26 UTC 2016

Modified Files:
xsrc/external/mit/glu/dist/include/GL: glu.h

Log Message:
Changing GLU_TESS_MAX_COORD to DBL_MAX causes internal constants derived
from GLU_TESS_MAX_COORD used in libtess to be +/-inf, leading to
logic errors. See
http://mail-index.netbsd.org/tech-x11/2016/05/25/msg001733.html
and
http://willkamp.com/opencpn/flyspray/index.php?do=details_id=2076
for details.
Change back GLU_TESS_MAX_COORD to its upstream value if it fits
in a double, or 1e15 if DBL_MAX_10_EXP is not large enough
(fix proposed by christos@)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/glu/dist/include/GL/glu.h

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

Modified files:

Index: xsrc/external/mit/glu/dist/include/GL/glu.h
diff -u xsrc/external/mit/glu/dist/include/GL/glu.h:1.2 xsrc/external/mit/glu/dist/include/GL/glu.h:1.3
--- xsrc/external/mit/glu/dist/include/GL/glu.h:1.2	Fri Dec 19 19:07:46 2014
+++ xsrc/external/mit/glu/dist/include/GL/glu.h	Thu May 26 07:59:26 2016
@@ -281,12 +281,12 @@ typedef GLUquadric GLUquadricObj;
 typedef GLUtesselator GLUtesselatorObj;
 typedef GLUtesselator GLUtriangulatorObj;
 
-/* GLdouble is double in gl.h so we are DBL_MAX */
-#include 	/* Not a good place to do that, but... */
-#ifndef DBL_MAX
-#define GLU_TESS_MAX_COORD 1.0e150
+/* GLdouble is double in gl.h */
+#include 	/* Not a good place to do that, but... */
+#if DBL_MAX_10_EXP < 40
+#define GLU_TESS_MAX_COORD 1e15
 #else
-#define GLU_TESS_MAX_COORD DBL_MAX
+#define GLU_TESS_MAX_COORD 1e150
 #endif
 
 /* Internal convenience typedefs */



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

2016-05-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu May 26 07:45:51 UTC 2016

Modified Files:
src/sys/arch/arm/allwinner: awin_gpio.c

Log Message:
Remove a KASSERT() which is A20-specific, as well as the local variable
used here.
Fix "error: unused variable 'grp'" for non-DIAGNOSTIC kernels,
reported by Rin Okuyama.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/allwinner/awin_gpio.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/allwinner/awin_gpio.c
diff -u src/sys/arch/arm/allwinner/awin_gpio.c:1.21 src/sys/arch/arm/allwinner/awin_gpio.c:1.22
--- src/sys/arch/arm/allwinner/awin_gpio.c:1.21	Wed May 11 18:33:40 2016
+++ src/sys/arch/arm/allwinner/awin_gpio.c	Thu May 26 07:45:51 2016
@@ -35,7 +35,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.21 2016/05/11 18:33:40 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_gpio.c,v 1.22 2016/05/26 07:45:51 bouyer Exp $");
 
 #include 
 #include 
@@ -934,11 +934,9 @@ awin_gpio_pin_ctl(void *cookie, int pin,
 static void
 awin_gpio_pin_irqen(void *cookie, int pin, bool enable)
 {
-	struct awin_gpio_pin_group * const grp = cookie;
 	uint32_t enabled;
 	struct awin_gpio_softc *sc = _gpio_sc;
 
-	KASSERT(grp->grp_index == 7);
 	mutex_enter(>sc_intr_lock);
 	enabled = bus_space_read_4(sc->sc_bst, sc->sc_eint_bsh,
 	INT_OFFSET(AWIN_PIO_INT_CTL_REG));



CVS commit: src/sys/arch

2016-05-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu May 26 07:24:55 UTC 2016

Modified Files:
src/sys/arch/amd64/amd64: locore.S
src/sys/arch/i386/i386: locore.S

Log Message:
There is an issue in the way the fillkpt macro sets up pages on both
amd64 and i386.

The fillkpt loop is equivalent to the following:

do {
/* fill in the slot */
/* increment %ebx to the next slot */
/* increment %eax to the next pa */
} while (%ecx > 0)

The issue here is that if %ecx = 0 (i.e., the chunk we are trying to
map is zero-sized), there is still one entry created in the page table.
The kernel expects the va<->pa translation to be linear in low memory.
If there is a zero-sized chunk, the dead entry creates a +4096 offset in
the virtual space, with two consecutive entries that point to the same
physical address. In other words, the mappings are not linear anymore,
which causes the kernel to die.

Before my recent changes, there were only two big chunks that were
mapped, and neither of these could be zero-sized. Now, with multiple,
fine-grained chunks, it is possible that the [SYMS]+[PRELOADED_MODULES]
chunk could be zero-sized.

[PRELOADED_MODULES] is almost never here, and [SYMS] is always here on
default kernels. Except for floppies, where the bootloader does not load
[SYMS].

Should fix PR 51148.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/i386/i386/locore.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/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.93 src/sys/arch/amd64/amd64/locore.S:1.94
--- src/sys/arch/amd64/amd64/locore.S:1.93	Sun May 22 10:11:55 2016
+++ src/sys/arch/amd64/amd64/locore.S	Thu May 26 07:24:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.93 2016/05/22 10:11:55 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.94 2016/05/26 07:24:55 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -220,16 +220,21 @@
  * Each entry is 8 (PDE_SIZE) bytes long: we must set the 4 upper bytes to 0.
  */
 #define fillkpt	\
+	cmpl	$0,%ecx			;	/* zero-sized? */	\
+	je 	2f			; \
 1:	movl	$0,(PDE_SIZE-4)(%ebx)	;	/* upper 32 bits: 0 */	\
 	movl	%eax,(%ebx)		;	/* store phys addr */	\
 	addl	$PDE_SIZE,%ebx		;	/* next PTE/PDE */	\
 	addl	$PAGE_SIZE,%eax		;	/* next phys page */	\
-	loop	1b			;
+	loop	1b			; \
+2:	;
 
 /*
  * fillkpt_nox - Same as fillkpt, but sets the NX/XD bit.
  */
 #define fillkpt_nox \
+	cmpl	$0,%ecx			;	/* zero-sized? */	\
+	je 	2f			; \
 	pushl	%ebp			; \
 	movl	RELOC(nox_flag),%ebp	; \
 1:	movl	%ebp,(PDE_SIZE-4)(%ebx)	;	/* upper 32 bits: NX */ \
@@ -237,7 +242,8 @@
 	addl	$PDE_SIZE,%ebx		;	/* next PTE/PDE */	\
 	addl	$PAGE_SIZE,%eax		;	/* next phys page */	\
 	loop	1b			; \
-	popl	%ebp			;
+	popl	%ebp			; \
+2:	;
 
 /*
  * killkpt - Destroy a kernel page table (long mode)

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.124 src/sys/arch/i386/i386/locore.S:1.125
--- src/sys/arch/i386/i386/locore.S:1.124	Sun May 15 07:17:53 2016
+++ src/sys/arch/i386/i386/locore.S	Thu May 26 07:24:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.124 2016/05/15 07:17:53 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.125 2016/05/26 07:24:55 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.124 2016/05/15 07:17:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.125 2016/05/26 07:24:55 maxv Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_copy_symtab.h"
@@ -192,16 +192,21 @@ __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1
  * instruction just clears the page table entry.
  */
 #define fillkpt	\
+	cmpl	$0,%ecx			;	/* zero-sized? */	\
+	je 	2f			; \
 1:	movl	$0,(PDE_SIZE-4)(%ebx)	;	/* upper 32 bits: 0 */	\
 	movl	%eax,(%ebx)		;	/* store phys addr */	\
 	addl	$PDE_SIZE,%ebx		;	/* next PTE/PDE */	\
 	addl	$PAGE_SIZE,%eax		;	/* next phys page */	\
-	loop	1b			;
+	loop	1b			; \
+2:	;
 
 /*
  * fillkpt_nox - Same as fillkpt, but sets the NX/XD bit.
  */
 #define fillkpt_nox \
+	cmpl	$0,%ecx			;	/* zero-sized? */	\
+	je 	2f			; \
 	pushl	%ebp			; \
 	movl	RELOC(nox_flag),%ebp	; \
 1:	movl	%ebp,(PDE_SIZE-4)(%ebx)	;	/* upper 32 bits: NX */ \
@@ -209,7 +214,8 @@ __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1
 	addl	$PDE_SIZE,%ebx		;	/* next PTE/PDE */	\
 	addl	$PAGE_SIZE,%eax		;	/* next phys page */	\
 	loop	1b			; \
-	popl	%ebp			;
+	popl	%ebp			; \
+2:	;
 
 /*
  * killkpt - Destroy a kernel page table