CVS commit: src

2021-01-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 14 07:42:31 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_156.exp
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: add type details to message for enum type mismatch

Before December 2020, it was cumbersome to add type information to a
message since the caller had to explicitly allocate buffers for the type
names.  That's probably the reason why this crucial detail had been left
out of the warning.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_156.exp
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/xlint/lint1/tree.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/usr.bin/xlint/lint1/msg_156.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_156.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_156.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_156.exp:1.2	Fri Jan  8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_156.exp	Thu Jan 14 07:42:31 2021
@@ -1 +1 @@
-msg_156.c(24): warning: enum type mismatch, arg #1 [156]
+msg_156.c(24): warning: enum type mismatch, arg #1 (enum color != enum size) [156]

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.66 src/usr.bin/xlint/lint1/err.c:1.67
--- src/usr.bin/xlint/lint1/err.c:1.66	Tue Jan 12 20:42:01 2021
+++ src/usr.bin/xlint/lint1/err.c	Thu Jan 14 07:42:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.66 2021/01/12 20:42:01 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.67 2021/01/14 07:42:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.66 2021/01/12 20:42:01 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.67 2021/01/14 07:42:31 rillig Exp $");
 #endif
 
 #include 
@@ -215,7 +215,7 @@ const	char *msgs[] = {
 	"argument has incompatible pointer type, arg #%d (%s != %s)", /* 153 */
 	"illegal combination of %s (%s) and %s (%s), arg #%d",	  /* 154 */
 	"argument is incompatible with prototype, arg #%d",	  /* 155 */
-	"enum type mismatch, arg #%d",  /* 156 */
+	"enum type mismatch, arg #%d (%s != %s)",		  /* 156 */
 	"ANSI C treats constant as unsigned",			  /* 157 */
 	"%s may be used before set",  /* 158 */
 	"assignment in conditional context",			  /* 159 */

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.151 src/usr.bin/xlint/lint1/tree.c:1.152
--- src/usr.bin/xlint/lint1/tree.c:1.151	Tue Jan 12 20:42:01 2021
+++ src/usr.bin/xlint/lint1/tree.c	Thu Jan 14 07:42:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.151 2021/01/12 20:42:01 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.152 2021/01/14 07:42:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.151 2021/01/12 20:42:01 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.152 2021/01/14 07:42:31 rillig Exp $");
 #endif
 
 #include 
@@ -1675,8 +1675,9 @@ check_enum_type_mismatch(op_t op, int ar
 			warning(210);
 			break;
 		case FARG:
-			/* enum type mismatch, arg #%d */
-			warning(156, arg);
+			/* enum type mismatch, arg #%d (%s != %s) */
+			warning(156, arg,
+			type_name(ln->tn_type), type_name(rn->tn_type));
 			break;
 		case RETURN:
 			/* return value type mismatch (%s) and (%s) */



CVS commit: src

2021-01-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 14 07:42:31 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_156.exp
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: add type details to message for enum type mismatch

Before December 2020, it was cumbersome to add type information to a
message since the caller had to explicitly allocate buffers for the type
names.  That's probably the reason why this crucial detail had been left
out of the warning.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_156.exp
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/xlint/lint1/tree.c

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



CVS commit: src/usr.bin/xlint/lint1

2021-01-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 14 07:34:48 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: scan.l

Log Message:
lint: fix enum type in the lexical analysis part

Detected by Clang, reported by riastradh:

> scan.l:144:29: error: implicit conversion from enumeration type
>   'tspec_t' to different enumeration type 'op_t'
> return operator(T_ASTERISK, NOTSPEC);
> ^~~

and by lint as well, with a less detailed and less helpful message:

> scan.l(144): warning: enum type mismatch, arg #2 [156]

Since scan.c is generated from scan.l, it is not included in the default
"make lint" though.

The value of these two constants is the same, furthermore that value is
never actually used in the code, therefore no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/scan.l

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



CVS commit: src/usr.bin/xlint/lint1

2021-01-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 14 07:34:48 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: scan.l

Log Message:
lint: fix enum type in the lexical analysis part

Detected by Clang, reported by riastradh:

> scan.l:144:29: error: implicit conversion from enumeration type
>   'tspec_t' to different enumeration type 'op_t'
> return operator(T_ASTERISK, NOTSPEC);
> ^~~

and by lint as well, with a less detailed and less helpful message:

> scan.l(144): warning: enum type mismatch, arg #2 [156]

Since scan.c is generated from scan.l, it is not included in the default
"make lint" though.

The value of these two constants is the same, furthermore that value is
never actually used in the code, therefore no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/scan.l

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

Modified files:

Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.116 src/usr.bin/xlint/lint1/scan.l:1.117
--- src/usr.bin/xlint/lint1/scan.l:1.116	Sun Jan 10 00:05:46 2021
+++ src/usr.bin/xlint/lint1/scan.l	Thu Jan 14 07:34:48 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.116 2021/01/10 00:05:46 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.117 2021/01/14 07:34:48 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.116 2021/01/10 00:05:46 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.117 2021/01/14 07:34:48 rillig Exp $");
 #endif
 
 #include 
@@ -141,7 +141,7 @@ TL	([fFlL]?[i]?)
 "."return operator(T_STROP, POINT);
 "+"return operator(T_ADDOP, PLUS);
 "-"return operator(T_ADDOP, MINUS);
-"*"return operator(T_ASTERISK, NOTSPEC);
+"*"return operator(T_ASTERISK, NOOP);
 "/"return operator(T_DIVOP, DIV);
 "%"return operator(T_DIVOP, MOD);
 "!"return operator(T_UNOP, NOT);



CVS commit: src/sys/dev/pci/ixgbe

2021-01-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 14 05:47:35 UTC 2021

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

Log Message:
 Add "TX " to "Queue No Descriptor Available" to make it more understandable.


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.277 src/sys/dev/pci/ixgbe/ixgbe.c:1.278
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.277	Thu Dec 31 12:34:33 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Jan 14 05:47:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.277 2020/12/31 12:34:33 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.278 2021/01/14 05:47:35 msaitoh Exp $ */
 
 /**
 
@@ -1902,7 +1902,7 @@ ixgbe_add_hw_stats(struct adapter *adapt
 		NULL, adapter->queues[i].evnamebuf, "TSO");
 		evcnt_attach_dynamic(>no_desc_avail, EVCNT_TYPE_MISC,
 		NULL, adapter->queues[i].evnamebuf,
-		"Queue No Descriptor Available");
+		"TX Queue No Descriptor Available");
 		evcnt_attach_dynamic(>total_packets, EVCNT_TYPE_MISC,
 		NULL, adapter->queues[i].evnamebuf,
 		"Queue Packets Transmitted");



CVS commit: src/sys/dev/pci/ixgbe

2021-01-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Jan 14 05:47:35 UTC 2021

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

Log Message:
 Add "TX " to "Queue No Descriptor Available" to make it more understandable.


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/sys/dev/pci/ixgbe/ixgbe.c

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



CVS commit: src/tests/dev/fss

2021-01-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Jan 14 04:30:40 UTC 2021

Modified Files:
src/tests/dev/fss: t_fss.sh

Log Message:
Unmount and unconfigure in the reverse order that they were done.  Fixes
problem with leaving a dangling snapshot configured.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/dev/fss/t_fss.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/dev/fss/t_fss.sh
diff -u src/tests/dev/fss/t_fss.sh:1.3 src/tests/dev/fss/t_fss.sh:1.4
--- src/tests/dev/fss/t_fss.sh:1.3	Wed Mar 15 10:53:15 2017
+++ src/tests/dev/fss/t_fss.sh	Thu Jan 14 04:30:40 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_fss.sh,v 1.3 2017/03/15 10:53:15 martin Exp $
+# $NetBSD: t_fss.sh,v 1.4 2021/01/14 04:30:40 simonb Exp $
 #
 # Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -74,9 +74,9 @@ basic_body() {
 
 basic_cleanup() {
 # Unmount our temporary stuff
-	umount ${vnd}		|| true
-	fssconfig -u fss0	|| true
 	umount /dev/fss0	|| true
+	fssconfig -u fss0	|| true
+	umount ${vnd}		|| true
 	vndconfig -u ${vnddev}	|| true
 }
 



CVS commit: src/tests/dev/fss

2021-01-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Jan 14 04:30:40 UTC 2021

Modified Files:
src/tests/dev/fss: t_fss.sh

Log Message:
Unmount and unconfigure in the reverse order that they were done.  Fixes
problem with leaving a dangling snapshot configured.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/dev/fss/t_fss.sh

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



CVS commit: src/sys/compat/netbsd32

2021-01-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Jan 14 02:51:52 UTC 2021

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

Log Message:
Handle rev 1.62 of kern/sys_lwp.c
   make _lwp_park return the remaining time to sleep in the "ts" argument
   if it is a relative timestamp, as discussed in tech-kern.
for compat32.  Thanks skrll@ for some cleanup tips.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/compat/netbsd32/netbsd32_lwp.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_lwp.c
diff -u src/sys/compat/netbsd32/netbsd32_lwp.c:1.22 src/sys/compat/netbsd32/netbsd32_lwp.c:1.23
--- src/sys/compat/netbsd32/netbsd32_lwp.c:1.22	Wed Jan 29 15:47:52 2020
+++ src/sys/compat/netbsd32/netbsd32_lwp.c	Thu Jan 14 02:51:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_lwp.c,v 1.22 2020/01/29 15:47:52 ad Exp $	*/
+/*	$NetBSD: netbsd32_lwp.c,v 1.23 2021/01/14 02:51:52 simonb Exp $	*/
 
 /*
  *  Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.22 2020/01/29 15:47:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.23 2021/01/14 02:51:52 simonb Exp $");
 
 #include 
 #include 
@@ -170,6 +170,7 @@ netbsd32lwp_park60(struct lwp *l,
 	} */
 	struct timespec ts, *tsp;
 	struct netbsd32_timespec ts32;
+	int ret;
 	int error;
 
 	if (SCARG_P32(uap, ts) == NULL)
@@ -188,7 +189,12 @@ netbsd32lwp_park60(struct lwp *l,
 			return error;
 	}
 
-	return lwp_park(SCARG(uap, clock_id), SCARG(uap, flags), tsp);
+	ret = lwp_park(SCARG(uap, clock_id), SCARG(uap, flags), tsp);
+	if (SCARG_P32(uap, ts) != NULL && (SCARG(uap, flags) & TIMER_ABSTIME) == 0) {
+		netbsd32_from_timespec(, );
+		(void)copyout(, SCARG_P32(uap, ts), sizeof(ts32));
+	}
+	return ret;
 }
 
 int



CVS commit: src/sys/compat/netbsd32

2021-01-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Jan 14 02:51:52 UTC 2021

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

Log Message:
Handle rev 1.62 of kern/sys_lwp.c
   make _lwp_park return the remaining time to sleep in the "ts" argument
   if it is a relative timestamp, as discussed in tech-kern.
for compat32.  Thanks skrll@ for some cleanup tips.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/compat/netbsd32/netbsd32_lwp.c

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



CVS commit: src/sys/compat/netbsd32

2021-01-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Jan 14 02:43:04 UTC 2021

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

Log Message:
Use netbsd32_* types instead of relying on __packed in the vnd ioctl
structures.  __packed didn't work on archs where 64-bit types were
64-bit aligned with a 32-bit ABI (eg MIPS n32).

OK mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/compat/netbsd32/netbsd32_ioctl.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_ioctl.h
diff -u src/sys/compat/netbsd32/netbsd32_ioctl.h:1.73 src/sys/compat/netbsd32/netbsd32_ioctl.h:1.74
--- src/sys/compat/netbsd32/netbsd32_ioctl.h:1.73	Mon Sep  7 03:12:51 2020
+++ src/sys/compat/netbsd32/netbsd32_ioctl.h	Thu Jan 14 02:43:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_ioctl.h,v 1.73 2020/09/07 03:12:51 mrg Exp $	*/
+/*	$NetBSD: netbsd32_ioctl.h,v 1.74 2021/01/14 02:43:04 simonb Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -42,6 +42,8 @@
 #include 
 #include 
 
+#include 
+
 /* we define some handy macros here... */
 #define IOCTL_STRUCT_CONV_TO(cmd, type)	\
 		size = IOCPARM_LEN(cmd); \
@@ -475,23 +477,19 @@ struct netbsd32_sioc_sg_req {
 /* from  */
 #define	SIOCGETSGCNT32	_IOWR('u', 52, struct netbsd32_sioc_sg_req) /* sg pkt cnt */
 
-/*
- * The next two structures are marked "__packed" as they normally end up
- * being padded in 64-bit mode.
- */
 struct netbsd32_vnd_ioctl {
 	netbsd32_charp	vnd_file;	/* pathname of file to mount */
 	int		vnd_flags;	/* flags; see below */
 	struct vndgeom	vnd_geom;	/* geometry to emulate */
 	unsigned int	vnd_osize;	/* (returned) size of disk */
-	uint64_t	vnd_size;	/* (returned) size of disk */
-} __packed;
+	netbsd32_uint64	vnd_size;	/* (returned) size of disk */
+};
 
 struct netbsd32_vnd_user {
 	int		vnu_unit;	/* which vnd unit */
-	dev_t		vnu_dev;	/* file is on this device... */
-	ino_t		vnu_ino;	/* ...at this inode */
-} __packed;
+	netbsd32_dev_t	vnu_dev;	/* file is on this device... */
+	netbsd32_ino_t	vnu_ino;	/* ...at this inode */
+};
 
 /* from  */
 #define VNDIOCSET32	_IOWR('F', 0, struct netbsd32_vnd_ioctl)	/* enable disk */



