CVS commit: src/sys/dev/dm

2019-12-06 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Sat Dec  7 06:26:31 UTC 2019

Modified Files:
src/sys/dev/dm: dm_pdev.c dm_table.c dm_target.c

Log Message:
dm: Simplify list eviction code

taken-from: DragonFlyBSD


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_pdev.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/dm/dm_table.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target.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/dm/dm_pdev.c
diff -u src/sys/dev/dm/dm_pdev.c:1.16 src/sys/dev/dm/dm_pdev.c:1.17
--- src/sys/dev/dm/dm_pdev.c:1.16	Fri Dec  6 16:46:14 2019
+++ src/sys/dev/dm/dm_pdev.c	Sat Dec  7 06:26:31 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $  */
+/*$NetBSD: dm_pdev.c,v 1.17 2019/12/07 06:26:31 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.17 2019/12/07 06:26:31 tkusumi Exp $");
 
 #include 
 #include 
@@ -188,16 +188,16 @@ dm_pdev_rem(dm_pdev_t * dmp)
 int
 dm_pdev_destroy(void)
 {
-	dm_pdev_t *dm_pdev;
+	dm_pdev_t *dmp;
 
 	mutex_enter(_pdev_mutex);
-	while (!SLIST_EMPTY(_pdev_list)) {	/* List Deletion. */
-		dm_pdev = SLIST_FIRST(_pdev_list);
-
-		SLIST_REMOVE_HEAD(_pdev_list, next_pdev);
 
-		dm_pdev_rem(dm_pdev);
+	while ((dmp = SLIST_FIRST(_pdev_list)) != NULL) {
+		SLIST_REMOVE(_pdev_list, dmp, dm_pdev, next_pdev);
+		dm_pdev_rem(dmp);
 	}
+	KASSERT(SLIST_EMPTY(_pdev_list));
+
 	mutex_exit(_pdev_mutex);
 
 	mutex_destroy(_pdev_mutex);

Index: src/sys/dev/dm/dm_table.c
diff -u src/sys/dev/dm/dm_table.c:1.10 src/sys/dev/dm/dm_table.c:1.11
--- src/sys/dev/dm/dm_table.c:1.10	Thu Dec  5 16:59:43 2019
+++ src/sys/dev/dm/dm_table.c	Sat Dec  7 06:26:31 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $  */
+/*$NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $");
 
 #include 
 #include 
@@ -160,15 +160,14 @@ dm_table_destroy(dm_table_head_t * head,
 
 	tbl = >tables[id];
 
-	while (!SLIST_EMPTY(tbl)) {	/* List Deletion. */
-		table_en = SLIST_FIRST(tbl);
+	while ((table_en = SLIST_FIRST(tbl)) != NULL) {
+		SLIST_REMOVE(tbl, table_en, dm_table_entry, next);
 		if (table_en->target->destroy(table_en) == 0)
 			table_en->target_config = NULL;
 
-		SLIST_REMOVE_HEAD(tbl, next);
-
 		kmem_free(table_en, sizeof(*table_en));
 	}
+	KASSERT(SLIST_EMPTY(tbl));
 
 	mutex_exit(>table_mtx);
 

Index: src/sys/dev/dm/dm_target.c
diff -u src/sys/dev/dm/dm_target.c:1.23 src/sys/dev/dm/dm_target.c:1.24
--- src/sys/dev/dm/dm_target.c:1.23	Fri Dec  6 16:11:59 2019
+++ src/sys/dev/dm/dm_target.c	Sat Dec  7 06:26:31 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $  */
+/*$NetBSD: dm_target.c,v 1.24 2019/12/07 06:26:31 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.24 2019/12/07 06:26:31 tkusumi Exp $");
 
 #include 
 #include 
@@ -220,14 +220,13 @@ dm_target_destroy(void)
 	dm_target_t *dm_target;
 
 	mutex_enter(_target_mutex);
-	while (TAILQ_FIRST(_target_list) != NULL) {
-		dm_target = TAILQ_FIRST(_target_list);
-
-		TAILQ_REMOVE(_target_list, TAILQ_FIRST(_target_list),
-		dm_target_next);
 
+	while ((dm_target = TAILQ_FIRST(_target_list)) != NULL) {
+		TAILQ_REMOVE(_target_list, dm_target, dm_target_next);
 		(void)kmem_free(dm_target, sizeof(dm_target_t));
 	}
+	KASSERT(TAILQ_EMPTY(_target_list));
+
 	mutex_exit(_target_mutex);
 
 	mutex_destroy(_target_mutex);



CVS commit: src/usr.sbin/mopd/common

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  7 04:55:01 UTC 2019

Modified Files:
src/usr.sbin/mopd/common: loop-linux2.c

Log Message:
Drop the advertising clause to match the other files.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/mopd/common/loop-linux2.c

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

Modified files:

Index: src/usr.sbin/mopd/common/loop-linux2.c
diff -u src/usr.sbin/mopd/common/loop-linux2.c:1.1 src/usr.sbin/mopd/common/loop-linux2.c:1.2
--- src/usr.sbin/mopd/common/loop-linux2.c:1.1	Tue Jun  7 21:11:49 2016
+++ src/usr.sbin/mopd/common/loop-linux2.c	Fri Dec  6 23:55:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: loop-linux2.c,v 1.1 2016/06/08 01:11:49 christos Exp $	*/
+/*	$NetBSD: loop-linux2.c,v 1.2 2019/12/07 04:55:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
@@ -11,11 +11,6 @@
  * 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.
- * 3. All advertising materials mentioning features or use of this software
- *must display the following acknowledgement:
- *	This product includes software developed by Mats O Jansson.
- * 4. The name of the author may not be used to endorse or promote products
- *derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -31,7 +26,7 @@
 
 #include "port.h"
 #ifndef lint
-__RCSID("$NetBSD: loop-linux2.c,v 1.1 2016/06/08 01:11:49 christos Exp $");
+__RCSID("$NetBSD: loop-linux2.c,v 1.2 2019/12/07 04:55:01 christos Exp $");
 #endif
 
 #include 



CVS commit: src/sys/arch/i386/stand/lib

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  7 02:29:03 UTC 2019

Modified Files:
src/sys/arch/i386/stand/lib: exec.c

Log Message:
loadfile sets errno, return the correct error, not EIO.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/i386/stand/lib/exec.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/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.74 src/sys/arch/i386/stand/lib/exec.c:1.75
--- src/sys/arch/i386/stand/lib/exec.c:1.74	Thu Sep 12 22:19:46 2019
+++ src/sys/arch/i386/stand/lib/exec.c	Fri Dec  6 21:29:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.74 2019/09/13 02:19:46 manu Exp $	 */
+/*	$NetBSD: exec.c,v 1.75 2019/12/07 02:29:03 christos Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -321,7 +321,7 @@ common_load_prekern(const char *file, u_
 	/* Load the prekern (static) */
 	flags = LOAD_KERNEL & ~(LOAD_HDR|LOAD_SYM);
 	if ((fd = loadfile(prekernpath, marks, flags)) == -1)
-		return EIO;
+		return errno;
 	close(fd);
 
 	prekern_start = marks[MARK_START];
