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

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 28 06:45:53 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
turn on INCLUDE_CONFIG_FILE.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/evbarm/conf/GENERIC64

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



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

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec 28 06:45:53 UTC 2018

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
turn on INCLUDE_CONFIG_FILE.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/evbarm/conf/GENERIC64

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/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.70 src/sys/arch/evbarm/conf/GENERIC64:1.71
--- src/sys/arch/evbarm/conf/GENERIC64:1.70	Fri Dec 21 14:52:12 2018
+++ src/sys/arch/evbarm/conf/GENERIC64	Fri Dec 28 06:45:53 2018
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.70 2018/12/21 14:52:12 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.71 2018/12/28 06:45:53 mrg Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -77,6 +77,7 @@ options 	DEBUG
 #options 	LOCKDEBUG
 #options 	PMAP_DEBUG	# Enable pmap_debug_level code
 options 	VERBOSE_INIT_ARM # verbose bootstrapping messages
+options 	INCLUDE_CONFIG_FILE
 # EARLYCONS is required for early init messages from VERBOSE_INIT_ARM.
 #options 	EARLYCONS=bcm2837
 #options 	EARLYCONS=rk3328, CONSADDR=0xff13



CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 06:20:32 UTC 2018

Modified Files:
src/sys/dev/mii: makphy.c makphyreg.h
Removed Files:
src/sys/dev/mii: e1000phyreg.h

Log Message:
- Backout some changes done in rev. 1.44. OK'd by jdolecek@:
  - Remove e1000phyreg.h and use makphyreg.h again.
  - Remove Energy detect stuff. Leave it by default.
  - Remove MDI crossover configuraton. Leave it by default. I think it's OK to
add new API to change the mode.
  - PHY_RESET() is used to commit some changes, so I think it's not good to
always clear BMCR_AUTOEN before reset in makphy_reset().
  - It's not required to read MII_100T2SR twice because this register has no
any bit which is latched.
- Use mii_phy_reset() instead of extracted code.
- Don't set PSCR_CRS_ON_TX on newer. Those chips have no this bit.
- Add some "XXX FIXME" comment. Non GMII mode uses different page except
  very old chip. Some bits are at the same location but others are not.
- Remove obsolete comment.
- s/MII_MAKPHY_/MAKPHY_/

XXX rev. 1.44 changed the setting of mii_media_active when the interface is
set to other than auto. I suspect the intention of the change is to reflect
the link up/down status. But, it didn't work because non auto setting makes
PSSR_LINK bit alwasy set "without modifing some registers".
This commit won't fix the change and it'll be fixed in the next commit.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r0 src/sys/dev/mii/e1000phyreg.h
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/mii/makphy.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/mii/makphyreg.h

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



CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 06:20:32 UTC 2018

Modified Files:
src/sys/dev/mii: makphy.c makphyreg.h
Removed Files:
src/sys/dev/mii: e1000phyreg.h

Log Message:
- Backout some changes done in rev. 1.44. OK'd by jdolecek@:
  - Remove e1000phyreg.h and use makphyreg.h again.
  - Remove Energy detect stuff. Leave it by default.
  - Remove MDI crossover configuraton. Leave it by default. I think it's OK to
add new API to change the mode.
  - PHY_RESET() is used to commit some changes, so I think it's not good to
always clear BMCR_AUTOEN before reset in makphy_reset().
  - It's not required to read MII_100T2SR twice because this register has no
any bit which is latched.
- Use mii_phy_reset() instead of extracted code.
- Don't set PSCR_CRS_ON_TX on newer. Those chips have no this bit.
- Add some "XXX FIXME" comment. Non GMII mode uses different page except
  very old chip. Some bits are at the same location but others are not.
- Remove obsolete comment.
- s/MII_MAKPHY_/MAKPHY_/

XXX rev. 1.44 changed the setting of mii_media_active when the interface is
set to other than auto. I suspect the intention of the change is to reflect
the link up/down status. But, it didn't work because non auto setting makes
PSSR_LINK bit alwasy set "without modifing some registers".
This commit won't fix the change and it'll be fixed in the next commit.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r0 src/sys/dev/mii/e1000phyreg.h
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/mii/makphy.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/mii/makphyreg.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/mii/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.45 src/sys/dev/mii/makphy.c:1.46
--- src/sys/dev/mii/makphy.c:1.45	Mon Jun 18 09:12:17 2018
+++ src/sys/dev/mii/makphy.c	Fri Dec 28 06:20:32 2018
@@ -1,5 +1,4 @@
-/*	$NetBSD: makphy.c,v 1.45 2018/06/18 09:12:17 msaitoh Exp $	*/
-/*	$OpenBSD: eephy.c,v 1.56 2015/03/14 03:38:48 jsg Exp $	*/
+/*	$NetBSD: makphy.c,v 1.46 2018/12/28 06:20:32 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -55,48 +54,8 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * Principal Author: Parag Patel
- * Copyright (c) 2001
- * 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 unmodified, this list of conditions, and the following
- *disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * Additonal Copyright (c) 2001 by Traakan Software under same licence.
- * Secondary Author: Matthew Jacob
- */
-/*
- * Driver for the Marvell 88E1000 ``Alaska'' 10/100/1000 PHY.
- */
-
-/*
- * Support added for the Marvell 88E1011 (Alaska) 1000/100/10baseTX and
- * 1000baseSX PHY.
- * Nathan Binkert 
- */
-
 #include 
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.45 2018/06/18 09:12:17 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.46 2018/12/28 06:20:32 msaitoh Exp $");
 
 #include 
 #include 
@@ -112,7 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1
 #include 
 #include 
 
-#include 
+#include 
 
 static int	makphymatch(device_t, cfdata_t, void *);
 static void	makphyattach(device_t, device_t, void *);