CVS commit: src/sys/compat/netbsd32

2021-01-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Jan 14 02:43:04 UTC 2021

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

Log Message:
Use netbsd32_* types instead of relying on __packed in the vnd ioctl
structures.  __packed didn't work on archs where 64-bit types were
64-bit aligned with a 32-bit ABI (eg MIPS n32).

OK mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/compat/netbsd32/netbsd32_ioctl.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

2021-01-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 13 23:54:21 UTC 2021

Modified Files:
src/sys/dev: random.c

Log Message:
/dev/random: Fix nonblocking read.

The flag passed to cdev_read is IO_NDELAY, not FNONBLOCK/O_NONBLOCK,
and although the latter two coincide, IO_NDELAY has a different
value.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/random.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

2021-01-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 13 23:54:21 UTC 2021

Modified Files:
src/sys/dev: random.c

Log Message:
/dev/random: Fix nonblocking read.

The flag passed to cdev_read is IO_NDELAY, not FNONBLOCK/O_NONBLOCK,
and although the latter two coincide, IO_NDELAY has a different
value.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/random.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/random.c
diff -u src/sys/dev/random.c:1.8 src/sys/dev/random.c:1.9
--- src/sys/dev/random.c:1.8	Fri Aug 14 00:53:16 2020
+++ src/sys/dev/random.c	Wed Jan 13 23:54:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.c,v 1.8 2020/08/14 00:53:16 riastradh Exp $	*/
+/*	$NetBSD: random.c,v 1.9 2021/01/13 23:54:21 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.8 2020/08/14 00:53:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.9 2021/01/13 23:54:21 riastradh Exp $");
 
 #include 
 #include 
@@ -67,6 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: random.c,v 1
 #include 
 #include 
 #include 
+#include 		/* IO_NDELAY */
 
 #include "ioconf.h"
 
