CVS commit: src/usr.bin/make/unit-tests

2020-08-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 19 05:51:19 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varname-dot-newline.exp
varname-dot-newline.mk

Log Message:
make(1): add test for the .newline variable


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-dot-newline.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dot-newline.mk

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/make/unit-tests/varname-dot-newline.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.1 src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.2
--- src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.1	Sun Aug 16 12:07:52 2020
+++ src/usr.bin/make/unit-tests/varname-dot-newline.exp	Wed Aug 19 05:51:18 2020
@@ -1 +1,4 @@
+make: "varname-dot-newline.mk" line 16: The .newline variable can be overwritten.  Just don't do that.
+first
+second
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-dot-newline.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-newline.mk:1.2 src/usr.bin/make/unit-tests/varname-dot-newline.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-newline.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dot-newline.mk	Wed Aug 19 05:51:18 2020
@@ -1,8 +1,23 @@
-# $NetBSD: varname-dot-newline.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dot-newline.mk,v 1.3 2020/08/19 05:51:18 rillig Exp $
 #
 # Tests for the special .newline variable.
+#
+# Contrary to the special variable named "" that is used in expressions like
+# ${:Usome-value}, the variable ".newline" is not protected against
+# modification.  Nobody exploits that though.
+
+NEWLINE:=	${.newline}
+
+.newline=	overwritten
+
+.if ${.newline} == ${NEWLINE}
+.info The .newline variable cannot be overwritten.  Good.
+.else
+.info The .newline variable can be overwritten.  Just don't do that.
+.endif
 
-# TODO: Implementation
+# Restore the original value.
+.newline=	${NEWLINE}
 
 all:
-	@:;
+	@echo 'first${.newline}second'



CVS commit: src/usr.bin/make/unit-tests

2020-08-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 19 05:40:07 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: varname-dollar.exp varname-dollar.mk

Log Message:
make(1): add test for the $$ expression


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-dollar.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dollar.mk

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/make/unit-tests/varname-dollar.exp
diff -u src/usr.bin/make/unit-tests/varname-dollar.exp:1.1 src/usr.bin/make/unit-tests/varname-dollar.exp:1.2
--- src/usr.bin/make/unit-tests/varname-dollar.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/varname-dollar.exp	Wed Aug 19 05:40:06 2020
@@ -1 +1,5 @@
+make: "varname-dollar.mk" line 16: dollar is $.
+make: "varname-dollar.mk" line 17: dollar in braces is .
+make: "varname-dollar.mk" line 25: dollar is $.
+make: "varname-dollar.mk" line 26: dollar in braces is dollar.
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-dollar.mk
diff -u src/usr.bin/make/unit-tests/varname-dollar.mk:1.2 src/usr.bin/make/unit-tests/varname-dollar.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dollar.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dollar.mk	Wed Aug 19 05:40:06 2020
@@ -1,9 +1,29 @@
-# $NetBSD: varname-dollar.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dollar.mk,v 1.3 2020/08/19 05:40:06 rillig Exp $
 #
 # Tests for the expression "$$", which looks as if it referred to a variable,
 # but simply expands to a single '$' sign.
+#
+# If there really were a special variable named '$', the expressions ${${DOLLAR}}
+# and $$ would always expand to the same value.
+
+# Using the dollar sign in variable names is tricky and not recommended.
+# To see that using this variable indeed affects the variable '$', run the
+# test individually with the -dv option.
+DOLLAR=		$$
+
+# At this point, the variable '$' is not defined. Therefore the second line
+# returns an empty string.
+.info dollar is $$.
+.info dollar in braces is ${${DOLLAR}}.
+
+# Now overwrite the '$' variable to see whether '$$' really expands to that
+# variable, or whether '$$' is handled by the parser.
+${DOLLAR}=	dollar
 
-# TODO: Implementation
+# At this point, the variable '$' is defined, therefore its value is printed
+# in the second .info directive.
+.info dollar is $$.
+.info dollar in braces is ${${DOLLAR}}.
 
 all:
 	@:;



CVS commit: src/usr.bin/make/unit-tests

2020-08-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 19 05:25:26 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-no-action.exp
opt-no-action.mk

Log Message:
make(1): add test for the -n option


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-no-action.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-no-action.mk

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/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.101 src/usr.bin/make/unit-tests/Makefile:1.102
--- src/usr.bin/make/unit-tests/Makefile:1.101	Wed Aug 19 05:13:18 2020
+++ src/usr.bin/make/unit-tests/Makefile	Wed Aug 19 05:25:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.101 2020/08/19 05:13:18 rillig Exp $
+# $NetBSD: Makefile,v 1.102 2020/08/19 05:25:26 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -310,6 +310,7 @@ FLAGS.doterror=		# none
 FLAGS.envfirst=		-e
 FLAGS.export=		# none
 FLAGS.lint=		-dL -k
+FLAGS.opt-no-action=	-n
 FLAGS.opt-query=	-q
 FLAGS.order=		-j1
 FLAGS.recursive=	-dL

Index: src/usr.bin/make/unit-tests/opt-no-action.exp
diff -u src/usr.bin/make/unit-tests/opt-no-action.exp:1.1 src/usr.bin/make/unit-tests/opt-no-action.exp:1.2
--- src/usr.bin/make/unit-tests/opt-no-action.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/opt-no-action.exp	Wed Aug 19 05:25:26 2020
@@ -1 +1,13 @@
+command during parsing
+echo '.BEGIN: hidden command'
+echo '.BEGIN: run always'
+.BEGIN: run always
+echo 'main: hidden command'
+echo 'main: run always'
+main: run always
+run-always: hidden command
+run-always: run always
+echo '.END: hidden command'
+echo '.END: run always'
+.END: run always
 exit status 0

Index: src/usr.bin/make/unit-tests/opt-no-action.mk
diff -u src/usr.bin/make/unit-tests/opt-no-action.mk:1.2 src/usr.bin/make/unit-tests/opt-no-action.mk:1.3
--- src/usr.bin/make/unit-tests/opt-no-action.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/opt-no-action.mk	Wed Aug 19 05:25:26 2020
@@ -1,8 +1,33 @@
-# $NetBSD: opt-no-action.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-no-action.mk,v 1.3 2020/08/19 05:25:26 rillig Exp $
 #
-# Tests for the -n command line option.
+# Tests for the -n command line option, which runs almost no commands.
+# It just outputs them, to be inspected by human readers.
+# Only commands that are in a .MAKE target or prefixed by '+' are run.
 
-# TODO: Implementation
+# This command cannot be prevented from being run since it is used at parse
+# time, and any later variable assignments may depend on its result.
+!=	echo 'command during parsing' 1>&2; echo
 
-all:
-	@:;
+all: main
+all: run-always
+
+# Both of these commands are printed, but only the '+' command is run.
+.BEGIN:
+	@echo '$@: hidden command'
+	@+echo '$@: run always'
+
+# Both of these commands are printed, but only the '+' command is run.
+main:
+	@echo '$@: hidden command'
+	@+echo '$@: run always'
+
+# None of these commands is printed, but both are run, because this target
+# depends on the special source ".MAKE".
+run-always: .MAKE
+	@echo '$@: hidden command'
+	@+echo '$@: run always'
+
+# Both of these commands are printed, but only the '+' command is run.
+.END:
+	@echo '$@: hidden command'
+	@+echo '$@: run always'



CVS commit: src/usr.bin/make/unit-tests

2020-08-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 19 05:13:18 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-query.exp opt-query.mk

Log Message:
make(1): add test for the -q option


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-query.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-query.mk

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/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.100 src/usr.bin/make/unit-tests/Makefile:1.101
--- src/usr.bin/make/unit-tests/Makefile:1.100	Sun Aug 16 20:43:01 2020
+++ src/usr.bin/make/unit-tests/Makefile	Wed Aug 19 05:13:18 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.100 2020/08/16 20:43:01 rillig Exp $
+# $NetBSD: Makefile,v 1.101 2020/08/19 05:13:18 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -310,6 +310,7 @@ FLAGS.doterror=		# none
 FLAGS.envfirst=		-e
 FLAGS.export=		# none
 FLAGS.lint=		-dL -k