@@ -124,11 +83,11 @@ static int	makphy_service(struct mii_sof
 static void	makphy_status(struct mii_softc *);
 static void	makphy_reset(struct mii_softc *);
 
-static const struct mii_phy_funcs eephy_funcs = {
+static const struct mii_phy_funcs makphy_funcs = {
 	makphy_service, makphy_status, makphy_reset,
 };
 
-static const struct mii_phydesc eephys[] = {
+static const struct mii_phydesc makphys[] = {
 	{ MII_OUI_MARVELL,		MII_MODEL_MARVELL_E1000_0,
 	  MII_STR_MARVELL_E1000_0 },
 
@@ -174,7 +133,6 @@ 

CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 05:56:07 UTC 2018

Modified Files:
src/sys/dev/mii: mii_physubr.c

Log Message:
 802.2 22.2.4.1.1 "Reset" says The reset shall be completed in 0.5s, so change
the value from 100ms to 500ms.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/mii/mii_physubr.c

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



CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 05:56:07 UTC 2018

Modified Files:
src/sys/dev/mii: mii_physubr.c

Log Message:
 802.2 22.2.4.1.1 "Reset" says The reset shall be completed in 0.5s, so change
the value from 100ms to 500ms.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/mii/mii_physubr.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/mii/mii_physubr.c
diff -u src/sys/dev/mii/mii_physubr.c:1.81 src/sys/dev/mii/mii_physubr.c:1.82
--- src/sys/dev/mii/mii_physubr.c:1.81	Mon Mar  5 08:56:49 2018
+++ src/sys/dev/mii/mii_physubr.c	Fri Dec 28 05:56:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mii_physubr.c,v 1.81 2018/03/05 08:56:49 msaitoh Exp $	*/
+/*	$NetBSD: mii_physubr.c,v 1.82 2018/12/28 05:56:07 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.81 2018/03/05 08:56:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.82 2018/12/28 05:56:07 msaitoh Exp $");
 
 #include 
 #include 
@@ -387,8 +387,8 @@ mii_phy_reset(struct mii_softc *sc)
 		reg = BMCR_RESET | BMCR_ISO;
 	PHY_WRITE(sc, MII_BMCR, reg);
 
-	/* Wait another 100ms for it to complete. */
-	for (i = 0; i < 100; i++) {
+	/* Wait another 500ms for it to complete. */
+	for (i = 0; i < 500; i++) {
 		reg = PHY_READ(sc, MII_BMCR);
 		if ((reg & BMCR_RESET) == 0)
 			break;



CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 05:04:55 UTC 2018

Modified Files:
src/sys/dev/mii: miidevs.h miidevs_data.h

Log Message:
 Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.122 -r1.123 src/sys/dev/mii/miidevs_data.h

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



CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 05:04:55 UTC 2018

Modified Files:
src/sys/dev/mii: miidevs.h miidevs_data.h

Log Message:
 Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.122 -r1.123 src/sys/dev/mii/miidevs_data.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/mii/miidevs.h
diff -u src/sys/dev/mii/miidevs.h:1.134 src/sys/dev/mii/miidevs.h:1.135
--- src/sys/dev/mii/miidevs.h:1.134	Mon Jul  2 09:27:18 2018
+++ src/sys/dev/mii/miidevs.h	Fri Dec 28 05:04:55 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.134 2018/07/02 09:27:18 msaitoh Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.135 2018/12/28 05:04:55 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.131 2018/07/02 09:26:48 msaitoh Exp
+ *	NetBSD: miidevs,v 1.132 2018/12/28 05:04:35 msaitoh Exp
  */
 
 /*-
@@ -423,7 +423,7 @@
 #define	MII_MODEL_xxMARVELL_E1116R_29	0x0029
 #define	MII_STR_xxMARVELL_E1116R_29	"Marvell 88E1116R Gigabit PHY"
 #define	MII_MODEL_xxMARVELL_E1543	0x002a
-#define	MII_STR_xxMARVELL_E1543	"Marvell 88E1543 Alaska Quad Port Gb PHY"
+#define	MII_STR_xxMARVELL_E1543	"Marvell 88E154[358] Alaska Quad Port Gb PHY"
 #define	MII_MODEL_MARVELL_E1000_0	0x
 #define	MII_STR_MARVELL_E1000_0	"Marvell 88E1000 Gigabit PHY"
 #define	MII_MODEL_MARVELL_E1011	0x0002

Index: src/sys/dev/mii/miidevs_data.h
diff -u src/sys/dev/mii/miidevs_data.h:1.122 src/sys/dev/mii/miidevs_data.h:1.123
--- src/sys/dev/mii/miidevs_data.h:1.122	Mon Jul  2 09:27:18 2018
+++ src/sys/dev/mii/miidevs_data.h	Fri Dec 28 05:04:55 2018
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs_data.h,v 1.122 2018/07/02 09:27:18 msaitoh Exp $	*/
+/*	$NetBSD: miidevs_data.h,v 1.123 2018/12/28 05:04:55 msaitoh Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.131 2018/07/02 09:26:48 msaitoh Exp
+ *	NetBSD: miidevs,v 1.132 2018/12/28 05:04:35 msaitoh Exp
  */
 
 /*-



CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 05:04:35 UTC 2018

Modified Files:
src/sys/dev/mii: miidevs

Log Message:
88E154[358] have the same ID.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/mii/miidevs

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/mii/miidevs
diff -u src/sys/dev/mii/miidevs:1.131 src/sys/dev/mii/miidevs:1.132
--- src/sys/dev/mii/miidevs:1.131	Mon Jul  2 09:26:48 2018
+++ src/sys/dev/mii/miidevs	Fri Dec 28 05:04:35 2018
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.131 2018/07/02 09:26:48 msaitoh Exp $
+$NetBSD: miidevs,v 1.132 2018/12/28 05:04:35 msaitoh Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -282,7 +282,7 @@ model xxMARVELL E1149R		0x0025 Marvell 8
 model xxMARVELL E3016		0x0026 Marvell 88E3016 10/100 Fast Ethernet PHY
 model xxMARVELL PHYG65G		0x0027 Marvell PHYG65G Gigabit PHY
 model xxMARVELL E1116R_29	0x0029 Marvell 88E1116R Gigabit PHY
-model xxMARVELL E1543		0x002a Marvell 88E1543 Alaska Quad Port Gb PHY
+model xxMARVELL E1543		0x002a Marvell 88E154[358] Alaska Quad Port Gb PHY
 model MARVELL E1000_0		0x Marvell 88E1000 Gigabit PHY
 model MARVELL E1011		0x0002 Marvell 88E1011 Gigabit PHY
 model MARVELL E1000_3		0x0003 Marvell 88E1000 Gigabit PHY



CVS commit: src/sys/dev/mii

2018-12-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Dec 28 05:04:35 UTC 2018

Modified Files:
src/sys/dev/mii: miidevs

Log Message:
88E154[358] have the same ID.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/mii/miidevs

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



CVS commit: src/sys/kern

2018-12-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Dec 28 00:15:57 UTC 2018

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

Log Message:
Fix job reference counting:
- threadpool_job_hold() no longer returns failure on overflow; it
  asserts that overflow doesn't happen.
- threadpool_job_rele() must be called with the job lock held.
- Always grab a reference count on the job in threadpool_schedule_job()
  if we're going to do any work.
- Drop that reference count directly in threadpool_job_done(); it's not
  safe to dereference the job structure after the job function has called it.
- In the overseer thread, when handing off the job to work thread, hold an
  extra reference briefly, as there's a window where we hold neither the
  pool lock or the job lock, and without this extra reference, the job could
  be snatched away.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_threadpool.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/kern_threadpool.c
diff -u src/sys/kern/kern_threadpool.c:1.12 src/sys/kern/kern_threadpool.c:1.13
--- src/sys/kern/kern_threadpool.c:1.12	Thu Dec 27 04:45:29 2018
+++ src/sys/kern/kern_threadpool.c	Fri Dec 28 00:15:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_threadpool.c,v 1.12 2018/12/27 04:45:29 thorpej Exp $	*/
+/*	$NetBSD: kern_threadpool.c,v 1.13 2018/12/28 00:15:57 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2014, 2018 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.12 2018/12/27 04:45:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_threadpool.c,v 1.13 2018/12/28 00:15:57 thorpej Exp $");
 
 #include 
 #include 
@@ -134,7 +134,7 @@ static void	threadpool_percpu_destroy(st
 
 static threadpool_job_fn_t threadpool_job_dead;
 
-static int	threadpool_job_hold(struct threadpool_job *);
+static void	threadpool_job_hold(struct threadpool_job *);
 static void	threadpool_job_rele(struct threadpool_job *);
 
 static void	threadpool_overseer_thread(void *) __dead;
@@ -650,19 +650,16 @@ threadpool_job_destroy(struct threadpool
 	(void)strlcpy(job->job_name, "deadjob", sizeof(job->job_name));
 }
 
-static int
+static void
 threadpool_job_hold(struct threadpool_job *job)
 {
 	unsigned int refcnt;
 
 	do {
 		refcnt = job->job_refcnt;
-		if (refcnt == UINT_MAX)
-			return EBUSY;
+		KASSERT(refcnt != UINT_MAX);
 	} while (atomic_cas_uint(>job_refcnt, refcnt, (refcnt + 1))
 	!= refcnt);
-
-	return 0;
 }
 
 static void
@@ -670,16 +667,16 @@ threadpool_job_rele(struct threadpool_jo
 {
 	unsigned int refcnt;
 
+	KASSERT(mutex_owned(job->job_lock));
+
 	do {
 		refcnt = job->job_refcnt;
 		KASSERT(0 < refcnt);
 		if (refcnt == 1) {
-			mutex_enter(job->job_lock);
 			refcnt = atomic_dec_uint_nv(>job_refcnt);
 			KASSERT(refcnt != UINT_MAX);
 			if (refcnt == 0)
 cv_broadcast(>job_cv);
-			mutex_exit(job->job_lock);
 			return;
 		}
 	} while (atomic_cas_uint(>job_refcnt, refcnt, (refcnt - 1))
@@ -703,6 +700,16 @@ threadpool_job_done(struct threadpool_jo
 	curlwp->l_name = job->job_thread->tpt_lwp_savedname;
 	lwp_unlock(curlwp);
 
+	/*
+	 * Inline the work of threadpool_job_rele(); the job is already
+	 * locked, the most likely scenario (XXXJRT only scenario?) is
+	 * that we're dropping the last reference (the one taken in
+	 * threadpool_schedule_job()), and we always do the cv_broadcast()
+	 * anyway.
+	 */
+	KASSERT(0 < job->job_refcnt);
+	unsigned int refcnt __diagused = atomic_dec_uint_nv(>job_refcnt);
+	KASSERT(refcnt != UINT_MAX);
 	cv_broadcast(>job_cv);
 	job->job_thread = NULL;
 }
@@ -725,6 +732,8 @@ threadpool_schedule_job(struct threadpoo
 		return;
 	}
 
+	threadpool_job_hold(job);
+
 	/* Otherwise, try to assign a thread to the job.  */
 	mutex_spin_enter(>tp_lock);
 	if (__predict_false(TAILQ_EMPTY(>tp_idle_threads))) {
@@ -740,7 +749,6 @@ threadpool_schedule_job(struct threadpoo
 		__func__, job->job_name, job->job_thread));
 		TAILQ_REMOVE(>tp_idle_threads, job->job_thread,
 		tpt_entry);
-		threadpool_job_hold(job);
 		job->job_thread->tpt_job = job;
 	}
 
@@ -786,6 +794,7 @@ threadpool_cancel_job_async(struct threa
 		mutex_spin_enter(>tp_lock);
 		TAILQ_REMOVE(>tp_jobs, job, job_entry);
 		mutex_spin_exit(>tp_lock);
+		threadpool_job_rele(job);
 		return true;
 	} else {
 		/* Too late -- already running.  */
@@ -889,15 +898,13 @@ threadpool_overseer_thread(void *arg)
 		}
 
 		/* There are idle threads, so try giving one a job.  */
-		bool rele_job = true;
 		struct threadpool_job *const job = TAILQ_FIRST(>tp_jobs);
 		TAILQ_REMOVE(>tp_jobs, job, job_entry);
-		error = threadpool_job_hold(job);
-		if (error) {
-			TAILQ_INSERT_HEAD(>tp_jobs, job, job_entry);
-			(void)kpause("pooljob", false, hz, >tp_lock);
-			continue;
-		}
+		/*
+		 * Take an extra reference on the job temporarily so that
+		 * it won't disappear on us while we 

CVS commit: src/sys/kern

2018-12-27 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Dec 28 00:15:57 UTC 2018

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

Log Message:
Fix job reference counting:
- threadpool_job_hold() no longer returns failure on overflow; it
  asserts that overflow doesn't happen.
- threadpool_job_rele() must be called with the job lock held.
- Always grab a reference count on the job in threadpool_schedule_job()
  if we're going to do any work.
- Drop that reference count directly in threadpool_job_done(); it's not
  safe to dereference the job structure after the job function has called it.
- In the overseer thread, when handing off the job to work thread, hold an
  extra reference briefly, as there's a window where we hold neither the
  pool lock or the job lock, and without this extra reference, the job could
  be snatched away.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_threadpool.c

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



Re: CVS commit: src/sbin/cgdconfig

2018-12-27 Thread Alexander Nasonov
Christoph Badura wrote:
> Using /etc/cgd/ROOT. has the advantage that the cgd will configure
> if the root device changes name, thus upholding POLA.
> 
> E.g. moving disks from a controller that attaches sd(4)s to one that
> attaches ld(4)s.  I believe you can see that when dd'ing an image from
> SDcard to MMC on Pinebook.
> 
> It seems to me that similar behaviour for NAME=label would be more useful
> too. dk(4) attachments move around in practice.

Yeah, I discovered it the hard way ;-)

Perhaps the simplest change would be to pass an unresolved (original)
name when composing a paramsfile. E.g.

/etc/cgd/NAME=mylabel
/etc/cgd/ROOT.e

-- 
Alex


Removal of M_COPY_PKTHDR etc.

2018-12-27 Thread Christoph Badura
Doesn't that trigger a kernel version bump?
And shouldn't changes like this be documented in src/CHANGES?

--chris

On Thu, Dec 27, 2018 at 02:03:55PM +, Maxime Villard wrote:
> Module Name:  src
> Committed By: maxv
> Date: Thu Dec 27 14:03:55 UTC 2018
> 
> Modified Files:
>   src/sys/dev/pci: hifn7751.c
>   src/sys/kern: uipc_mbuf.c
>   src/sys/netmpls: mpls_ttl.c
>   src/sys/sys: mbuf.h
> 
> Log Message:
> Remove M_COPY_PKTHDR, M_MOVE_PKTHDR, M_ALIGN and MH_ALIGN.


Re: CVS commit: src/sbin/cgdconfig

2018-12-27 Thread Christoph Badura
On Thu, Dec 27, 2018 at 09:53:44PM +, Alexander Nasonov wrote:
> Alexander Nasonov wrote:
> > XXX Default paramsfile for NAME=label is /etc/cgd/dkNN (resolved wedge
> > partition) and /etc/cgd/ROOT. for ROOT.. This isn't yet
> > documented. IMO, it should be the other way around: /etc/cgd/label
> > for the former and /et/cgd/[root-device] for the latter.
> 
> This is true for NetBSD-8 which doesn't support ROOT. prefix.
> Both prefixes are resolved to real device names before composing
> a default paramsfile in NetBSD-current.

Using /etc/cgd/ROOT. has the advantage that the cgd will configure
if the root device changes name, thus upholding POLA.

E.g. moving disks from a controller that attaches sd(4)s to one that
attaches ld(4)s.  I believe you can see that when dd'ing an image from
SDcard to MMC on Pinebook.

It seems to me that similar behaviour for NAME=label would be more useful
too. dk(4) attachments move around in practice.

--chris


CVS commit: src/sys/arch/aarch64/aarch64

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 21:48:01 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
redo the previous using ptoa().  also apply to another instance of
the same integer overflow, and now savecore actually does something
in the OD1K.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.25 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.26
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.25	Thu Dec 27 21:29:41 2018
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Thu Dec 27 21:48:01 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.25 2018/12/27 21:29:41 mrg Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.26 2018/12/27 21:48:01 mrg Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.25 2018/12/27 21:29:41 mrg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.26 2018/12/27 21:48:01 mrg Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -573,7 +573,7 @@ cpu_dump(void)
 	 */
 	for (i = 0; i < bootconfig.dramblocks; i++) {
 		memsegp[i].start = bootconfig.dram[i].address;
-		memsegp[i].size = bootconfig.dram[i].pages * PAGE_SIZE;
+		memsegp[i].size = ptoa(bootconfig.dram[i].pages);
 	}
 
 	return (dump(dumpdev, dumplo, bf, dbtob(1)));
@@ -629,7 +629,7 @@ dumpsys(void)
 	for (block = 0; block < bootconfig.dramblocks && error == 0; ++block) {
 		addr = bootconfig.dram[block].address;
 		end = bootconfig.dram[block].address +
-		  ((uint64_t)bootconfig.dram[block].pages * PAGE_SIZE);
+		  ptoa(bootconfig.dram[block].pages);
 		for (; addr < end; addr += PAGE_SIZE) {
 			if (((len * PAGE_SIZE) % (1024*1024)) == 0)
 				printf("%lu ", (len * PAGE_SIZE) / (1024 * 1024));



CVS commit: src/sys/arch/aarch64/aarch64

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 21:48:01 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
redo the previous using ptoa().  also apply to another instance of
the same integer overflow, and now savecore actually does something
in the OD1K.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

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



CVS commit: src/lib/libutil

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:35:48 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.c

Log Message:
No need to quadruple a buffer because strunvis(3) doesn't expand.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libutil/getfsspecname.c

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

Modified files:

Index: src/lib/libutil/getfsspecname.c
diff -u src/lib/libutil/getfsspecname.c:1.7 src/lib/libutil/getfsspecname.c:1.8
--- src/lib/libutil/getfsspecname.c:1.7	Sat Oct  6 23:48:00 2018
+++ src/lib/libutil/getfsspecname.c	Thu Dec 27 21:35:48 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $	*/
+/*	$NetBSD: getfsspecname.c,v 1.8 2018/12/27 21:35:48 alnsn Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: getfsspecname.c,v 1.7 2018/10/06 23:48:00 christos Exp $");
+__RCSID("$NetBSD: getfsspecname.c,v 1.8 2018/12/27 21:35:48 alnsn Exp $");
 
 #include 
 #include 
@@ -108,7 +108,7 @@ getfsspecname(char *buf, size_t bufsiz, 
 #ifdef COMPAT_DKWEDGE
 search:
 #endif
-	vname = malloc(strlen(name) * 4 + 1);
+	vname = malloc(strlen(name) + 1);
 	if (vname == NULL) {
 		savee = errno;
 		strlcpy(buf, "malloc failed", bufsiz);



CVS commit: src/lib/libutil

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:35:48 UTC 2018

Modified Files:
src/lib/libutil: getfsspecname.c

Log Message:
No need to quadruple a buffer because strunvis(3) doesn't expand.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libutil/getfsspecname.c

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



CVS commit: src/sys/arch/aarch64/aarch64

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 21:29:41 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
avoid integer overflow when calculating the end address of a ram
block.  fixes a bug when a PhysMem range covers more than 4GB.

with this, my OD1K (8GB ram) is almost able to properly coredump.
savecore finds the core, but can't read it properly.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.24 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.25
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.24	Thu Dec 27 09:55:27 2018
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Thu Dec 27 21:29:41 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.24 2018/12/27 09:55:27 mrg Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.25 2018/12/27 21:29:41 mrg Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.24 2018/12/27 09:55:27 mrg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.25 2018/12/27 21:29:41 mrg Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -586,7 +586,7 @@ dumpsys(void)
 	daddr_t blkno;
 	int psize;
 	int error;
-	paddr_t addr = 0;
+	paddr_t addr = 0, end;
 	int block;
 	psize_t len;
 	vaddr_t dumpspace;
@@ -624,15 +624,15 @@ dumpsys(void)
 
 	blkno = dumplo + cpu_dumpsize();
 	error = 0;
-	len = 0;
+	len = dumpsize;
 
 	for (block = 0; block < bootconfig.dramblocks && error == 0; ++block) {
 		addr = bootconfig.dram[block].address;
-		for (; addr < (bootconfig.dram[block].address
-			   + (bootconfig.dram[block].pages * PAGE_SIZE));
-		 addr += PAGE_SIZE) {
-			if ((len % (1024*1024)) == 0)
-				printf("%lu ", len / (1024*1024));
+		end = bootconfig.dram[block].address +
+		  ((uint64_t)bootconfig.dram[block].pages * PAGE_SIZE);
+		for (; addr < end; addr += PAGE_SIZE) {
+			if (((len * PAGE_SIZE) % (1024*1024)) == 0)
+				printf("%lu ", (len * PAGE_SIZE) / (1024 * 1024));
 
 			if (!mm_md_direct_mapped_phys(addr, )) {
 error = ENOMEM;
@@ -644,7 +644,7 @@ dumpsys(void)
 			if (error)
 goto err;
 			blkno += btodb(PAGE_SIZE);
-			len += PAGE_SIZE;
+			len--;
 		}
 	}
 err:



CVS commit: src/sys/arch/aarch64/aarch64

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 21:29:41 UTC 2018

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
avoid integer overflow when calculating the end address of a ram
block.  fixes a bug when a PhysMem range covers more than 4GB.

with this, my OD1K (8GB ram) is almost able to properly coredump.
savecore finds the core, but can't read it properly.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

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



CVS commit: src/sbin/savecore

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 21:25:46 UTC 2018

Modified Files:
src/sbin/savecore: savecore.c

Log Message:
avoid infinite loop in kmem_check().  fixes bug introduced in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sbin/savecore/savecore.c

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

Modified files:

Index: src/sbin/savecore/savecore.c
diff -u src/sbin/savecore/savecore.c:1.87 src/sbin/savecore/savecore.c:1.88
--- src/sbin/savecore/savecore.c:1.87	Tue Nov  6 04:07:22 2018
+++ src/sbin/savecore/savecore.c	Thu Dec 27 21:25:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: savecore.c,v 1.87 2018/11/06 04:07:22 mrg Exp $	*/
+/*	$NetBSD: savecore.c,v 1.88 2018/12/27 21:25:46 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1986, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 19
 #if 0
 static char sccsid[] = "@(#)savecore.c	8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: savecore.c,v 1.87 2018/11/06 04:07:22 mrg Exp $");
+__RCSID("$NetBSD: savecore.c,v 1.88 2018/12/27 21:25:46 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -446,7 +446,7 @@ check_kmem(void)
 	}
 nomsguf:
 	KREAD_LOGWARN(kd_dump, dump_nl[X_PANICSTR].n_value, panicstr,
-	goto nomsguf);
+	return);
 	if (panicstr) {
 		cp = panic_mesg;
 		panicloc = panicstr;



CVS commit: src/sbin/savecore

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 21:25:46 UTC 2018

Modified Files:
src/sbin/savecore: savecore.c

Log Message:
avoid infinite loop in kmem_check().  fixes bug introduced in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sbin/savecore/savecore.c

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



CVS commit: src/doc

2018-12-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Dec 27 21:20:40 UTC 2018

Modified Files:
src/doc: TODO.sanitizers

Log Message:
Update TODO.sanitizers

Mark as done:
- upstream local patches, mostly to compiler-rt
  <- all patches submitted to review
- investigate and address the libcxx failing tests on NetBSD
  <- done by Michal Gorny
- FILE and DIR sanitization (needed by at least: ESan, MSan)
  <- done by Michal Gorny
- add missing interceptors (mostly MSan-centric)
  <- all local patches merged upstream, it's too opaque to keep it around
- port or finish the port of: XRay, profile
  <- done
- detect and fix more bugs in basesystem
  <- too opaque to keep it here
- uvm_map.c E2BIG workaround or limit raise (1MB -> 10MB?), needed by libFuzzer
  <- done


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/doc/TODO.sanitizers

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

Modified files:

Index: src/doc/TODO.sanitizers
diff -u src/doc/TODO.sanitizers:1.9 src/doc/TODO.sanitizers:1.10
--- src/doc/TODO.sanitizers:1.9	Fri Dec  7 17:57:22 2018
+++ src/doc/TODO.sanitizers	Thu Dec 27 21:20:40 2018
@@ -4,32 +4,25 @@ Short term:
  - compiler-rt import and integration with base
  - merge TSan, MSan and libFuzzer ATF tests
  - prepare MKSANITIZER readme
- - upstream local patches, mostly to compiler-rt
 
 Long term:
  - handle fts_open(3) compar callback in sanitizers (use TLS to store
the real callback and call a wrapper that will [un]poison appropriate
memory regions)
- - investigate and address the libcxx failing tests on NetBSD
- - FILE and DIR sanitization (needed by at least: ESan, MSan)
- - add missing interceptors (mostly MSan-centric)
  - improve the framework for ioctl(2) database and handle special cases when a
part of a struct can be uninitialized and passed to the kernel (MSan)
  - port or finish the port of:
* ESan,
* LSan,
-   * XRay,
* shadowcallstack,
* cfi,
* scudo,
-   * profile,
* DFSan.
  - finish the research of a new syscall for StopTheWorld() operation
ptrace(2) style for self-introspection and debugging (LSan)
  - port HWASan -- aarch64 specific, needs hardware or emulator
  - make MKSANITIZER usable with any supported by a compiler combination of
sanitizers
- - detect and fix more bugs in basesystem
  - pkgsrc integration with sanitizers and MKSANITIZER (PKGSANITIZER?)
  - port what possible to !amd64
  - fixes with the signal code
@@ -39,7 +32,6 @@ Long term:
  - lld port to NetBSD (GNU ld(1) is too slow for serious LLVM development)
  - merge of the libFuzzer integration with the basesystem
  - oom-killer ATF tests and fixes
- - uvm_map.c E2BIG workaround or limit raise (1MB -> 10MB?), needed by libFuzzer
  - utime(3) allow changing actime regardless of noatime mount property
  - NetBSD tar: handle character escaping in file names (\\ \), needed in
check-lld (lld::reproduce-backslash.s)



CVS commit: src/doc

2018-12-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu Dec 27 21:20:40 UTC 2018

Modified Files:
src/doc: TODO.sanitizers

Log Message:
Update TODO.sanitizers

Mark as done:
- upstream local patches, mostly to compiler-rt
  <- all patches submitted to review
- investigate and address the libcxx failing tests on NetBSD
  <- done by Michal Gorny
- FILE and DIR sanitization (needed by at least: ESan, MSan)
  <- done by Michal Gorny
- add missing interceptors (mostly MSan-centric)
  <- all local patches merged upstream, it's too opaque to keep it around
- port or finish the port of: XRay, profile
  <- done
- detect and fix more bugs in basesystem
  <- too opaque to keep it here
- uvm_map.c E2BIG workaround or limit raise (1MB -> 10MB?), needed by libFuzzer
  <- done


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/doc/TODO.sanitizers

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



CVS commit: src/sbin/cgdconfig

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:17:08 UTC 2018

Modified Files:
src/sbin/cgdconfig: cgdconfig.8

Log Message:
Document that cgd.conf supports NAME=label and ROOT. targets.

XXX Default paramsfile for NAME=label is /etc/cgd/dkNN (resolved wedge
partition) and /etc/cgd/ROOT. for ROOT.. This isn't yet
documented. IMO, it should be the other way around: /etc/cgd/label
for the former and /et/cgd/[root-device] for the latter.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sbin/cgdconfig/cgdconfig.8

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

Modified files:

Index: src/sbin/cgdconfig/cgdconfig.8
diff -u src/sbin/cgdconfig/cgdconfig.8:1.41 src/sbin/cgdconfig/cgdconfig.8:1.42
--- src/sbin/cgdconfig/cgdconfig.8:1.41	Sat Sep  1 11:46:52 2018
+++ src/sbin/cgdconfig/cgdconfig.8	Thu Dec 27 21:17:08 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: cgdconfig.8,v 1.41 2018/09/01 11:46:52 prlw1 Exp $
+.\" $NetBSD: cgdconfig.8,v 1.42 2018/12/27 21:17:08 alnsn Exp $
 .\"
 .\" Copyright (c) 2002, The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 9, 2018
+.Dd Dec 27, 2018
 .Dt CGDCONFIG 8
 .Os
 .Sh NAME
@@ -248,6 +248,24 @@ A
 at the end of a line indicates that the next line is a continuation of
 the current line.
 .Pp
+If the second field is of the form
+.Dq NAME=
+then all the
+.Xr dk 4
+wedge partitions are searched for one that has a wedge name equal to
+.Ar 
+and the device corresponding to it is selected.
+.Pp
+If the second field starts with the prefix
+.Dq ROOT.
+the prefix is replaced with
+.Dq /dev/[root_device] ,
+where
+.Bq root_device
+is the value of the
+.Dq kern.root_device
+sysctl.
+.Pp
 See
 .Sx EXAMPLES
 for an example of
@@ -418,7 +436,7 @@ An example
 
 	# cgd		target		[paramsfile]
 	cgd0		/dev/wd0e
-	cgd1		/dev/sd0h	/usr/local/etc/cgd/sd0h
+	cgd1		NAME=mycgd	/usr/local/etc/cgd/mycgd
 .Ed
 .Pp
 Note the first entry will store the parameters file as
@@ -439,6 +457,8 @@ program's execution.
 .Sh SEE ALSO
 .Xr cgd 4 ,
 .Xr disklabel 8 ,
+.Xr dk 4 ,
+.Xr fstab 5 ,
 .Xr gpt 8
 .Pp
 .Dq PKCS #5 v2.0: Password-Based Cryptography Standard ,



CVS commit: src/sbin/cgdconfig

2018-12-27 Thread Alexander Nasonov
Module Name:src
Committed By:   alnsn
Date:   Thu Dec 27 21:17:08 UTC 2018

Modified Files:
src/sbin/cgdconfig: cgdconfig.8

Log Message:
Document that cgd.conf supports NAME=label and ROOT. targets.

XXX Default paramsfile for NAME=label is /etc/cgd/dkNN (resolved wedge
partition) and /etc/cgd/ROOT. for ROOT.. This isn't yet
documented. IMO, it should be the other way around: /etc/cgd/label
for the former and /et/cgd/[root-device] for the latter.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sbin/cgdconfig/cgdconfig.8

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



CVS commit: src/distrib/sets/lists

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 19:35:32 UTC 2018

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi

Log Message:
initfini_array test


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.801 -r1.802 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.273 src/distrib/sets/lists/debug/mi:1.274
--- src/distrib/sets/lists/debug/mi:1.273	Tue Dec 25 21:06:02 2018
+++ src/distrib/sets/lists/debug/mi	Thu Dec 27 14:35:31 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.273 2018/12/26 02:06:02 kre Exp $
+# $NetBSD: mi,v 1.274 2018/12/27 19:35:31 christos 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
@@ -1878,6 +1878,7 @@
 ./usr/libdata/debug/usr/tests/lib/csu/h_initfini1.debug			tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/csu/h_initfini2.debug			tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/csu/h_initfini3.debug			tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/csu/h_initfini_array.debug			tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libbluetooth/t_bluetooth.debug	tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libbluetooth/t_sdp_data.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libbluetooth/t_sdp_get.debug		tests-lib-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.801 src/distrib/sets/lists/tests/mi:1.802
--- src/distrib/sets/lists/tests/mi:1.801	Mon Dec 24 22:54:44 2018
+++ src/distrib/sets/lists/tests/mi	Thu Dec 27 14:35:31 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.801 2018/12/25 03:54:44 knakahara Exp $
+# $NetBSD: mi,v 1.802 2018/12/27 19:35:31 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2421,6 +2421,7 @@
 ./usr/tests/lib/csu/h_initfini1			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/csu/h_initfini2			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/csu/h_initfini3			tests-lib-tests		compattestfile,atf
+./usr/tests/lib/csu/h_initfini_array		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/csu/t_crt0			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/csu/t_ifunc_static		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libbluetooth			tests-lib-tests	compattestfile,atf



CVS commit: src/distrib/sets/lists

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 19:35:32 UTC 2018

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi

Log Message:
initfini_array test


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.801 -r1.802 src/distrib/sets/lists/tests/mi

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



CVS commit: src/tests/lib/csu

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 19:33:52 UTC 2018

Modified Files:
src/tests/lib/csu: Makefile t_crt0.sh
Added Files:
src/tests/lib/csu: h_initfini_array.c

Log Message:
Add an initfini_array test that does not depend on the linker putting it
there automatically.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/csu/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/csu/h_initfini_array.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/csu/t_crt0.sh

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

Modified files:

Index: src/tests/lib/csu/Makefile
diff -u src/tests/lib/csu/Makefile:1.6 src/tests/lib/csu/Makefile:1.7
--- src/tests/lib/csu/Makefile:1.6	Fri Mar  9 15:20:47 2018
+++ src/tests/lib/csu/Makefile	Thu Dec 27 14:33:52 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2018/03/09 20:20:47 joerg Exp $
+# $NetBSD: Makefile,v 1.7 2018/12/27 19:33:52 christos Exp $
 
 NOMAN=			# defined
 
@@ -24,8 +24,9 @@ SRCS.h_initfini3=	h_initfini3.cxx h_init
 			${SRCS_CHECK_STACK}
 LDADD.h_initfini3+=	-Wl,-rpath,${TESTSDIR}
 
-PROGS+=			h_ifunc_static
+PROGS+=			h_ifunc_static h_initfini_array
 SRCS.h_ifunc_static=	h_ifunc_static.c
+SRCS.h_initfini_array=	h_initfini_array.c
 LDSTATIC.h_ifunc_static=-static
 
 .include 

Index: src/tests/lib/csu/t_crt0.sh
diff -u src/tests/lib/csu/t_crt0.sh:1.4 src/tests/lib/csu/t_crt0.sh:1.5
--- src/tests/lib/csu/t_crt0.sh:1.4	Sun Dec 11 09:57:07 2011
+++ src/tests/lib/csu/t_crt0.sh	Thu Dec 27 14:33:52 2018
@@ -1,4 +1,4 @@
-# $NetBSD: t_crt0.sh,v 1.4 2011/12/11 14:57:07 joerg Exp $
+# $NetBSD: t_crt0.sh,v 1.5 2018/12/27 19:33:52 christos Exp $
 #
 # Copyright (c) 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -95,10 +95,21 @@ EOF
 	atf_check -o file:expout -x "env LD_PRELOAD=$(atf_get_srcdir)/h_initfini3_dso.so $(atf_get_srcdir)/h_initfini1"
 }
 
+atf_test_case initfini_array
+initfini_array_head()
+{
+	atf_set "descr" "Checks support for init_array/fini_array sections"
+}
+initfini_array_body()
+{
+	atf_check -x "$(atf_get_srcdir)/h_initfini_array"
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case initfini1
 	atf_add_test_case initfini2
 	atf_add_test_case initfini3
 	atf_add_test_case initfini4
+	atf_add_test_case initfini_array
 }

Added files:

Index: src/tests/lib/csu/h_initfini_array.c
diff -u /dev/null src/tests/lib/csu/h_initfini_array.c:1.1
--- /dev/null	Thu Dec 27 14:33:52 2018
+++ src/tests/lib/csu/h_initfini_array.c	Thu Dec 27 14:33:52 2018
@@ -0,0 +1,16 @@
+static int x = 1;
+
+static void
+foo(void)
+{
+	x = 0;
+}
+
+static void (*fp) (void) __attribute__((__section__(".init_array"), __used__)) =
+foo;
+
+int
+main(void)
+{
+	return x;
+}



CVS commit: src/tests/lib/csu

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 19:33:52 UTC 2018

Modified Files:
src/tests/lib/csu: Makefile t_crt0.sh
Added Files:
src/tests/lib/csu: h_initfini_array.c

Log Message:
Add an initfini_array test that does not depend on the linker putting it
there automatically.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/csu/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/csu/h_initfini_array.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/csu/t_crt0.sh

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



CVS commit: src/lib/csu/common

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 19:32:32 UTC 2018

Modified Files:
src/lib/csu/common: crt0-common.c crtbegin.c

Log Message:
Allow both array and non-array constructors for transition.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/csu/common/crt0-common.c
cvs rdiff -u -r1.14 -r1.15 src/lib/csu/common/crtbegin.c

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

Modified files:

Index: src/lib/csu/common/crt0-common.c
diff -u src/lib/csu/common/crt0-common.c:1.20 src/lib/csu/common/crt0-common.c:1.21
--- src/lib/csu/common/crt0-common.c:1.20	Mon Nov 26 12:37:46 2018
+++ src/lib/csu/common/crt0-common.c	Thu Dec 27 14:32:32 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: crt0-common.c,v 1.20 2018/11/26 17:37:46 joerg Exp $ */
+/* $NetBSD: crt0-common.c,v 1.21 2018/12/27 19:32:32 christos Exp $ */
 
 /*
  * Copyright (c) 1998 Christos Zoulas
@@ -36,7 +36,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: crt0-common.c,v 1.20 2018/11/26 17:37:46 joerg Exp $");
+__RCSID("$NetBSD: crt0-common.c,v 1.21 2018/12/27 19:32:32 christos Exp $");
 
 #include 
 #include 
@@ -50,10 +50,9 @@ extern int main(int, char **, char **);
 
 #ifdef HAVE_INITFINI_ARRAY
 typedef void (*fptr_t)(void);
-#else
+#endif
 extern void	_init(void);
 extern void	_fini(void);
-#endif
 extern void	_libc_init(void);
 
 /*
@@ -111,7 +110,7 @@ _preinit(void)
 }
 
 static inline void
-_init(void)
+_initarray(void)
 {
 	for (const fptr_t *f = __init_array_start; f < __init_array_end; f++) {
 		(*f)();
@@ -119,7 +118,7 @@ _init(void)
 }
 
 static void
-_fini(void)
+_finiarray(void)
 {
 	for (const fptr_t *f = __fini_array_start; f < __fini_array_end; f++) {
 		(*f)();
@@ -337,6 +336,10 @@ ___start(void (*cleanup)(void),			/* fro
 #endif
 
 	atexit(_fini);
+#ifdef HAVE_INITFINI_ARRAY
+	atexit(_finiarray);
+	_initarray();
+#endif
 	_init();
 
 	exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ));

Index: src/lib/csu/common/crtbegin.c
diff -u src/lib/csu/common/crtbegin.c:1.14 src/lib/csu/common/crtbegin.c:1.15
--- src/lib/csu/common/crtbegin.c:1.14	Tue Jul 18 10:34:19 2017
+++ src/lib/csu/common/crtbegin.c	Thu Dec 27 14:32:32 2018
@@ -27,7 +27,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: crtbegin.c,v 1.14 2017/07/18 14:34:19 joerg Exp $");
+__RCSID("$NetBSD: crtbegin.c,v 1.15 2018/12/27 19:32:32 christos Exp $");
 
 #include "crtbegin.h"
 
@@ -38,14 +38,12 @@ __dso_hidden const fptr_t __JCR_LIST__[0
 __weakref_visible void Jv_RegisterClasses(const fptr_t *)
 	__weak_reference(_Jv_RegisterClasses);
 
-#if !defined(HAVE_INITFINI_ARRAY)
 extern __dso_hidden const fptr_t __CTOR_LIST__start __asm("__CTOR_LIST__");
 
 __dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = {
 	(fptr_t) -1,
 };
 __dso_hidden extern const fptr_t __CTOR_LIST_END__[];
-#endif
 
 #ifdef SHARED
 __dso_hidden void *__dso_handle = &__dso_handle;



CVS commit: src/lib/csu/common

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 19:32:32 UTC 2018

Modified Files:
src/lib/csu/common: crt0-common.c crtbegin.c

Log Message:
Allow both array and non-array constructors for transition.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/csu/common/crt0-common.c
cvs rdiff -u -r1.14 -r1.15 src/lib/csu/common/crtbegin.c

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



CVS commit: src/libexec/ld.elf_so

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 18:58:14 UTC 2018

Modified Files:
src/libexec/ld.elf_so: Makefile
src/libexec/ld.elf_so/arch/aarch64: Makefile.inc
src/libexec/ld.elf_so/arch/arm: Makefile.inc
src/libexec/ld.elf_so/arch/riscv: Makefile.inc

Log Message:
initfini array support for everyone.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/libexec/ld.elf_so/Makefile
cvs rdiff -u -r1.1 -r1.2 src/libexec/ld.elf_so/arch/aarch64/Makefile.inc
cvs rdiff -u -r1.21 -r1.22 src/libexec/ld.elf_so/arch/arm/Makefile.inc
cvs rdiff -u -r1.1 -r1.2 src/libexec/ld.elf_so/arch/riscv/Makefile.inc

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

Modified files:

Index: src/libexec/ld.elf_so/Makefile
diff -u src/libexec/ld.elf_so/Makefile:1.139 src/libexec/ld.elf_so/Makefile:1.140
--- src/libexec/ld.elf_so/Makefile:1.139	Wed Oct 17 19:36:58 2018
+++ src/libexec/ld.elf_so/Makefile	Thu Dec 27 13:58:14 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.139 2018/10/17 23:36:58 joerg Exp $
+#	$NetBSD: Makefile,v 1.140 2018/12/27 18:58:14 christos Exp $
 #
 # NOTE: when changing ld.so, ensure that ldd still compiles.
 #
@@ -97,6 +97,7 @@ CPPFLAGS+=	-I${.CURDIR} -I. -D_KERNTYPES
 CPPFLAGS+=	-DRTLD_LOADER
 CPPFLAGS+=	-DGNU_RELRO
 CPPFLAGS+=	-D_RTLD_SOURCE
+CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 #CPPFLAGS+=	-DDEBUG
 #CPPFLAGS+=	-DRTLD_DEBUG
 #CPPFLAGS+=	-DRTLD_DEBUG_RELOC

Index: src/libexec/ld.elf_so/arch/aarch64/Makefile.inc
diff -u src/libexec/ld.elf_so/arch/aarch64/Makefile.inc:1.1 src/libexec/ld.elf_so/arch/aarch64/Makefile.inc:1.2
--- src/libexec/ld.elf_so/arch/aarch64/Makefile.inc:1.1	Sun Aug 10 01:47:37 2014
+++ src/libexec/ld.elf_so/arch/aarch64/Makefile.inc	Thu Dec 27 13:58:14 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:37 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2018/12/27 18:58:14 christos Exp $
 
 SRCS+=		rtld_start.S mdreloc.c
 
@@ -6,7 +6,6 @@ SRCS+=		rtld_start.S mdreloc.c
 CPPFLAGS+=	-fpic
 
 CPPFLAGS+=	-DELFSIZE=64
-CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 CPPFLAGS+=	-DELF_NOTE_MARCH_DESC=\"${LDELFSO_MACHINE_ARCH}\"
 
 LDFLAGS+=	-Wl,-e,_rtld_start

Index: src/libexec/ld.elf_so/arch/arm/Makefile.inc
diff -u src/libexec/ld.elf_so/arch/arm/Makefile.inc:1.21 src/libexec/ld.elf_so/arch/arm/Makefile.inc:1.22
--- src/libexec/ld.elf_so/arch/arm/Makefile.inc:1.21	Tue Apr  3 17:10:27 2018
+++ src/libexec/ld.elf_so/arch/arm/Makefile.inc	Thu Dec 27 13:58:14 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.21 2018/04/03 21:10:27 joerg Exp $
+#	$NetBSD: Makefile.inc,v 1.22 2018/12/27 18:58:14 christos Exp $
 
 SRCS+=		rtld_start.S mdreloc.c
 #CPUFLAGS.rtld_start.S+=	-marm
@@ -9,7 +9,6 @@ CPPFLAGS+=	-fpic
 CPPFLAGS+=	-DELFSIZE=32
 CPPFLAGS+=	-DRTLD_COMMON_CALL_IFUNC_REL
 .if !empty(LDELFSO_MACHINE_ARCH:Mearm*)
-CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 CPPFLAGS+=	-DELF_NOTE_MARCH_DESC=\"${LDELFSO_MACHINE_ARCH}\"
 SRCS+=		find_exidx.c
 .endif

Index: src/libexec/ld.elf_so/arch/riscv/Makefile.inc
diff -u src/libexec/ld.elf_so/arch/riscv/Makefile.inc:1.1 src/libexec/ld.elf_so/arch/riscv/Makefile.inc:1.2
--- src/libexec/ld.elf_so/arch/riscv/Makefile.inc:1.1	Fri Sep 19 13:36:25 2014
+++ src/libexec/ld.elf_so/arch/riscv/Makefile.inc	Thu Dec 27 13:58:14 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2018/12/27 18:58:14 christos Exp $
 
 SRCS+=		rtld_start.S mdreloc.c
 
@@ -10,6 +10,5 @@ CPPFLAGS+=	-DELFSIZE=64
 .else
 CPPFLAGS+=	-DELFSIZE=32
 .endif
-CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 
 LDFLAGS+=	-Wl,-e,_rtld_start



CVS commit: src/libexec/ld.elf_so

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 18:58:14 UTC 2018

Modified Files:
src/libexec/ld.elf_so: Makefile
src/libexec/ld.elf_so/arch/aarch64: Makefile.inc
src/libexec/ld.elf_so/arch/arm: Makefile.inc
src/libexec/ld.elf_so/arch/riscv: Makefile.inc

Log Message:
initfini array support for everyone.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/libexec/ld.elf_so/Makefile
cvs rdiff -u -r1.1 -r1.2 src/libexec/ld.elf_so/arch/aarch64/Makefile.inc
cvs rdiff -u -r1.21 -r1.22 src/libexec/ld.elf_so/arch/arm/Makefile.inc
cvs rdiff -u -r1.1 -r1.2 src/libexec/ld.elf_so/arch/riscv/Makefile.inc

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



CVS commit: src/libexec/ld.elf_so

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 18:57:43 UTC 2018

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
explain why we skip objmain.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/libexec/ld.elf_so/rtld.c

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

Modified files:

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.193 src/libexec/ld.elf_so/rtld.c:1.194
--- src/libexec/ld.elf_so/rtld.c:1.193	Wed Oct 17 19:36:58 2018
+++ src/libexec/ld.elf_so/rtld.c	Thu Dec 27 13:57:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.193 2018/10/17 23:36:58 joerg Exp $	 */
+/*	$NetBSD: rtld.c,v 1.194 2018/12/27 18:57:43 christos Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.193 2018/10/17 23:36:58 joerg Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.194 2018/12/27 18:57:43 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -847,6 +847,10 @@ _rtld_initlist_tsort(Objlist* list, int 
 
 	Obj_Entry* obj;
 
+	/*
+	 * We don't include objmain here (starting from next)
+	 * because csu handles it
+	 */
 	for (obj = _rtld_objlist->next; obj; obj = obj->next) {
 		obj->init_done = 0;
 	}



CVS commit: src/libexec/ld.elf_so

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 18:57:43 UTC 2018

Modified Files:
src/libexec/ld.elf_so: rtld.c

Log Message:
explain why we skip objmain.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/libexec/ld.elf_so/rtld.c

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



CVS commit: src/lib/csu

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 18:57:15 UTC 2018

Modified Files:
src/lib/csu/arch/aarch64: Makefile.inc
src/lib/csu/arch/arm: Makefile.inc
src/lib/csu/arch/earm: Makefile.inc
src/lib/csu/arch/or1k: Makefile.inc
src/lib/csu/arch/riscv: Makefile.inc
src/lib/csu/common: Makefile.inc

Log Message:
Enable initfini array support for everyone.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/aarch64/Makefile.inc
cvs rdiff -u -r1.7 -r1.8 src/lib/csu/arch/arm/Makefile.inc
cvs rdiff -u -r1.3 -r1.4 src/lib/csu/arch/earm/Makefile.inc
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/or1k/Makefile.inc
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/riscv/Makefile.inc
cvs rdiff -u -r1.33 -r1.34 src/lib/csu/common/Makefile.inc

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



CVS commit: src/lib/csu

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 18:57:15 UTC 2018

Modified Files:
src/lib/csu/arch/aarch64: Makefile.inc
src/lib/csu/arch/arm: Makefile.inc
src/lib/csu/arch/earm: Makefile.inc
src/lib/csu/arch/or1k: Makefile.inc
src/lib/csu/arch/riscv: Makefile.inc
src/lib/csu/common: Makefile.inc

Log Message:
Enable initfini array support for everyone.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/aarch64/Makefile.inc
cvs rdiff -u -r1.7 -r1.8 src/lib/csu/arch/arm/Makefile.inc
cvs rdiff -u -r1.3 -r1.4 src/lib/csu/arch/earm/Makefile.inc
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/or1k/Makefile.inc
cvs rdiff -u -r1.1 -r1.2 src/lib/csu/arch/riscv/Makefile.inc
cvs rdiff -u -r1.33 -r1.34 src/lib/csu/common/Makefile.inc

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

Modified files:

Index: src/lib/csu/arch/aarch64/Makefile.inc
diff -u src/lib/csu/arch/aarch64/Makefile.inc:1.1 src/lib/csu/arch/aarch64/Makefile.inc:1.2
--- src/lib/csu/arch/aarch64/Makefile.inc:1.1	Sun Aug 10 01:47:36 2014
+++ src/lib/csu/arch/aarch64/Makefile.inc	Thu Dec 27 13:57:14 2018
@@ -1,5 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:36 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2018/12/27 18:57:14 christos Exp $
 
 CPPFLAGS+=	-I${ARCHDIR}
-CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 #CPPFLAGS+=	-DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\"

Index: src/lib/csu/arch/arm/Makefile.inc
diff -u src/lib/csu/arch/arm/Makefile.inc:1.7 src/lib/csu/arch/arm/Makefile.inc:1.8
--- src/lib/csu/arch/arm/Makefile.inc:1.7	Tue Sep 10 18:00:01 2013
+++ src/lib/csu/arch/arm/Makefile.inc	Thu Dec 27 13:57:15 2018
@@ -1,7 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.7 2013/09/10 22:00:01 matt Exp $
+# $NetBSD: Makefile.inc,v 1.8 2018/12/27 18:57:15 christos Exp $
 
 CPPFLAGS+=	-I${ARCHDIR}
-.if (!empty(CPUFLAGS) && ${CPUFLAGS:M-mabi=aapcs*} != "")
-CPPFLAGS+=  -DHAVE_INITFINI_ARRAY
-.endif
 CPPFLAGS+=	-DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\"

Index: src/lib/csu/arch/earm/Makefile.inc
diff -u src/lib/csu/arch/earm/Makefile.inc:1.3 src/lib/csu/arch/earm/Makefile.inc:1.4
--- src/lib/csu/arch/earm/Makefile.inc:1.3	Tue Sep 10 12:45:33 2013
+++ src/lib/csu/arch/earm/Makefile.inc	Thu Dec 27 13:57:15 2018
@@ -1,5 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.3 2013/09/10 16:45:33 matt Exp $
+# $NetBSD: Makefile.inc,v 1.4 2018/12/27 18:57:15 christos Exp $
 
 CPPFLAGS+=	-I${ARCHDIR}
-CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 CPPFLAGS+=	-DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\"

Index: src/lib/csu/arch/or1k/Makefile.inc
diff -u src/lib/csu/arch/or1k/Makefile.inc:1.1 src/lib/csu/arch/or1k/Makefile.inc:1.2
--- src/lib/csu/arch/or1k/Makefile.inc:1.1	Wed Sep  3 15:34:25 2014
+++ src/lib/csu/arch/or1k/Makefile.inc	Thu Dec 27 13:57:15 2018
@@ -1,5 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2014/09/03 19:34:25 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2018/12/27 18:57:15 christos Exp $
 
 CPPFLAGS+=	-I${ARCHDIR}
-CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 #CPPFLAGS+=	-DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\"

Index: src/lib/csu/arch/riscv/Makefile.inc
diff -u src/lib/csu/arch/riscv/Makefile.inc:1.1 src/lib/csu/arch/riscv/Makefile.inc:1.2
--- src/lib/csu/arch/riscv/Makefile.inc:1.1	Fri Sep 19 13:36:25 2014
+++ src/lib/csu/arch/riscv/Makefile.inc	Thu Dec 27 13:57:15 2018
@@ -1,5 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $
+# $NetBSD: Makefile.inc,v 1.2 2018/12/27 18:57:15 christos Exp $
 
 CPPFLAGS+=	-I${ARCHDIR}
-CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 #CPPFLAGS+=	-DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\"

Index: src/lib/csu/common/Makefile.inc
diff -u src/lib/csu/common/Makefile.inc:1.33 src/lib/csu/common/Makefile.inc:1.34
--- src/lib/csu/common/Makefile.inc:1.33	Mon Nov 26 12:37:46 2018
+++ src/lib/csu/common/Makefile.inc	Thu Dec 27 13:57:15 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.33 2018/11/26 17:37:46 joerg Exp $
+#	$NetBSD: Makefile.inc,v 1.34 2018/12/27 18:57:15 christos Exp $
 
 .include 
 
@@ -9,6 +9,7 @@ COMMON_DIR:=	${.CURDIR}/common
 .PATH:		${COMMON_DIR}
 
 CPPFLAGS+=	-I${COMMON_DIR} -I.
+CPPFLAGS+=	-DHAVE_INITFINI_ARRAY
 
 OBJS+=		crt0.o gcrt0.o crti.o crtn.o
 OBJS+=		crtbegin.o crtend.o



CVS commit: src/sys

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 16:59:17 UTC 2018

Modified Files:
src/sys/netinet: tcp_output.c tcp_subr.c tcp_var.h udp_usrreq.c
src/sys/netinet6: udp6_usrreq.c

Log Message:
Remove unused arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/sys/netinet/tcp_output.c
cvs rdiff -u -r1.281 -r1.282 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.189 -r1.190 src/sys/netinet/tcp_var.h
cvs rdiff -u -r1.257 -r1.258 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.144 -r1.145 src/sys/netinet6/udp6_usrreq.c

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



CVS commit: src/sys

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 16:59:17 UTC 2018

Modified Files:
src/sys/netinet: tcp_output.c tcp_subr.c tcp_var.h udp_usrreq.c
src/sys/netinet6: udp6_usrreq.c

Log Message:
Remove unused arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/sys/netinet/tcp_output.c
cvs rdiff -u -r1.281 -r1.282 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.189 -r1.190 src/sys/netinet/tcp_var.h
cvs rdiff -u -r1.257 -r1.258 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.144 -r1.145 src/sys/netinet6/udp6_usrreq.c

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

Modified files:

Index: src/sys/netinet/tcp_output.c
diff -u src/sys/netinet/tcp_output.c:1.209 src/sys/netinet/tcp_output.c:1.210
--- src/sys/netinet/tcp_output.c:1.209	Mon Sep  3 16:29:36 2018
+++ src/sys/netinet/tcp_output.c	Thu Dec 27 16:59:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_output.c,v 1.209 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: tcp_output.c,v 1.210 2018/12/27 16:59:17 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -135,7 +135,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.209 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.210 2018/12/27 16:59:17 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1656,10 +1656,10 @@ out:
 		if (error == ENOBUFS) {
 			TCP_STATINC(TCP_STAT_SELFQUENCH);
 			if (tp->t_inpcb)
-tcp_quench(tp->t_inpcb, 0);
+tcp_quench(tp->t_inpcb);
 #ifdef INET6
 			if (tp->t_in6pcb)
-tcp6_quench(tp->t_in6pcb, 0);
+tcp6_quench(tp->t_in6pcb);
 #endif
 			error = 0;
 		} else if ((error == EHOSTUNREACH || error == ENETDOWN) &&

Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.281 src/sys/netinet/tcp_subr.c:1.282
--- src/sys/netinet/tcp_subr.c:1.281	Mon Sep  3 16:29:36 2018
+++ src/sys/netinet/tcp_subr.c	Thu Dec 27 16:59:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.281 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.282 2018/12/27 16:59:17 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.281 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.282 2018/12/27 16:59:17 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1631,7 +1631,7 @@ tcp_ctlinput(int cmd, const struct socka
  * We will gradually open it again as we proceed.
  */
 void
-tcp_quench(struct inpcb *inp, int errno)
+tcp_quench(struct inpcb *inp)
 {
 	struct tcpcb *tp = intotcpcb(inp);
 
@@ -1643,7 +1643,7 @@ tcp_quench(struct inpcb *inp, int errno)
 
 #ifdef INET6
 void
-tcp6_quench(struct in6pcb *in6p, int errno)
+tcp6_quench(struct in6pcb *in6p)
 {
 	struct tcpcb *tp = in6totcpcb(in6p);
 

Index: src/sys/netinet/tcp_var.h
diff -u src/sys/netinet/tcp_var.h:1.189 src/sys/netinet/tcp_var.h:1.190
--- src/sys/netinet/tcp_var.h:1.189	Fri Sep 14 05:09:51 2018
+++ src/sys/netinet/tcp_var.h	Thu Dec 27 16:59:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_var.h,v 1.189 2018/09/14 05:09:51 maxv Exp $	*/
+/*	$NetBSD: tcp_var.h,v 1.190 2018/12/27 16:59:17 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -891,9 +891,9 @@ u_int	 tcp_optlen(struct tcpcb *);
 int	 tcp_output(struct tcpcb *);
 void	 tcp_pulloutofband(struct socket *,
 	struct tcphdr *, struct mbuf *, int);
-void	 tcp_quench(struct inpcb *, int);
+void	 tcp_quench(struct inpcb *);
 #ifdef INET6
-void	 tcp6_quench(struct in6pcb *, int);
+void	 tcp6_quench(struct in6pcb *);
 #endif
 void	 tcp_mtudisc(struct inpcb *, int);
 #ifdef INET6

Index: src/sys/netinet/udp_usrreq.c
diff -u src/sys/netinet/udp_usrreq.c:1.257 src/sys/netinet/udp_usrreq.c:1.258
--- src/sys/netinet/udp_usrreq.c:1.257	Thu Nov 22 04:48:34 2018
+++ src/sys/netinet/udp_usrreq.c	Thu Dec 27 16:59:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp_usrreq.c,v 1.257 2018/11/22 04:48:34 knakahara Exp $	*/
+/*	$NetBSD: udp_usrreq.c,v 1.258 2018/12/27 16:59:17 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.257 2018/11/22 04:48:34 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.258 2018/12/27 16:59:17 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -127,7 +127,7 @@ percpu_t *udpstat_percpu;
 
 #ifdef INET
 #ifdef IPSEC
-static int udp4_espinudp(struct mbuf **, int, struct socket *);
+static int udp4_espinudp(struct mbuf **, int);
 #endif
 static void udp4_sendup(struct mbuf *, int, struct sockaddr *,
 struct socket *);
@@ -577,7 +577,7 @@ udp4_realinput(struct sockaddr_in *src, 
 #ifdef IPSEC
 		/* Handle ESP over UDP */
 		if (inp->inp_flags & INP_ESPINUDP) {
-			switch (udp4_espinudp(mp, off, inp->inp_socket)) {
+			switch (udp4_espinudp(mp, 

CVS commit: src/share/mk

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 16:27:29 UTC 2018

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
Back to 2.31 for x86! Hooray :-)


To generate a diff of this commit:
cvs rdiff -u -r1.1087 -r1.1088 src/share/mk/bsd.own.mk

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



CVS commit: src/share/mk

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 16:27:29 UTC 2018

Modified Files:
src/share/mk: bsd.own.mk

Log Message:
Back to 2.31 for x86! Hooray :-)


To generate a diff of this commit:
cvs rdiff -u -r1.1087 -r1.1088 src/share/mk/bsd.own.mk

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

Modified files:

Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1087 src/share/mk/bsd.own.mk:1.1088
--- src/share/mk/bsd.own.mk:1.1087	Mon Dec 24 19:35:26 2018
+++ src/share/mk/bsd.own.mk	Thu Dec 27 11:27:29 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.own.mk,v 1.1087 2018/12/25 00:35:26 christos Exp $
+#	$NetBSD: bsd.own.mk,v 1.1088 2018/12/27 16:27:29 christos Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -150,7 +150,7 @@ EXTERNAL_GDB_SUBDIR=		/does/not/exist
 # What binutils is used?
 #
 .if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
-HAVE_BINUTILS?=	227
+HAVE_BINUTILS?=	231
 .else
 HAVE_BINUTILS?=	227
 .endif



CVS commit: src/tools/binutils

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 16:26:53 UTC 2018

Modified Files:
src/tools/binutils: Makefile

Log Message:
explicitly disable initfini-array; we don't have it yet.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/tools/binutils/Makefile

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



CVS commit: src/tools/binutils

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 16:26:53 UTC 2018

Modified Files:
src/tools/binutils: Makefile

Log Message:
explicitly disable initfini-array; we don't have it yet.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/tools/binutils/Makefile

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

Modified files:

Index: src/tools/binutils/Makefile
diff -u src/tools/binutils/Makefile:1.29 src/tools/binutils/Makefile:1.30
--- src/tools/binutils/Makefile:1.29	Tue Nov  6 20:14:19 2018
+++ src/tools/binutils/Makefile	Thu Dec 27 11:26:52 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.29 2018/11/07 01:14:19 christos Exp $
+#	$NetBSD: Makefile,v 1.30 2018/12/27 16:26:52 christos Exp $
 
 .include 
 
@@ -13,7 +13,7 @@ BRANDING?=	\
 
 CONFIGURE_ARGS=	--target=${MACHINE_GNU_PLATFORM} --disable-nls \
 		--program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-," \
-		--disable-werror \
+		--disable-werror --disable-initfini-array \
 		${BRANDING}
 
 build/gas/m68k-parse.c: ${GNUHOSTDIST}/gas/m68k-parse.c



CVS commit: src/external/gpl3/binutils/dist/ld

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 14:53:05 UTC 2018

Modified Files:
src/external/gpl3/binutils/dist/ld: configure.ac

Log Message:
Remove initfini array rest (restore original FSF version).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/gpl3/binutils/dist/ld/configure.ac

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



CVS commit: src/external/gpl3/binutils/dist/ld

2018-12-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 27 14:53:05 UTC 2018

Modified Files:
src/external/gpl3/binutils/dist/ld: configure.ac

Log Message:
Remove initfini array rest (restore original FSF version).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/gpl3/binutils/dist/ld/configure.ac

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

Modified files:

Index: src/external/gpl3/binutils/dist/ld/configure.ac
diff -u src/external/gpl3/binutils/dist/ld/configure.ac:1.6 src/external/gpl3/binutils/dist/ld/configure.ac:1.7
--- src/external/gpl3/binutils/dist/ld/configure.ac:1.6	Tue Nov  6 20:13:54 2018
+++ src/external/gpl3/binutils/dist/ld/configure.ac	Thu Dec 27 09:53:05 2018
@@ -268,23 +268,11 @@ AC_SEARCH_LIBS([dlopen], [dl])
 AM_CONDITIONAL([ENABLE_PLUGINS], [test x$plugins = xyes])
 
 AC_ARG_ENABLE(initfini-array,
-	[  --enable-initfini-array	use .init_array/.fini_array sections],
-	[], [
-AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
-		 gcc_cv_initfini_array, [dnl
-  if test "x${build}" = "x${target}" ; then
-AC_RUN_IFELSE([AC_LANG_SOURCE([
-static int x = -1;
-int main (void) { return x; }
-int foo (void) { x = 0; }
-int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;])],
-	 [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
-	 [gcc_cv_initfini_array=no])
-   else
- gcc_cv_initfini_array=no
-   fi])
-  enable_initfini_array=$gcc_cv_initfini_array
-])
+[  --disable-initfini-array do not use .init_array/.fini_array sections],
+[case "${enableval}" in
+ yes|no) ;;
+ *) AC_MSG_ERROR([invalid --enable-initfini-array argument]) ;;
+ esac], [enable_initfini_array=yes])
 AC_SUBST(enable_initfini_array)
 if test $enable_initfini_array = yes; then
   AC_DEFINE(HAVE_INITFINI_ARRAY, 1,



Re: CVS commit: src

2018-12-27 Thread Jason Thorpe



> On Dec 27, 2018, at 6:04 AM, Jason Thorpe  wrote:
> 
> -- job_hold remains lockless, but job_rele can only be called **without** the 
> job_lock held, because it needs to acquire the lock in the unlikely case it 
> performs a cv_broadcast (see below).  Also need a job_rele_locked.

Correction -- all cases of job_rele can be called with the job_lock held.  (I 
mis-read the block of the code in the overseer where the job_lock is dropped 
immediately before calling job_rele.)

Index: kern_threadpool.c
===
RCS file: /cvsroot/src/sys/kern/kern_threadpool.c,v
retrieving revision 1.12
diff -u -p -r1.12 kern_threadpool.c
--- kern_threadpool.c   27 Dec 2018 04:45:29 -  1.12
+++ kern_threadpool.c   27 Dec 2018 14:37:46 -
@@ -134,7 +134,7 @@ static void threadpool_percpu_destroy(st
 
 static threadpool_job_fn_t threadpool_job_dead;
 
-static int threadpool_job_hold(struct threadpool_job *);
+static voidthreadpool_job_hold(struct threadpool_job *);
 static voidthreadpool_job_rele(struct threadpool_job *);
 
 static voidthreadpool_overseer_thread(void *) __dead;
@@ -650,19 +650,16 @@ threadpool_job_destroy(struct threadpool
(void)strlcpy(job->job_name, "deadjob", sizeof(job->job_name));
 }
 
-static int
+static void
 threadpool_job_hold(struct threadpool_job *job)
 {
unsigned int refcnt;
 
do {
refcnt = job->job_refcnt;
-   if (refcnt == UINT_MAX)
-   return EBUSY;
+   KASSERT(refcnt != UINT_MAX);
} while (atomic_cas_uint(>job_refcnt, refcnt, (refcnt + 1))
!= refcnt);
-
-   return 0;
 }
 
 static void
@@ -670,16 +667,16 @@ threadpool_job_rele(struct threadpool_jo
 {
unsigned int refcnt;
 
+   KASSERT(mutex_owned(job->job_lock));
+
do {
refcnt = job->job_refcnt;
KASSERT(0 < refcnt);
if (refcnt == 1) {
-   mutex_enter(job->job_lock);
refcnt = atomic_dec_uint_nv(>job_refcnt);
KASSERT(refcnt != UINT_MAX);
if (refcnt == 0)
cv_broadcast(>job_cv);
-   mutex_exit(job->job_lock);
return;
}
} while (atomic_cas_uint(>job_refcnt, refcnt, (refcnt - 1))
@@ -703,6 +700,16 @@ threadpool_job_done(struct threadpool_jo
curlwp->l_name = job->job_thread->tpt_lwp_savedname;
lwp_unlock(curlwp);
 
+   /*
+* Inline the work of threadpool_job_rele(); the job is already
+* locked, the most likely scenario (XXXJRT only scenario?) is
+* that we're dropping the last reference (the one taken in
+* threadpool_schedule_job()), and we always do the cv_broadcast()
+* anyway.
+*/
+   KASSERT(0 < job->job_refcnt);
+   unsigned int refcnt __diagused = atomic_dec_uint_nv(>job_refcnt);
+   KASSERT(refcnt != UINT_MAX);
cv_broadcast(>job_cv);
job->job_thread = NULL;
 }
@@ -725,6 +732,8 @@ threadpool_schedule_job(struct threadpoo
return;
}
 
+   threadpool_job_hold(job);
+
/* Otherwise, try to assign a thread to the job.  */
mutex_spin_enter(>tp_lock);
if (__predict_false(TAILQ_EMPTY(>tp_idle_threads))) {
@@ -740,7 +749,6 @@ threadpool_schedule_job(struct threadpoo
__func__, job->job_name, job->job_thread));
TAILQ_REMOVE(>tp_idle_threads, job->job_thread,
tpt_entry);
-   threadpool_job_hold(job);
job->job_thread->tpt_job = job;
}
 
@@ -786,6 +794,7 @@ threadpool_cancel_job_async(struct threa
mutex_spin_enter(>tp_lock);
TAILQ_REMOVE(>tp_jobs, job, job_entry);
mutex_spin_exit(>tp_lock);
+   threadpool_job_rele(job);
return true;
} else {
/* Too late -- already running.  */
@@ -889,15 +898,13 @@ threadpool_overseer_thread(void *arg)
}
 
/* There are idle threads, so try giving one a job.  */
-   bool rele_job = true;
struct threadpool_job *const job = TAILQ_FIRST(>tp_jobs);
TAILQ_REMOVE(>tp_jobs, job, job_entry);
-   error = threadpool_job_hold(job);
-   if (error) {
-   TAILQ_INSERT_HEAD(>tp_jobs, job, job_entry);
-   (void)kpause("pooljob", false, hz, >tp_lock);
-   continue;
-   }
+   /*
+* Take an extra reference on the job temporarily so that
+* it won't disappear on us while we have both locks dropped.
+*/
+   threadpool_job_hold(job);
mutex_spin_exit(>tp_lock);
 
mutex_enter(job->job_lock);
@@ 

CVS commit: src/sys/sys

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 14:24:11 UTC 2018

Modified Files:
src/sys/sys: mbuf.h

Log Message:
Style, use __nothing, and remove _M_ (unused, appears to be a typo). No
functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/sys/mbuf.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/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.217 src/sys/sys/mbuf.h:1.218
--- src/sys/sys/mbuf.h:1.217	Thu Dec 27 14:03:55 2018
+++ src/sys/sys/mbuf.h	Thu Dec 27 14:24:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.217 2018/12/27 14:03:55 maxv Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.218 2018/12/27 14:24:11 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -144,13 +144,13 @@ struct mowner_user {
  * Macros for type conversion
  * mtod(m,t) -	convert mbuf pointer to data pointer of correct type
  */
-#define	mtod(m, t)	((t)((m)->m_data))
+#define mtod(m, t)	((t)((m)->m_data))
 
 /* header at beginning of each mbuf */
 struct m_hdr {
 	struct	mbuf *mh_next;		/* next buffer in chain */
 	struct	mbuf *mh_nextpkt;	/* next chain in queue/record */
-	char   *mh_data;		/* location of data */
+	char	*mh_data;		/* location of data */
 	struct	mowner *mh_owner;	/* mbuf owner */
 	int	mh_len;			/* amount of data in this mbuf */
 	int	mh_flags;		/* flags; see below */
@@ -205,19 +205,19 @@ struct pkthdr {
 };
 
 /* Checksumming flags (csum_flags). */
-#define	M_CSUM_TCPv4		0x0001	/* TCP header/payload */
-#define	M_CSUM_UDPv4		0x0002	/* UDP header/payload */
-#define	M_CSUM_TCP_UDP_BAD	0x0004	/* TCP/UDP checksum bad */
-#define	M_CSUM_DATA		0x0008	/* consult csum_data */
-#define	M_CSUM_TCPv6		0x0010	/* IPv6 TCP header/payload */
-#define	M_CSUM_UDPv6		0x0020	/* IPv6 UDP header/payload */
-#define	M_CSUM_IPv4		0x0040	/* IPv4 header */
-#define	M_CSUM_IPv4_BAD		0x0080	/* IPv4 header checksum bad */
-#define	M_CSUM_TSOv4		0x0100	/* TCPv4 segmentation offload */
-#define	M_CSUM_TSOv6		0x0200	/* TCPv6 segmentation offload */
+#define M_CSUM_TCPv4		0x0001	/* TCP header/payload */
+#define M_CSUM_UDPv4		0x0002	/* UDP header/payload */
+#define M_CSUM_TCP_UDP_BAD	0x0004	/* TCP/UDP checksum bad */
+#define M_CSUM_DATA		0x0008	/* consult csum_data */
+#define M_CSUM_TCPv6		0x0010	/* IPv6 TCP header/payload */
+#define M_CSUM_UDPv6		0x0020	/* IPv6 UDP header/payload */
+#define M_CSUM_IPv4		0x0040	/* IPv4 header */
+#define M_CSUM_IPv4_BAD		0x0080	/* IPv4 header checksum bad */
+#define M_CSUM_TSOv4		0x0100	/* TCPv4 segmentation offload */
+#define M_CSUM_TSOv6		0x0200	/* TCPv6 segmentation offload */
 
 /* Checksum-assist quirks: keep separate from jump-table bits. */
-#define	M_CSUM_NO_PSEUDOHDR	0x8000	/* Rx csum_data does not include
+#define M_CSUM_NO_PSEUDOHDR	0x8000	/* Rx csum_data does not include
 		 * the UDP/TCP pseudo-hdr, and
 		 * is not yet 1s-complemented.
 		 */
@@ -234,18 +234,18 @@ struct pkthdr {
  *words the offset of the UDP/TCP header in the packet.
  *   _OFFSET: Offset of the checksum field in the UDP/TCP header.
  */
-#define	M_CSUM_DATA_IPv4_IPHL(x)	((x) >> 16)
-#define	M_CSUM_DATA_IPv4_OFFSET(x)	((x) & 0x)
-#define	M_CSUM_DATA_IPv6_IPHL(x)	((x) >> 16)
-#define	M_CSUM_DATA_IPv6_OFFSET(x)	((x) & 0x)
-#define	M_CSUM_DATA_IPv6_SET(x, v)	(x) = ((x) & 0x) | ((v) << 16)
+#define M_CSUM_DATA_IPv4_IPHL(x)	((x) >> 16)
+#define M_CSUM_DATA_IPv4_OFFSET(x)	((x) & 0x)
+#define M_CSUM_DATA_IPv6_IPHL(x)	((x) >> 16)
+#define M_CSUM_DATA_IPv6_OFFSET(x)	((x) & 0x)
+#define M_CSUM_DATA_IPv6_SET(x, v)	(x) = ((x) & 0x) | ((v) << 16)
 
 /*
  * Max # of pages we can attach to m_ext.  This is carefully chosen
  * to be able to handle SOSEND_LOAN_CHUNK with our minimum sized page.
  */
 #ifdef MIN_PAGE_SIZE
-#define	M_EXT_MAXPAGES		((65536 / MIN_PAGE_SIZE) + 1)
+#define M_EXT_MAXPAGES		((65536 / MIN_PAGE_SIZE) + 1)
 #endif
 
 /*
@@ -267,8 +267,8 @@ struct _m_ext_storage {
 		struct vm_page *extun_pgs[M_EXT_MAXPAGES];
 #endif
 	} ext_un;
-#define	ext_paddr	ext_un.extun_paddr
-#define	ext_pgs		ext_un.extun_pgs
+#define ext_paddr	ext_un.extun_paddr
+#define ext_pgs		ext_un.extun_pgs
 };
 
 struct _m_ext {
@@ -276,13 +276,13 @@ struct _m_ext {
 	struct _m_ext_storage ext_storage;
 };
 
-#define	M_PADDR_INVALID		POOL_PADDR_INVALID
+#define M_PADDR_INVALID		POOL_PADDR_INVALID
 
 /*
  * Definition of "struct mbuf".
  * Don't change this without understanding how MHLEN/MLEN are defined.
  */
-#define	MBUF_DEFINE(name, mhlen, mlen)	\
+#define MBUF_DEFINE(name, mhlen, mlen)	\
 	struct name {			\
 		struct m_hdr m_hdr;	\
 		union {			\
@@ -296,20 +296,20 @@ struct _m_ext {
 			char M_databuf[(mlen)];\
 		} M_dat;		\
 	}
-#define	m_next		m_hdr.mh_next
-#define	m_len		m_hdr.mh_len

CVS commit: src/sys/sys

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 14:24:11 UTC 2018

Modified Files:
src/sys/sys: mbuf.h

Log Message:
Style, use __nothing, and remove _M_ (unused, appears to be a typo). No
functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/sys/mbuf.h

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



CVS commit: src/lib/libdm

2018-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Dec 27 14:05:54 UTC 2018

Modified Files:
src/lib/libdm: libdm_ioctl.c

Log Message:
Clean up double free in some error paths that did trigger
an assertion in libprop.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libdm/libdm_ioctl.c

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



CVS commit: src/lib/libdm

2018-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Dec 27 14:05:54 UTC 2018

Modified Files:
src/lib/libdm: libdm_ioctl.c

Log Message:
Clean up double free in some error paths that did trigger
an assertion in libprop.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libdm/libdm_ioctl.c

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

Modified files:

Index: src/lib/libdm/libdm_ioctl.c
diff -u src/lib/libdm/libdm_ioctl.c:1.2 src/lib/libdm/libdm_ioctl.c:1.3
--- src/lib/libdm/libdm_ioctl.c:1.2	Mon May 30 01:10:57 2011
+++ src/lib/libdm/libdm_ioctl.c	Thu Dec 27 14:05:54 2018
@@ -165,8 +165,6 @@ libdm_task_run(libdm_task_t libdm_task)
 
 	error = rump_sys_ioctl(libdm_control_fd, NETBSD_DM_IOCTL, );
 	if (error < 0) {
-		libdm_task_destroy(libdm_task);
-		libdm_task = NULL;
 		libdm_control_close(libdm_control_fd);
 
 		return error;
@@ -177,8 +175,6 @@ libdm_task_run(libdm_task_t libdm_task)
 	error = prop_dictionary_sendrecv_ioctl(libdm_task->ldm_task,
 	libdm_control_fd, NETBSD_DM_IOCTL, );
 	if ( error != 0) {
-		libdm_task_destroy(libdm_task);
-		libdm_task = NULL;
 		libdm_control_close(libdm_control_fd);
 		return error;
 	}



CVS commit: src/sys

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 14:03:55 UTC 2018

Modified Files:
src/sys/dev/pci: hifn7751.c
src/sys/kern: uipc_mbuf.c
src/sys/netmpls: mpls_ttl.c
src/sys/sys: mbuf.h

Log Message:
Remove M_COPY_PKTHDR, M_MOVE_PKTHDR, M_ALIGN and MH_ALIGN.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/hifn7751.c
cvs rdiff -u -r1.229 -r1.230 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.14 -r1.15 src/sys/netmpls/mpls_ttl.c
cvs rdiff -u -r1.216 -r1.217 src/sys/sys/mbuf.h

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

Modified files:

Index: src/sys/dev/pci/hifn7751.c
diff -u src/sys/dev/pci/hifn7751.c:1.62 src/sys/dev/pci/hifn7751.c:1.63
--- src/sys/dev/pci/hifn7751.c:1.62	Fri Oct  5 05:37:49 2018
+++ src/sys/dev/pci/hifn7751.c	Thu Dec 27 14:03:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: hifn7751.c,v 1.62 2018/10/05 05:37:49 msaitoh Exp $	*/
+/*	$NetBSD: hifn7751.c,v 1.63 2018/12/27 14:03:54 maxv Exp $	*/
 /*	$FreeBSD: hifn7751.c,v 1.5.2.7 2003/10/08 23:52:00 sam Exp $ */
 /*	$OpenBSD: hifn7751.c,v 1.140 2003/08/01 17:55:54 deraadt Exp $	*/
 
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.62 2018/10/05 05:37:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.63 2018/12/27 14:03:54 maxv Exp $");
 
 #include 
 #include 
@@ -82,7 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v
 #undef HIFN_DEBUG
 
 #ifdef __NetBSD__
-#define M_DUP_PKTHDR M_COPY_PKTHDR	/* XXX */
+#define M_DUP_PKTHDR m_copy_pkthdr	/* XXX */
 #endif
 
 #ifdef HIFN_DEBUG

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.229 src/sys/kern/uipc_mbuf.c:1.230
--- src/sys/kern/uipc_mbuf.c:1.229	Sat Dec 22 14:28:56 2018
+++ src/sys/kern/uipc_mbuf.c	Thu Dec 27 14:03:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.229 2018/12/22 14:28:56 maxv Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.230 2018/12/27 14:03:55 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2001, 2018 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.229 2018/12/22 14:28:56 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.230 2018/12/27 14:03:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -1279,7 +1279,7 @@ m_split_internal(struct mbuf *m0, int le
 
 		if (remain > MHLEN) {
 			/* m can't be the lead packet */
-			MH_ALIGN(n, 0);
+			m_align(n, 0);
 			n->m_len = 0;
 			n->m_next = m_split(m, len, wait);
 			if (n->m_next == NULL) {
@@ -1289,7 +1289,7 @@ m_split_internal(struct mbuf *m0, int le
 			}
 			return n;
 		} else {
-			MH_ALIGN(n, remain);
+			m_align(n, remain);
 		}
 	} else if (remain == 0) {
 		n = m->m_next;

Index: src/sys/netmpls/mpls_ttl.c
diff -u src/sys/netmpls/mpls_ttl.c:1.14 src/sys/netmpls/mpls_ttl.c:1.15
--- src/sys/netmpls/mpls_ttl.c:1.14	Mon Sep  3 16:29:36 2018
+++ src/sys/netmpls/mpls_ttl.c	Thu Dec 27 14:03:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpls_ttl.c,v 1.14 2018/09/03 16:29:36 riastradh Exp $ */
+/*	$NetBSD: mpls_ttl.c,v 1.15 2018/12/27 14:03:55 maxv Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpls_ttl.c,v 1.14 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpls_ttl.c,v 1.15 2018/12/27 14:03:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -250,7 +250,7 @@ mpls_icmp_error(struct mbuf *n, int type
 	MCLAIM(m, n->m_owner);
 	m->m_len = packetlen;
 	if ((m->m_flags & M_EXT) == 0)
-		MH_ALIGN(m, m->m_len);
+		m_align(m, m->m_len);
 	m->m_data += sizeof(struct ip);
 	m->m_len -= sizeof(struct ip);
 

Index: src/sys/sys/mbuf.h
diff -u src/sys/sys/mbuf.h:1.216 src/sys/sys/mbuf.h:1.217
--- src/sys/sys/mbuf.h:1.216	Sat Dec 22 13:55:56 2018
+++ src/sys/sys/mbuf.h	Thu Dec 27 14:03:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.h,v 1.216 2018/12/22 13:55:56 maxv Exp $	*/
+/*	$NetBSD: mbuf.h,v 1.217 2018/12/27 14:03:55 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -514,12 +514,6 @@ do {	\
 		(m)->m_data = (m)->m_dat;\
 } while (/* CONSTCOND */ 0)
 
-#define	M_COPY_PKTHDR(to, from)	m_copy_pkthdr(to, from)
-#define	M_MOVE_PKTHDR(to, from)	m_move_pkthdr(to, from)
-
-#define M_ALIGN(m, len)		m_align(m, len)
-#define MH_ALIGN(m, len)	m_align(m, len)
-
 /*
  * Determine if an mbuf's data area is read-only.  This is true
  * if external storage is read-only mapped, or not marked as R/W,



CVS commit: src/sys

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 14:03:55 UTC 2018

Modified Files:
src/sys/dev/pci: hifn7751.c
src/sys/kern: uipc_mbuf.c
src/sys/netmpls: mpls_ttl.c
src/sys/sys: mbuf.h

Log Message:
Remove M_COPY_PKTHDR, M_MOVE_PKTHDR, M_ALIGN and MH_ALIGN.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/dev/pci/hifn7751.c
cvs rdiff -u -r1.229 -r1.230 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.14 -r1.15 src/sys/netmpls/mpls_ttl.c
cvs rdiff -u -r1.216 -r1.217 src/sys/sys/mbuf.h

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



CVS commit: [netbsd-8] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:21:08 UTC 2018

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

Log Message:
Tickets #1146 - #1148


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.81 -r1.1.2.82 src/doc/CHANGES-8.1

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.1
diff -u src/doc/CHANGES-8.1:1.1.2.81 src/doc/CHANGES-8.1:1.1.2.82
--- src/doc/CHANGES-8.1:1.1.2.81	Wed Dec 26 13:19:54 2018
+++ src/doc/CHANGES-8.1	Thu Dec 27 12:21:08 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.1,v 1.1.2.81 2018/12/26 13:19:54 martin Exp $
+# $NetBSD: CHANGES-8.1,v 1.1.2.82 2018/12/27 12:21:08 martin Exp $
 
 A complete list of changes from the NetBSD 8.0 release to the NetBSD 8.1
 release:
@@ -2109,4 +2109,19 @@ sys/external/bsd/ipf/netinet/fil.c		1.22
 	Fix missing braces.
 	[sevan, ticket #1144]
 
+sys/compat/netbsd32/netbsd32_netbsd.c		1.219
+
+	pset_create() takes a pointer so it needs special handling.
+	[mrg, ticket #1146]
+
+sys/arch/x86/include/specialreg.h		1.131 (patch)
+sys/arch/x86/x86/identcpu.c			1.81,1.82,1.84 (patch)
+
+	Disable ALTINST on VIA CPUs, it is unsafe.
+	[maxv, ticket #1148]
+
+sys/kern/kern_time.c1.191
+
+	Fix kernel info leak.
+	[maxv, ticket #1147]
 



CVS commit: [netbsd-8] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:21:08 UTC 2018

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

Log Message:
Tickets #1146 - #1148


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.81 -r1.1.2.82 src/doc/CHANGES-8.1

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



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

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:19:45 UTC 2018

Modified Files:
src/sys/kern [netbsd-8]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1147):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.189.8.2 -r1.189.8.3 src/sys/kern/kern_time.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/kern_time.c
diff -u src/sys/kern/kern_time.c:1.189.8.2 src/sys/kern/kern_time.c:1.189.8.3
--- src/sys/kern/kern_time.c:1.189.8.2	Fri Nov 30 10:28:46 2018
+++ src/sys/kern/kern_time.c	Thu Dec 27 12:19:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.189.8.2 2018/11/30 10:28:46 martin Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.189.8.3 2018/12/27 12:19:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.2 2018/11/30 10:28:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.189.8.3 2018/12/27 12:19:45 martin Exp $");
 
 #include 
 #include 
@@ -1068,6 +1068,7 @@ sys___getitimer50(struct lwp *l, const s
 	struct itimerval aitv;
 	int error;
 
+	memset(, 0, sizeof(aitv));
 	error = dogetitimer(p, SCARG(uap, which), );
 	if (error)
 		return error;



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

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:19:45 UTC 2018

Modified Files:
src/sys/kern [netbsd-8]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1147):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.189.8.2 -r1.189.8.3 src/sys/kern/kern_time.c

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



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

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:17:19 UTC 2018

Modified Files:
src/sys/arch/x86/include [netbsd-8]: specialreg.h
src/sys/arch/x86/x86 [netbsd-8]: identcpu.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1148):

sys/arch/x86/x86/identcpu.c: revision 1.81
sys/arch/x86/x86/identcpu.c: revision 1.82
sys/arch/x86/x86/identcpu.c: revision 1.84
sys/arch/x86/include/specialreg.h: revision 1.131

Declare the MSR_VIA_ACE values as macros, and use a consistent naming,
similar to the rest of the file.

I'm wondering if I'm not fixing a huge bug here. The ECX8 value we were
using was wrong: ECX8 is bit 1, not bit 0. Bit 0 is ALTINST, an alternate
ISA, which is now known to be backdoored.

So it looks like we were explicitly enabling the backdoor.

Not tested, because I don't have a VIA cpu.

 -

Merge the VIA detection code into cpu_probe_c3.

 -

Explicitly disable ALTINST on VIA, in case it isn't disabled by default
already (the 'VIA cpu backdoor').


To generate a diff of this commit:
cvs rdiff -u -r1.98.2.8 -r1.98.2.9 src/sys/arch/x86/include/specialreg.h
cvs rdiff -u -r1.55.2.5 -r1.55.2.6 src/sys/arch/x86/x86/identcpu.c

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

Modified files:

Index: src/sys/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.98.2.8 src/sys/arch/x86/include/specialreg.h:1.98.2.9
--- src/sys/arch/x86/include/specialreg.h:1.98.2.8	Tue Dec  4 11:52:57 2018
+++ src/sys/arch/x86/include/specialreg.h	Thu Dec 27 12:17:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.98.2.8 2018/12/04 11:52:57 martin Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.98.2.9 2018/12/27 12:17:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -871,7 +871,9 @@
 #define MSR_VIA_RNG_NOISE_B	0x0100
 #define MSR_VIA_RNG_2NOISE	0x0300
 #define MSR_VIA_ACE		0x1107
-#define MSR_VIA_ACE_ENABLE	0x1000
+#define 	VIA_ACE_ALTINST	0x0001
+#define 	VIA_ACE_ECX8	0x0002
+#define 	VIA_ACE_ENABLE	0x1000
 
 /*
  * VIA "Eden" MSRs

Index: src/sys/arch/x86/x86/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.55.2.5 src/sys/arch/x86/x86/identcpu.c:1.55.2.6
--- src/sys/arch/x86/x86/identcpu.c:1.55.2.5	Fri Jul 13 15:51:28 2018
+++ src/sys/arch/x86/x86/identcpu.c	Thu Dec 27 12:17:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.55.2.5 2018/07/13 15:51:28 martin Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.55.2.6 2018/12/27 12:17:19 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.55.2.5 2018/07/13 15:51:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.55.2.6 2018/12/27 12:17:19 martin Exp $");
 
 #include "opt_xen.h"
 
@@ -482,32 +482,13 @@ static void
 cpu_probe_winchip(struct cpu_info *ci)
 {
 
-	if (cpu_vendor != CPUVENDOR_IDT)
+	if (cpu_vendor != CPUVENDOR_IDT ||
+	CPUID_TO_FAMILY(ci->ci_signature) != 5)
 		return;
 
-	switch (CPUID_TO_FAMILY(ci->ci_signature)) {
-	case 5:
-		/* WinChip C6 */
-		if (CPUID_TO_MODEL(ci->ci_signature) == 4)
-			ci->ci_feat_val[0] &= ~CPUID_TSC;
-		break;
-	case 6:
-		/*
-		 * VIA Eden ESP 
-		 *
-		 * Quoting from page 3-4 of: "VIA Eden ESP Processor Datasheet"
-		 * http://www.via.com.tw/download/mainboards/6/14/Eden20v115.pdf
-		 * 
-		 * 1. The CMPXCHG8B instruction is provided and always enabled,
-		 *however, it appears disabled in the corresponding CPUID
-		 *function bit 0 to avoid a bug in an early version of
-		 *Windows NT. However, this default can be changed via a
-		 *bit in the FCR MSR.
-		 */
-		ci->ci_feat_val[0] |= CPUID_CX8;
-		wrmsr(MSR_VIA_FCR, rdmsr(MSR_VIA_FCR) | 0x0001);
-		break;
-	}
+	/* WinChip C6 */
+	if (CPUID_TO_MODEL(ci->ci_signature) == 4)
+		ci->ci_feat_val[0] &= ~CPUID_TSC;
 }
 
 static void
@@ -528,8 +509,25 @@ cpu_probe_c3(struct cpu_info *ci)
 	x86_cpuid(0x8000, descs);
 	lfunc = descs[0];
 
+	if (family == 6) {
+		/*
+		 * VIA Eden ESP.
+		 *
+		 * Quoting from page 3-4 of: "VIA Eden ESP Processor Datasheet"
+		 * http://www.via.com.tw/download/mainboards/6/14/Eden20v115.pdf
+		 * 
+		 * 1. The CMPXCHG8B instruction is provided and always enabled,
+		 *however, it appears disabled in the corresponding CPUID
+		 *function bit 0 to avoid a bug in an early version of
+		 *Windows NT. However, this default can be changed via a
+		 *bit in the FCR MSR.
+		 */
+		ci->ci_feat_val[0] |= CPUID_CX8;
+		wrmsr(MSR_VIA_FCR, rdmsr(MSR_VIA_FCR) | VIA_ACE_ECX8);
+	}
+
 	if (family > 6 || model > 0x9 || (model == 0x9 && stepping >= 3)) {
-		/* Nehemiah or Esther */
+		/* VIA Nehemiah or Esther. */
 		x86_cpuid(0xc000, descs);
 		lfunc = descs[0];
 		if (lfunc >= 0xc001) {	/* has ACE, RNG */
@@ -598,12 +596,17 @@ 

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

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:17:19 UTC 2018

Modified Files:
src/sys/arch/x86/include [netbsd-8]: specialreg.h
src/sys/arch/x86/x86 [netbsd-8]: identcpu.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1148):

sys/arch/x86/x86/identcpu.c: revision 1.81
sys/arch/x86/x86/identcpu.c: revision 1.82
sys/arch/x86/x86/identcpu.c: revision 1.84
sys/arch/x86/include/specialreg.h: revision 1.131

Declare the MSR_VIA_ACE values as macros, and use a consistent naming,
similar to the rest of the file.

I'm wondering if I'm not fixing a huge bug here. The ECX8 value we were
using was wrong: ECX8 is bit 1, not bit 0. Bit 0 is ALTINST, an alternate
ISA, which is now known to be backdoored.

So it looks like we were explicitly enabling the backdoor.

Not tested, because I don't have a VIA cpu.

 -

Merge the VIA detection code into cpu_probe_c3.

 -

Explicitly disable ALTINST on VIA, in case it isn't disabled by default
already (the 'VIA cpu backdoor').


To generate a diff of this commit:
cvs rdiff -u -r1.98.2.8 -r1.98.2.9 src/sys/arch/x86/include/specialreg.h
cvs rdiff -u -r1.55.2.5 -r1.55.2.6 src/sys/arch/x86/x86/identcpu.c

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



CVS commit: [netbsd-8] src/sys/compat/netbsd32

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:04:09 UTC 2018

Modified Files:
src/sys/compat/netbsd32 [netbsd-8]: netbsd32_netbsd.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1146):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.219

pset_create() takes a pointer so it needs special handling.


To generate a diff of this commit:
cvs rdiff -u -r1.206.2.1 -r1.206.2.2 \
src/sys/compat/netbsd32/netbsd32_netbsd.c

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

Modified files:

Index: src/sys/compat/netbsd32/netbsd32_netbsd.c
diff -u src/sys/compat/netbsd32/netbsd32_netbsd.c:1.206.2.1 src/sys/compat/netbsd32/netbsd32_netbsd.c:1.206.2.2
--- src/sys/compat/netbsd32/netbsd32_netbsd.c:1.206.2.1	Tue Dec 25 11:19:52 2018
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c	Thu Dec 27 12:04:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_netbsd.c,v 1.206.2.1 2018/12/25 11:19:52 martin Exp $	*/
+/*	$NetBSD: netbsd32_netbsd.c,v 1.206.2.2 2018/12/27 12:04:09 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.206.2.1 2018/12/25 11:19:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.206.2.2 2018/12/27 12:04:09 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -2837,8 +2837,11 @@ netbsd32_pset_create(struct lwp *l,
 	/* {
 		syscallarg(netbsd32_psetidp_t) psid;
 	}; */
+	struct sys_pset_create_args ua;
 
-	return sys_pset_create(l, (const void *)uap, retval);
+	NETBSD32TOP_UAP(psid, psetid_t);
+
+	return sys_pset_create(l, , retval);
 }
 
 int



CVS commit: [netbsd-8] src/sys/compat/netbsd32

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:04:09 UTC 2018

Modified Files:
src/sys/compat/netbsd32 [netbsd-8]: netbsd32_netbsd.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1146):

sys/compat/netbsd32/netbsd32_netbsd.c: revision 1.219

pset_create() takes a pointer so it needs special handling.


To generate a diff of this commit:
cvs rdiff -u -r1.206.2.1 -r1.206.2.2 \
src/sys/compat/netbsd32/netbsd32_netbsd.c

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



CVS commit: [netbsd-7-0] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:02:18 UTC 2018

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

Log Message:
Ticket #1667


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.124 -r1.1.2.125 src/doc/CHANGES-7.0.3

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



CVS commit: [netbsd-7-0] src/sys/kern

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:01:50 UTC 2018

Modified Files:
src/sys/kern [netbsd-7-0]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1667):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.179.12.3 -r1.179.12.4 src/sys/kern/kern_time.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/kern_time.c
diff -u src/sys/kern/kern_time.c:1.179.12.3 src/sys/kern/kern_time.c:1.179.12.4
--- src/sys/kern/kern_time.c:1.179.12.3	Fri Dec 14 12:07:54 2018
+++ src/sys/kern/kern_time.c	Thu Dec 27 12:01:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.179.12.3 2018/12/14 12:07:54 martin Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.179.12.4 2018/12/27 12:01:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.179.12.3 2018/12/14 12:07:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.179.12.4 2018/12/27 12:01:50 martin Exp $");
 
 #include 
 #include 
@@ -1030,6 +1030,7 @@ sys___getitimer50(struct lwp *l, const s
 	struct itimerval aitv;
 	int error;
 
+	memset(, 0, sizeof(aitv));
 	error = dogetitimer(p, SCARG(uap, which), );
 	if (error)
 		return error;



CVS commit: [netbsd-7-0] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:02:18 UTC 2018

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

Log Message:
Ticket #1667


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.124 -r1.1.2.125 src/doc/CHANGES-7.0.3

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.0.3
diff -u src/doc/CHANGES-7.0.3:1.1.2.124 src/doc/CHANGES-7.0.3:1.1.2.125
--- src/doc/CHANGES-7.0.3:1.1.2.124	Tue Dec 25 11:34:48 2018
+++ src/doc/CHANGES-7.0.3	Thu Dec 27 12:02:18 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.0.3,v 1.1.2.124 2018/12/25 11:34:48 martin Exp $
+# $NetBSD: CHANGES-7.0.3,v 1.1.2.125 2018/12/27 12:02:18 martin Exp $
 
 A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3
 release:
@@ -5637,4 +5637,8 @@ sys/compat/netbsd32/netbsd32_netbsd.c		(
 	Fix kernel info leak in swapctl(2).
 	[maxv, ticket #1666]
 
+sys/kern/kern_time.c1.191
+
+	Fix kernel info leak.
+	[maxv, ticket #1667]
 



CVS commit: [netbsd-7-0] src/sys/kern

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:01:50 UTC 2018

Modified Files:
src/sys/kern [netbsd-7-0]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1667):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.179.12.3 -r1.179.12.4 src/sys/kern/kern_time.c

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



CVS commit: [netbsd-7-1] src/sys/kern

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:01:06 UTC 2018

Modified Files:
src/sys/kern [netbsd-7-1]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1667):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.179.8.1.4.2 -r1.179.8.1.4.3 src/sys/kern/kern_time.c

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



CVS commit: [netbsd-7-1] src/sys/kern

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:01:06 UTC 2018

Modified Files:
src/sys/kern [netbsd-7-1]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1667):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.179.8.1.4.2 -r1.179.8.1.4.3 src/sys/kern/kern_time.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/kern_time.c
diff -u src/sys/kern/kern_time.c:1.179.8.1.4.2 src/sys/kern/kern_time.c:1.179.8.1.4.3
--- src/sys/kern/kern_time.c:1.179.8.1.4.2	Fri Dec 14 12:06:43 2018
+++ src/sys/kern/kern_time.c	Thu Dec 27 12:01:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.179.8.1.4.2 2018/12/14 12:06:43 martin Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.179.8.1.4.3 2018/12/27 12:01:06 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.179.8.1.4.2 2018/12/14 12:06:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.179.8.1.4.3 2018/12/27 12:01:06 martin Exp $");
 
 #include 
 #include 
@@ -1030,6 +1030,7 @@ sys___getitimer50(struct lwp *l, const s
 	struct itimerval aitv;
 	int error;
 
+	memset(, 0, sizeof(aitv));
 	error = dogetitimer(p, SCARG(uap, which), );
 	if (error)
 		return error;



CVS commit: [netbsd-7-1] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:01:28 UTC 2018

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

Log Message:
Ticket #1667


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.31 -r1.1.2.32 src/doc/CHANGES-7.1.3

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



CVS commit: [netbsd-7-1] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:01:28 UTC 2018

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

Log Message:
Ticket #1667


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.31 -r1.1.2.32 src/doc/CHANGES-7.1.3

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.1.3
diff -u src/doc/CHANGES-7.1.3:1.1.2.31 src/doc/CHANGES-7.1.3:1.1.2.32
--- src/doc/CHANGES-7.1.3:1.1.2.31	Tue Dec 25 11:33:54 2018
+++ src/doc/CHANGES-7.1.3	Thu Dec 27 12:01:28 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.1.3,v 1.1.2.31 2018/12/25 11:33:54 martin Exp $
+# $NetBSD: CHANGES-7.1.3,v 1.1.2.32 2018/12/27 12:01:28 martin Exp $
 
 A complete list of changes from the NetBSD 7.1.2 release to the NetBSD 7.1.3
 release:
@@ -329,3 +329,8 @@ sys/compat/netbsd32/netbsd32_netbsd.c		(
 	Fix kernel info leak in swapctl(2).
 	[maxv, ticket #1666]
 
+sys/kern/kern_time.c1.191
+
+	Fix kernel info leak.
+	[maxv, ticket #1667]
+



CVS commit: [netbsd-7] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:00:43 UTC 2018

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

Log Message:
Ticket #1667


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.27 -r1.1.2.28 src/doc/CHANGES-7.3

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.3
diff -u src/doc/CHANGES-7.3:1.1.2.27 src/doc/CHANGES-7.3:1.1.2.28
--- src/doc/CHANGES-7.3:1.1.2.27	Tue Dec 25 11:33:02 2018
+++ src/doc/CHANGES-7.3	Thu Dec 27 12:00:42 2018
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.3,v 1.1.2.27 2018/12/25 11:33:02 martin Exp $
+# $NetBSD: CHANGES-7.3,v 1.1.2.28 2018/12/27 12:00:42 martin Exp $
 
 A complete list of changes from the NetBSD 7.2 release to the NetBSD 7.3
 release:
@@ -342,3 +342,8 @@ sys/compat/netbsd32/netbsd32_netbsd.c		(
 	Fix kernel info leak in swapctl(2).
 	[maxv, ticket #1666]
 
+sys/kern/kern_time.c1.191
+
+	Fix kernel info leak.
+	[maxv, ticket #1667]
+



CVS commit: [netbsd-7] src/doc

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:00:43 UTC 2018

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

Log Message:
Ticket #1667


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.27 -r1.1.2.28 src/doc/CHANGES-7.3

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



CVS commit: [netbsd-7] src/sys/kern

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:00:10 UTC 2018

Modified Files:
src/sys/kern [netbsd-7]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1667):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.179.8.3 -r1.179.8.4 src/sys/kern/kern_time.c

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



CVS commit: [netbsd-7] src/sys/kern

2018-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 27 12:00:10 UTC 2018

Modified Files:
src/sys/kern [netbsd-7]: kern_time.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1667):

sys/kern/kern_time.c: revision 1.191

Fix kernel info leak. There are 2x4 bytes of padding in struct itimerval.

[  738.451860] kleak: Possible leak in copyout: [len=32, leaked=8]
[  738.481840] #0 0x80b7c42a in kleak_note 
[  738.491821] #1 0x80b7c4aa in kleak_copyout 
[  738.501806] #2 0x80b6154e in sys___getitimer50 
[  738.511778] #3 0x80b61e39 in sys___setitimer50 
[  738.521781] #4 0x8025ab3c in sy_call 
[  738.521781] #5 0x8025ad6e in sy_invoke 
[  738.531808] #6 0x8025adf4 in syscall 


To generate a diff of this commit:
cvs rdiff -u -r1.179.8.3 -r1.179.8.4 src/sys/kern/kern_time.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/kern_time.c
diff -u src/sys/kern/kern_time.c:1.179.8.3 src/sys/kern/kern_time.c:1.179.8.4
--- src/sys/kern/kern_time.c:1.179.8.3	Fri Dec 14 12:04:26 2018
+++ src/sys/kern/kern_time.c	Thu Dec 27 12:00:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.179.8.3 2018/12/14 12:04:26 martin Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.179.8.4 2018/12/27 12:00:10 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.179.8.3 2018/12/14 12:04:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.179.8.4 2018/12/27 12:00:10 martin Exp $");
 
 #include 
 #include 
@@ -1030,6 +1030,7 @@ sys___getitimer50(struct lwp *l, const s
 	struct itimerval aitv;
 	int error;
 
+	memset(, 0, sizeof(aitv));
 	error = dogetitimer(p, SCARG(uap, which), );
 	if (error)
 		return error;



CVS commit: src/doc

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 10:09:56 UTC 2018

Modified Files:
src/doc: CHANGES

Log Message:
note kernel crash dumps for arm64.


To generate a diff of this commit:
cvs rdiff -u -r1.2473 -r1.2474 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/CHANGES
diff -u src/doc/CHANGES:1.2473 src/doc/CHANGES:1.2474
--- src/doc/CHANGES:1.2473	Thu Dec 27 04:54:03 2018
+++ src/doc/CHANGES	Thu Dec 27 10:09:56 2018
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2473 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2474 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -273,3 +273,4 @@ Changes from NetBSD 8.0 to NetBSD 9.0:
 	threadpool(9): Added threadpool(9) API. [thorpej 20181224]
 	systat(1): Extend vmstat display for better insight about bufcache.
 		[sevan 20181226]
+	arm: Support kernel crash dumps on 64 bit platforms.  [mrg 20181227]



CVS commit: src/doc

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 10:09:56 UTC 2018

Modified Files:
src/doc: CHANGES

Log Message:
note kernel crash dumps for arm64.


To generate a diff of this commit:
cvs rdiff -u -r1.2473 -r1.2474 src/doc/CHANGES

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



CVS commit: src/sys/compat

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 09:57:16 UTC 2018

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_14.c netbsd32_conv.h
src/sys/compat/sys: msg.h

Log Message:
Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0x80bad7a7 in kleak_copyout
| #1 0x8048e71b in netbsd32___msgctl50
| #2 0x8022fb5b in netbsd32_syscall
| #3 0x802096dd in handle_syscall


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.36 -r1.37 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/sys/msg.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/compat/netbsd32/netbsd32_compat_14.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_14.c:1.26 src/sys/compat/netbsd32/netbsd32_compat_14.c:1.27
--- src/sys/compat/netbsd32/netbsd32_compat_14.c:1.26	Thu Jan  7 21:58:28 2016
+++ src/sys/compat/netbsd32/netbsd32_compat_14.c	Thu Dec 27 09:57:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_14.c,v 1.26 2016/01/07 21:58:28 joerg Exp $	*/
+/*	$NetBSD: netbsd32_compat_14.c,v 1.27 2018/12/27 09:57:16 maxv Exp $	*/
 
 /*
  * Copyright (c) 1999 Eduardo E. Horvath
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_14.c,v 1.26 2016/01/07 21:58:28 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_14.c,v 1.27 2018/12/27 09:57:16 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -107,6 +107,7 @@ static inline void
 native_to_netbsd32_msqid_ds14(struct msqid_ds *msqbuf, struct netbsd32_msqid_ds14 *omsqbuf)
 {
 
+	memset(omsqbuf, 0, sizeof(*omsqbuf));
 	native_to_netbsd32_ipc_perm14(>msg_perm, >msg_perm);
 
 #define	CVT(x)	omsqbuf->x = msqbuf->x

Index: src/sys/compat/netbsd32/netbsd32_conv.h
diff -u src/sys/compat/netbsd32/netbsd32_conv.h:1.36 src/sys/compat/netbsd32/netbsd32_conv.h:1.37
--- src/sys/compat/netbsd32/netbsd32_conv.h:1.36	Sun Nov 25 17:58:29 2018
+++ src/sys/compat/netbsd32/netbsd32_conv.h	Thu Dec 27 09:57:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_conv.h,v 1.36 2018/11/25 17:58:29 mlelstv Exp $	*/
+/*	$NetBSD: netbsd32_conv.h,v 1.37 2018/12/27 09:57:16 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -555,6 +555,7 @@ netbsd32_from_msqid_ds50(const struct ms
 struct netbsd32_msqid_ds50 *ds32p)
 {
 
+	memset(ds32p, 0, sizeof(*ds32p));
 	netbsd32_from_ipc_perm(>msg_perm, >msg_perm);
 	ds32p->_msg_cbytes = (netbsd32_u_long)dsp->_msg_cbytes;
 	ds32p->msg_qnum = (netbsd32_u_long)dsp->msg_qnum;
@@ -571,6 +572,7 @@ netbsd32_from_msqid_ds(const struct msqi
 struct netbsd32_msqid_ds *ds32p)
 {
 
+	memset(ds32p, 0, sizeof(*ds32p));
 	netbsd32_from_ipc_perm(>msg_perm, >msg_perm);
 	ds32p->_msg_cbytes = (netbsd32_u_long)dsp->_msg_cbytes;
 	ds32p->msg_qnum = (netbsd32_u_long)dsp->msg_qnum;

Index: src/sys/compat/sys/msg.h
diff -u src/sys/compat/sys/msg.h:1.4 src/sys/compat/sys/msg.h:1.5
--- src/sys/compat/sys/msg.h:1.4	Mon Jan 19 19:39:41 2009
+++ src/sys/compat/sys/msg.h	Thu Dec 27 09:57:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg.h,v 1.4 2009/01/19 19:39:41 christos Exp $	*/
+/*	$NetBSD: msg.h,v 1.5 2018/12/27 09:57:16 maxv Exp $	*/
 
 /*
  * SVID compatible msg.h file
@@ -108,6 +108,7 @@ static __inline void
 __native_to_msqid_ds13(const struct msqid_ds *msqbuf, struct msqid_ds13 *omsqbuf)
 {
 
+	memset(omsqbuf, 0, sizeof(*omsqbuf));
 	omsqbuf->msg_perm = msqbuf->msg_perm;
 
 #define	CVT(x)	omsqbuf->x = msqbuf->x
@@ -149,6 +150,7 @@ static __inline void
 __native_to_msqid_ds14(const struct msqid_ds *msqbuf, struct msqid_ds14 *omsqbuf)
 {
 
+	memset(omsqbuf, 0, sizeof(*omsqbuf));
 	__native_to_ipc_perm14(>msg_perm, >msg_perm);
 
 #define	CVT(x)	omsqbuf->x = msqbuf->x



CVS commit: src/sys/compat

2018-12-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 09:57:16 UTC 2018

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_14.c netbsd32_conv.h
src/sys/compat/sys: msg.h

Log Message:
Fix kernel info leaks.

+ Possible info leak: [len=80, leaked=10]
| #0 0x80bad7a7 in kleak_copyout
| #1 0x8048e71b in netbsd32___msgctl50
| #2 0x8022fb5b in netbsd32_syscall
| #3 0x802096dd in handle_syscall


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/compat/netbsd32/netbsd32_compat_14.c
cvs rdiff -u -r1.36 -r1.37 src/sys/compat/netbsd32/netbsd32_conv.h
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/sys/msg.h

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



CVS commit: src

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 09:55:27 UTC 2018

Modified Files:
src/external/gpl3/gdb/dist/gdb: aarch64-nbsd-nat.c
src/sys/arch/aarch64/aarch64: aarch64_machdep.c cpuswitch.S
db_machdep.c db_trace.c genassym.cf vm_machdep.c
src/sys/arch/aarch64/include: pcb.h proc.h

Log Message:
make savecore for arm64 basically work.

- move MD lwp "md_ktf" member into struct pcb.  the pcb is used by
  the gdb "bsd-kvm" target code to find the stack of each thread
  and needs to be available in a well known location.
- implement aarch64_nbsd_supply_pcb() in GDB.  makes basic gdb work
  on a crash dump.
- remove '#if L_MD_KTF + 8 == L_MD_CPACR' conditional code, as there
  is no more L_MD_KTF.

with this gdb has minimal working functionality with "target kvm",
and crash can at least "ps" on a crash dump.

ok skrll.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/cpuswitch.S
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/db_machdep.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/db_trace.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/vm_machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/pcb.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/include/proc.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/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c
diff -u src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c:1.1 src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c:1.2
--- src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c:1.1	Mon May 21 02:10:47 2018
+++ src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c	Thu Dec 27 09:55:27 2018
@@ -22,7 +22,9 @@
 
 #include 
 #include 
-#include 
+
+#include 
+#include 
 
 #include "nbsd-nat.h"
 #include "aarch64-tdep.h"
@@ -124,6 +126,50 @@ aarch64_nbsd_store_inferior_registers (s
 }
 }
 
+static int
+aarch64_nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
+{
+  struct trapframe tf;
+  int i;
+
+  /* The following is true for NetBSD/arm64:
+
+ The pcb contains the frame pointer at the point of the context
+ switch in cpu_switchto().  At that point we have a stack frame as
+ described by `struct trapframe', which has the following layout:
+
+ x0..x30
+ sp
+ pc
+ spsr
+ tpidr
+
+ This accounts for all callee-saved registers specified by the psABI.
+ From this information we reconstruct the register state as it would
+ look when we just returned from cpu_switchto().
+
+ For kernel core dumps, dumpsys() builds a fake trapframe for us. */
+
+  /* The trapframe pointer shouldn't be zero.  */
+  if (pcb->pcb_tf == 0)
+return 0;
+
+  /* Read the stack frame, and check its validity.  */
+  read_memory ((uintptr_t)pcb->pcb_tf, (gdb_byte *) , sizeof tf);
+
+  for (i = 0; i <= 30; i++)
+{
+  regcache_raw_supply (regcache, AARCH64_X0_REGNUM + i, _reg[i]);
+}
+  regcache_raw_supply (regcache, AARCH64_SP_REGNUM, _sp);
+  regcache_raw_supply (regcache, AARCH64_PC_REGNUM, _pc);
+
+  regcache_raw_supply (regcache, AARCH64_FPCR_REGNUM, >pcb_fpregs.fpcr);
+  regcache_raw_supply (regcache, AARCH64_FPSR_REGNUM, >pcb_fpregs.fpsr);
+
+  return 1;
+}
+
 void
 _initialize_aarch64_nbsd_nat (void)
 {
@@ -133,4 +179,7 @@ _initialize_aarch64_nbsd_nat (void)
   t->to_fetch_registers = aarch64_nbsd_fetch_inferior_registers;
   t->to_store_registers = aarch64_nbsd_store_inferior_registers;
   nbsd_nat_add_target (t);
+
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (aarch64_nbsd_supply_pcb);
 }

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.23 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.24
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.23	Wed Nov 28 09:16:19 2018
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Thu Dec 27 09:55:27 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.23 2018/11/28 09:16:19 ryo Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.24 2018/12/27 09:55:27 mrg Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.23 2018/11/28 09:16:19 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.24 2018/12/27 09:55:27 mrg Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -199,6 +199,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	extern char _end[];
 	extern char lwp0uspace[];
 
+	struct pcb *pcb;
 	struct trapframe *tf;
 	psize_t memsize_total;
 	vaddr_t kernstart, kernend;
@@ -374,12 +375,13 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	 */
 	

CVS commit: src

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 09:55:27 UTC 2018

Modified Files:
src/external/gpl3/gdb/dist/gdb: aarch64-nbsd-nat.c
src/sys/arch/aarch64/aarch64: aarch64_machdep.c cpuswitch.S
db_machdep.c db_trace.c genassym.cf vm_machdep.c
src/sys/arch/aarch64/include: pcb.h proc.h

Log Message:
make savecore for arm64 basically work.

- move MD lwp "md_ktf" member into struct pcb.  the pcb is used by
  the gdb "bsd-kvm" target code to find the stack of each thread
  and needs to be available in a well known location.
- implement aarch64_nbsd_supply_pcb() in GDB.  makes basic gdb work
  on a crash dump.
- remove '#if L_MD_KTF + 8 == L_MD_CPACR' conditional code, as there
  is no more L_MD_KTF.

with this gdb has minimal working functionality with "target kvm",
and crash can at least "ps" on a crash dump.

ok skrll.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/cpuswitch.S
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/db_machdep.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/db_trace.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/vm_machdep.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/pcb.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/include/proc.h

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



Re: CVS commit: src

2018-12-27 Thread Maxime Villard

Le 27/12/2018 à 08:41, matthew green a écrit :

"Maxime Villard" writes:

Module Name:src
Committed By:   maxv
Date:   Thu Dec 27 07:22:31 UTC 2018

Modified Files:
src/lib/libnvmm: libnvmm.3 libnvmm.c libnvmm_x86.c nvmm.h
src/tests/lib/libnvmm: h_mem_assist.c h_mem_assist_asm.S

Log Message:
Several improvements and fixes:

  * Change the Assist API. Rather than passing callbacks in each call, the
callbacks are now registered beforehand. Then change the I/O Assist to
fetch MMIO data via the Mem callback. This allows a guest to perform an
I/O string operation on a memory that is itself an MMIO.


this should have included a shlib bump i guess - there was
at least one function signature change.

thanks.


Well, I think I've done that several times already. Basically, given that
I keep changing the design, I don't want to bump the versions each time.
They will be bumped starting from NetBSD 9.


CVS commit: src/sys/dev/pci

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 08:13:50 UTC 2018

Modified Files:
src/sys/dev/pci: if_msk.c if_mskvar.h

Log Message:
- initialise sk_rx_hiaddr and sk_tx_hiaddr
- use MSK_ADDR_LO() and MSK_ADDR_HI()
- expand a debug message
- remove unused softc members


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/if_mskvar.h

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

Modified files:

Index: src/sys/dev/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.81 src/sys/dev/pci/if_msk.c:1.82
--- src/sys/dev/pci/if_msk.c:1.81	Sat Dec  8 13:31:31 2018
+++ src/sys/dev/pci/if_msk.c	Thu Dec 27 08:13:50 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.81 2018/12/08 13:31:31 bouyer Exp $ */
+/* $NetBSD: if_msk.c,v 1.82 2018/12/27 08:13:50 mrg Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.81 2018/12/08 13:31:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.82 2018/12/27 08:13:50 mrg Exp $");
 
 #include 
 #include 
@@ -429,6 +429,7 @@ msk_init_rx_ring(struct sk_if_softc *sc_
 	sc_if->sk_cdata.sk_rx_prod = 0;
 	sc_if->sk_cdata.sk_rx_cons = 0;
 	sc_if->sk_cdata.sk_rx_cnt = 0;
+	sc_if->sk_cdata.sk_rx_hiaddr = 0;
 
 	/* Mark the first ring element to initialize the high address. */
 	sc_if->sk_cdata.sk_rx_hiaddr = 0;
@@ -484,6 +485,7 @@ msk_init_tx_ring(struct sk_if_softc *sc_
 	sc_if->sk_cdata.sk_tx_prod = 0;
 	sc_if->sk_cdata.sk_tx_cons = 0;
 	sc_if->sk_cdata.sk_tx_cnt = 0;
+	sc_if->sk_cdata.sk_tx_hiaddr = 0;
 
 	/* Mark the first ring element to initialize the high address. */
 	sc_if->sk_cdata.sk_tx_hiaddr = 0;
@@ -1022,9 +1024,9 @@ mskc_reset(struct sk_softc *sc)
 
 	sk_win_write_2(sc, SK_STAT_BMU_LIDX, MSK_STATUS_RING_CNT - 1);
 	sk_win_write_4(sc, SK_STAT_BMU_ADDRLO,
-	sc->sk_status_map->dm_segs[0].ds_addr);
+	MSK_ADDR_LO(sc->sk_status_map->dm_segs[0].ds_addr));
 	sk_win_write_4(sc, SK_STAT_BMU_ADDRHI,
-	(u_int64_t)sc->sk_status_map->dm_segs[0].ds_addr >> 32);
+	MSK_ADDR_HI(sc->sk_status_map->dm_segs[0].ds_addr));
 	if (sc->sk_type == SK_YUKON_EC &&
 	sc->sk_rev == SK_YUKON_EC_REV_A1) {
 		/* WA for dev. #4.3 */
@@ -1900,7 +1902,7 @@ msk_encap(struct sk_if_softc *sc_if, str
 
 	*txidx = frag;
 
-	DPRINTFN(2, ("msk_encap: completed successfully\n"));
+	DPRINTFN(2, ("msk_encap: successful: %u entries\n", entries));
 
 	return (0);
 }

Index: src/sys/dev/pci/if_mskvar.h
diff -u src/sys/dev/pci/if_mskvar.h:1.20 src/sys/dev/pci/if_mskvar.h:1.21
--- src/sys/dev/pci/if_mskvar.h:1.20	Sun Oct 21 00:51:12 2018
+++ src/sys/dev/pci/if_mskvar.h	Thu Dec 27 08:13:50 2018
@@ -1,5 +1,5 @@
 /*	$OpenBSD: if_mskvar.h,v 1.3 2006/12/28 16:34:42 kettenis Exp $	*/
-/*	$NetBSD: if_mskvar.h,v 1.20 2018/10/21 00:51:12 jmcneill Exp $	*/
+/*	$NetBSD: if_mskvar.h,v 1.21 2018/12/27 08:13:50 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -198,7 +198,6 @@ struct sk_softc {
 	u_int8_t		sk_fibertype;
 	u_int8_t		sk_type;
 	u_int8_t		sk_rev;
-	u_int32_t		sk_workaround;
 	u_int8_t		sk_macs;	/* # of MACs */
 	const char		*sk_name;
 	u_int32_t		sk_ramsize;	/* amount of RAM on NIC */



CVS commit: src/sys/dev/pci

2018-12-27 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Dec 27 08:13:50 UTC 2018

Modified Files:
src/sys/dev/pci: if_msk.c if_mskvar.h

Log Message:
- initialise sk_rx_hiaddr and sk_tx_hiaddr
- use MSK_ADDR_LO() and MSK_ADDR_HI()
- expand a debug message
- remove unused softc members


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/if_mskvar.h

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