@@ -222,8 +223,11 @@ random_read(dev_t dev, struct uio *uio, 
 		return ENXIO;
 	}
 
-	/* Set GRND_NONBLOCK if the user requested FNONBLOCK.  */
-	if (flags & FNONBLOCK)
+	/*
+	 * Set GRND_NONBLOCK if the user requested IO_NDELAY (i.e., the
+	 * file was opened with O_NONBLOCK).
+	 */
+	if (flags & IO_NDELAY)
 		gflags |= GRND_NONBLOCK;
 
 	/* Defer to getrandom.  */



CVS commit: src/sys/kern

2021-01-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 13 23:53:23 UTC 2021

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

Log Message:
entropy: Use a separate condvar for rndsource list lock.

Otherwise, two processes both waiting for entropy will dance around
waking each other up (by releasing the rndsource list lock) and going
back to sleep (waiting for entropy).

Witnessed on the armv7 testbed when /etc/security presumably ran
twice over a >day-long test, until the metaphorical plug got pulled:

net/if_ipsec/t_ipsec_natt (509/888): 2 test cases
ipsecif_natt_transport_null: [ 37123.2631856] entropy: pid 1005 (dd) 
blocking due to lack of entropy
[256.523317s] Failed: atf-check failed; see the output of the test for details
ipsecif_natt_transport_rijndaelcbc: [274.370791s] Failed: atf-check failed; 
see the output of the test for details
[532.486697s]
...
puffs_lstat_symlink: [ 123442.1606517] entropy: pid 9499 (dd) blocking due 
to lack of entropy
[ 123442.1835067] entropy: pid 1005 (dd) blocking due to lack of entropy
[ 123442.1944600] entropy: pid 9499 (dd) blocking due to lack of entropy
[ 123442.1944600] entropy: pid 1005 (dd) blocking due to lack of entropy
...


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/kern/kern_entropy.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_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.26 src/sys/kern/kern_entropy.c:1.27
--- src/sys/kern/kern_entropy.c:1.26	Mon Jan 11 02:18:40 2021
+++ src/sys/kern/kern_entropy.c	Wed Jan 13 23:53:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.26 2021/01/11 02:18:40 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.27 2021/01/13 23:53:23 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.26 2021/01/11 02:18:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.27 2021/01/13 23:53:23 riastradh Exp $");
 
 #include 
 #include 