+FLAGS.opt-query=	-q
 FLAGS.order=		-j1
 FLAGS.recursive=	-dL
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=

Index: src/usr.bin/make/unit-tests/opt-query.exp
diff -u src/usr.bin/make/unit-tests/opt-query.exp:1.1 src/usr.bin/make/unit-tests/opt-query.exp:1.2
--- src/usr.bin/make/unit-tests/opt-query.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/opt-query.exp	Wed Aug 19 05:13:18 2020
@@ -1 +1,2 @@
-exit status 0
+command during parsing
+exit status 1

Index: src/usr.bin/make/unit-tests/opt-query.mk
diff -u src/usr.bin/make/unit-tests/opt-query.mk:1.2 src/usr.bin/make/unit-tests/opt-query.mk:1.3
--- src/usr.bin/make/unit-tests/opt-query.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/opt-query.mk	Wed Aug 19 05:13:18 2020
@@ -1,8 +1,24 @@
-# $NetBSD: opt-query.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-query.mk,v 1.3 2020/08/19 05:13:18 rillig Exp $
 #
 # Tests for the -q command line option.
+#
+# The -q option only looks at the dependencies between the targets.
+# None of the commands in the targets are run, not even those that are
+# prefixed with '+'.
+
+# This command cannot be prevented from being run since it is used at parse
+# time, and any later variable assignments may depend on its result.
+!=	echo 'command during parsing' 1>&2; echo
 
-# TODO: Implementation
+# None of these commands are run.
+.BEGIN:
+	@echo '$@: hidden command'
+	@+echo '$@: run always'
 
+# None of these commands are run.
 all:
-	@:;
+	@echo '$@: hidden command'
+	@+echo '$@: run always'
+
+# The exit status 1 is because the "all" target has to be made, that is,
+# it is not up-to-date.



CVS commit: src

2020-08-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Aug 19 02:19:08 UTC 2020

Modified Files:
src/games/fortune/datfiles: fortunes fortunes2
src/share/doc/papers/fsinterface: fsinterface.ms
src/share/doc/papers/newvm: 1.t
src/share/man/man9: condvar.9
src/sys/arch/acorn32/doc: history
src/sys/arch/hppa/hppa: trap.c
src/sys/arch/ia64/stand/common: boot.c
src/sys/dev/ic: isp_tpublic.h
src/sys/dev/usb: usbdi.c
src/usr.sbin/sysinst: main.c

Log Message:
s/ be be / be /


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/games/fortune/datfiles/fortunes
cvs rdiff -u -r1.63 -r1.64 src/games/fortune/datfiles/fortunes2
cvs rdiff -u -r1.4 -r1.5 src/share/doc/papers/fsinterface/fsinterface.ms
cvs rdiff -u -r1.3 -r1.4 src/share/doc/papers/newvm/1.t
cvs rdiff -u -r1.28 -r1.29 src/share/man/man9/condvar.9
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/acorn32/doc/history
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/hppa/hppa/trap.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/ia64/stand/common/boot.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/isp_tpublic.h
cvs rdiff -u -r1.203 -r1.204 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/sysinst/main.c

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

Modified files:

Index: src/games/fortune/datfiles/fortunes
diff -u src/games/fortune/datfiles/fortunes:1.91 src/games/fortune/datfiles/fortunes:1.92
--- src/games/fortune/datfiles/fortunes:1.91	Mon Jun 15 12:57:51 2020
+++ src/games/fortune/datfiles/fortunes	Wed Aug 19 02:19:06 2020
@@ -6918,7 +6918,7 @@ shopping center in the world?
 %
 If you throw a New Year's Party, the worst thing that you can do would
 be to throw the kind of party where your guests wake up today, and call
-you to say they had a nice time.  Now you'll be be expected to throw
+you to say they had a nice time.  Now you'll be expected to throw
 another party next year.
 
 What you should do is throw the kind of party where your guest wake up

Index: src/games/fortune/datfiles/fortunes2
diff -u src/games/fortune/datfiles/fortunes2:1.63 src/games/fortune/datfiles/fortunes2:1.64
--- src/games/fortune/datfiles/fortunes2:1.63	Sat Aug 25 19:38:37 2018
+++ src/games/fortune/datfiles/fortunes2	Wed Aug 19 02:19:06 2020
@@ -25089,7 +25089,7 @@ lack sufficient imagination.
 %
 If you throw a New Year's Party, the worst thing that you can do would be
 to throw the kind of party where your guests wake up today, and call you to
-say they had a nice time.  Now you'll be be expected to throw another party
+say they had a nice time.  Now you'll be expected to throw another party
 next year.
 	What you should do is throw the kind of party where your guest wake
 	up several days from now and call their lawyers to find out if

Index: src/share/doc/papers/fsinterface/fsinterface.ms
diff -u src/share/doc/papers/fsinterface/fsinterface.ms:1.4 src/share/doc/papers/fsinterface/fsinterface.ms:1.5
--- src/share/doc/papers/fsinterface/fsinterface.ms:1.4	Thu Aug  7 10:30:42 2003
+++ src/share/doc/papers/fsinterface/fsinterface.ms	Wed Aug 19 02:19:07 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: fsinterface.ms,v 1.4 2003/08/07 10:30:42 agc Exp $
+.\"	$NetBSD: fsinterface.ms,v 1.5 2020/08/19 02:19:07 msaitoh Exp $
 .\"
 .\" Copyright (c) 1986 The Regents of the University of California.
 .\" All rights reserved.
@@ -576,7 +576,7 @@ and they may be accessed using short off
 .PP
 The proposed filesystem interface is described very tersely here.
 For the most part, data structures and procedures are analogous
-to those used by VFS, and only the changes will be be treated here.
+to those used by VFS, and only the changes will be treated here.
 See [Kleiman86] for complete descriptions of the vfs and vnode operations
 in Sun's interface.
 .PP

Index: src/share/doc/papers/newvm/1.t
diff -u src/share/doc/papers/newvm/1.t:1.3 src/share/doc/papers/newvm/1.t:1.4
--- src/share/doc/papers/newvm/1.t:1.3	Thu Aug  7 10:30:44 2003
+++ src/share/doc/papers/newvm/1.t	Wed Aug 19 02:19:07 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: 1.t,v 1.3 2003/08/07 10:30:44 agc Exp $
+.\"	$NetBSD: 1.t,v 1.4 2020/08/19 02:19:07 msaitoh Exp $
 .\"
 .\" Copyright (c) 1986 The Regents of the University of California.
 .\" All rights reserved.
@@ -154,7 +154,7 @@ be governed by the amount of physical me
 .PP
 Another effect of the current technology is that the latency and overhead
 associated with accessing the file system is considerably higher
-since the access must be be over the network
+since the access must be over the network
 rather than to a locally-attached disk.
 One use of the surplus memory would be to
 maintain a cache of recently used files;

Index: src/share/man/man9/condvar.9
diff -u src/share/man/man9/condvar.9:1.28 src/share/man/man9/condvar.9:1.29
--- src/share/man/man9/condvar.9:1.28	Mon May 11 03:59:33 2020
+++ src/share/man/man9/condvar.9	Wed Aug 19 

CVS commit: src/usr.sbin/mdconfig

2020-08-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 18 19:26:29 UTC 2020

Modified Files:
src/usr.sbin/mdconfig: Makefile mdconfig.c

Log Message:
use opendisk()/dehumanize_number


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mdconfig/Makefile
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/mdconfig/mdconfig.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/mdconfig/Makefile
diff -u src/usr.sbin/mdconfig/Makefile:1.2 src/usr.sbin/mdconfig/Makefile:1.3
--- src/usr.sbin/mdconfig/Makefile:1.2	Wed Jan  1 19:22:43 1997
+++ src/usr.sbin/mdconfig/Makefile	Tue Aug 18 15:26:29 2020
@@ -1,6 +1,10 @@
-#	$NetBSD: Makefile,v 1.2 1997/01/02 00:22:43 pk Exp $
+#	$NetBSD: Makefile,v 1.3 2020/08/18 19:26:29 christos Exp $
 