@@ -334,7 +334,7 @@ common_load_prekern(const char *file, u_
 	/* Load the kernel (dynamic) */
 	flags = (LOAD_KERNEL | LOAD_DYN) & ~(floppy ? LOAD_BACKWARDS : 0);
 	if ((fd = loadfile(file, marks, flags)) == -1)
-		return EIO;
+		return errno;
 	close(fd);
 
 	kernpa_end = marks[MARK_END] - loadaddr;
@@ -399,7 +399,7 @@ common_load_kernel(const char *file, u_l
 		 */
 		marks[MARK_START] = loadaddr;
 		if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1)
-			return EIO;
+			return errno;
 		close(fd);
 
 		kernsize = marks[MARK_END];
@@ -413,7 +413,7 @@ common_load_kernel(const char *file, u_l
 	marks[MARK_START] = loadaddr;
 	if ((fd = loadfile(file, marks,
 	LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1)
-		return EIO;
+		return errno;
 
 	close(fd);
 



CVS commit: src/sys/dev/pci

2019-12-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Dec  7 01:00:40 UTC 2019

Modified Files:
src/sys/dev/pci: machfb.c

Log Message:
clean up the video mode selection logic, switch modes only when actually
necessary
while there make some debug output optional


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/dev/pci/machfb.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/pci/machfb.c
diff -u src/sys/dev/pci/machfb.c:1.97 src/sys/dev/pci/machfb.c:1.98
--- src/sys/dev/pci/machfb.c:1.97	Tue Feb  5 06:12:39 2019
+++ src/sys/dev/pci/machfb.c	Sat Dec  7 01:00:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machfb.c,v 1.97 2019/02/05 06:12:39 mrg Exp $	*/
+/*	$NetBSD: machfb.c,v 1.98 2019/12/07 01:00:40 macallan Exp $	*/
 
 /*
  * Copyright (c) 2002 Bang Jun-Young
@@ -34,7 +34,7 @@
 
 #include 
 __KERNEL_RCSID(0,
-	"$NetBSD: machfb.c,v 1.97 2019/02/05 06:12:39 mrg Exp $");
+	"$NetBSD: machfb.c,v 1.98 2019/12/07 01:00:40 macallan Exp $");
 
 #include 
 #include 
@@ -68,6 +68,12 @@ __KERNEL_RCSID(0,
 #include "opt_machfb.h"
 #include "opt_glyphcache.h"
 
+#ifdef MACHFB_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF while (0) printf
+#endif
+
 #define MACH64_REG_SIZE		0x800
 #define MACH64_REG_OFF		0x7ff800
 
@@ -140,6 +146,7 @@ struct mach64_softc {
 	int sc_edid_size;
 	uint8_t sc_edid_data[1024];
 	struct edid_info sc_ei;
+	int sc_setmode;
 
 	u_char sc_cmap_red[256];
 	u_char sc_cmap_green[256];
@@ -221,7 +228,9 @@ static void	mach64_init(struct mach64_so
 static int	mach64_get_memsize(struct mach64_softc *);
 static int	mach64_get_max_ramdac(struct mach64_softc *);
 
+#if 0
 static void	mach64_get_mode(struct mach64_softc *, struct videomode *);
+#endif
 
 static int	mach64_calc_crtcregs(struct mach64_softc *,
  struct mach64_crtcregs *,
@@ -408,7 +417,7 @@ mach64_attach(device_t parent, device_t 
 	const char **memtype_names;
 	struct wsemuldisplaydev_attach_args aa;
 	long defattr;
-	int setmode = 0, width, height;
+	int width = 1024, height = 768;
 	pcireg_t screg;
 	uint32_t reg;
 	const pcireg_t enables = PCI_COMMAND_MEM_ENABLE;
@@ -426,6 +435,7 @@ mach64_attach(device_t parent, device_t 
 	sc->sc_iot = pa->pa_iot;
 	sc->sc_accessops.ioctl = mach64_ioctl;
 	sc->sc_accessops.mmap = mach64_mmap;
+	sc->sc_setmode = 0;
 
 	pci_aprint_devinfo(pa, "Graphics processor");
 #ifdef MACHFB_DEBUG
@@ -498,6 +508,9 @@ mach64_attach(device_t parent, device_t 
 	prop_dictionary_get_uint32(device_properties(self), "width", );
 	prop_dictionary_get_uint32(device_properties(self), "height", );
 
+	default_mode.hdisplay = width;
+	default_mode.vdisplay = height;
+
 	memset(>sc_ei, 0, sizeof(sc->sc_ei));
 	if ((edid_data = prop_dictionary_get(device_properties(self), "EDID"))
 	!= NULL) {
@@ -513,7 +526,6 @@ mach64_attach(device_t parent, device_t 
 		edid_print(>sc_ei);
 #endif
 	}
-
 	is_gx = 0;
 	switch(mach64_chip_id) {
 		case PCI_PRODUCT_ATI_MACH64_GX:
@@ -561,9 +573,9 @@ mach64_attach(device_t parent, device_t 
 	aprint_debug("using clock %d\n", sc->sc_clock);
 
 	sc->ref_div = regrb_pll(sc, PLL_REF_DIV);
-	aprint_error("ref_div: %d\n", sc->ref_div);
+	DPRINTF("ref_div: %d\n", sc->ref_div);
 	sc->mclk_fb_div = regrb_pll(sc, MCLK_FB_DIV);
-	aprint_error("mclk_fb_div: %d\n", sc->mclk_fb_div);
+	DPRINTF("mclk_fb_div: %d\n", sc->mclk_fb_div);
 	sc->mem_freq = (2 * sc->ref_freq * sc->mclk_fb_div) /
 	(sc->ref_div * 2);
 	sc->mclk_post_div = (sc->mclk_fb_div * 2 * sc->ref_freq) /
@@ -572,7 +584,7 @@ mach64_attach(device_t parent, device_t 
 	{
 		sc->minref = sc->ramdac_freq / 510;
 		sc->m = sc->ref_freq / sc->minref;
-		aprint_error("minref: %d m: %d\n", sc->minref, sc->m);
+		DPRINTF("minref: %d m: %d\n", sc->minref, sc->m);
 	}
 	aprint_normal_dev(sc->sc_dev,
 	"%ld KB %s %d.%d MHz, maximum RAMDAC clock %d MHz\n",
@@ -604,10 +616,10 @@ mach64_attach(device_t parent, device_t 
 	aprint_debug("gen_cntl: %08x\n", regr(sc, CRTC_GEN_CNTL));
 
 #define MODE_IS_VALID(m) ((sc->ramdac_freq >= (m)->dot_clock) && \
-			  ((m)->hdisplay <= 11280))
+			  ((m)->hdisplay <= 1280))
 
 	/* no mode setting support on ancient chips with external clocks */
-	setmode = 0;
+	sc->sc_setmode = 0;
 	if (!is_gx) {
 		/*
 		 * Now pick a mode.
@@ -617,7 +629,7 @@ mach64_attach(device_t parent, device_t 
 			if (MODE_IS_VALID(m)) {
 memcpy(_mode, m,
 sizeof(struct videomode));
-setmode = 1;
+sc->sc_setmode = 1;
 			} else {
 aprint_error_dev(sc->sc_dev,
 "unable to use preferred mode\n");
@@ -627,7 +639,7 @@ mach64_attach(device_t parent, device_t 
 		 * if we can't use the preferred mode go look for the
 		 * best one we can support
 		 */
-		if (setmode == 0) {
+		if (sc->sc_setmode == 0) {
 			struct videomode *m = sc->sc_ei.edid_modes;
 
 			mode = NULL;
@@ -642,32 +654,39 @@ mach64_attach(device_t parent, device_t 
 			if (mode != NULL) {
 

CVS commit: src

2019-12-06 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Dec  6 21:45:14 UTC 2019

Modified Files:
src/lib/libc/sys: modctl.2
src/sbin/modstat: modstat.8

Log Message:
Note also that the load address (if provided) is also for the module's
text segment.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/sys/modctl.2
cvs rdiff -u -r1.24 -r1.25 src/sbin/modstat/modstat.8

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

Modified files:

Index: src/lib/libc/sys/modctl.2
diff -u src/lib/libc/sys/modctl.2:1.16 src/lib/libc/sys/modctl.2:1.17
--- src/lib/libc/sys/modctl.2:1.16	Wed Dec  4 23:35:36 2019
+++ src/lib/libc/sys/modctl.2	Fri Dec  6 21:45:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: modctl.2,v 1.16 2019/12/04 23:35:36 pgoyette Exp $
+.\"	$NetBSD: modctl.2,v 1.17 2019/12/06 21:45:14 pgoyette Exp $
 .\"
 .\" Copyright (c) 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 4, 2019
+.Dd December 5, 2019
 .Dt MODCTL 2
 .Os
 .Sh NAME
@@ -181,10 +181,10 @@ Executable file format.
 Miscellaneous.
 .El
 .It Fa "uint64_t ms_addr"
-The load address within the kernel.
+The load address within the kernel of the module's text segment.
 (This value is available only for privileged users.)
 .It Fa "u_int ms_size"
-Loaded size of the module's text section.
+Loaded size of the module's text segment.
 (This value is available only for privileged users.)
 .It Fa "u_int ms_refcnt"
 Current number of live references to this module.

Index: src/sbin/modstat/modstat.8
diff -u src/sbin/modstat/modstat.8:1.24 src/sbin/modstat/modstat.8:1.25
--- src/sbin/modstat/modstat.8:1.24	Wed Dec  4 23:35:36 2019
+++ src/sbin/modstat/modstat.8	Fri Dec  6 21:45:14 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: modstat.8,v 1.24 2019/12/04 23:35:36 pgoyette Exp $
+.\" $NetBSD: modstat.8,v 1.25 2019/12/06 21:45:14 pgoyette Exp $
 .\"
 .\" Copyright (c) 1993 Christopher G. Demetriou
 .\" All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\" <>
 .\"
-.Dd December 4, 2019
+.Dd December 5, 2019
 .Dt MODSTAT 8
 .Os
 .Sh NAME
@@ -107,7 +107,7 @@ flag
 Number of references held on the module.
 Disabled builtin modules will show a count of \-1 here.
 .It Li ADDRESS
-The kernel address at which the module is loaded.
+The kernel address at which the module's text segment is loaded.
 Builtin modules will show 0 here.
 This field is only displayed if the
 .Fl k



CVS commit: src/sys

2019-12-06 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Dec  6 21:36:11 UTC 2019

Modified Files:
src/sys/kern: kern_exec.c kern_exit.c kern_idle.c kern_lwp.c kern_sig.c
kern_sleepq.c kern_softint.c kern_synch.c
src/sys/sys: sched.h

Log Message:
Make it possible to call mi_switch() and immediately switch to another CPU.
This seems to take about 3us on my Intel system.  Two changes required:

- Have the caller to mi_switch() be responsible for calling spc_lock().
- Avoid using l->l_cpu in mi_switch().

While here:

- Add a couple of calls to membar_enter()
- Have the idle LWP set itself to LSIDL, to match softint_thread().
- Remove unused return value from mi_switch().


To generate a diff of this commit:
cvs rdiff -u -r1.484 -r1.485 src/sys/kern/kern_exec.c
cvs rdiff -u -r1.277 -r1.278 src/sys/kern/kern_exit.c
cvs rdiff -u -r1.27 -r1.28 src/sys/kern/kern_idle.c
cvs rdiff -u -r1.216 -r1.217 src/sys/kern/kern_lwp.c
cvs rdiff -u -r1.380 -r1.381 src/sys/kern/kern_sig.c
cvs rdiff -u -r1.53 -r1.54 src/sys/kern/kern_sleepq.c
cvs rdiff -u -r1.54 -r1.55 src/sys/kern/kern_softint.c
cvs rdiff -u -r1.328 -r1.329 src/sys/kern/kern_synch.c
cvs rdiff -u -r1.79 -r1.80 src/sys/sys/sched.h

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

Modified files:

Index: src/sys/kern/kern_exec.c
diff -u src/sys/kern/kern_exec.c:1.484 src/sys/kern/kern_exec.c:1.485
--- src/sys/kern/kern_exec.c:1.484	Sat Nov 23 19:42:52 2019
+++ src/sys/kern/kern_exec.c	Fri Dec  6 21:36:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exec.c,v 1.484 2019/11/23 19:42:52 ad Exp $	*/
+/*	$NetBSD: kern_exec.c,v 1.485 2019/12/06 21:36:10 ad Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.484 2019/11/23 19:42:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.485 2019/12/06 21:36:10 ad Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -1363,6 +1363,7 @@ execve_runproc(struct lwp *l, struct exe
 		mutex_exit(p->p_lock);
 		mutex_exit(proc_lock);
 		lwp_lock(l);
+		spc_lock(l->l_cpu);
 		mi_switch(l);
 		ksiginfo_queue_drain();
 		KERNEL_LOCK(l->l_biglocks, l);

Index: src/sys/kern/kern_exit.c
diff -u src/sys/kern/kern_exit.c:1.277 src/sys/kern/kern_exit.c:1.278
--- src/sys/kern/kern_exit.c:1.277	Thu Oct  3 22:48:44 2019
+++ src/sys/kern/kern_exit.c	Fri Dec  6 21:36:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exit.c,v 1.277 2019/10/03 22:48:44 kamil Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.278 2019/12/06 21:36:10 ad Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.277 2019/10/03 22:48:44 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.278 2019/12/06 21:36:10 ad Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -245,6 +245,7 @@ exit1(struct lwp *l, int exitcode, int s
 		lwp_unlock(l);
 		mutex_exit(p->p_lock);
 		lwp_lock(l);
+		spc_lock(l->l_cpu);
 		mi_switch(l);
 		KERNEL_LOCK(l->l_biglocks, l);
 		mutex_enter(p->p_lock);

Index: src/sys/kern/kern_idle.c
diff -u src/sys/kern/kern_idle.c:1.27 src/sys/kern/kern_idle.c:1.28
--- src/sys/kern/kern_idle.c:1.27	Sun Dec  1 15:34:46 2019
+++ src/sys/kern/kern_idle.c	Fri Dec  6 21:36:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_idle.c,v 1.27 2019/12/01 15:34:46 ad Exp $	*/
+/*	$NetBSD: kern_idle.c,v 1.28 2019/12/06 21:36:10 ad Exp $	*/
 
 /*-
  * Copyright (c)2002, 2006, 2007 YAMAMOTO Takashi,
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.27 2019/12/01 15:34:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.28 2019/12/06 21:36:10 ad Exp $");
 
 #include 
 #include 
@@ -93,6 +93,8 @@ idle_loop(void *dummy)
 		}
 		KASSERT(l->l_mutex == l->l_cpu->ci_schedstate.spc_lwplock);
 		lwp_lock(l);
+		l->l_stat = LSIDL;
+		spc_lock(l->l_cpu);
 		mi_switch(l);
 		KASSERT(curlwp == l);
 		KASSERT(l->l_stat == LSONPROC);

Index: src/sys/kern/kern_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.216 src/sys/kern/kern_lwp.c:1.217
--- src/sys/kern/kern_lwp.c:1.216	Tue Dec  3 05:07:48 2019
+++ src/sys/kern/kern_lwp.c	Fri Dec  6 21:36:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.216 2019/12/03 05:07:48 riastradh Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.217 2019/12/06 21:36:10 ad Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -209,7 +209,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.216 2019/12/03 05:07:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.217 2019/12/06 21:36:10 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -1602,6 +1602,7 @@ lwp_userret(struct lwp *l)
 			lwp_unlock(l);
 			mutex_exit(p->p_lock);
 			lwp_lock(l);
+			spc_lock(l->l_cpu);
 			mi_switch(l);
 		}
 

Index: src/sys/kern/kern_sig.c
diff -u 

CVS commit: src/sys/sys

2019-12-06 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Dec  6 21:07:08 UTC 2019

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

Log Message:
NetBSD 9.99.20 cpu_info/cpu_data changes for topology


To generate a diff of this commit:
cvs rdiff -u -r1.620 -r1.621 src/sys/sys/param.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/param.h
diff -u src/sys/sys/param.h:1.620 src/sys/sys/param.h:1.621
--- src/sys/sys/param.h:1.620	Sun Dec  1 16:36:25 2019
+++ src/sys/sys/param.h	Fri Dec  6 21:07:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.620 2019/12/01 16:36:25 ad Exp $	*/
+/*	$NetBSD: param.h,v 1.621 2019/12/06 21:07:07 ad Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999001900	/* NetBSD 9.99.19 */
+#define	__NetBSD_Version__	999002000	/* NetBSD 9.99.20 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/sys

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  6 19:37:43 UTC 2019

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

Log Message:
Adjust snprintb(3) format from '%d' to '%ju' to reflect reality and so that
it works on big endian machines.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/sys/mman.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/mman.h
diff -u src/sys/sys/mman.h:1.61 src/sys/sys/mman.h:1.62
--- src/sys/sys/mman.h:1.61	Tue Apr 30 05:23:00 2019
+++ src/sys/sys/mman.h	Fri Dec  6 14:37:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mman.h,v 1.61 2019/04/30 09:23:00 uwe Exp $	*/
+/*	$NetBSD: mman.h,v 1.62 2019/12/06 19:37:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1993
@@ -158,7 +158,7 @@ typedef	__off_t		off_t;		/* file offset 
 		":\064" "ALIGN=4PB\0"		\
 		":\070" "ALIGN=64PB\0"		\
 		":\074" "ALIGN=256PB\0"		\
-		"*"	"ALIGN=2^%d\0"
+		"*"	"ALIGN=2^%ju\0"
 #endif
 
 /*



CVS commit: src/usr.sbin/sysinst

2019-12-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec  6 19:36:22 UTC 2019

Modified Files:
src/usr.sbin/sysinst: disklabel.c

Log Message:
Sanitize disk type and packname a bit more - when using existing disklabel
partitions we might run into trouble later when filing this label (unescaped)
in disktab format otherwise.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sysinst/disklabel.c

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

Modified files:

Index: src/usr.sbin/sysinst/disklabel.c
diff -u src/usr.sbin/sysinst/disklabel.c:1.15 src/usr.sbin/sysinst/disklabel.c:1.16
--- src/usr.sbin/sysinst/disklabel.c:1.15	Tue Nov 12 16:33:14 2019
+++ src/usr.sbin/sysinst/disklabel.c	Fri Dec  6 19:36:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: disklabel.c,v 1.15 2019/11/12 16:33:14 martin Exp $	*/
+/*	$NetBSD: disklabel.c,v 1.16 2019/12/06 19:36:22 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -281,13 +281,10 @@ disklabel_write_to_disk(struct disk_part
 	assert(parts->l.d_ncylinders != 0);
 	assert(parts->l.d_secpercyl != 0);
 
-	sprintf(fname, "/tmp/disklabel.%u", getpid());
-	f = fopen(fname, "w");
-	if (f == NULL)
-		return false;
-
 	/* make sure we have a 0 terminated packname */
 	strlcpy(packname, parts->l.d_packname, sizeof packname);
+	if (packname[0] == 0)
+		strcpy(packname, "fictious");
 
 	/* fill typename with disk name prefix, if not already set */
 	if (strlen(parts->l.d_typename) == 0) {
@@ -299,6 +296,12 @@ disklabel_write_to_disk(struct disk_part
 		}
 	}
 	parts->l.d_typename[sizeof(parts->l.d_typename)-1] = 0;
+	for (d = parts->l.d_typename; *d; d++) {
+		if (isalnum((unsigned char)*d) || *d == '-')
+			continue;
+		*d = 0;
+		break;
+	}
 
 	/* we need a valid disk type name, so enforce an arbitrary if
 	 * above did not yield a usable one */
@@ -306,6 +309,11 @@ disklabel_write_to_disk(struct disk_part
 		strncpy(parts->l.d_typename, "SCSI",
 		sizeof(parts->l.d_typename));
 
+	sprintf(fname, "/tmp/disklabel.%u", getpid());
+	f = fopen(fname, "w");
+	if (f == NULL)
+		return false;
+
 	lp = parts->l.d_partitions;
 	scripting_fprintf(NULL, "cat <%s\n", fname);
 	scripting_fprintf(f, "%s|NetBSD installation generated:\\\n",



CVS commit: src/common/lib/libutil

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  6 19:36:22 UTC 2019

Modified Files:
src/common/lib/libutil: snprintb.c

Log Message:
Formalize that the printf formats should be uintmax_t so we can
uniformly use 'j' in the user-provided formatting strings instead
of depending on _LP64 to use 'll' or 'l' (and the PRI macros). The
alternative is to parse the printf format manually to determine
which modifier to apply which would make this transparent to the
user (they could still always use '%u' or '%x'), but that's too
painful.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/common/lib/libutil/snprintb.c

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

Modified files:

Index: src/common/lib/libutil/snprintb.c
diff -u src/common/lib/libutil/snprintb.c:1.21 src/common/lib/libutil/snprintb.c:1.22
--- src/common/lib/libutil/snprintb.c:1.21	Mon Jun 17 13:03:58 2019
+++ src/common/lib/libutil/snprintb.c	Fri Dec  6 14:36:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: snprintb.c,v 1.21 2019/06/17 17:03:58 christos Exp $	*/
+/*	$NetBSD: snprintb.c,v 1.22 2019/12/06 19:36:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #  include 
 #  if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: snprintb.c,v 1.21 2019/06/17 17:03:58 christos Exp $");
+__RCSID("$NetBSD: snprintb.c,v 1.22 2019/12/06 19:36:22 christos Exp $");
 #  endif
 
 #  include 
@@ -51,7 +51,7 @@ __RCSID("$NetBSD: snprintb.c,v 1.21 2019
 #  include 
 # else /* ! _KERNEL */
 #  include 
-__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.21 2019/06/17 17:03:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snprintb.c,v 1.22 2019/12/06 19:36:22 christos Exp $");
 #  include 
 #  include 
 #  include 
@@ -81,13 +81,13 @@ snprintb_m(char *buf, size_t buflen, con
 	ch = *bitfmt++;
 	switch (ch != '\177' ? ch : *bitfmt++) {
 	case 8:
-		sbase = "0%" PRIo64;
+		sbase = "%#jo";
 		break;
 	case 10:
-		sbase = "%" PRId64;
+		sbase = "%ju";
 		break;
 	case 16:
-		sbase = "0x%" PRIx64;
+		sbase = "%#jx";
 		break;
 	default:
 		goto internal;
@@ -97,7 +97,7 @@ snprintb_m(char *buf, size_t buflen, con
 	if (l_max > 0)
 		buflen--;
 
-	t_len = snprintf(bp, buflen, sbase, val);
+	t_len = snprintf(bp, buflen, sbase, (uintmax_t)val);
 	if (t_len < 0)
 		goto internal;
 
@@ -128,7 +128,7 @@ snprintb_m(char *buf, size_t buflen, con
 		  }			\
 		  STORE('>'); STORE('\0');\
 		  if ((size_t)t_len < buflen)\
-			snprintf(bp, buflen - t_len, sbase, val);	\
+			snprintf(bp, buflen - t_len, sbase, (uintmax_t)val);\
 		  t_len += v_len; l_len = v_len; bp += v_len;		\
 		} while ( /* CONSTCOND */ 0)
 
@@ -168,7 +168,7 @@ snprintb_m(char *buf, size_t buflen, con
 		}
 #define FMTSTR(sb, f) 			\
 	do { \
-		f_len = snprintf(bp, buflen - t_len, sb, f);		\
+		f_len = snprintf(bp, buflen - t_len, sb, (uintmax_t)f);	\
 		if (f_len < 0) 		\
 			goto internal; 	\
 		t_len += f_len; 	\



CVS commit: src/lib/libutil

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  6 19:31:52 UTC 2019

Modified Files:
src/lib/libutil: snprintb.3

Log Message:
Correct the man page, and say that the printf(3) format characters need
to be uintmax_t.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libutil/snprintb.3

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/snprintb.3
diff -u src/lib/libutil/snprintb.3:1.21 src/lib/libutil/snprintb.3:1.22
--- src/lib/libutil/snprintb.3:1.21	Mon Apr 29 03:55:38 2019
+++ src/lib/libutil/snprintb.3	Fri Dec  6 14:31:52 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: snprintb.3,v 1.21 2019/04/29 07:55:38 kre Exp $
+.\" $NetBSD: snprintb.3,v 1.22 2019/12/06 19:31:52 christos Exp $
 .\"
 .\" Copyright (c) 1998 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 April 27, 2019
+.Dd December 6, 2019
 .Dt SNPRINTB 3
 .Os
 .Sh NAME
@@ -190,8 +190,10 @@ or
 .Sq \&=
 have not matched.
 .Ar FMT
-may contain an integer format specification that prints the value that
-did not match.
+may contain a
+.Ft uintmax_t 
+format specification that prints the value that
+did not match, since the field can be more than 32 bits wide.
 .El
 .Pp
 Finally, each field is delimited by a NUL
@@ -307,7 +309,7 @@ F\e30\e010\e0\e
 :\e064ALIGN=4PB\e0\e
 :\e070ALIGN=64PB\e0\e
 :\e074ALIGN=256PB\e0\e
-*ALIGN=2^%d\e0\e
+*ALIGN=2^%jd\e0\e
 "
 snprintb(buf, buflen, MAP_FMT, 0x0d001234)
 \(rA "0xd001234"



CVS commit: src/tests/lib/libutil

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  6 19:28:11 UTC 2019

Modified Files:
src/tests/lib/libutil: t_snprintb.c

Log Message:
Fix broken tests in big endian machines. Internally field values are
stored as uint64_t/uintmax_t so printing them with %d on big endian
ends up being 0.


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

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

Modified files:

Index: src/tests/lib/libutil/t_snprintb.c
diff -u src/tests/lib/libutil/t_snprintb.c:1.6 src/tests/lib/libutil/t_snprintb.c:1.7
--- src/tests/lib/libutil/t_snprintb.c:1.6	Mon Apr 29 03:55:38 2019
+++ src/tests/lib/libutil/t_snprintb.c	Fri Dec  6 14:28:11 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: t_snprintb.c,v 1.6 2019/04/29 07:55:38 kre Exp $ */
+/* $NetBSD: t_snprintb.c,v 1.7 2019/12/06 19:28:11 christos Exp $ */
 
 /*
  * Copyright (c) 2002, 2004, 2008, 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008, 2010\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_snprintb.c,v 1.6 2019/04/29 07:55:38 kre Exp $");
+__RCSID("$NetBSD: t_snprintb.c,v 1.7 2019/12/06 19:28:11 christos Exp $");
 
 #include 
 #include 
@@ -82,9 +82,9 @@ ATF_TC_BODY(snprintb, tc)
 
 	h_snprintb("\177\20f\0\4FOO\0=\1ONE\0=\2TWO\0*=OTHER\0\0", 3,
 	"0x3");
-	h_snprintb("\177\20f\0\4X\0=\1ONE\0=\2TWO\0*=Other(%d)\0\0", 3,
+	h_snprintb("\177\20f\0\4X\0=\1ONE\0=\2TWO\0*=Other(%jd)\0\0", 3,
 	"0x3");
-	h_snprintb("\177\20f\0\x8X\0=\1ONE\0=\2TWO\0*=other(%o)\0\0", 0x20,
+	h_snprintb("\177\20f\0\x8X\0=\1ONE\0=\2TWO\0*=other(%jo)\0\0", 0x20,
 	"0x20");
 	h_snprintb("\177\020F\0\4\0:\1ONE\0:\2TWO\0\0", 3,
 	"0x3<>");
@@ -94,7 +94,7 @@ ATF_TC_BODY(snprintb, tc)
 	"0x12");
 
 	h_snprintb("\177\20f\0\4Field_1\0=\1ONE\0=\2TWO\0"
-		   "F\x8\4\0*Field_3=%d\0"
+		   "F\x8\4\0*Field_3=%jd\0"
 		   "f\4\4Field_2\0:\1:ONE\0:\2:TWO\0\0", 0xD12,
 	"0xd12");
 }



CVS commit: src/sys/kern

2019-12-06 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Dec  6 18:33:19 UTC 2019

Modified Files:
src/sys/kern: sched_4bsd.c sched_m2.c

Log Message:
sched_tick(): don't try to optimise something that's called 10 times a
second, it's a fine way to introduce bugs (and I did).  Use the MI
interface for rescheduling which always does the correct thing.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/sched_4bsd.c
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/sched_m2.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/sched_4bsd.c
diff -u src/sys/kern/sched_4bsd.c:1.40 src/sys/kern/sched_4bsd.c:1.41
--- src/sys/kern/sched_4bsd.c:1.40	Sun Dec  1 15:34:46 2019
+++ src/sys/kern/sched_4bsd.c	Fri Dec  6 18:33:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sched_4bsd.c,v 1.40 2019/12/01 15:34:46 ad Exp $	*/
+/*	$NetBSD: sched_4bsd.c,v 1.41 2019/12/06 18:33:19 ad Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2019
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.40 2019/12/01 15:34:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.41 2019/12/06 18:33:19 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -104,13 +104,15 @@ void
 sched_tick(struct cpu_info *ci)
 {
 	struct schedstate_percpu *spc = >ci_schedstate;
+	pri_t pri = PRI_NONE;
 	lwp_t *l;
 
 	spc->spc_ticks = rrticks;
 
 	if (CURCPU_IDLE_P()) {
-		atomic_or_uint(>ci_want_resched,
-		RESCHED_IDLE | RESCHED_UPREEMPT);
+		spc_lock(ci);
+		sched_resched_cpu(ci, MAXPRI_KTHREAD, true);
+		/* spc now unlocked */
 		return;
 	}
 	l = ci->ci_onproc;
@@ -128,12 +130,7 @@ sched_tick(struct cpu_info *ci)
 		break;
 	case SCHED_RR:
 		/* Force it into mi_switch() to look for other jobs to run. */
-#ifdef __HAVE_PREEMPTION
-		atomic_or_uint(>l_dopreempt, DOPREEMPT_ACTIVE);
-		atomic_or_uint(>ci_want_resched, RESCHED_KPREEMPT);
-#else
-		atomic_or_uint(>ci_want_resched, RESCHED_UPREEMPT);
-#endif
+		pri = MAXPRI_KERNEL_RT;
 		break;
 	default:
 		if (spc->spc_flags & SPCF_SHOULDYIELD) {
@@ -142,25 +139,25 @@ sched_tick(struct cpu_info *ci)
 			 * due to buggy or inefficient code.  Force a
 			 * kernel preemption.
 			 */
-#ifdef __HAVE_PREEMPTION
-			atomic_or_uint(>l_dopreempt, DOPREEMPT_ACTIVE);
-			atomic_or_uint(>ci_want_resched, RESCHED_KPREEMPT);
-#else
-			atomic_or_uint(>ci_want_resched, RESCHED_UPREEMPT);
-#endif
+			pri = MAXPRI_KERNEL_RT;
 		} else if (spc->spc_flags & SPCF_SEENRR) {
 			/*
 			 * The process has already been through a roundrobin
 			 * without switching and may be hogging the CPU.
 			 * Indicate that the process should yield.
 			 */
-			spc->spc_flags |= SPCF_SHOULDYIELD;
-			atomic_or_uint(>ci_want_resched, RESCHED_UPREEMPT);
+			pri = MAXPRI_KTHREAD;
 		} else {
 			spc->spc_flags |= SPCF_SEENRR;
 		}
 		break;
 	}
+
+	if (pri != PRI_NONE) {
+		spc_lock(ci);
+		sched_resched_cpu(ci, pri, true);
+		/* spc now unlocked */
+	}
 }
 
 /*

Index: src/sys/kern/sched_m2.c
diff -u src/sys/kern/sched_m2.c:1.36 src/sys/kern/sched_m2.c:1.37
--- src/sys/kern/sched_m2.c:1.36	Sun Dec  1 15:34:46 2019
+++ src/sys/kern/sched_m2.c	Fri Dec  6 18:33:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sched_m2.c,v 1.36 2019/12/01 15:34:46 ad Exp $	*/
+/*	$NetBSD: sched_m2.c,v 1.37 2019/12/06 18:33:19 ad Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008 Mindaugas Rasiukevicius 
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sched_m2.c,v 1.36 2019/12/01 15:34:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sched_m2.c,v 1.37 2019/12/06 18:33:19 ad Exp $");
 
 #include 
 
@@ -330,7 +330,9 @@ sched_tick(struct cpu_info *ci)
 	 */
 	if (lwp_eprio(l) <= spc->spc_maxpriority || l->l_target_cpu) {
 		spc->spc_flags |= SPCF_SHOULDYIELD;
-		atomic_or_uint(>ci_want_resched, RESCHED_UPREEMPT);
+		spc_lock(ci);
+		sched_resched_cpu(ci, MAXPRI_KTHREAD, true);
+		/* spc now unlocked */
 	} else
 		spc->spc_ticks = l->l_sched.timeslice; 
 	lwp_unlock(l);



CVS commit: src/sys/kern

2019-12-06 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Dec  6 18:15:57 UTC 2019

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

Log Message:
softint_trigger (slow case): set RESCHED_IDLE too just to be consistent.
No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/kern/kern_softint.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_softint.c
diff -u src/sys/kern/kern_softint.c:1.53 src/sys/kern/kern_softint.c:1.54
--- src/sys/kern/kern_softint.c:1.53	Tue Dec  3 05:07:48 2019
+++ src/sys/kern/kern_softint.c	Fri Dec  6 18:15:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.53 2019/12/03 05:07:48 riastradh Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.54 2019/12/06 18:15:57 ad Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.53 2019/12/03 05:07:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.54 2019/12/06 18:15:57 ad Exp $");
 
 #include 
 #include 
@@ -692,7 +692,8 @@ softint_trigger(uintptr_t machdep)
 	ci->ci_data.cpu_softints |= machdep;
 	l = ci->ci_onproc;
 	if (l == ci->ci_data.cpu_idlelwp) {
-		atomic_or_uint(>ci_want_resched, RESCHED_UPREEMPT);
+		atomic_or_uint(>ci_want_resched,
+		RESCHED_IDLE | RESCHED_UPREEMPT);
 	} else {
 		/* MI equivalent of aston() */
 		cpu_signotify(l);



CVS commit: src/sys/arch/aarch64

2019-12-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Dec  6 18:16:23 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: sys_machdep.c
src/sys/arch/aarch64/include: types.h

Log Message:
Remove __HAVE_CPU_LWP_SETPRIVATE from aarch64

aarch64 specific cpu_lwp_setprivate() is redundant with its caller
lwp_setprivate() and there are no MD bits.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/sys_machdep.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/include/types.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/arch/aarch64/aarch64/sys_machdep.c
diff -u src/sys/arch/aarch64/aarch64/sys_machdep.c:1.3 src/sys/arch/aarch64/aarch64/sys_machdep.c:1.4
--- src/sys/arch/aarch64/aarch64/sys_machdep.c:1.3	Tue Jul 17 00:36:30 2018
+++ src/sys/arch/aarch64/aarch64/sys_machdep.c	Fri Dec  6 18:16:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_machdep.c,v 1.3 2018/07/17 00:36:30 christos Exp $ */
+/* $NetBSD: sys_machdep.c,v 1.4 2019/12/06 18:16:22 kamil Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: sys_machdep.c,v 1.3 2018/07/17 00:36:30 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sys_machdep.c,v 1.4 2019/12/06 18:16:22 kamil Exp $");
 
 #include 
 #include 
@@ -47,10 +47,3 @@ sys_sysarch(struct lwp *l, const struct 
 {
 	return EINVAL;
 }
-
-int
-cpu_lwp_setprivate(lwp_t *l, void *addr)
-{
-	l->l_private = addr;
-	return 0;
-}

Index: src/sys/arch/aarch64/include/types.h
diff -u src/sys/arch/aarch64/include/types.h:1.12 src/sys/arch/aarch64/include/types.h:1.13
--- src/sys/arch/aarch64/include/types.h:1.12	Sat Oct 13 08:32:36 2018
+++ src/sys/arch/aarch64/include/types.h	Fri Dec  6 18:16:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.12 2018/10/13 08:32:36 ryo Exp $ */
+/* $NetBSD: types.h,v 1.13 2019/12/06 18:16:22 kamil Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -100,7 +100,6 @@ typedef __uint64_t __register_t;
 #define __HAVE_NEW_STYLE_BUS_H
 #define __HAVE_MINIMAL_EMUL
 #define __HAVE_CPU_DATA_FIRST
-#define __HAVE_CPU_LWP_SETPRIVATE
 #define __HAVE___LWP_GETPRIVATE_FAST
 #define __HAVE_COMMON___TLS_GET_ADDR
 #define __HAVE_TLS_VARIANT_I



CVS commit: src/share/man/man5

2019-12-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Dec  6 18:03:49 UTC 2019

Modified Files:
src/share/man/man5: core.5

Log Message:
Remove misleading comments from core(5)

netbsd_elfcore_procinfo is still in version 1.
cpi_siglwp is stored in the same netbsd_elfcore_procinfo version (1).

The size of struct is stored in cpi_cpisize and the struct can be
expanded without versioning the struct.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/share/man/man5/core.5

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

Modified files:

Index: src/share/man/man5/core.5
diff -u src/share/man/man5/core.5:1.32 src/share/man/man5/core.5:1.33
--- src/share/man/man5/core.5:1.32	Mon Sep  9 00:14:55 2019
+++ src/share/man/man5/core.5	Fri Dec  6 18:03:49 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: core.5,v 1.32 2019/09/09 00:14:55 sevan Exp $
+.\"	$NetBSD: core.5,v 1.33 2019/12/06 18:03:49 kamil Exp $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,7 +56,7 @@
 .\"
 .\" @(#)core.5	8.3 (Berkeley) 12/11/93
 .\"
-.Dd September 9, 2019
+.Dd December 6, 2019
 .Dt CORE 5
 .Os
 .Sh NAME
@@ -144,7 +144,6 @@ and contains the following
 structure:
 .Bd -literal
 struct netbsd_elfcore_procinfo {
-   /* Version 1 fields start here. */
 uint32_t cpi_version;  /* netbsd_elfcore_procinfo version */
 uint32_t cpi_cpisize;  /* sizeof(netbsd_elfcore_procinfo) */
 uint32_t cpi_signo;/* killing signal */
@@ -165,8 +164,7 @@ struct netbsd_elfcore_procinfo {
 uint32_t cpi_svgid;/* saved group ID */
 uint32_t cpi_nlwps;/* number of LWPs */
 int8_t   cpi_name[32]; /* copy of p->p_comm */
-/* Add version 2 fields below here. */
-int32_t cpi_siglwp; /* LWP target of killing signal */
+int32_t  cpi_siglwp;   /* LWP target of killing signal */
 };
 .Ed
 .Pp



CVS commit: src/sys/kern

2019-12-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Dec  6 17:41:43 UTC 2019

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

Log Message:
Correct signals in siglist+sigmask passed in kinfo_lwp

Make the union of LWP and PROC pending signals correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/sys/kern/kern_proc.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_proc.c
diff -u src/sys/kern/kern_proc.c:1.236 src/sys/kern/kern_proc.c:1.237
--- src/sys/kern/kern_proc.c:1.236	Sat Oct 12 10:55:23 2019
+++ src/sys/kern/kern_proc.c	Fri Dec  6 17:41:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_proc.c,v 1.236 2019/10/12 10:55:23 kamil Exp $	*/
+/*	$NetBSD: kern_proc.c,v 1.237 2019/12/06 17:41:43 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.236 2019/10/12 10:55:23 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.237 2019/12/06 17:41:43 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -2457,7 +2457,7 @@ fill_kproc2(struct proc *p, struct kinfo
 			ki->p_estcpu += l->l_estcpu;
 		}
 	}
-	sigplusset(>p_sigpend.sp_set, );
+	sigplusset(>p_sigpend.sp_set, );
 	memcpy(>p_siglist, , sizeof(ki_sigset_t));
 	memcpy(>p_sigmask, , sizeof(ki_sigset_t));
 



CVS commit: src/sys/kern

2019-12-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Dec  6 16:54:47 UTC 2019

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

Log Message:
cast to proper type


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/kern/subr_msan.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/subr_msan.c
diff -u src/sys/kern/subr_msan.c:1.3 src/sys/kern/subr_msan.c:1.4
--- src/sys/kern/subr_msan.c:1.3	Fri Nov 22 14:28:46 2019
+++ src/sys/kern/subr_msan.c	Fri Dec  6 16:54:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_msan.c,v 1.3 2019/11/22 14:28:46 maxv Exp $	*/
+/*	$NetBSD: subr_msan.c,v 1.4 2019/12/06 16:54:47 maxv Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define KMSAN_NO_INST
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_msan.c,v 1.3 2019/11/22 14:28:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_msan.c,v 1.4 2019/12/06 16:54:47 maxv Exp $");
 
 #include 
 #include 
@@ -1168,7 +1168,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	void kmsan_atomic_add_##name(volatile targ1 *ptr, targ2 val) \
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(val), __func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		atomic_add_##name(ptr, val); \
 	} \
 	tret atomic_add_##name##_nv(volatile targ1 *, targ2); \
@@ -1176,7 +1177,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	tret kmsan_atomic_add_##name##_nv(volatile targ1 *ptr, targ2 val) \
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(val), __func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		kmsan_init_ret(sizeof(tret)); \
 		return atomic_add_##name##_nv(ptr, val); \
 	}
@@ -1186,7 +1188,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	void kmsan_atomic_and_##name(volatile targ1 *ptr, targ2 val) \
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(val), __func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		atomic_and_##name(ptr, val); \
 	} \
 	tret atomic_and_##name##_nv(volatile targ1 *, targ2); \
@@ -1194,7 +1197,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	tret kmsan_atomic_and_##name##_nv(volatile targ1 *ptr, targ2 val) \
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(val), __func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		kmsan_init_ret(sizeof(tret)); \
 		return atomic_and_##name##_nv(ptr, val); \
 	}
@@ -1205,7 +1209,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	void kmsan_atomic_or_##name(volatile targ1 *ptr, targ2 val) \
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(val), __func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		atomic_or_##name(ptr, val); \
 	} \
 	tret atomic_or_##name##_nv(volatile targ1 *, targ2); \
@@ -1213,7 +1218,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	tret kmsan_atomic_or_##name##_nv(volatile targ1 *ptr, targ2 val) \
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(val), __func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		kmsan_init_ret(sizeof(tret)); \
 		return atomic_or_##name##_nv(ptr, val); \
 	}
@@ -1225,7 +1231,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(exp) + sizeof(new), \
 		__func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		kmsan_init_ret(sizeof(tret)); \
 		return atomic_cas_##name(ptr, exp, new); \
 	} \
@@ -1235,7 +1242,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(exp) + sizeof(new), \
 		__func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		kmsan_init_ret(sizeof(tret)); \
 		return atomic_cas_##name##_ni(ptr, exp, new); \
 	}
@@ -1246,7 +1254,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	tret kmsan_atomic_swap_##name(volatile targ1 *ptr, targ2 val) \
 	{ \
 		kmsan_check_arg(sizeof(ptr) + sizeof(val), __func__); \
-		kmsan_shadow_check((uintptr_t)ptr, sizeof(tret), __func__); \
+		kmsan_shadow_check((const void *)(uintptr_t)ptr, sizeof(tret), \
+		__func__); \
 		kmsan_init_ret(sizeof(tret)); \
 		return atomic_swap_##name(ptr, val); \
 	}
@@ -1257,7 +1266,8 @@ kmsan__ustore_64(uint64_t *uaddr, uint64
 	void kmsan_atomic_dec_##name(volatile targ1 

CVS commit: src/sys/dev/dm

2019-12-06 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Fri Dec  6 16:46:14 UTC 2019

Modified Files:
src/sys/dev/dm: dm_pdev.c dm_target_linear.c dm_target_zero.c
netbsd-dm.h

Log Message:
dm: Remove trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/dm_pdev.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target_linear.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_target_zero.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/dm/netbsd-dm.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/dm/dm_pdev.c
diff -u src/sys/dev/dm/dm_pdev.c:1.15 src/sys/dev/dm/dm_pdev.c:1.16
--- src/sys/dev/dm/dm_pdev.c:1.15	Wed Dec  4 16:55:30 2019
+++ src/sys/dev/dm/dm_pdev.c	Fri Dec  6 16:46:14 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $  */
+/*$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.15 2019/12/04 16:55:30 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.16 2019/12/06 16:46:14 tkusumi Exp $");
 
 #include 
 #include 
@@ -240,15 +240,14 @@ static int
 dm_pdev_dump_list(void)
 {
 	dm_pdev_t *dmp;
-	
+
 	aprint_verbose("Dumping dm_pdev_list\n");
-	
+
 	SLIST_FOREACH(dmp, _pdev_list, next_pdev) {
 		aprint_verbose("dm_pdev_name %s ref_cnt %d list_rf_cnt %d\n",
 		dmp->name, dmp->ref_cnt, dmp->list_ref_cnt);
 	}
-	
+
 	return 0;
-	
 }
 #endif

Index: src/sys/dev/dm/dm_target_linear.c
diff -u src/sys/dev/dm/dm_target_linear.c:1.22 src/sys/dev/dm/dm_target_linear.c:1.23
--- src/sys/dev/dm/dm_target_linear.c:1.22	Thu Dec  5 16:59:43 2019
+++ src/sys/dev/dm/dm_target_linear.c	Fri Dec  6 16:46:14 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_linear.c,v 1.22 2019/12/05 16:59:43 tkusumi Exp $  */
+/*$NetBSD: dm_target_linear.c,v 1.23 2019/12/06 16:46:14 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.22 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.23 2019/12/06 16:46:14 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper dklinear target.
@@ -146,9 +146,9 @@ dm_target_linear_sync(dm_table_entry_t *
 	tlc = table_en->target_config;
 
 	cmd = 1;
-	
+
 	return VOP_IOCTL(tlc->pdev->pdev_vnode,  DIOCCACHESYNC, ,
-	FREAD|FWRITE, kauth_cred_get());	
+	FREAD|FWRITE, kauth_cred_get());
 }
 
 /*

Index: src/sys/dev/dm/dm_target_zero.c
diff -u src/sys/dev/dm/dm_target_zero.c:1.16 src/sys/dev/dm/dm_target_zero.c:1.17
--- src/sys/dev/dm/dm_target_zero.c:1.16	Fri Dec  6 16:11:59 2019
+++ src/sys/dev/dm/dm_target_zero.c	Fri Dec  6 16:46:14 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_zero.c,v 1.16 2019/12/06 16:11:59 tkusumi Exp $  */
+/*$NetBSD: dm_target_zero.c,v 1.17 2019/12/06 16:46:14 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.16 2019/12/06 16:11:59 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.17 2019/12/06 16:46:14 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper zero target.
@@ -84,7 +84,7 @@ dm_target_zero_modcmd(modcmd_t cmd, void
 		dmt->init = _target_zero_init;
 		dmt->status = _target_zero_status;
 		dmt->strategy = _target_zero_strategy;
-		dmt->sync = _target_zero_sync;		 
+		dmt->sync = _target_zero_sync;
 		dmt->deps = _target_zero_deps;
 		dmt->destroy = _target_zero_destroy;
 		dmt->upcall = _target_zero_upcall;

Index: src/sys/dev/dm/netbsd-dm.h
diff -u src/sys/dev/dm/netbsd-dm.h:1.9 src/sys/dev/dm/netbsd-dm.h:1.10
--- src/sys/dev/dm/netbsd-dm.h:1.9	Tue Dec  3 15:03:14 2019
+++ src/sys/dev/dm/netbsd-dm.h	Fri Dec  6 16:46:14 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: netbsd-dm.h,v 1.9 2019/12/03 15:03:14 tkusumi Exp $  */
+/*$NetBSD: netbsd-dm.h,v 1.10 2019/12/06 16:46:14 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  * ...
  *
  * dev
- *  
+ * 
  *
  * flags
  * 
@@ -110,7 +110,7 @@
  */
 
 /*
- * DM_DEV_LIST == "names" 
+ * DM_DEV_LIST == "names"
  * Request list of device-mapper created devices from kernel.
  *
  * 
@@ -128,7 +128,7 @@
  */
 
  /*
-  * DM_DEV_RENAME == "rename" 
+  * DM_DEV_RENAME == "rename"
   * Rename device to string.
   *
   * 
@@ -138,14 +138,14 @@
   */
 
  /*
-  * DM_DEV_STATUS == "info, mknodes" 
+  * DM_DEV_STATUS == "info, mknodes"
   * Will change fields DM_IOCTL_OPEN, DM_IOCTL_DEV in received dictionary,
   * with dm device values with 

CVS commit: src/sys/dev/dm

2019-12-06 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Fri Dec  6 16:33:47 UTC 2019

Modified Files:
src/sys/dev/dm: device-mapper.c dm_ioctl.c dm_target_stripe.c

Log Message:
dm: Fix typos in comments/messages

taken-from: DragonFlyBSD


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/dm/device-mapper.c
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/dm/dm_ioctl.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/dm/dm_target_stripe.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/dm/device-mapper.c
diff -u src/sys/dev/dm/device-mapper.c:1.45 src/sys/dev/dm/device-mapper.c:1.46
--- src/sys/dev/dm/device-mapper.c:1.45	Thu Dec  5 15:52:39 2019
+++ src/sys/dev/dm/device-mapper.c	Fri Dec  6 16:33:47 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: device-mapper.c,v 1.45 2019/12/05 15:52:39 tkusumi Exp $ */
+/*$NetBSD: device-mapper.c,v 1.46 2019/12/06 16:33:47 tkusumi Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -428,7 +428,7 @@ dm_ioctl_switch(u_long cmd)
 
 	switch(cmd) {
 	case NETBSD_DM_IOCTL:
-		aprint_debug("dm NetBSD_DM_IOCTL called\n");
+		aprint_debug("dm NETBSD_DM_IOCTL called\n");
 		break;
 	default:
 		 aprint_debug("dm unknown ioctl called\n");
@@ -637,9 +637,9 @@ dmstrategy(struct buf *bp)
 		PRIu64"\n", buf_start, buf_len);
 		aprint_debug("start-buf_start %010"PRIu64", end %010"
 		PRIu64"\n", start - buf_start, end);
-		aprint_debug("start %010" PRIu64" , end %010"
+		aprint_debug("start %010" PRIu64", end %010"
 PRIu64"\n", start, end);
-		aprint_debug("\n\n");
+		aprint_debug("\n");
 
 		if (start < end) {
 			/* create nested buffer  */

Index: src/sys/dev/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.38 src/sys/dev/dm/dm_ioctl.c:1.39
--- src/sys/dev/dm/dm_ioctl.c:1.38	Thu Dec  5 15:52:39 2019
+++ src/sys/dev/dm/dm_ioctl.c	Fri Dec  6 16:33:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.38 2019/12/05 15:52:39 tkusumi Exp $  */
+/* $NetBSD: dm_ioctl.c,v 1.39 2019/12/06 16:33:47 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.38 2019/12/05 15:52:39 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.39 2019/12/06 16:33:47 tkusumi Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -131,10 +131,10 @@ dm_dbg_print_flags(int flags)
 		aprint_debug("dbg_flags: DM_READONLY_FLAG set In/Out\n");
 
 	if (flags & DM_SUSPEND_FLAG)
-		aprint_debug("dbg_flags: DM_SUSPEND_FLAG set In/Out \n");
+		aprint_debug("dbg_flags: DM_SUSPEND_FLAG set In/Out\n");
 
 	if (flags & DM_PERSISTENT_DEV_FLAG)
-		aprint_debug("db_flags: DM_PERSISTENT_DEV_FLAG set In\n");
+		aprint_debug("dbg_flags: DM_PERSISTENT_DEV_FLAG set In\n");
 
 	if (flags & DM_STATUS_TABLE_FLAG)
 		aprint_debug("dbg_flags: DM_STATUS_TABLE_FLAG set In\n");

Index: src/sys/dev/dm/dm_target_stripe.c
diff -u src/sys/dev/dm/dm_target_stripe.c:1.28 src/sys/dev/dm/dm_target_stripe.c:1.29
--- src/sys/dev/dm/dm_target_stripe.c:1.28	Fri Dec  6 16:11:59 2019
+++ src/sys/dev/dm/dm_target_stripe.c	Fri Dec  6 16:33:47 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_stripe.c,v 1.28 2019/12/06 16:11:59 tkusumi Exp $*/
+/*$NetBSD: dm_target_stripe.c,v 1.29 2019/12/06 16:33:47 tkusumi Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.28 2019/12/06 16:11:59 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.29 2019/12/06 16:33:47 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper stripe target.
@@ -241,11 +241,11 @@ dm_target_stripe_strategy(dm_table_entry
 	blkoff = 0;
 	num_blks = bp->b_resid / DEV_BSIZE;
 	for (;;) {
-		/* blockno to strip piece nr */
+		/* blockno to stripe piece nr */
 		stripe = blkno / tsc->stripe_chunksize;
 		stripe_off = blkno % tsc->stripe_chunksize;
 
-		/* where we are inside the strip */
+		/* where we are inside the stripe */
 		stripe_devnr = stripe % tsc->stripe_num;
 		stripe_blknr = stripe / tsc->stripe_num;
 



CVS commit: src/lib/libc/stdlib

2019-12-06 Thread Niclas Rosenvik
Module Name:src
Committed By:   nros
Date:   Fri Dec  6 16:19:32 UTC 2019

Modified Files:
src/lib/libc/stdlib: posix_memalign.3

Log Message:
Fix manpage due to updated aligned_alloc behavior

Since aligned_alloc does not demand that size is to be multiple of alignment
anymore, don't make that claim in the man page.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/stdlib/posix_memalign.3

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

Modified files:

Index: src/lib/libc/stdlib/posix_memalign.3
diff -u src/lib/libc/stdlib/posix_memalign.3:1.6 src/lib/libc/stdlib/posix_memalign.3:1.7
--- src/lib/libc/stdlib/posix_memalign.3:1.6	Fri Jul 27 15:15:30 2018
+++ src/lib/libc/stdlib/posix_memalign.3	Fri Dec  6 16:19:32 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: posix_memalign.3,v 1.6 2018/07/27 15:15:30 maya Exp $
+.\"	$NetBSD: posix_memalign.3,v 1.7 2019/12/06 16:19:32 nros Exp $
 .\"
 .\" Copyright (C) 2006 Jason Evans .
 .\" All rights reserved.
@@ -113,17 +113,6 @@ The
 parameter is not at least as large as
 .Fn sizeof "void *" .
 .El
-.Pp
-The
-.Fn aligned_alloc
-function will also fail if
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa size
-parameter is not an integer multiple of
-.Fa alignment .
-.El
 .Sh SEE ALSO
 .Xr free 3 ,
 .Xr malloc 3 ,



CVS commit: src/sys/dev/dm

2019-12-06 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Fri Dec  6 16:11:59 UTC 2019

Modified Files:
src/sys/dev/dm: dm_target.c dm_target_error.c dm_target_mirror.c
dm_target_snapshot.c dm_target_stripe.c dm_target_zero.c

Log Message:
dm: Don't ignore dm_target_alloc() argument

dm_target_alloc() is supposed to be copying the name argument to its ->name.
taken-from: DragonFlyBSD


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/dm/dm_target.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/dm/dm_target_error.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/dm/dm_target_mirror.c
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target_snapshot.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/dm/dm_target_stripe.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/dm/dm_target_zero.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/dm/dm_target.c
diff -u src/sys/dev/dm/dm_target.c:1.22 src/sys/dev/dm/dm_target.c:1.23
--- src/sys/dev/dm/dm_target.c:1.22	Wed Dec  4 15:31:12 2019
+++ src/sys/dev/dm/dm_target.c	Fri Dec  6 16:11:59 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target.c,v 1.22 2019/12/04 15:31:12 tkusumi Exp $  */
+/*$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.22 2019/12/04 15:31:12 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.23 2019/12/06 16:11:59 tkusumi Exp $");
 
 #include 
 #include 
@@ -241,7 +241,16 @@ dm_target_destroy(void)
 dm_target_t *
 dm_target_alloc(const char *name)
 {
-	return kmem_zalloc(sizeof(dm_target_t), KM_SLEEP);
+	dm_target_t *dmt;
+
+	dmt = kmem_zalloc(sizeof(dm_target_t), KM_SLEEP);
+	if (dmt == NULL)
+		return NULL;
+
+	if (name)
+		strlcpy(dmt->name, name, sizeof(dmt->name));
+
+	return dmt;
 }
 
 /*
@@ -298,7 +307,6 @@ dm_target_init(void)
 	dmt->version[0] = 1;
 	dmt->version[1] = 0;
 	dmt->version[2] = 2;
-	strlcpy(dmt->name, "linear", DM_MAX_TYPE_NAME);
 	dmt->init = _target_linear_init;
 	dmt->status = _target_linear_status;
 	dmt->strategy = _target_linear_strategy;
@@ -313,7 +321,6 @@ dm_target_init(void)
 	dmt3->version[0] = 1;
 	dmt3->version[1] = 0;
 	dmt3->version[2] = 3;
-	strlcpy(dmt3->name, "striped", DM_MAX_TYPE_NAME);
 	dmt3->init = _target_stripe_init;
 	dmt3->status = _target_stripe_status;
 	dmt3->strategy = _target_stripe_strategy;

Index: src/sys/dev/dm/dm_target_error.c
diff -u src/sys/dev/dm/dm_target_error.c:1.14 src/sys/dev/dm/dm_target_error.c:1.15
--- src/sys/dev/dm/dm_target_error.c:1.14	Thu Dec  5 16:59:43 2019
+++ src/sys/dev/dm/dm_target_error.c	Fri Dec  6 16:11:59 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $  */
+/*$NetBSD: dm_target_error.c,v 1.15 2019/12/06 16:11:59 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.14 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.15 2019/12/06 16:11:59 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper error target.
@@ -81,7 +81,6 @@ dm_target_error_modcmd(modcmd_t cmd, voi
 		dmt->version[0] = 1;
 		dmt->version[1] = 0;
 		dmt->version[2] = 0;
-		strlcpy(dmt->name, "error", DM_MAX_TYPE_NAME);
 		dmt->init = _target_error_init;
 		dmt->status = _target_error_status;
 		dmt->strategy = _target_error_strategy;

Index: src/sys/dev/dm/dm_target_mirror.c
diff -u src/sys/dev/dm/dm_target_mirror.c:1.12 src/sys/dev/dm/dm_target_mirror.c:1.13
--- src/sys/dev/dm/dm_target_mirror.c:1.12	Thu Dec  5 16:59:43 2019
+++ src/sys/dev/dm/dm_target_mirror.c	Fri Dec  6 16:11:59 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_mirror.c,v 1.12 2019/12/05 16:59:43 tkusumi Exp $*/
+/*$NetBSD: dm_target_mirror.c,v 1.13 2019/12/06 16:11:59 tkusumi Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.12 2019/12/05 16:59:43 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_mirror.c,v 1.13 2019/12/06 16:11:59 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper mirror target.
@@ -81,7 +81,6 @@ dm_target_mirror_modcmd(modcmd_t cmd, vo
 		dmt->version[0] = 1;
 		dmt->version[1] = 0;
 		dmt->version[2] = 0;
-		strlcpy(dmt->name, "mirror", DM_MAX_TYPE_NAME);
 		dmt->init = _target_mirror_init;
 		dmt->status = _target_mirror_status;
 		dmt->strategy = _target_mirror_strategy;

Index: src/sys/dev/dm/dm_target_snapshot.c
diff -u src/sys/dev/dm/dm_target_snapshot.c:1.23 src/sys/dev/dm/dm_target_snapshot.c:1.24
--- src/sys/dev/dm/dm_target_snapshot.c:1.23	Thu Dec  5 16:59:43 

CVS commit: src

2019-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 14:43:30 UTC 2019

Modified Files:
src/etc: security
src/etc/defaults: security.conf
src/share/man/man5: security.conf.5

Log Message:
Save the entropy seed daily in /etc/security.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/etc/security
cvs rdiff -u -r1.26 -r1.27 src/etc/defaults/security.conf
cvs rdiff -u -r1.40 -r1.41 src/share/man/man5/security.conf.5

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

Modified files:

Index: src/etc/security
diff -u src/etc/security:1.125 src/etc/security:1.126
--- src/etc/security:1.125	Wed Sep 18 22:27:55 2019
+++ src/etc/security	Fri Dec  6 14:43:30 2019
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#	$NetBSD: security,v 1.125 2019/09/18 22:27:55 uwe Exp $
+#	$NetBSD: security,v 1.126 2019/12/06 14:43:30 riastradh Exp $
 #	from: @(#)security	8.1 (Berkeley) 6/9/93
 #
 
@@ -1049,6 +1049,13 @@ if checkyesno check_changelist ; then
 	CHANGELIST="$CHANGEFILES $CHANGELIST"
 fi
 
+# Save entropy to ${random_file} if defined, like
+# /etc/rc.d/random_seed.
+#
+if [ -n "${random_file:-}" ]; then
+	rndctl -S "$random_file"
+fi
+
 # Special case backups, including the master password file and
 # ssh private host keys. The normal backup mechanisms for
 # $check_changelist (see below) also print out the actual file

Index: src/etc/defaults/security.conf
diff -u src/etc/defaults/security.conf:1.26 src/etc/defaults/security.conf:1.27
--- src/etc/defaults/security.conf:1.26	Wed Nov  6 19:37:05 2013
+++ src/etc/defaults/security.conf	Fri Dec  6 14:43:29 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: security.conf,v 1.26 2013/11/06 19:37:05 spz Exp $
+#	$NetBSD: security.conf,v 1.27 2019/12/06 14:43:29 riastradh Exp $
 #
 # /etc/defaults/security.conf --
 #	default configuration of /etc/security.conf
@@ -46,3 +46,5 @@ check_passwd_permit_star=NO
 check_passwd_permit_nonalpha=NO
 max_loginlen=16
 max_grouplen=16
+
+random_file=/var/db/entropy-file

Index: src/share/man/man5/security.conf.5
diff -u src/share/man/man5/security.conf.5:1.40 src/share/man/man5/security.conf.5:1.41
--- src/share/man/man5/security.conf.5:1.40	Wed Nov  6 19:37:06 2013
+++ src/share/man/man5/security.conf.5	Fri Dec  6 14:43:30 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: security.conf.5,v 1.40 2013/11/06 19:37:06 spz Exp $
+.\"	$NetBSD: security.conf.5,v 1.41 2019/12/06 14:43:30 riastradh Exp $
 .\"
 .\" Copyright (c) 1996 Matthew R. Green
 .\" All rights reserved.
@@ -282,6 +282,17 @@ for maintaining backup copies of files n
 and
 .Sy check_changelist
 instead of just keeping a current copy and a backup copy.
+.It Sy random_file
+Name of the entropy seed file used at boot.
+Default is
+.Pa /var/db/entropy-file
+as used by
+.Pa /etc/rc.d/random_seed .
+Set
+.Sy random_file
+to empty to disable saving a seed every time
+.Pa /etc/security
+runs.
 .El
 .Sh FILES
 .Bl -tag -width /etc/defaults/security.conf -compact



CVS commit: src/sbin/rndctl

2019-12-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Dec  6 14:43:18 UTC 2019

Modified Files:
src/sbin/rndctl: Makefile rndctl.8 rndctl.c
Added Files:
src/sbin/rndctl: namespace.h

Log Message:
Teach `rndctl -L' to update the seed file, not just delete it.

The seed file is updated by entering the old seed into the system and
then hashing the old seed together with data from /dev/urandom, and
writing it atomically with write-to-temporary/rename-to-permanent.

This way, interruption by crash or power loss does not obliterate
your persistent entropy (unless it causes file system corruption).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/rndctl/Makefile
cvs rdiff -u -r0 -r1.1 src/sbin/rndctl/namespace.h
cvs rdiff -u -r1.22 -r1.23 src/sbin/rndctl/rndctl.8
cvs rdiff -u -r1.30 -r1.31 src/sbin/rndctl/rndctl.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/rndctl/Makefile
diff -u src/sbin/rndctl/Makefile:1.3 src/sbin/rndctl/Makefile:1.4
--- src/sbin/rndctl/Makefile:1.3	Sun Oct 13 07:28:13 2019
+++ src/sbin/rndctl/Makefile	Fri Dec  6 14:43:18 2019
@@ -1,8 +1,20 @@
-#	$NetBSD: Makefile,v 1.3 2019/10/13 07:28:13 mrg Exp $
+#	$NetBSD: Makefile,v 1.4 2019/12/06 14:43:18 riastradh Exp $
 
 PROG=	rndctl
 MAN=	rndctl.8
 
 COPTS.rndctl.c+=	${GCC_NO_STRINGOP_TRUNCATION}
 
+SRCS+=	rndctl.c
+
+# Hack: libc does not export public SHA-3 symbols, so we'll just copy
+# them here statically.
+.PATH:	${NETBSDSRCDIR}/common/lib/libc/hash/sha3
+
+# Hack for namespace.h in sha3.c.
+CPPFLAGS+=	-I${.CURDIR}
+
+SRCS+=	sha3.c
+SRCS+=	keccak.c
+
 .include 

Index: src/sbin/rndctl/rndctl.8
diff -u src/sbin/rndctl/rndctl.8:1.22 src/sbin/rndctl/rndctl.8:1.23
--- src/sbin/rndctl/rndctl.8:1.22	Sun Aug 10 17:13:02 2014
+++ src/sbin/rndctl/rndctl.8	Fri Dec  6 14:43:18 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rndctl.8,v 1.22 2014/08/10 17:13:02 wiz Exp $
+.\"	$NetBSD: rndctl.8,v 1.23 2019/12/06 14:43:18 riastradh Exp $
 .\"
 .\" Copyright (c) 1997 Michael Graff
 .\" All rights reserved.
@@ -78,9 +78,13 @@ Enable entropy estimation using the coll
 for the given device name or device type.
 .It Fl L
 Load saved entropy from file
-.Ar save-file ,
-which will be overwritten and deleted before the entropy is loaded into
-the kernel.
+.Ar save-file
+and overwrite it with a seed derived by hashing it together with output
+from
+.Pa /dev/urandom
+so that the new seed has at least as much entropy as either the old
+seed had or the system already has.
+If interrupted, either the old seed or the new seed will be in place.
 .It Fl l
 List all sources, or, if the
 .Fl t

Index: src/sbin/rndctl/rndctl.c
diff -u src/sbin/rndctl/rndctl.c:1.30 src/sbin/rndctl/rndctl.c:1.31
--- src/sbin/rndctl/rndctl.c:1.30	Mon Apr 13 22:18:50 2015
+++ src/sbin/rndctl/rndctl.c	Fri Dec  6 14:43:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndctl.c,v 1.30 2015/04/13 22:18:50 riastradh Exp $	*/
+/*	$NetBSD: rndctl.c,v 1.31 2019/12/06 14:43:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997 Michael Graff.
@@ -33,7 +33,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: rndctl.c,v 1.30 2015/04/13 22:18:50 riastradh Exp $");
+__RCSID("$NetBSD: rndctl.c,v 1.31 2019/12/06 14:43:18 riastradh Exp $");
 #endif
 
 
@@ -41,6 +41,7 @@ __RCSID("$NetBSD: rndctl.c,v 1.30 2015/0
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -127,111 +128,227 @@ find_name(u_int32_t type)
 }
 
 static void
-do_save(const char *const filename)
+do_save(const char *filename, const void *extra, size_t nextra,
+uint32_t extraentropy)
 {
-	int est1, est2;
-	rndpoolstat_t rp;
+	char tmp[PATH_MAX];
+	uint32_t systementropy;
+	uint8_t buf[32];
+	SHAKE128_CTX shake128;
 	rndsave_t rs;
 	SHA1_CTX s;
-
+	ssize_t nread, nwrit;
 	int fd;
 
-	fd = open(_PATH_URANDOM, O_RDONLY, 0644);
-	if (fd < 0) {
-		err(1, "device open");
-	}
-
-	if (ioctl(fd, RNDGETPOOLSTAT, ) < 0) {
-		err(1, "ioctl(RNDGETPOOLSTAT)");
-	}
+	/* Paranoia: Avoid stack memory disclosure.  */
+	memset(, 0, sizeof rs);
 
-	est1 = rp.curentropy;
+	/* Format the temporary file name.  */
+	if (snprintf(tmp, sizeof tmp, "%s.tmp", filename) >= PATH_MAX)
+		errx(1, "path too long");
 
-	if (read(fd, rs.data, sizeof(rs.data)) != sizeof(rs.data)) {
-		err(1, "entropy read");
-	}
+	/* Open /dev/urandom.  */
+	if ((fd = open(_PATH_URANDOM, O_RDONLY)) == -1)
+		err(1, "device open");
 
-	if (ioctl(fd, RNDGETPOOLSTAT, ) < 0) {
-		err(1, "ioctl(RNDGETPOOLSTAT)");
-	}
+	/* Find how much entropy is in the pool.  */
+	if (ioctl(fd, RNDGETENTCNT, ) == -1)
+		err(1, "ioctl(RNDGETENTCNT)");
+
+	/* Read some data from /dev/urandom.  */
+	if ((size_t)(nread = read(fd, buf, sizeof buf)) != sizeof buf) {
+		if (nread == -1)
+			err(1, "read");
+		else
+			errx(1, "truncated read");
+	}
+
+	/* Close /dev/urandom; we're done with it.  */
+	if (close(fd) == -1)
+		warn("close");
+	fd = -1;		/* paranoia */
 
-	est2 = 

CVS commit: src/sys/dev/hyperv

2019-12-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec  6 12:46:06 UTC 2019

Modified Files:
src/sys/dev/hyperv: hyperv_common.c vmbus.c

Log Message:
Clear the allocated memory in hyperv_dma_alloc().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/hyperv/hyperv_common.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/hyperv/vmbus.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/hyperv/hyperv_common.c
diff -u src/sys/dev/hyperv/hyperv_common.c:1.2 src/sys/dev/hyperv/hyperv_common.c:1.3
--- src/sys/dev/hyperv/hyperv_common.c:1.2	Fri May 31 04:23:19 2019
+++ src/sys/dev/hyperv/hyperv_common.c	Fri Dec  6 12:46:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $	*/
+/*	$NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.2 2019/05/31 04:23:19 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv_common.c,v 1.3 2019/12/06 12:46:06 nonaka Exp $");
 
 #include "hyperv.h"
 
@@ -155,6 +155,10 @@ hyperv_dma_alloc(bus_dma_tag_t dmat, str
 		goto fail4;
 	}
 
+	memset(dma->addr, 0, dma->map->dm_mapsize);
+	bus_dmamap_sync(dmat, dma->map, 0, dma->map->dm_mapsize,
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+
 	return dma->addr;
 
 fail4:	bus_dmamap_destroy(dmat, dma->map);

Index: src/sys/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.5 src/sys/dev/hyperv/vmbus.c:1.6
--- src/sys/dev/hyperv/vmbus.c:1.5	Fri Nov 22 12:30:32 2019
+++ src/sys/dev/hyperv/vmbus.c	Fri Dec  6 12:46:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.5 2019/11/22 12:30:32 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.6 2019/12/06 12:46:06 nonaka Exp $");
 
 #include 
 #include 
@@ -985,7 +985,6 @@ vmbus_channel_alloc(struct vmbus_softc *
 		kmem_free(ch, sizeof(*ch));
 		return NULL;
 	}
-	memset(ch->ch_monprm, 0, sizeof(*ch->ch_monprm));
 
 	ch->ch_refs = 1;
 	ch->ch_sc = sc;
@@ -1264,7 +1263,6 @@ vmbus_channel_ring_create(struct vmbus_c
 		"failed to allocate channel ring\n");
 		return ENOMEM;
 	}
-	memset(ch->ch_ring, 0, ch->ch_ring_size);
 
 	memset(>ch_wrd, 0, sizeof(ch->ch_wrd));
 	ch->ch_wrd.rd_ring = (struct vmbus_bufring *)ch->ch_ring;



CVS commit: src/sys/dev/ic

2019-12-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec  6 12:41:17 UTC 2019

Modified Files:
src/sys/dev/ic: rndisreg.h

Log Message:
Added RNDIS RSS and TCP offload related definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/rndisreg.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/ic/rndisreg.h
diff -u src/sys/dev/ic/rndisreg.h:1.3 src/sys/dev/ic/rndisreg.h:1.4
--- src/sys/dev/ic/rndisreg.h:1.3	Thu Aug  8 06:16:39 2019
+++ src/sys/dev/ic/rndisreg.h	Fri Dec  6 12:41:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rndisreg.h,v 1.3 2019/08/08 06:16:39 maya Exp $ */
+/*	$NetBSD: rndisreg.h,v 1.4 2019/12/06 12:41:17 nonaka Exp $ */
 /*	NetBSD: if_urndisreg.h,v 1.4 2018/11/09 21:57:09 maya Exp */
 /*	$OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */
 
@@ -64,6 +64,8 @@
 #define	OID_GEN_SUPPORTED_GUIDS		0x00010117
 #define	OID_GEN_NETWORK_LAYER_ADDRESSES	0x00010118
 #define	OID_GEN_TRANSPORT_HEADER_OFFSET	0x00010119
+#define	OID_GEN_RECEIVE_SCALE_CAPABILITIES	0x00010203
+#define	OID_GEN_RECEIVE_SCALE_PARAMETERS	0x00010204
 #define	OID_GEN_MACHINE_NAME		0x0001021A
 #define	OID_GEN_RNDIS_CONFIG_PARAMETER	0x0001021B
 #define	OID_GEN_VLAN_ID			0x0001021C
@@ -85,6 +87,7 @@
 #define	OID_802_3_XMIT_LATE_COLLISIONS	0x01020207
 
 #define OID_TCP_OFFLOAD_PARAMETERS	0xFC01020C
+#define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES	0xFC01020D
 
 #define RNDIS_MEDIUM_802_3		0x
 



CVS commit: src/sys/dev/ic

2019-12-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Dec  6 12:39:51 UTC 2019

Modified Files:
src/sys/dev/ic: ndisreg.h

Log Message:
Added NDIS ver.6.20 definition.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/ndisreg.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/ic/ndisreg.h
diff -u src/sys/dev/ic/ndisreg.h:1.1 src/sys/dev/ic/ndisreg.h:1.2
--- src/sys/dev/ic/ndisreg.h:1.1	Fri Feb 15 08:54:02 2019
+++ src/sys/dev/ic/ndisreg.h	Fri Dec  6 12:39:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndisreg.h,v 1.1 2019/02/15 08:54:02 nonaka Exp $	*/
+/*	$NetBSD: ndisreg.h,v 1.2 2019/12/06 12:39:51 nonaka Exp $	*/
 /*	$OpenBSD: ndis.h,v 1.2 2016/09/23 11:32:13 mikeb Exp $	*/
 
 /*-
@@ -39,6 +39,7 @@
 #define NDIS_VERSION_5_1		0x00050001
 #define NDIS_VERSION_6_0		0x0006
 #define NDIS_VERSION_6_1		0x00060001
+#define NDIS_VERSION_6_20		0x00060014
 #define NDIS_VERSION_6_30		0x0006001e
 
 #define	NDIS_MEDIA_STATE_CONNECTED	0



CVS commit: src/sys/arch/hppa/hppa

2019-12-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Dec  6 08:40:34 UTC 2019

Modified Files:
src/sys/arch/hppa/hppa: trap.c

Log Message:
Simplify userret function signature.  From ad@


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/hppa/hppa/trap.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/hppa/hppa/trap.c
diff -u src/sys/arch/hppa/hppa/trap.c:1.113 src/sys/arch/hppa/hppa/trap.c:1.114
--- src/sys/arch/hppa/hppa/trap.c:1.113	Fri Nov 29 18:27:32 2019
+++ src/sys/arch/hppa/hppa/trap.c	Fri Dec  6 08:40:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.113 2019/11/29 18:27:32 ad Exp $	*/
+/*	$NetBSD: trap.c,v 1.114 2019/12/06 08:40:33 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.113 2019/11/29 18:27:32 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.114 2019/12/06 08:40:33 skrll Exp $");
 
 /* #define INTRDEBUG */
 /* #define TRAPDEBUG */
@@ -198,9 +198,10 @@ u_int rctr_next_iioq;
 #endif
 
 static inline void
-userret(struct lwp *l, register_t pc, u_quad_t oticks)
+userret(struct lwp *l, struct trapframe *tf)
 {
 	struct proc *p = l->l_proc;
+	int oticks = 0; /* XXX why zero? */
 
 	do {
 		l->l_md.md_astpending = 0;
@@ -214,7 +215,8 @@ userret(struct lwp *l, register_t pc, u_
 	if (p->p_stflag & PST_PROFIL) {
 		extern int psratio;
 
-		addupc_task(l, pc, (int)(p->p_sticks - oticks) * psratio);
+		addupc_task(l, tf->tf_iioq_head,
+		(int)(p->p_sticks - oticks) * psratio);
 	}
 }
 
@@ -962,7 +964,7 @@ do_onfault:
 #endif
 
 	if (type & T_USER)
-		userret(l, l->l_md.md_regs->tf_iioq_head, 0);
+		userret(l, l->l_md.md_regs);
 
 #ifdef DEBUG
 	frame_sanity_check(__func__, __LINE__, type, frame, l);
@@ -979,7 +981,7 @@ md_child_return(struct lwp *l)
 	 * Return values in the frame set by cpu_lwp_fork().
 	 */
 
-	userret(l, l->l_md.md_regs->tf_iioq_head, 0);
+	userret(l, l->l_md.md_regs);
 #ifdef DEBUG
 	frame_sanity_check(__func__, __LINE__, 0, l->l_md.md_regs, l);
 #endif /* DEBUG */
@@ -992,7 +994,7 @@ void
 cpu_spawn_return(struct lwp *l)
 {
 
-	userret(l, l->l_md.md_regs->tf_iioq_head, 0);
+	userret(l, l->l_md.md_regs);
 #ifdef DEBUG
 	frame_sanity_check(__func__, __LINE__, 0, l->l_md.md_regs, l);
 #endif /* DEBUG */
@@ -1264,7 +1266,7 @@ syscall(struct trapframe *frame, int *ar
 		break;
 	}
 
-	userret(l, frame->tf_iioq_head, 0);
+	userret(l, frame);
 
 #ifdef DIAGNOSTIC
 	if (ci->ci_cpl != oldcpl) {
@@ -1294,5 +1296,5 @@ startlwp(void *arg)
 	KASSERT(error == 0);
 
 	kmem_free(uc, sizeof(ucontext_t));
-	userret(l, l->l_md.md_regs->tf_iioq_head, 0);
+	userret(l, l->l_md.md_regs);
 }



CVS commit: src/sys

2019-12-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Dec  6 08:35:21 UTC 2019

Modified Files:
src/sys/arch/amd64/amd64: machdep.c
src/sys/compat/common: compat_sysctl_09_43.c
src/sys/kern: tty_subr.c

Log Message:
Fix a bunch of unimportant "Local variable hides global variable" warnings
from the LGTM bot.


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/compat/common/compat_sysctl_09_43.c
cvs rdiff -u -r1.41 -r1.42 src/sys/kern/tty_subr.c

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

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.341 src/sys/arch/amd64/amd64/machdep.c:1.342
--- src/sys/arch/amd64/amd64/machdep.c:1.341	Thu Nov 14 17:09:23 2019
+++ src/sys/arch/amd64/amd64/machdep.c	Fri Dec  6 08:35:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.341 2019/11/14 17:09:23 maxv Exp $	*/
+/*	$NetBSD: machdep.c,v 1.342 2019/12/06 08:35:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.341 2019/11/14 17:09:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.342 2019/12/06 08:35:21 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -912,25 +912,25 @@ dump_seg_iter(int (*callback)(paddr_t, p
 		 * dump will always be smaller than a full one.
 		 */
 		if (sparse_dump && sparse_dump_physmap) {
-			paddr_t p, start, end;
+			paddr_t p, sp_start, sp_end;
 			int lastset;
 
-			start = mem_clusters[i].start;
-			end = start + mem_clusters[i].size;
-			start = rounddown(start, PAGE_SIZE); /* unnecessary? */
+			sp_start = mem_clusters[i].start;
+			sp_end = sp_start + mem_clusters[i].size;
+			sp_start = rounddown(sp_start, PAGE_SIZE); /* unnecessary? */
 			lastset = 0;
-			for (p = start; p < end; p += PAGE_SIZE) {
+			for (p = sp_start; p < sp_end; p += PAGE_SIZE) {
 int thisset = isset(sparse_dump_physmap,
 p/PAGE_SIZE);
 
 if (!lastset && thisset)
-	start = p;
+	sp_start = p;
 if (lastset && !thisset)
-	CALLBACK(start, p - start);
+	CALLBACK(sp_start, p - sp_start);
 lastset = thisset;
 			}
 			if (lastset)
-CALLBACK(start, p - start);
+CALLBACK(sp_start, p - sp_start);
 		} else
 #endif
 			CALLBACK(mem_clusters[i].start, mem_clusters[i].size);

Index: src/sys/compat/common/compat_sysctl_09_43.c
diff -u src/sys/compat/common/compat_sysctl_09_43.c:1.2 src/sys/compat/common/compat_sysctl_09_43.c:1.3
--- src/sys/compat/common/compat_sysctl_09_43.c:1.2	Sun Jan 27 02:08:39 2019
+++ src/sys/compat/common/compat_sysctl_09_43.c	Fri Dec  6 08:35:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_sysctl_09_43.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $	*/
+/*	$NetBSD: compat_sysctl_09_43.c,v 1.3 2019/12/06 08:35:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_sysctl_09_43.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_sysctl_09_43.c,v 1.3 2019/12/06 08:35:21 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -129,20 +129,20 @@ compat_sysctl_vfs(struct sysctllog **clo
 }
 #endif
 
-static struct sysctllog *clog = NULL;
+static struct sysctllog *compat_09_43_clog = NULL;
 
 int
 compat_sysctl_09_43_init(void)
 {
 
-	return compat_sysctl_vfs();
+	return compat_sysctl_vfs(_09_43_clog);
 }
 
 int
 compat_sysctl_09_43_fini(void)
 {
 
-	sysctl_teardown();
+	sysctl_teardown(_09_43_clog);
 	return 0;
 }
 

Index: src/sys/kern/tty_subr.c
diff -u src/sys/kern/tty_subr.c:1.41 src/sys/kern/tty_subr.c:1.42
--- src/sys/kern/tty_subr.c:1.41	Thu Jun  1 02:45:13 2017
+++ src/sys/kern/tty_subr.c	Fri Dec  6 08:35:21 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_subr.c,v 1.41 2017/06/01 02:45:13 chs Exp $	*/
+/*	$NetBSD: tty_subr.c,v 1.42 2019/12/06 08:35:21 maxv Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994 Theo de Raadt
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tty_subr.c,v 1.41 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_subr.c,v 1.42 2019/12/06 08:35:21 maxv Exp $");
 
 #include 
 #include 
@@ -378,7 +378,7 @@ out:
 	return count;
 }
 
-static int cc;
+static int tty_global_cc;
 
 /*
  * Given a non-NULL pointer into the clist return the pointer
@@ -396,11 +396,11 @@ nextc(struct clist *clp, u_char *cp, int
 		/*
 		 * First time initialization.
 		 */
-		cc = clp->c_cc;
+		tty_global_cc = clp->c_cc;
 	}
-	if (cc == 0 || cp == NULL)
+	if (tty_global_cc == 0 || cp == NULL)
 		return NULL;
-	if (--cc == 0)
+	if (--tty_global_cc == 0)
 		return NULL;
 	if (++cp == clp->c_ce)
 		cp = clp->c_cs;
@@ -432,8 +432,8 @@ firstc(struct clist *clp, int *c)
 {
 	u_char *cp;
 
-	cc = clp->c_cc;
-	if (cc == 0)
+	tty_global_cc = clp->c_cc;
+	if (tty_global_cc ==