@@ -161,6 +161,7 @@ struct {
 	kcondvar_t	cv;		/* notifies state changes */
 	struct selinfo	selq;		/* notifies needed -> 0 */
 	struct lwp	*sourcelock;	/* lock on list of sources */
+	kcondvar_t	sourcelock_cv;	/* notifies sourcelock release */
 	LIST_HEAD(,krndsource) sources;	/* list of entropy sources */
 	enum entropy_stage {
 		ENTROPY_COLD = 0, /* single-threaded */
@@ -367,6 +368,7 @@ entropy_init(void)
 	mutex_init(>lock, MUTEX_DEFAULT, IPL_VM);
 	cv_init(>cv, "entropy");
 	selinit(>selq);
+	cv_init(>sourcelock_cv, "entsrclock");
 
 	/* Make sure the seed source is attached.  */
 	attach_seed_rndsource();
@@ -1594,7 +1596,7 @@ rnd_detach_source(struct krndsource *rs)
 	/* Wait until the source list is not in use, and remove it.  */
 	mutex_enter(>lock);
 	while (E->sourcelock)
-		cv_wait(>cv, >lock);
+		cv_wait(>sourcelock_cv, >lock);
 	LIST_REMOVE(rs, list);
 	mutex_exit(>lock);
 
@@ -1618,7 +1620,7 @@ rnd_lock_sources(void)
 	KASSERT(mutex_owned(>lock));
 
 	while (E->sourcelock) {
-		error = cv_wait_sig(>cv, >lock);
+		error = cv_wait_sig(>sourcelock_cv, >lock);
 		if (error)
 			return error;
 	}
@@ -1663,7 +1665,7 @@ rnd_unlock_sources(void)
 	curlwp, E->sourcelock);
 	E->sourcelock = NULL;
 	if (E->stage >= ENTROPY_WARM)
-		cv_broadcast(>cv);
+		cv_signal(>sourcelock_cv);
 }
 
 /*



CVS commit: src/sys/kern

2021-01-13 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jan 13 23:53:23 UTC 2021

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

Log Message:
entropy: Use a separate condvar for rndsource list lock.

Otherwise, two processes both waiting for entropy will dance around
waking each other up (by releasing the rndsource list lock) and going
back to sleep (waiting for entropy).

Witnessed on the armv7 testbed when /etc/security presumably ran
twice over a >day-long test, until the metaphorical plug got pulled:

net/if_ipsec/t_ipsec_natt (509/888): 2 test cases
ipsecif_natt_transport_null: [ 37123.2631856] entropy: pid 1005 (dd) 
blocking due to lack of entropy
[256.523317s] Failed: atf-check failed; see the output of the test for details
ipsecif_natt_transport_rijndaelcbc: [274.370791s] Failed: atf-check failed; 
see the output of the test for details
[532.486697s]
...
puffs_lstat_symlink: [ 123442.1606517] entropy: pid 9499 (dd) blocking due 
to lack of entropy
[ 123442.1835067] entropy: pid 1005 (dd) blocking due to lack of entropy
[ 123442.1944600] entropy: pid 9499 (dd) blocking due to lack of entropy
[ 123442.1944600] entropy: pid 1005 (dd) blocking due to lack of entropy
...


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/kern/kern_entropy.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/pci

2021-01-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jan 13 19:46:49 UTC 2021

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

Log Message:
Fix for virtios viomb memory balloon driver. The inflate_done() and
deflate_done() issued a wrong extent to bus_dmamap_sync() giving rise to
panics on aarch64s mmio backend.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/viomb.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/viomb.c
diff -u src/sys/dev/pci/viomb.c:1.10 src/sys/dev/pci/viomb.c:1.11
--- src/sys/dev/pci/viomb.c:1.10	Tue Dec 10 18:00:17 2019
+++ src/sys/dev/pci/viomb.c	Wed Jan 13 19:46:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: viomb.c,v 1.10 2019/12/10 18:00:17 ad Exp $	*/
+/*	$NetBSD: viomb.c,v 1.11 2021/01/13 19:46:49 reinoud Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.10 2019/12/10 18:00:17 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.11 2021/01/13 19:46:49 reinoud Exp $");
 
 #include 
 #include 
@@ -341,7 +341,7 @@ inflate_done(struct viomb_softc *sc)
 	b = >sc_req;
 	nvpages = b->bl_nentries;
 	bus_dmamap_sync(virtio_dmat(vsc), b->bl_dmamap,
-			offsetof(struct balloon_req, bl_pages),
+			0,
 			sizeof(uint32_t)*nvpages,
 			BUS_DMASYNC_POSTWRITE);
 	while (!TAILQ_EMPTY(>bl_pglist)) {
@@ -456,7 +456,7 @@ deflate_done(struct viomb_softc *sc)
 	b = >sc_req;
 	nvpages = b->bl_nentries;
 	bus_dmamap_sync(virtio_dmat(vsc), b->bl_dmamap,
-			offsetof(struct balloon_req, bl_pages),
+			0,
 			sizeof(uint32_t)*nvpages,
 			BUS_DMASYNC_POSTWRITE);
 



CVS commit: src/sys/dev/pci

2021-01-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jan 13 19:46:49 UTC 2021

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

Log Message:
Fix for virtios viomb memory balloon driver. The inflate_done() and
deflate_done() issued a wrong extent to bus_dmamap_sync() giving rise to
panics on aarch64s mmio backend.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/viomb.c

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



CVS commit: src/external/mpl/dhcp/dist/common

2021-01-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 13 17:01:31 UTC 2021

Modified Files:
src/external/mpl/dhcp/dist/common: options.c

Log Message:
Reset options on every loop.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/mpl/dhcp/dist/common/options.c

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

Modified files:

Index: src/external/mpl/dhcp/dist/common/options.c
diff -u src/external/mpl/dhcp/dist/common/options.c:1.4 src/external/mpl/dhcp/dist/common/options.c:1.5
--- src/external/mpl/dhcp/dist/common/options.c:1.4	Wed Jan 13 10:51:49 2021
+++ src/external/mpl/dhcp/dist/common/options.c	Wed Jan 13 12:01:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: options.c,v 1.4 2021/01/13 15:51:49 christos Exp $	*/
+/*	$NetBSD: options.c,v 1.5 2021/01/13 17:01:31 christos Exp $	*/
 
 /* options.c
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: options.c,v 1.4 2021/01/13 15:51:49 christos Exp $");
+__RCSID("$NetBSD: options.c,v 1.5 2021/01/13 17:01:31 christos Exp $");
 
 #define DHCP_OPTION_DATA
 #include "dhcpd.h"
@@ -130,8 +130,8 @@ int parse_option_buffer (options, buffer
 	unsigned len, offset;
 	unsigned code;
 	struct option_cache *op = NULL, *nop = NULL;
-	struct buffer *bp = (struct buffer *)0;
-	struct option *option = NULL;
+	struct buffer *bp = NULL;
+	struct option *option;
 	char *reason = "general failure";
 
 	if (!buffer_allocate (, length, MDL)) {
@@ -143,6 +143,7 @@ int parse_option_buffer (options, buffer
 	for (offset = 0;
 	 (offset + universe->tag_size) <= length &&
 	 (code = universe->get_tag(buffer + offset)) != universe->end; ) {
+		option = NULL;
 		offset += universe->tag_size;
 
 		/* Pad options don't have a length - just skip them. */