+WARNS?=6
 PROG=		mdconfig
 MAN=		mdconfig.8
 
+LDADD+=	-lutil
+DPADD+= ${LIBUTIL}
+
 .include 

Index: src/usr.sbin/mdconfig/mdconfig.c
diff -u src/usr.sbin/mdconfig/mdconfig.c:1.6 src/usr.sbin/mdconfig/mdconfig.c:1.7
--- src/usr.sbin/mdconfig/mdconfig.c:1.6	Tue Jan 23 16:06:25 2018
+++ src/usr.sbin/mdconfig/mdconfig.c	Tue Aug 18 15:26:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mdconfig.c,v 1.6 2018/01/23 21:06:25 sevan Exp $	*/
+/*	$NetBSD: mdconfig.c,v 1.7 2020/08/18 19:26:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: mdconfig.c,v 1.6 2018/01/23 21:06:25 sevan Exp $");
+__RCSID("$NetBSD: mdconfig.c,v 1.7 2020/08/18 19:26:29 christos Exp $");
 #endif
 
 /*
@@ -37,58 +37,62 @@ __RCSID("$NetBSD: mdconfig.c,v 1.6 2018/
  * (But this design allows any filesystem format!)
  */
 
-#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 int
 main(int argc, char *argv[])
 {
 	struct md_conf md;
-	size_t nblks;
+	char fname[MAXPATHLEN];
+	int64_t num;
+	size_t blks, bytes;
 	int fd;
 
-	if (argc <= 2) {
-		fprintf(stderr, "usage: mdconfig  <%d-byte-blocks>\n",
-DEV_BSIZE);
-		exit(1);
-	}
+	setprogname(argv[0]);
 
-	nblks = (size_t)strtoul(argv[2], NULL, 0);
-	if (nblks == 0) {
-		fprintf(stderr, "invalid number of blocks\n");
-		exit(1);
+	if (argc != 3) {
+		(void)fprintf(stderr, "Usage: %s  <%d-byte-blocks>\n",
+		getprogname(), DEV_BSIZE);
+		return EXIT_FAILURE;
 	}
-	md.md_size = nblks << DEV_BSHIFT;
 
-	fd = open(argv[1], O_RDWR, 0);
-	if (fd < 0) {
-		perror(argv[1]);
-		exit(1);
-	}
+	if (dehumanize_number(argv[2], ) == -1)
+		goto bad_num;
 
-	md.md_addr = mmap(NULL, md.md_size,
-PROT_READ | PROT_WRITE,
-MAP_ANON | MAP_PRIVATE,
--1, 0);
-	if (md.md_addr == MAP_FAILED) {
-		perror("mmap");
-		exit(1);
+	blks = (size_t)num;
+	bytes = blks << DEV_BSHIFT;
+	if (num <= 0 || bytes >> DEV_BSHIFT != blks) {
+bad_num:	err(EXIT_FAILURE, "blocks: `%s'", argv[2]);
 	}
+	md.md_size = bytes;
+
+	fd = opendisk(argv[1], O_RDWR, fname, sizeof(fname), 0);
+	if (fd == -1)
+		err(EXIT_FAILURE, "Can't open `%s'", argv[1]);
+
+	md.md_addr = mmap(NULL, md.md_size, PROT_READ | PROT_WRITE,
+	MAP_ANON | MAP_PRIVATE, -1, 0);
+	if (md.md_addr == MAP_FAILED)
+		err(EXIT_FAILURE, "mmap");
 
 	/* Become server! */
 	md.md_type = MD_UMEM_SERVER;
-	if (ioctl(fd, MD_SETCONF, )) {
-		perror("ioctl");
-		exit(1);
-	}
+	if (ioctl(fd, MD_SETCONF, ) == -1)
+		err(EXIT_FAILURE, "ioctl");
 
-	exit(0);
+	return EXIT_SUCCESS;
 }



CVS commit: src/lib/libc/gen

2020-08-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 18 19:18:06 UTC 2020

Modified Files:
src/lib/libc/gen: dehumanize_number.c

Log Message:
make sure errno is always set when we return -1 (Anon Ymous)


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

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

Modified files:

Index: src/lib/libc/gen/dehumanize_number.c
diff -u src/lib/libc/gen/dehumanize_number.c:1.7 src/lib/libc/gen/dehumanize_number.c:1.8
--- src/lib/libc/gen/dehumanize_number.c:1.7	Wed Oct  1 09:53:04 2014
+++ src/lib/libc/gen/dehumanize_number.c	Tue Aug 18 15:18:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $	*/
+/*	$NetBSD: dehumanize_number.c,v 1.8 2020/08/18 19:18:06 christos Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $");
+__RCSID("$NetBSD: dehumanize_number.c,v 1.8 2020/08/18 19:18:06 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -104,8 +104,10 @@ dehumanize_number(const char *str, int64
 
 	errno = 0;
 	tmp = strtoll(str, , 10);
-	if (str[0] == '\0' || (ep != delimit && *ep != '\0'))
+	if (str[0] == '\0' || (ep != delimit && *ep != '\0')) {
+		errno = EINVAL;
 		return -1; /* Not a number. */
+	}
 	else if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN))
 		return -1; /* Out of range. */
 



CVS commit: src/sys/dev/nvmm/x86

2020-08-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 18 17:08:05 UTC 2020

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_svm.c

Log Message:
nvmm-x86-svm: improve the CPUID emulation

Limit the hypervisor range, and properly handle each basic leaf until 0xD.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/nvmm/x86/nvmm_x86_svm.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/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.68 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.69
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.68	Tue Aug 18 17:03:10 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Tue Aug 18 17:08:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.68 2020/08/18 17:03:10 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.69 2020/08/18 17:08:05 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.68 2020/08/18 17:03:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.69 2020/08/18 17:08:05 maxv Exp $");
 
 #include 
 #include 
@@ -793,7 +793,21 @@ svm_inkernel_advance(struct vmcb *vmcb)
 	vmcb->ctrl.intr &= ~VMCB_CTRL_INTR_SHADOW;
 }
 
+#define SVM_CPUID_MAX_BASIC		0xD
 #define SVM_CPUID_MAX_HYPERVISOR	0x4000
+static uint32_t svm_cpuid_max_basic __read_mostly;
+
+static void
+svm_inkernel_exec_cpuid(struct svm_cpudata *cpudata, uint64_t eax, uint64_t ecx)
+{
+	u_int descs[4];
+
+	x86_cpuid2(eax, ecx, descs);
+	cpudata->vmcb->state.rax = descs[0];
+	cpudata->gprs[NVMM_X64_GPR_RBX] = descs[1];
+	cpudata->gprs[NVMM_X64_GPR_RCX] = descs[2];
+	cpudata->gprs[NVMM_X64_GPR_RDX] = descs[3];
+}
 
 static void
 svm_inkernel_handle_cpuid(struct nvmm_cpu *vcpu, uint64_t eax, uint64_t ecx)
@@ -801,7 +815,22 @@ svm_inkernel_handle_cpuid(struct nvmm_cp
 	struct svm_cpudata *cpudata = vcpu->cpudata;
 	uint64_t cr4;
 
+	if (eax < 0x4000) {
+		if (__predict_false(eax > svm_cpuid_max_basic)) {
+			eax = svm_cpuid_max_basic;
+			svm_inkernel_exec_cpuid(cpudata, eax, ecx);
+		}
+	} else if (eax < 0x8000) {
+		if (__predict_false(eax > SVM_CPUID_MAX_HYPERVISOR)) {
+			eax = svm_cpuid_max_basic;
+			svm_inkernel_exec_cpuid(cpudata, eax, ecx);
+		}
+	}
+
 	switch (eax) {
+	case 0x:
+		cpudata->vmcb->state.rax = svm_cpuid_max_basic;
+		break;
 	case 0x0001:
 		cpudata->vmcb->state.rax &= nvmm_cpuid_0001.eax;
 
@@ -831,10 +860,20 @@ svm_inkernel_handle_cpuid(struct nvmm_cp
 		cpudata->gprs[NVMM_X64_GPR_RDX] = 0;
 		break;
 	case 0x0007: /* Structured Extended Features */
-		cpudata->vmcb->state.rax &= nvmm_cpuid_0007.eax;
-		cpudata->gprs[NVMM_X64_GPR_RBX] &= nvmm_cpuid_0007.ebx;
-		cpudata->gprs[NVMM_X64_GPR_RCX] &= nvmm_cpuid_0007.ecx;
-		cpudata->gprs[NVMM_X64_GPR_RDX] &= nvmm_cpuid_0007.edx;
+		switch (ecx) {
+		case 0:
+			cpudata->vmcb->state.rax = 0;
+			cpudata->gprs[NVMM_X64_GPR_RBX] &= nvmm_cpuid_0007.ebx;
+			cpudata->gprs[NVMM_X64_GPR_RCX] &= nvmm_cpuid_0007.ecx;
+			cpudata->gprs[NVMM_X64_GPR_RDX] &= nvmm_cpuid_0007.edx;
+			break;
+		default:
+			cpudata->vmcb->state.rax = 0;
+			cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
+			cpudata->gprs[NVMM_X64_GPR_RCX] = 0;
+			cpudata->gprs[NVMM_X64_GPR_RDX] = 0;
+			break;
+		}
 		break;
 	case 0x0008: /* Empty */
 	case 0x0009: /* Empty */
@@ -2418,6 +2457,9 @@ svm_init(void)
 	/* Init the XCR0 mask. */
 	svm_xcr0_mask = SVM_XCR0_MASK_DEFAULT & x86_xsave_features;
 
+	/* Init the max basic CPUID leaf. */
+	svm_cpuid_max_basic = uimin(cpuid_level, SVM_CPUID_MAX_BASIC);
+
 	memset(hsave, 0, sizeof(hsave));
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO);



CVS commit: src/sys/dev/nvmm

2020-08-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 18 17:04:38 UTC 2020

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

Log Message:
nvmm: use relaxed atomics to read nmachines


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/nvmm/nvmm.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/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.34 src/sys/dev/nvmm/nvmm.c:1.35
--- src/sys/dev/nvmm/nvmm.c:1.34	Tue Aug 18 17:03:58 2020
+++ src/sys/dev/nvmm/nvmm.c	Tue Aug 18 17:04:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.c,v 1.34 2020/08/18 17:03:58 maxv Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.35 2020/08/18 17:04:37 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.34 2020/08/18 17:03:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.35 2020/08/18 17:04:37 maxv Exp $");
 
 #include 
 #include 
@@ -1218,7 +1218,7 @@ nvmm_attach(device_t parent, device_t se
 static int
 nvmm_detach(device_t self, int flags)
 {
-	if (nmachines > 0)
+	if (atomic_load_relaxed() > 0)
 		return EBUSY;
 	nvmm_fini();
 	return 0;



CVS commit: src/sys/dev/nvmm

2020-08-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 18 17:03:58 UTC 2020

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

Log Message:
nvmm: localify a variable that doesn't need to be global


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/nvmm/nvmm.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/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.33 src/sys/dev/nvmm/nvmm.c:1.34
--- src/sys/dev/nvmm/nvmm.c:1.33	Sat Aug  1 08:18:36 2020
+++ src/sys/dev/nvmm/nvmm.c	Tue Aug 18 17:03:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.c,v 1.33 2020/08/01 08:18:36 maxv Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.34 2020/08/18 17:03:58 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.33 2020/08/01 08:18:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.34 2020/08/18 17:03:58 maxv Exp $");
 
 #include 
 #include 
@@ -1040,7 +1040,7 @@ static int nvmm_close(file_t *);
 static int nvmm_mmap(file_t *, off_t *, size_t, int, int *, int *,
 struct uvm_object **, int *);
 
-const struct fileops nvmm_fileops = {
+static const struct fileops nvmm_fileops = {
 	.fo_read = fbadop_read,
 	.fo_write = fbadop_write,
 	.fo_ioctl = nvmm_ioctl,



CVS commit: src/sys/dev/nvmm/x86

2020-08-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 18 17:03:10 UTC 2020

Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c

Log Message:
nvmm-x86: also flush the guest TLB when CR4.{PCIDE,SMEP} changes


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.69 -r1.70 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.67 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.68
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.67	Wed Aug  5 15:22:25 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Tue Aug 18 17:03:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.67 2020/08/05 15:22:25 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.68 2020/08/18 17:03:10 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.67 2020/08/05 15:22:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.68 2020/08/18 17:03:10 maxv Exp $");
 
 #include 
 #include 
@@ -521,7 +521,7 @@ static uint64_t svm_xcr0_mask __read_mos
 #define CR0_TLB_FLUSH \
 	(CR0_PG|CR0_WP|CR0_CD|CR0_NW)
 #define CR4_TLB_FLUSH \
-	(CR4_PGE|CR4_PAE|CR4_PSE)
+	(CR4_PSE|CR4_PAE|CR4_PGE|CR4_PCIDE|CR4_SMEP)
 
 /* -- */
 

Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.69 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.70
--- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.69	Tue Aug 11 15:31:51 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Tue Aug 18 17:03:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.69 2020/08/11 15:31:51 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.70 2020/08/18 17:03:10 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.69 2020/08/11 15:31:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.70 2020/08/18 17:03:10 maxv Exp $");
 
 #include 
 #include 
@@ -734,7 +734,7 @@ static uint64_t vmx_xcr0_mask __read_mos
 #define CR0_TLB_FLUSH \
 	(CR0_PG|CR0_WP|CR0_CD|CR0_NW)
 #define CR4_TLB_FLUSH \
-	(CR4_PGE|CR4_PAE|CR4_PSE)
+	(CR4_PSE|CR4_PAE|CR4_PGE|CR4_PCIDE|CR4_SMEP)
 
 /* -- */
 



CVS commit: src/sys/dev/usb

2020-08-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Aug 18 14:32:34 UTC 2020

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

Log Message:
Fix ugen detach after partial attach.

While here, register null pmf handler even for partially attached
devices so they don't needlessly interfere with suspend.

Reported-by: syzbot+5a091d2e62da20b77...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/usb/ugen.c

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

Modified files:

Index: src/sys/dev/usb/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.156 src/sys/dev/usb/ugen.c:1.157
--- src/sys/dev/usb/ugen.c:1.156	Sun Aug 16 06:17:31 2020
+++ src/sys/dev/usb/ugen.c	Tue Aug 18 14:32:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.156 2020/08/16 06:17:31 riastradh Exp $	*/
+/*	$NetBSD: ugen.c,v 1.157 2020/08/18 14:32:34 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.156 2020/08/16 06:17:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.157 2020/08/18 14:32:34 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -139,6 +139,7 @@ struct ugen_softc {
 	int sc_refcnt;
 	char sc_buffer[UGEN_BBSIZE];
 	u_char sc_dying;
+	u_char sc_attached;
 };
 
 static struct {
@@ -379,6 +380,9 @@ ugenif_attach(device_t parent, device_t 
 		}
 	}
 
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	if (uiaa->uiaa_ifaceno < 0) {
 		/*
 		 * If we attach the whole device,
@@ -388,7 +392,6 @@ ugenif_attach(device_t parent, device_t 
 		if (err) {
 			aprint_error_dev(self,
 			"setting configuration index 0 failed\n");
-			sc->sc_dying = 1;
 			return;
 		}
 	}
@@ -401,16 +404,12 @@ ugenif_attach(device_t parent, device_t 
 	if (err) {
 		aprint_error_dev(self, "setting configuration %d failed\n",
 		conf);
-		sc->sc_dying = 1;
 		return;
 	}
 
 	ugenif_get_unit(sc);
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev);
-
-	if (!pmf_device_register(self, NULL, NULL))
-		aprint_error_dev(self, "couldn't establish power handler\n");
-
+	sc->sc_attached = 1;
 }
 
 Static void
@@ -1143,6 +1142,10 @@ ugen_detach(device_t self, int flags)
 
 	sc->sc_dying = 1;
 	pmf_device_deregister(self);
+
+	if (!sc->sc_attached)
+		goto out;
+
 	/* Abort all pipes.  Causes processes waiting for transfer to wake. */
 	for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
 		for (dir = OUT; dir <= IN; dir++) {
@@ -1173,7 +1176,7 @@ ugen_detach(device_t self, int flags)
 	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);
 	ugenif_put_unit(sc);
 
-	for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
+out:	for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
 		for (dir = OUT; dir <= IN; dir++) {
 			sce = >sc_endpoints[i][dir];
 			seldestroy(>rsel);



CVS commit: src/sys/uvm/pmap

2020-08-18 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Aug 18 11:48:21 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Fix small tyop in a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/uvm/pmap/pmap_segtab.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/uvm/pmap/pmap_segtab.c
diff -u src/sys/uvm/pmap/pmap_segtab.c:1.17 src/sys/uvm/pmap/pmap_segtab.c:1.18
--- src/sys/uvm/pmap/pmap_segtab.c:1.17	Tue Aug 18 07:25:46 2020
+++ src/sys/uvm/pmap/pmap_segtab.c	Tue Aug 18 11:48:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_segtab.c,v 1.17 2020/08/18 07:25:46 skrll Exp $	*/
+/*	$NetBSD: pmap_segtab.c,v 1.18 2020/08/18 11:48:21 simonb Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.17 2020/08/18 07:25:46 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.18 2020/08/18 11:48:21 simonb Exp $");
 
 /*
  *	Manages physical address maps.
@@ -237,7 +237,7 @@ pmap_segtab_release(pmap_t pmap, pmap_se
 			continue;
 
 		/*
-		 * If our caller want a callback, do so.
+		 * If our caller wants a callback, do so.
 		 */
 		if (callback != NULL) {
 			(*callback)(pmap, va, va + vinc, pte, flags);



CVS commit: src/sys/arch/mips/mips

2020-08-18 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Aug 18 11:21:26 UTC 2020

Modified Files:
src/sys/arch/mips/mips: pmap_machdep.c

Log Message:
Remove an extra word from a comment to make it more readable.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/mips/mips/pmap_machdep.c

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

Modified files:

Index: src/sys/arch/mips/mips/pmap_machdep.c
diff -u src/sys/arch/mips/mips/pmap_machdep.c:1.28 src/sys/arch/mips/mips/pmap_machdep.c:1.29
--- src/sys/arch/mips/mips/pmap_machdep.c:1.28	Thu Jul 30 07:31:30 2020
+++ src/sys/arch/mips/mips/pmap_machdep.c	Tue Aug 18 11:21:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_machdep.c,v 1.28 2020/07/30 07:31:30 skrll Exp $	*/
+/*	$NetBSD: pmap_machdep.c,v 1.29 2020/08/18 11:21:25 simonb Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.28 2020/07/30 07:31:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.29 2020/08/18 11:21:25 simonb Exp $");
 
 /*
  *	Manages physical address maps.
@@ -704,10 +704,10 @@ struct vm_page *
 pmap_md_alloc_poolpage(int flags)
 {
 	/*
-	 * The VM_FREELIST used for pool pages is only set on 32bit kernels.
-	 * This is to must make sure that we only allocate pages that
-	 * can be mapped via KSEG0.  On 64bit kernels, all memory can be
-	 * mapped via XKPHYS so just use the default freelist.
+	 * The VM_FREELIST used for pool pages is only set on 32bit
+	 * kernels.  This is to make sure that we only allocate pages
+	 * that can be mapped via KSEG0.  On 64bit kernels, all memory
+	 * can be mapped via XKPHYS so just use the default freelist.
 	 */
 	if (mips_poolpage_vmfreelist != VM_FREELIST_DEFAULT)
 		return uvm_pagealloc_strat(NULL, 0, NULL, flags,



CVS commit: src/sys/uvm

2020-08-18 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Aug 18 10:40:20 UTC 2020

Modified Files:
src/sys/uvm: uvm_amap.c

Log Message:
fix amap_extend() to handle amaps where we previously failed to allocate
the ppref memory.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/uvm/uvm_amap.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/uvm/uvm_amap.c
diff -u src/sys/uvm/uvm_amap.c:1.122 src/sys/uvm/uvm_amap.c:1.123
--- src/sys/uvm/uvm_amap.c:1.122	Thu Jul  9 05:57:15 2020
+++ src/sys/uvm/uvm_amap.c	Tue Aug 18 10:40:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_amap.c,v 1.122 2020/07/09 05:57:15 skrll Exp $	*/
+/*	$NetBSD: uvm_amap.c,v 1.123 2020/08/18 10:40:20 chs Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.122 2020/07/09 05:57:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.123 2020/08/18 10:40:20 chs Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -353,7 +353,7 @@ amap_extend(struct vm_map_entry *entry, 
 	struct vm_amap *amap = entry->aref.ar_amap;
 	int slotoff = entry->aref.ar_pageoff;
 	int slotmapped, slotadd, slotneed, slotadded, slotalloc;
-	int slotadj, slotarea;
+	int slotadj, slotarea, slotendoff;
 	int oldnslots;
 #ifdef UVM_AMAP_PPREF
 	int *newppref, *oldppref;
@@ -388,6 +388,36 @@ amap_extend(struct vm_map_entry *entry, 
 	}
 
 	/*
+	 * Because this amap only has 1 ref, we know that there is
+	 * only one vm_map_entry pointing to it, and the one entry is
+	 * using slots between slotoff and slotoff + slotmapped.  If
+	 * we have been using ppref then we know that only slots in
+	 * the one map entry's range can have anons, since ppref
+	 * allowed us to free any anons outside that range as other map
+	 * entries which used this amap were removed. But without ppref,
+	 * we couldn't know which slots were still needed by other map
+	 * entries, so we couldn't free any anons as we removed map
+	 * entries, and so any slot from 0 to am_nslot can have an
+	 * anon.  But now that we know there is only one map entry
+	 * left and we know its range, we can free up any anons
+	 * outside that range.  This is necessary because the rest of
+	 * this function assumes that there are no anons in the amap
+	 * outside of the one map entry's range.
+	 */
+
+	slotendoff = slotoff + slotmapped;
+	if (amap->am_ppref == PPREF_NONE) {
+		amap_wiperange(amap, 0, slotoff);
+		amap_wiperange(amap, slotendoff, amap->am_nslot - slotendoff);
+	}
+	for (i = 0; i < slotoff; i++) {
+		KASSERT(amap->am_anon[i] == NULL);
+	}
+	for (i = slotendoff; i < amap->am_nslot - slotendoff; i++) {
+		KASSERT(amap->am_anon[i] == NULL);
+	}
+
+	/*
 	 * case 1: we already have enough slots in the map and thus
 	 * only need to bump the reference counts on the slots we are
 	 * adding.



CVS commit: src/sys/arch/mips/cavium

2020-08-18 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Aug 18 10:35:51 UTC 2020

Modified Files:
src/sys/arch/mips/cavium: mainbus.c

Log Message:
We don't need to call the POW and FGA bootstrap functions from the FDT
mainbus attach, the iobus attach code does this already and is called
for both iobus-only and FDT cases anyway.

After discussion with jmcneill@.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/cavium/mainbus.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/mips/cavium/mainbus.c
diff -u src/sys/arch/mips/cavium/mainbus.c:1.4 src/sys/arch/mips/cavium/mainbus.c:1.5
--- src/sys/arch/mips/cavium/mainbus.c:1.4	Mon Aug 17 21:25:12 2020
+++ src/sys/arch/mips/cavium/mainbus.c	Tue Aug 18 10:35:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.4 2020/08/17 21:25:12 jmcneill Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.5 2020/08/18 10:35:51 simonb Exp $	*/
 
 /*
  * Copyright (c) 2007
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.4 2020/08/17 21:25:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.5 2020/08/18 10:35:51 simonb Exp $");
 
 #define	_MIPS_BUS_DMA_PRIVATE
 
@@ -122,9 +122,6 @@ mainbus_attach_devicetree(device_t self)
 	config_found_sm_loc(self, "mainbus", NULL, , mainbus_print,
 	mainbus_submatch);
 
-	octpow_bootstrap(_configuration);
-	octfpa_bootstrap(_configuration);
-
 	simplebus_bus_io_init(_bus_tag, NULL);
 
 	faa.faa_bst = _bus_tag;



CVS commit: src/sys/fs/union

2020-08-18 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Aug 18 09:44:07 UTC 2020

Modified Files:
src/sys/fs/union: union.h union_subr.c union_vnops.c

Log Message:
Operation union_readdirhook() stores the lower directory as un_uppervp.
This breaks the assumption that un_uppervp->v_mount is the upper mount.

Fix by storing the directory as un_lowervp and adapt union_readdir().

Should fix PR kern/2: panic with union mount


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/fs/union/union.h
cvs rdiff -u -r1.78 -r1.79 src/sys/fs/union/union_subr.c
cvs rdiff -u -r1.73 -r1.74 src/sys/fs/union/union_vnops.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/fs/union/union.h
diff -u src/sys/fs/union/union.h:1.29 src/sys/fs/union/union.h:1.30
--- src/sys/fs/union/union.h:1.29	Mon Jul 17 09:22:36 2017
+++ src/sys/fs/union/union.h	Tue Aug 18 09:44:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: union.h,v 1.29 2017/07/17 09:22:36 hannken Exp $	*/
+/*	$NetBSD: union.h,v 1.30 2020/08/18 09:44:07 hannken Exp $	*/
 
 /*
  * Copyright (c) 1994 The Regents of the University of California.
@@ -130,6 +130,7 @@ struct union_node {
 	char			*un_path;	/* v: saved component name */
 	int			un_openl;	/* v: # of opens on lowervp */
 	unsigned int		un_cflags;	/* c: cache flags */
+	bool			un_hooknode;	/* :: from union_readdirhook */
 	struct vnode		**un_dircache;	/* v: cached union stack */
 	off_t			un_uppersz;	/* l: size of upper object */
 	off_t			un_lowersz;	/* l: size of lower object */

Index: src/sys/fs/union/union_subr.c
diff -u src/sys/fs/union/union_subr.c:1.78 src/sys/fs/union/union_subr.c:1.79
--- src/sys/fs/union/union_subr.c:1.78	Sun Feb 23 15:46:41 2020
+++ src/sys/fs/union/union_subr.c	Tue Aug 18 09:44:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_subr.c,v 1.78 2020/02/23 15:46:41 ad Exp $	*/
+/*	$NetBSD: union_subr.c,v 1.79 2020/08/18 09:44:07 hannken Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.78 2020/02/23 15:46:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.79 2020/08/18 09:44:07 hannken Exp $");
 
 #include 
 #include 
@@ -480,6 +480,7 @@ found:
 	un->un_dircache = 0;
 	un->un_openl = 0;
 	un->un_cflags = 0;
+	un->un_hooknode = false;
 
 	un->un_uppersz = VNOVAL;
 	un->un_lowersz = VNOVAL;
@@ -1067,7 +1068,7 @@ union_dircache(struct vnode *vp, struct 
 	} else {
 		vpp = dircache;
 		do {
-			if (*vpp++ == VTOUNION(vp)->un_uppervp)
+			if (*vpp++ == VTOUNION(vp)->un_lowervp)
 break;
 		} while (*vpp != NULLVP);
 	}
@@ -1076,10 +1077,12 @@ union_dircache(struct vnode *vp, struct 
 		goto out;
 
 	vref(*vpp);
-	error = union_allocvp(, vp->v_mount, NULLVP, NULLVP, 0, *vpp, NULLVP, 0);
+	error = union_allocvp(, vp->v_mount, NULLVP, NULLVP, 0,
+	NULLVP, *vpp, 0);
 	if (!error) {
 		vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY);
 		VTOUNION(vp)->un_dircache = 0;
+		VTOUNION(nvp)->un_hooknode = true;
 		VTOUNION(nvp)->un_dircache = dircache;
 	}
 

Index: src/sys/fs/union/union_vnops.c
diff -u src/sys/fs/union/union_vnops.c:1.73 src/sys/fs/union/union_vnops.c:1.74
--- src/sys/fs/union/union_vnops.c:1.73	Sat May 16 18:31:50 2020
+++ src/sys/fs/union/union_vnops.c	Tue Aug 18 09:44:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: union_vnops.c,v 1.73 2020/05/16 18:31:50 christos Exp $	*/
+/*	$NetBSD: union_vnops.c,v 1.74 2020/08/18 09:44:07 hannken Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1994, 1995
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.73 2020/05/16 18:31:50 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.74 2020/08/18 09:44:07 hannken Exp $");
 
 #include 
 #include 
@@ -1493,13 +1493,29 @@ union_readdir(void *v)
 		int a_ncookies;
 	} */ *ap = v;
 	struct union_node *un = VTOUNION(ap->a_vp);
-	struct vnode *uvp = un->un_uppervp;
+	struct vnode *vp;
+	int dolock, error;
 
-	if (uvp == NULLVP)
-		return (0);
+	if (un->un_hooknode) {
+		KASSERT(un->un_uppervp == NULLVP);
+		KASSERT(un->un_lowervp != NULLVP);
+		vp = un->un_lowervp;
+		dolock = 1;
+	} else {
+		vp = un->un_uppervp;
+		dolock = 0;
+	}
+	if (vp == NULLVP)
+		return 0;
 
-	ap->a_vp = uvp;
-	return (VCALL(uvp, VOFFSET(vop_readdir), ap));
+	if (dolock)
+		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+	ap->a_vp = vp;
+	error = VCALL(vp, VOFFSET(vop_readdir), ap);
+	if (dolock)
+		VOP_UNLOCK(vp);
+
+	return error;
 }
 
 int



CVS commit: [netbsd-8] src/doc

2020-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 18 09:42:00 UTC 2020

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

Log Message:
Ticket #1597


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.29 -r1.1.2.30 src/doc/CHANGES-8.3

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

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.29 src/doc/CHANGES-8.3:1.1.2.30
--- src/doc/CHANGES-8.3:1.1.2.29	Tue Aug 11 17:08:36 2020
+++ src/doc/CHANGES-8.3	Tue Aug 18 09:42:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.29 2020/08/11 17:08:36 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.30 2020/08/18 09:42:00 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -997,5 +997,9 @@ sys/dev/pci/mpii.c1.25
 	mpii(4): make it compilable without bio(4).
 	[jnemeth, ticket #1596]
 
+sys/dev/ipmi.c	1.5
+	(applied to sys/arch/x86/x86/ipmi.c)
 
+	ipmi(4): Fix critical/warning threshold confusion.
+	[nonaka, ticket #1597]
 



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

2020-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 18 09:41:10 UTC 2020

Modified Files:
src/sys/arch/x86/x86 [netbsd-8]: ipmi.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1597):

sys/dev/ipmi.c: revision 1.5
(applied to sys/arch/x86/x86/ipmi.c)

ipmi(4): Fixed a bug that incorrect condition is notified.

When the value obtained from the sensor is below the lower limit of
the critical threshold, it is notified that the value is below the lower
limit of the warning threshold.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.64.10.1 src/sys/arch/x86/x86/ipmi.c

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

Modified files:

Index: src/sys/arch/x86/x86/ipmi.c
diff -u src/sys/arch/x86/x86/ipmi.c:1.64 src/sys/arch/x86/x86/ipmi.c:1.64.10.1
--- src/sys/arch/x86/x86/ipmi.c:1.64	Thu Jul  7 06:55:40 2016
+++ src/sys/arch/x86/x86/ipmi.c	Tue Aug 18 09:41:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $ */
+/*	$NetBSD: ipmi.c,v 1.64.10.1 2020/08/18 09:41:10 martin Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.64 2016/07/07 06:55:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.64.10.1 2020/08/18 09:41:10 martin Exp $");
 
 #include 
 #include 
@@ -1667,14 +1667,14 @@ ipmi_sensor_status(struct ipmi_softc *sc
 		edata->value_cur > psensor->i_limits.sel_warnmax)
 			return ENVSYS_SWARNOVER;
 
-		if (psensor->i_props & PROP_WARNMIN &&
-		edata->value_cur < psensor->i_limits.sel_warnmin)
-			return ENVSYS_SWARNUNDER;
-
 		if (psensor->i_props & PROP_CRITMIN &&
 		edata->value_cur < psensor->i_limits.sel_critmin)
 			return ENVSYS_SCRITUNDER;
 
+		if (psensor->i_props & PROP_WARNMIN &&
+		edata->value_cur < psensor->i_limits.sel_warnmin)
+			return ENVSYS_SWARNUNDER;
+
 		break;
 
 	case IPMI_SENSOR_TYPE_INTRUSION:



CVS commit: [netbsd-9] src/doc

2020-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 18 09:37:41 UTC 2020

Modified Files:
src/doc [netbsd-9]: CHANGES-9.1

Log Message:
Tickets #1055 and #1056


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.97 -r1.1.2.98 src/doc/CHANGES-9.1

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

Modified files:

Index: src/doc/CHANGES-9.1
diff -u src/doc/CHANGES-9.1:1.1.2.97 src/doc/CHANGES-9.1:1.1.2.98
--- src/doc/CHANGES-9.1:1.1.2.97	Mon Aug 17 14:38:32 2020
+++ src/doc/CHANGES-9.1	Tue Aug 18 09:37:41 2020
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.1,v 1.1.2.97 2020/08/17 14:38:32 martin Exp $
+# $NetBSD: CHANGES-9.1,v 1.1.2.98 2020/08/18 09:37:41 martin Exp $
 
 A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1
 release:
@@ -4758,3 +4758,18 @@ sys/dev/pci/cmdide.c1.46
 	on boot.
 	[jdolecek, ticket #1054]
 
+sys/dev/nvmm/nvmm.c1.33
+sys/dev/nvmm/nvmm.h1.13,1.14
+sys/dev/nvmm/nvmm_internal.h			1.17
+sys/dev/nvmm/x86/nvmm_x86.c			1.10
+sys/dev/nvmm/x86/nvmm_x86_svm.c			1.67
+sys/dev/nvmm/x86/nvmm_x86_vmx.c			1.67
+
+	nvmm(4): reduce the diff against -current, no functional change.
+	[maxv, ticket #1055]
+
+sys/dev/ipmi.c	1.5
+
+	ipmi(4): Fix critical/warning threshold confusion.
+	[nonaka, ticket #1056]
+



CVS commit: [netbsd-9] src/sys/dev

2020-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 18 09:36:36 UTC 2020

Modified Files:
src/sys/dev [netbsd-9]: ipmi.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1056):

sys/dev/ipmi.c: revision 1.5

ipmi(4): Fixed a bug that incorrect condition is notified.

When the value obtained from the sensor is below the lower limit of
the critical threshold, it is notified that the value is below the lower
limit of the warning threshold.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.4.1 src/sys/dev/ipmi.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/ipmi.c
diff -u src/sys/dev/ipmi.c:1.4 src/sys/dev/ipmi.c:1.4.4.1
--- src/sys/dev/ipmi.c:1.4	Sat May 18 08:38:00 2019
+++ src/sys/dev/ipmi.c	Tue Aug 18 09:36:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.4 2019/05/18 08:38:00 mlelstv Exp $ */
+/*	$NetBSD: ipmi.c,v 1.4.4.1 2020/08/18 09:36:36 martin Exp $ */
 
 /*
  * Copyright (c) 2019 Michael van Elst
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4 2019/05/18 08:38:00 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4.4.1 2020/08/18 09:36:36 martin Exp $");
 
 #include 
 #include 
@@ -1632,14 +1632,14 @@ ipmi_sensor_status(struct ipmi_softc *sc
 		edata->value_cur > psensor->i_limits.sel_warnmax)
 			return ENVSYS_SWARNOVER;
 
-		if (psensor->i_props & PROP_WARNMIN &&
-		edata->value_cur < psensor->i_limits.sel_warnmin)
-			return ENVSYS_SWARNUNDER;
-
 		if (psensor->i_props & PROP_CRITMIN &&
 		edata->value_cur < psensor->i_limits.sel_critmin)
 			return ENVSYS_SCRITUNDER;
 
+		if (psensor->i_props & PROP_WARNMIN &&
+		edata->value_cur < psensor->i_limits.sel_warnmin)
+			return ENVSYS_SWARNUNDER;
+
 		break;
 
 	case IPMI_SENSOR_TYPE_INTRUSION:



CVS commit: [netbsd-9] src/sys/dev/nvmm

2020-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 18 09:29:52 UTC 2020

Modified Files:
src/sys/dev/nvmm [netbsd-9]: nvmm.c nvmm.h nvmm_internal.h
src/sys/dev/nvmm/x86 [netbsd-9]: nvmm_x86.c nvmm_x86_svm.c
nvmm_x86_vmx.c

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

sys/dev/nvmm/nvmm.h: revision 1.13
sys/dev/nvmm/nvmm.h: revision 1.14
sys/dev/nvmm/nvmm.c: revision 1.33
sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.67
sys/dev/nvmm/nvmm_internal.h: revision 1.17
sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.67
sys/dev/nvmm/x86/nvmm_x86.c: revision 1.10

Put the few x86-specific structures under #ifdef __x86_64__, for clarity.

Make it easier to understand what's going on, no functional change.

Add new field definitions.

Add new field definitions, and intercept everything, for future-proofness.

Add CTASSERT.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.5 -r1.22.2.6 src/sys/dev/nvmm/nvmm.c
cvs rdiff -u -r1.10.4.1 -r1.10.4.2 src/sys/dev/nvmm/nvmm.h
cvs rdiff -u -r1.12.2.4 -r1.12.2.5 src/sys/dev/nvmm/nvmm_internal.h
cvs rdiff -u -r1.7.4.2 -r1.7.4.3 src/sys/dev/nvmm/x86/nvmm_x86.c
cvs rdiff -u -r1.46.4.7 -r1.46.4.8 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
cvs rdiff -u -r1.36.2.9 -r1.36.2.10 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.22.2.5 src/sys/dev/nvmm/nvmm.c:1.22.2.6
--- src/sys/dev/nvmm/nvmm.c:1.22.2.5	Sun Aug  2 08:49:08 2020
+++ src/sys/dev/nvmm/nvmm.c	Tue Aug 18 09:29:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm.c,v 1.22.2.5 2020/08/02 08:49:08 martin Exp $	*/
+/*	$NetBSD: nvmm.c,v 1.22.2.6 2020/08/18 09:29:52 martin Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.22.2.5 2020/08/02 08:49:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.22.2.6 2020/08/18 09:29:52 martin Exp $");
 
 #include 
 #include 
@@ -59,8 +59,10 @@ static struct nvmm_machine machines[NVMM
 static volatile unsigned int nmachines __cacheline_aligned;
 
 static const struct nvmm_impl *nvmm_impl_list[] = {
+#if defined(__x86_64__)
 	_x86_svm,	/* x86 AMD SVM */
 	_x86_vmx	/* x86 Intel VMX */
+#endif
 };
 
 static const struct nvmm_impl *nvmm_impl = NULL;

Index: src/sys/dev/nvmm/nvmm.h
diff -u src/sys/dev/nvmm/nvmm.h:1.10.4.1 src/sys/dev/nvmm/nvmm.h:1.10.4.2
--- src/sys/dev/nvmm/nvmm.h:1.10.4.1	Sun Nov 10 12:58:30 2019
+++ src/sys/dev/nvmm/nvmm.h	Tue Aug 18 09:29:52 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: nvmm.h,v 1.10.4.1 2019/11/10 12:58:30 martin Exp $	*/
+/*	$NetBSD: nvmm.h,v 1.10.4.2 2020/08/18 09:29:52 martin Exp $	*/
 
 /*
- * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -44,7 +44,7 @@ typedef uint64_t	gvaddr_t;
 typedef uint32_t	nvmm_machid_t;
 typedef uint32_t	nvmm_cpuid_t;
 
-#ifdef __x86_64__
+#if defined(__x86_64__)
 #include 
 #endif
 
@@ -96,4 +96,9 @@ struct nvmm_comm_page {
 #define NVMM_COMM_CPUID(off)		\
 	((off >> 12) & 0xFF)
 
+#ifdef _KERNEL
+/* At most one page, for the NVMM_COMM_* macros. */
+CTASSERT(sizeof(struct nvmm_comm_page) <= PAGE_SIZE);
+#endif
+
 #endif

Index: src/sys/dev/nvmm/nvmm_internal.h
diff -u src/sys/dev/nvmm/nvmm_internal.h:1.12.2.4 src/sys/dev/nvmm/nvmm_internal.h:1.12.2.5
--- src/sys/dev/nvmm/nvmm_internal.h:1.12.2.4	Sun Aug  2 11:19:09 2020
+++ src/sys/dev/nvmm/nvmm_internal.h	Tue Aug 18 09:29:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_internal.h,v 1.12.2.4 2020/08/02 11:19:09 martin Exp $	*/
+/*	$NetBSD: nvmm_internal.h,v 1.12.2.5 2020/08/18 09:29:52 martin Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
@@ -119,8 +119,10 @@ struct nvmm_impl {
 	struct nvmm_vcpu_exit *);
 };
 
+#if defined(__x86_64__)
 extern const struct nvmm_impl nvmm_x86_svm;
 extern const struct nvmm_impl nvmm_x86_vmx;
+#endif
 
 static inline bool
 nvmm_return_needed(void)

Index: src/sys/dev/nvmm/x86/nvmm_x86.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86.c:1.7.4.2 src/sys/dev/nvmm/x86/nvmm_x86.c:1.7.4.3
--- src/sys/dev/nvmm/x86/nvmm_x86.c:1.7.4.2	Thu May 21 10:52:58 2020
+++ src/sys/dev/nvmm/x86/nvmm_x86.c	Tue Aug 18 09:29:52 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: nvmm_x86.c,v 1.7.4.2 2020/05/21 10:52:58 martin Exp $	*/
+/*	$NetBSD: nvmm_x86.c,v 1.7.4.3 2020/08/18 09:29:52 martin Exp $	*/
 
 /*
- * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2018-2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.7.4.2 2020/05/21 10:52:58 

CVS commit: src/sys/net/npf

2020-08-18 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 18 07:53:24 UTC 2020

Modified Files:
src/sys/net/npf: npf_os.c

Log Message:
Add missing cases, to prevent memory corruption.

Reported-by: syzbot+f8b8a689a3560dda2...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/net/npf/npf_os.c

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

Modified files:

Index: src/sys/net/npf/npf_os.c
diff -u src/sys/net/npf/npf_os.c:1.18 src/sys/net/npf/npf_os.c:1.19
--- src/sys/net/npf/npf_os.c:1.18	Sat May 30 14:16:56 2020
+++ src/sys/net/npf/npf_os.c	Tue Aug 18 07:53:24 2020
@@ -33,7 +33,7 @@
 
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf_os.c,v 1.18 2020/05/30 14:16:56 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_os.c,v 1.19 2020/08/18 07:53:24 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pf.h"
@@ -268,15 +268,21 @@ npf_dev_ioctl(dev_t dev, u_long cmd, voi
 	case IOC_NPF_VERSION:
 		*(int *)data = NPF_VERSION;
 		return 0;
-
 	case IOC_NPF_SWITCH:
 		return npfctl_switch(data);
-
 	case IOC_NPF_TABLE:
 		return npfctl_table(npf, data);
-
 	case IOC_NPF_STATS:
 		return npf_stats_export(npf, data);
+	case IOC_NPF_LOAD:
+	case IOC_NPF_SAVE:
+	case IOC_NPF_RULE:
+	case IOC_NPF_CONN_LOOKUP:
+	case IOC_NPF_TABLE_REPLACE:
+		/* nvlist_ref_t argument, handled below */
+		break;
+	default:
+		return EINVAL;
 	}
 
 	error = nvlist_copyin(data, , NPF_IOCTL_DATA_LIMIT);



CVS commit: src/sys/arch/mips/cavium

2020-08-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 18 07:41:41 UTC 2020

Modified Files:
src/sys/arch/mips/cavium: octeon_intr.c

Log Message:
Fix MULTIPROCESSOR build


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/mips/cavium/octeon_intr.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/mips/cavium/octeon_intr.c
diff -u src/sys/arch/mips/cavium/octeon_intr.c:1.23 src/sys/arch/mips/cavium/octeon_intr.c:1.24
--- src/sys/arch/mips/cavium/octeon_intr.c:1.23	Mon Aug 17 21:00:29 2020
+++ src/sys/arch/mips/cavium/octeon_intr.c	Tue Aug 18 07:41:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_intr.c,v 1.23 2020/08/17 21:00:29 jmcneill Exp $	*/
+/*	$NetBSD: octeon_intr.c,v 1.24 2020/08/18 07:41:41 skrll Exp $	*/
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
  * All rights reserved.
@@ -44,7 +44,7 @@
 #define __INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.23 2020/08/17 21:00:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_intr.c,v 1.24 2020/08/18 07:41:41 skrll Exp $");
 
 #include 
 #include 
@@ -166,7 +166,7 @@ struct octeon_intrhand {
 static int octeon_send_ipi(struct cpu_info *, int);
 static int octeon_ipi_intr(void *);
 
-static struct octeon_intrhand ipi_intrhands[1] = {
+static struct octeon_intrhand ipi_intrhands[2] = {
 	[0] = {
 		.ih_func = octeon_ipi_intr,
 		.ih_arg = (void *)(uintptr_t)__BITS(15,0),



CVS commit: src/sys/uvm/pmap

2020-08-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 18 07:25:46 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Improve a panic message ever so slightly


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/uvm/pmap/pmap_segtab.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/uvm/pmap/pmap_segtab.c
diff -u src/sys/uvm/pmap/pmap_segtab.c:1.16 src/sys/uvm/pmap/pmap_segtab.c:1.17
--- src/sys/uvm/pmap/pmap_segtab.c:1.16	Mon Aug 17 08:56:27 2020
+++ src/sys/uvm/pmap/pmap_segtab.c	Tue Aug 18 07:25:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_segtab.c,v 1.16 2020/08/17 08:56:27 mrg Exp $	*/
+/*	$NetBSD: pmap_segtab.c,v 1.17 2020/08/18 07:25:46 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.16 2020/08/17 08:56:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.17 2020/08/18 07:25:46 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -245,7 +245,7 @@ pmap_segtab_release(pmap_t pmap, pmap_se
 #ifdef DEBUG
 		for (size_t j = 0; j < NPTEPG; j++) {
 			if (!pte_zero_p(pte[j]))
-panic("%s: pte entry %p not 0 (%#"PRIxPTE")",
+panic("%s: pte entry at %p not 0 (%#"PRIxPTE")",
 __func__, [j], pte_value(pte[j]));
 		}
 #endif



CVS commit: src/distrib/sets/lists/tests

2020-08-18 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Tue Aug 18 07:13:59 UTC 2020

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

Log Message:
Quoted from the top of the file:
# Note: don't delete entries from here - mark them as "obsolete" instead.


To generate a diff of this commit:
cvs rdiff -u -r1.893 -r1.894 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.893 src/distrib/sets/lists/tests/mi:1.894
--- src/distrib/sets/lists/tests/mi:1.893	Tue Aug 18 03:02:50 2020
+++ src/distrib/sets/lists/tests/mi	Tue Aug 18 07:13:59 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.893 2020/08/18 03:02:50 perseant Exp $
+# $NetBSD: mi,v 1.894 2020/08/18 07:13:59 nakayama Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4758,6 +4758,8 @@
 ./usr/tests/usr.bin/make/unit-tests/modmatch.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/modmisc.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/modmisc.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/modorder.exp	tests-obsolete	obsolete
+./usr/tests/usr.bin/make/unit-tests/modorder.mk	tests-obsolete	obsolete
 ./usr/tests/usr.bin/make/unit-tests/modts.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/modts.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/modword.exp	tests-usr.bin-tests	compattestfile,atf