CVS commit: src/external/mpl/dhcp/dist/common

2021-01-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 13 17:01:31 UTC 2021

Modified Files:
src/external/mpl/dhcp/dist/common: options.c

Log Message:
Reset options on every loop.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/mpl/dhcp/dist/common/options.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/sparc/sparc

2021-01-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Jan 13 16:42:17 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: pmap.c

Log Message:
in pmap_writetext(), restore the context also when we return early.


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 src/sys/arch/sparc/sparc/pmap.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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.370 src/sys/arch/sparc/sparc/pmap.c:1.371
--- src/sys/arch/sparc/sparc/pmap.c:1.370	Mon Jan 11 06:12:43 2021
+++ src/sys/arch/sparc/sparc/pmap.c	Wed Jan 13 16:42:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $ */
+/*	$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -7868,8 +7868,7 @@ pmap_writetext(unsigned char *dst, int c
 	if (CPU_HAS_SRMMU) {
 		pte0 = getpte4m(va);
 		if ((pte0 & SRMMU_TETYPE) != SRMMU_TEPTE) {
-			splx(s);
-			return;
+			goto out;
 		}
 		pte = pte0 | PPROT_WRITE;
 		setpte4m(va, pte);
@@ -7882,8 +7881,7 @@ pmap_writetext(unsigned char *dst, int c
 	if (CPU_ISSUN4C || CPU_ISSUN4) {
 		pte0 = getpte4(va);
 		if ((pte0 & PG_V) == 0) {
-			splx(s);
-			return;
+			goto out;
 		}
 		pte = pte0 | PG_W;
 		setpte4(va, pte);
@@ -7892,6 +7890,8 @@ pmap_writetext(unsigned char *dst, int c
 	}
 #endif
 	cache_flush(dst, 1);
+
+out:
 	setcontext(ctx);
 	splx(s);
 }



CVS commit: src/sys/arch/sparc/sparc

2021-01-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Jan 13 16:42:17 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: pmap.c

Log Message:
in pmap_writetext(), restore the context also when we return early.


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 src/sys/arch/sparc/sparc/pmap.c

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



CVS commit: src/external/mpl/dhcp/dist/common

2021-01-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 13 15:51:49 UTC 2021

Modified Files:
src/external/mpl/dhcp/dist/common: options.c

Log Message:
If an option is not found in the standard table, log it and don't try to
dereference it. This prevents crashes from XenServer VM that PXE boots and
includes option 175 in the DHCP request. Reported by Stephen Borrill.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/mpl/dhcp/dist/common/options.c

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

Modified files:

Index: src/external/mpl/dhcp/dist/common/options.c
diff -u src/external/mpl/dhcp/dist/common/options.c:1.3 src/external/mpl/dhcp/dist/common/options.c:1.4
--- src/external/mpl/dhcp/dist/common/options.c:1.3	Mon Aug  3 17:10:56 2020
+++ src/external/mpl/dhcp/dist/common/options.c	Wed Jan 13 10:51:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: options.c,v 1.3 2020/08/03 21:10:56 christos Exp $	*/
+/*	$NetBSD: options.c,v 1.4 2021/01/13 15:51:49 christos Exp $	*/
 
 /* options.c
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: options.c,v 1.3 2020/08/03 21:10:56 christos Exp $");
+__RCSID("$NetBSD: options.c,v 1.4 2021/01/13 15:51:49 christos Exp $");
 
 #define DHCP_OPTION_DATA
 #include "dhcpd.h"
@@ -179,13 +179,16 @@ int parse_option_buffer (options, buffer
 
 		offset += universe->length_size;
 
-		option_code_hash_lookup(, universe->code_hash, ,
-	0, MDL);
+		if (!option_code_hash_lookup(, universe->code_hash,
+		, 0, MDL)) {
+			log_error("Can't find option with code %u", code);
+		}
 
 		/* If the length is outrageous, the options are bad. */
 		if (offset + len > length) {
 			/* Avoid reference count overflow */
-			option_dereference(, MDL);
+			if (option)
+option_dereference(, MDL);
 			reason = "option length exceeds option buffer length";
 		  bogus:
 			log_error("parse_option_buffer: malformed option "
@@ -216,7 +219,8 @@ int parse_option_buffer (options, buffer
 			/* non-compliant clients can send it
 			 * we'll just drop it and go on */
 			log_debug ("Ignoring empty DHO_HOST_NAME option");
-			option_dereference(, MDL);
+			if (option)
+option_dereference(, MDL);
 			offset += len;
 			continue;
 		}
@@ -282,7 +286,8 @@ int parse_option_buffer (options, buffer
 			option_cache_dereference(, MDL);
 		}
 
-		option_dereference(, MDL);
+		if (option)
+			option_dereference(, MDL);
 		offset += len;
 	}
 	buffer_dereference (, MDL);



CVS commit: src/external/mpl/dhcp/dist/common

2021-01-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 13 15:51:49 UTC 2021

Modified Files:
src/external/mpl/dhcp/dist/common: options.c

Log Message:
If an option is not found in the standard table, log it and don't try to
dereference it. This prevents crashes from XenServer VM that PXE boots and
includes option 175 in the DHCP request. Reported by Stephen Borrill.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/mpl/dhcp/dist/common/options.c

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