CVS commit: src/common/lib/libc/arch/aarch64/string

2020-04-10 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Apr 11 05:12:52 UTC 2020

Modified Files:
src/common/lib/libc/arch/aarch64/string: bcopy.S memset.S

Log Message:
Fixed to not use the "br" instruction. Branch Target Identification (BTI) 
doesn't like "br".

requested by maxv@


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/aarch64/string/bcopy.S
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/aarch64/string/memset.S

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

Modified files:

Index: src/common/lib/libc/arch/aarch64/string/bcopy.S
diff -u src/common/lib/libc/arch/aarch64/string/bcopy.S:1.1 src/common/lib/libc/arch/aarch64/string/bcopy.S:1.2
--- src/common/lib/libc/arch/aarch64/string/bcopy.S:1.1	Sun Feb  4 21:52:16 2018
+++ src/common/lib/libc/arch/aarch64/string/bcopy.S	Sat Apr 11 05:12:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bcopy.S,v 1.1 2018/02/04 21:52:16 skrll Exp $ */
+/* $NetBSD: bcopy.S,v 1.2 2020/04/11 05:12:52 ryo Exp $ */
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -29,7 +29,7 @@
 #include 
 
 #if defined(LIBC_SCCS)
-RCSID("$NetBSD: bcopy.S,v 1.1 2018/02/04 21:52:16 skrll Exp $")
+RCSID("$NetBSD: bcopy.S,v 1.2 2020/04/11 05:12:52 ryo Exp $")
 #endif
 
 #if defined(MEMCOPY)
@@ -207,32 +207,60 @@ copy_backward:
 #endif /* (STP_ALIGN > 8) */
 9:
 
+backward_copy1k:
+	/* while (len >= 1024) */
+	/* { src -= 1024; dst -= 1024; copy1024(dst, src); len -= 1024; } */
 	cmp	LEN, #1024
-	bhs	backward_copy1k
-backward_less1k:
-	/* copy 16*n bytes */
-	and	TMP_D, LEN, #(1023-15)		/* len &= 1023; len &= ~15; */
-	adr	TMP_X, 8f
-	sub	LEN, LEN, TMP_D
-	sub	TMP_X, TMP_X, TMP_D, lsr #1	/* jump to (8f - len/2) */
-	br	TMP_X
-backward_copy1k:	/* copy 16*64 bytes */
+	blo	9f
+1:
 	sub	LEN, LEN, #1024
 	.rept	(1024 / 16)
 	ldp	DATA0, DATA1, [SRC0, #-16]!	/* *--dst = *--src; */
 	stp	DATA0, DATA1, [DST, #-16]!
 	.endr
-8:
-	cbz	LEN, done
 	cmp	LEN, #1024
-	bhs	backward_copy1k
-	cmp	LEN, #16
-	bhs	backward_less1k
+	bhs	1b
+9:
 
+	/* if (len & 512) { src -= 512; dst -= 512; copy512(dst, src); } */
+	tbz	LEN, #9, 1f
+	.rept	(512 / 16)
+	ldp	DATA0, DATA1, [SRC0, #-16]!
+	stp	DATA0, DATA1, [DST, #-16]!
+	.endr
+1:
+	/* if (len & 256) { src -= 256; dst -= 256; copy256(dst, src); } */
+	tbz	LEN, #8, 1f
+	.rept	(256 / 16)
+	ldp	DATA0, DATA1, [SRC0, #-16]!
+	stp	DATA0, DATA1, [DST, #-16]!
+	.endr
+1:
+	/* if (len & 128) { src -= 128; dst -= 128; copy128(dst, src); } */
+	tbz	LEN, #7, 1f
+	.rept	(128 / 16)
+	ldp	DATA0, DATA1, [SRC0, #-16]!
+	stp	DATA0, DATA1, [DST, #-16]!
+	.endr
+1:
+	/* if (len & 64) { src -= 64; dst -= 64; copy64(dst, src); } */
+	tbz	LEN, #6, 1f
+	.rept	(64 / 16)
+	ldp	DATA0, DATA1, [SRC0, #-16]!
+	stp	DATA0, DATA1, [DST, #-16]!
+	.endr
+1:
+	/* if (len & 32) { src -= 32; dst -= 32; copy32(dst, src); } */
+	tbz	LEN, #5, 1f
+	.rept	(32 / 16)
+	ldp	DATA0, DATA1, [SRC0, #-16]!
+	stp	DATA0, DATA1, [DST, #-16]!
+	.endr
+1:
 	/* if (len & 16) { *--(uint128_t *)dst = *--(uint128_t *)src; } */
 	tbz	LEN, #4, 1f
 	ldp	DATA0, DATA1, [SRC0, #-16]!
-	ldp	DATA0, DATA1, [DST, #-16]!
+	stp	DATA0, DATA1, [DST, #-16]!
 1:
 	/* if (len & 8) { *--(uint64_t *)dst = *--(uint64_t *)src; } */
 	tbz	LEN, #3, 1f
@@ -271,14 +299,10 @@ backward_copy:
 	bcs	9f
 backward_tiny:
 	/* copy 1-10 bytes */
-	adr	TMP_X, 8f
-	sub	TMP_X, TMP_X, LEN, lsl #3	/* jump to (8f - len*2) */
-	br	TMP_X
-	.rept	10
+1:	sub	LEN, LEN, #1
 	ldrb	TMP_Xw, [SRC0, #-1]!
 	strb	TMP_Xw, [DST, #-1]!
-	.endr
-8:
+	cbz	LEN, 1b
 	ret
 9:
 	/* length is small(<32), and src or dst may be unaligned */
@@ -548,14 +572,10 @@ ENTRY(FUNCTION)
 	bcs	9f
 forward_tiny:
 	/* copy 1-10 bytes */
-	adr	TMP_X, 8f
-	sub	TMP_X, TMP_X, LEN, lsl #3	/* jump to (8f - len*2) */
-	br	TMP_X
-	.rept	10
+1:	sub	LEN, LEN, #1
 	ldrb	TMP_Xw, [SRC0], #1
 	strb	TMP_Xw, [DST], #1
-	.endr
-8:
+	cbz	LEN, 1b
 	ret
 9:
 	/* length is small(<32), and src or dst may be unaligned */
@@ -938,28 +958,56 @@ copy_forward:
 #endif /* (STP_ALIGN > 8) */
 9:
 
+forward_copy1k:
+	/* while (len >= 1024) */
+	/* { copy1024(dst, src); src += 1024; dst += 1024; len -= 1024; } */
 	cmp	LEN, #1024
-	bhs	forward_copy1k
-forward_less1k:
-	/* copy 16*n bytes */
-	and	TMP_D, LEN, #(1023-15)		/* len &= 1023; len &= ~15; */
-	adr	TMP_X, 8f
-	sub	LEN, LEN, TMP_D
-	sub	TMP_X, TMP_X, TMP_D, lsr #1	/* jump to (8f - len/2) */
-	br	TMP_X
-forward_copy1k:	/* copy 16*64 bytes */
+	blo	9f
+1:
 	sub	LEN, LEN, #1024
 	.rept	(1024 / 16)
 	ldp	DATA0, DATA1, [SRC0], #16	/* *dst++ = *src++; */
 	stp	DATA0, DATA1, [DST], #16
 	.endr
-8:
-	cbz	LEN, done
 	cmp	LEN, #1024
-	bhs	forward_copy1k
-	cmp	LEN, #16
-	bhs	forward_less1k
+	bhs	1b
+9:
 
+	/* if (len & 512) { copy512(dst, src); src += 512; dst += 512; */
+	tbz	LEN, #9, 1f
+	.rept	(512 / 16)
+	ldp	DATA0, DATA1, [SRC0], #16
+	stp	DATA0, DATA1, [DST], #16
+	.endr
+1:
+	/* if (len & 256) { copy256(dst, src); src += 256; dst += 256; */
+	tbz	LEN, #8, 1f
+	.rept	(256 / 

CVS commit: src/distrib/sets/lists

2020-04-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr 11 01:51:14 UTC 2020

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

Log Message:
Add new t_extattr


To generate a diff of this commit:
cvs rdiff -u -r1.305 -r1.306 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.834 -r1.835 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.305 src/distrib/sets/lists/debug/mi:1.306
--- src/distrib/sets/lists/debug/mi:1.305	Sat Apr  4 21:21:43 2020
+++ src/distrib/sets/lists/debug/mi	Fri Apr 10 21:51:14 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.305 2020/04/05 01:21:43 christos Exp $
+# $NetBSD: mi,v 1.306 2020/04/11 01:51:14 christos Exp $
 ./etc/mtree/set.debug   comp-sys-root
 ./usr/lib	comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -1643,6 +1643,7 @@
 ./usr/libdata/debug/usr/tests/fs/ffs/h_ffs_server.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_server.debug		tests-obsolete		obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_tests.debug		tests-fs-debug		debug,atf,rump
+./usr/libdata/debug/usr/tests/fs/ffs/t_extattr.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/ffs/t_fifos.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/ffs/t_mount.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/ffs/t_quota2_1.debug			tests-fs-debug		debug,atf,rump

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.834 src/distrib/sets/lists/tests/mi:1.835
--- src/distrib/sets/lists/tests/mi:1.834	Sun Mar  8 22:22:20 2020
+++ src/distrib/sets/lists/tests/mi	Fri Apr 10 21:51:14 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.834 2020/03/09 02:22:20 christos Exp $
+# $NetBSD: mi,v 1.835 2020/04/11 01:51:14 christos Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1460,6 +1460,7 @@
 ./usr/tests/fs/ffs/rump_quotactl			tests-obsolete		obsolete
 ./usr/tests/fs/ffs/rump_repquota			tests-obsolete		obsolete
 ./usr/tests/fs/ffs/t_clearquotatests-fs-tests		atf,rump
+./usr/tests/fs/ffs/t_extattrtests-fs-tests		atf,rump
 ./usr/tests/fs/ffs/t_fifostests-fs-tests		atf,rump
 ./usr/tests/fs/ffs/t_getquotatests-fs-tests		atf,rump
 ./usr/tests/fs/ffs/t_miscquotatests-fs-tests		atf,rump



CVS commit: src/common/lib/libc/gen

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Apr 11 01:46:47 UTC 2020

Modified Files:
src/common/lib/libc/gen: radixtree.c

Log Message:
Match the naming convention in the file.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/common/lib/libc/gen/radixtree.c

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

Modified files:

Index: src/common/lib/libc/gen/radixtree.c
diff -u src/common/lib/libc/gen/radixtree.c:1.25 src/common/lib/libc/gen/radixtree.c:1.26
--- src/common/lib/libc/gen/radixtree.c:1.25	Fri Apr 10 23:43:05 2020
+++ src/common/lib/libc/gen/radixtree.c	Sat Apr 11 01:46:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $	*/
+/*	$NetBSD: radixtree.c,v 1.26 2020/04/11 01:46:47 ad Exp $	*/
 
 /*-
  * Copyright (c)2011,2012,2013 YAMAMOTO Takashi,
@@ -112,7 +112,7 @@
 #include 
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.26 2020/04/11 01:46:47 ad Exp $");
 #include 
 #include 
 #include 
@@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c,
 #include 
 #endif /* defined(_STANDALONE) */
 #else /* defined(_KERNEL) || defined(_STANDALONE) */
-__RCSID("$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $");
+__RCSID("$NetBSD: radixtree.c,v 1.26 2020/04/11 01:46:47 ad Exp $");
 #include 
 #include 
 #include 
@@ -356,14 +356,14 @@ radix_tree_await_memory(void)
 #endif /* defined(_KERNEL) */
 
 /*
- * radix_tree_node_sum:
+ * radix_tree_sum_node:
  *
  * return the logical sum of all entries in the given node.  used to quickly
  * check for tag masks or empty nodes.
  */
 
 static uintptr_t
-radix_tree_node_sum(const struct radix_tree_node *n)
+radix_tree_sum_node(const struct radix_tree_node *n)
 {
 #if RADIX_TREE_PTR_PER_NODE > 16
 	unsigned int i;
@@ -437,7 +437,7 @@ radix_tree_alloc_node(void)
 		radix_tree_node_init(n);
 	}
 #endif /* defined(_KERNEL) */
-	KASSERT(n == NULL || radix_tree_node_sum(n) == 0);
+	KASSERT(n == NULL || radix_tree_sum_node(n) == 0);
 	return n;
 }
 
@@ -445,7 +445,7 @@ static void
 radix_tree_free_node(struct radix_tree_node *n)
 {
 
-	KASSERT(radix_tree_node_sum(n) == 0);
+	KASSERT(radix_tree_sum_node(n) == 0);
 #if defined(_KERNEL)
 	pool_cache_put(radix_tree_node_cache, n);
 #elif defined(_STANDALONE)
@@ -627,7 +627,7 @@ radix_tree_undo_insert_node(struct radix
 		KASSERT(pptr != NULL);
 		n = entry_ptr(*pptr);
 		KASSERT(n != NULL);
-		if (radix_tree_node_sum(n) != 0) {
+		if (radix_tree_sum_node(n) != 0) {
 			break;
 		}
 		radix_tree_free_node(n);
@@ -735,7 +735,7 @@ radix_tree_remove_node(struct radix_tree
 		entry = *pptr;
 		n = entry_ptr(entry);
 		KASSERT(n != NULL);
-		if (radix_tree_node_sum(n) != 0) {
+		if (radix_tree_sum_node(n) != 0) {
 			break;
 		}
 		radix_tree_free_node(n);
@@ -762,8 +762,8 @@ radix_tree_remove_node(struct radix_tree
 		entry = *pptr;
 		n = entry_ptr(entry);
 		KASSERT(n != NULL);
-		KASSERT(radix_tree_node_sum(n) != 0);
-		newmask = radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK;
+		KASSERT(radix_tree_sum_node(n) != 0);
+		newmask = radix_tree_sum_node(n) & RADIX_TREE_TAG_MASK;
 		if (newmask == entry_tagmask(entry)) {
 			break;
 		}
@@ -1139,7 +1139,7 @@ radix_tree_clear_tag(struct radix_tree *
 		if (0 < i) {
 			struct radix_tree_node *n = path_node(t, , i - 1);
 
-			if ((radix_tree_node_sum(n) & tagmask) != 0) {
+			if ((radix_tree_sum_node(n) & tagmask) != 0) {
 break;
 			}
 		}
@@ -1172,7 +1172,7 @@ radix_tree_dump_node(const struct radix_
 		return;
 	}
 	n = entry_ptr(vp);
-	assert((radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK) ==
+	assert((radix_tree_sum_node(n) & RADIX_TREE_TAG_MASK) ==
 	entry_tagmask(vp));
 	printf(" (%u children)\n", radix_tree_node_count_ptrs(n));
 	for (i = 0; i < __arraycount(n->n_ptrs); i++) {



CVS commit: src/sys/arch/macppc/dev

2020-04-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 11 01:42:56 UTC 2020

Modified Files:
src/sys/arch/macppc/dev: snapper.c

Log Message:
don't try to read a 32bit property into a uint8_t.
Now headphone detection works properly on machines which have the gpio's
polarity reversed, like Quicksilver and TiBook.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/macppc/dev/snapper.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/macppc/dev/snapper.c
diff -u src/sys/arch/macppc/dev/snapper.c:1.53 src/sys/arch/macppc/dev/snapper.c:1.54
--- src/sys/arch/macppc/dev/snapper.c:1.53	Fri Sep 20 21:24:34 2019
+++ src/sys/arch/macppc/dev/snapper.c	Sat Apr 11 01:42:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: snapper.c,v 1.53 2019/09/20 21:24:34 macallan Exp $	*/
+/*	$NetBSD: snapper.c,v 1.54 2020/04/11 01:42:56 macallan Exp $	*/
 /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
 /*	Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp		*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.53 2019/09/20 21:24:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.54 2020/04/11 01:42:56 macallan Exp $");
 
 #include 
 #include 
@@ -497,7 +497,7 @@ static bus_size_t amp_mute;
 static bus_size_t headphone_mute;
 static bus_size_t audio_hw_reset;
 static bus_size_t headphone_detect;
-static uint8_t headphone_detect_active;
+static uint8_t headphone_detect_active = 0;
 
 
 /* I2S registers */
@@ -2091,9 +2091,10 @@ snapper_init(struct snapper_softc *sc, i
 		/* extint-gpio15 */
 		if (strcmp(audio_gpio, "headphone-detect") == 0 ||
 		strcmp(name, "headphone-detect") == 0) {
+			uint32_t act;
 			headphone_detect = addr;
-			OF_getprop(gpio, "audio-gpio-active-state",
-			_detect_active, 4);
+			OF_getprop(gpio, "audio-gpio-active-state", , 4);
+			headphone_detect_active = act;
 			if (OF_getprop(gpio, "interrupts", intr, 8) == 8) {
 headphone_detect_intr = intr[0];
 			}



CVS commit: src/sys/sys

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 23:58:48 UTC 2020

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

Log Message:
NetBSD 9.99.56 - struct buf changed


To generate a diff of this commit:
cvs rdiff -u -r1.658 -r1.659 src/sys/sys/param.h

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

Modified files:

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.658 src/sys/sys/param.h:1.659
--- src/sys/sys/param.h:1.658	Mon Apr  6 08:28:53 2020
+++ src/sys/sys/param.h	Fri Apr 10 23:58:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.658 2020/04/06 08:28:53 kamil Exp $	*/
+/*	$NetBSD: param.h,v 1.659 2020/04/10 23:58:48 ad Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999005500	/* NetBSD 9.99.55 */
+#define	__NetBSD_Version__	999005600	/* NetBSD 9.99.56 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/common/lib/libc/gen

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 23:43:05 UTC 2020

Modified Files:
src/common/lib/libc/gen: radixtree.c

Log Message:
PR kern/54979 (radixtree might misbehave if ENOMEM)

- radix_tree_insert_node(): if the insert failed due to ENOMEM, roll back
  any updates made to the tree.

- radix_tree_grow(): either succeed or fail, never make partial adjustments
  to the tree.

- radix_tree_await_memory(): allocate & free the maximum possible number of
  nodes required by any insertion.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/common/lib/libc/gen/radixtree.c

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

Modified files:

Index: src/common/lib/libc/gen/radixtree.c
diff -u src/common/lib/libc/gen/radixtree.c:1.24 src/common/lib/libc/gen/radixtree.c:1.25
--- src/common/lib/libc/gen/radixtree.c:1.24	Fri Apr 10 21:56:41 2020
+++ src/common/lib/libc/gen/radixtree.c	Fri Apr 10 23:43:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $	*/
+/*	$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $	*/
 
 /*-
  * Copyright (c)2011,2012,2013 YAMAMOTO Takashi,
@@ -112,7 +112,7 @@
 #include 
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $");
 #include 
 #include 
 #include 
@@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c,
 #include 
 #endif /* defined(_STANDALONE) */
 #else /* defined(_KERNEL) || defined(_STANDALONE) */
-__RCSID("$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $");
+__RCSID("$NetBSD: radixtree.c,v 1.25 2020/04/10 23:43:05 ad Exp $");
 #include 
 #include 
 #include 
@@ -335,16 +335,22 @@ radix_tree_init(void)
  * radix_tree_await_memory:
  *
  * after an insert has failed with ENOMEM, wait for memory to become
- * available, so the caller can retry.
+ * available, so the caller can retry.  this needs to ensure that the
+ * maximum possible required number of nodes is available.
  */
 
 void
 radix_tree_await_memory(void)
 {
-	struct radix_tree_node *n;
+	struct radix_tree_node *nodes[RADIX_TREE_MAX_HEIGHT];
+	int i;
 
-	n = pool_cache_get(radix_tree_node_cache, PR_WAITOK);
-	pool_cache_put(radix_tree_node_cache, n);
+	for (i = 0; i < __arraycount(nodes); i++) {
+		nodes[i] = pool_cache_get(radix_tree_node_cache, PR_WAITOK);
+	}
+	while (--i >= 0) {
+		pool_cache_put(radix_tree_node_cache, nodes[i]);
+	}
 }
 
 #endif /* defined(_KERNEL) */
@@ -360,8 +366,8 @@ static uintptr_t
 radix_tree_node_sum(const struct radix_tree_node *n)
 {
 #if RADIX_TREE_PTR_PER_NODE > 16
+	unsigned int i;
 	uintptr_t sum;
-	unsigned i;
 
 	for (i = 0, sum = 0; i < RADIX_TREE_PTR_PER_NODE; i++) {
 		sum |= (uintptr_t)n->n_ptrs[i];
@@ -449,31 +455,39 @@ radix_tree_free_node(struct radix_tree_n
 #endif
 }
 
-static int
+/*
+ * radix_tree_grow:
+ *
+ * increase the height of the tree.
+ */
+
+static __noinline int
 radix_tree_grow(struct radix_tree *t, unsigned int newheight)
 {
 	const unsigned int tagmask = entry_tagmask(t->t_root);
+	struct radix_tree_node *newnodes[RADIX_TREE_MAX_HEIGHT];
+	void *root;
+	int h;
 
-	KASSERT(newheight <= 64 / RADIX_TREE_BITS_PER_HEIGHT);
-	if (t->t_root == NULL) {
+	KASSERT(newheight <= RADIX_TREE_MAX_HEIGHT);
+	if ((root = t->t_root) == NULL) {
 		t->t_height = newheight;
 		return 0;
 	}
-	while (t->t_height < newheight) {
-		struct radix_tree_node *n;
-
-		n = radix_tree_alloc_node();
-		if (n == NULL) {
-			/*
-			 * don't bother to revert our changes.
-			 * the caller will likely retry.
-			 */
+	for (h = t->t_height; h < newheight; h++) {
+		newnodes[h] = radix_tree_alloc_node();
+		if (__predict_false(newnodes[h] == NULL)) {
+			while (--h >= (int)t->t_height) {
+newnodes[h]->n_ptrs[0] = NULL;
+radix_tree_free_node(newnodes[h]);
+			}
 			return ENOMEM;
 		}
-		n->n_ptrs[0] = t->t_root;
-		t->t_root = entry_compose(n, tagmask);
-		t->t_height++;
+		newnodes[h]->n_ptrs[0] = root;
+		root = entry_compose(newnodes[h], tagmask);
 	}
+	t->t_root = root;
+	t->t_height = h;
 	return 0;
 }
 
@@ -583,6 +597,52 @@ radix_tree_lookup_ptr(struct radix_tree 
 }
 
 /*
+ * radix_tree_undo_insert_node:
+ *
+ * Undo the effects of a failed insert.  The conditions that led to the
+ * insert may change and it may not be retried.  If the insert is not
+ * retried, there will be no corresponding radix_tree_remove_node() for
+ * this index in the future.  Therefore any adjustments made to the tree
+ * before memory was exhausted must be reverted.
+ */
+
+static __noinline void
+radix_tree_undo_insert_node(struct radix_tree *t, uint64_t idx)
+{
+	struct radix_tree_path path;
+	int i;
+
+	(void)radix_tree_lookup_ptr(t, idx, , false, 0);
+	if (path.p_lastidx == RADIX_TREE_INVALID_HEIGHT) {
+		/*
+		 * no nodes were inserted.
+		 */
+		return;
+	}
+	for (i = path.p_lastidx - 1; 

CVS commit: src/tests/fs/ffs

2020-04-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 10 22:58:47 UTC 2020

Modified Files:
src/tests/fs/ffs: Makefile
Added Files:
src/tests/fs/ffs: t_extattr.c

Log Message:
New extended attributes test (does not work until we commit kernel changes)


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/fs/ffs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/fs/ffs/t_extattr.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/fs/ffs/Makefile
diff -u src/tests/fs/ffs/Makefile:1.20 src/tests/fs/ffs/Makefile:1.21
--- src/tests/fs/ffs/Makefile:1.20	Sun Mar  1 13:08:13 2020
+++ src/tests/fs/ffs/Makefile	Fri Apr 10 18:58:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.20 2020/03/01 18:08:13 christos Exp $
+#	$NetBSD: Makefile,v 1.21 2020/04/10 22:58:47 christos Exp $
 #
 
 .include 
@@ -20,6 +20,7 @@ TESTS_SH+=	${name}
 TESTS_SH_SRC_${name}=	ffs_common.sh quotas_common.sh ${name}.sh
 .endfor
 
+TESTS_C+=	t_extattr
 TESTS_C+=	t_fifos
 TESTS_C+=	t_snapshot
 TESTS_C+=	t_snapshot_log

Added files:

Index: src/tests/fs/ffs/t_extattr.c
diff -u /dev/null src/tests/fs/ffs/t_extattr.c:1.1
--- /dev/null	Fri Apr 10 18:58:47 2020
+++ src/tests/fs/ffs/t_extattr.c	Fri Apr 10 18:58:47 2020
@@ -0,0 +1,176 @@
+/*	$NetBSD: t_extattr.c,v 1.1 2020/04/10 22:58:47 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include 
+__RCSID("$NetBSD: t_extattr.c,v 1.1 2020/04/10 22:58:47 christos Exp $");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "h_macros.h"
+
+ATF_TC_WITH_CLEANUP(extattr);
+ATF_TC_HEAD(extattr, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "test extended attribute support in "
+	"ffsv2");
+	atf_tc_set_md_var(tc, "timeout", "5");
+}
+
+#define IMGNAME "extattr.img"
+
+#define G "/garage"
+#define M "mercedes"
+#define C "carburator"
+#define E "engine"
+#define T "trunk"
+#define S "suitcase"
+
+static const char *attrs[] = { E, T };
+
+static void
+check_list(const char *buf, ssize_t nr)
+{
+	size_t p = 0;
+	for (size_t i = 0; i < __arraycount(attrs); i++) {
+		size_t l = buf[p++];
+		if (l != strlen(attrs[i]))
+		atf_tc_fail("got invalid len %zu expected %zu", l,
+			strlen(attrs[i]));
+		if (strncmp([p], attrs[i], l) != 0)
+			atf_tc_fail("got invalid str %.*s expected %s", (int)l,
+			[p], attrs[i]);
+		p += l;
+	}
+}
+
+// Make it ffsv2
+const char *newfs = "newfs -O 2 -F -s 1 " IMGNAME;
+#define FAKEBLK "/dev/formula1"
+
+ATF_TC_BODY(extattr, tc)
+{
+	struct ufs_args args;
+	ssize_t nr;
+	int fd;
+	char buf[512];
+
+	if (system(newfs) == -1)
+		atf_tc_fail_errno("newfs failed");
+
+	memset(, 0, sizeof(args));
+	args.fspec = __UNCONST(FAKEBLK);
+
+	rump_init();
+	if (rump_sys_mkdir(G, 0777) == -1)
+		atf_tc_fail_errno("cannot create mountpoint");
+	rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK);
+	if (rump_sys_mount(MOUNT_FFS, G, 0, , sizeof(args))==-1)
+		atf_tc_fail_errno("rump_sys_mount failed");
+
+	/* create extattr */
+	if (rump_sys_chdir(G) == 1)
+		atf_tc_fail_errno("chdir");
+	if ((fd = rump_sys_open(M, O_RDWR | O_CREAT, 0600)) == -1)
+		atf_tc_fail_errno("open");
+	if (rump_sys_write(fd, "hi mom\n", 7) != 7)
+		atf_tc_fail_errno("write");
+
+	if (rump_sys_extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, E, C, 11) == -1)
+		atf_tc_fail_errno("exattr_set_fd");
+	if 

CVS commit: src/sys/kern

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 22:34:36 UTC 2020

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

Log Message:
vfs_mountroot(): don't needlessly grab a second reference to the root vnode
(the kernel never chdirs) nor a lock on it.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/kern/vfs_mount.c

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

Modified files:

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.75 src/sys/kern/vfs_mount.c:1.76
--- src/sys/kern/vfs_mount.c:1.75	Sun Feb 23 22:14:03 2020
+++ src/sys/kern/vfs_mount.c	Fri Apr 10 22:34:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.75 2020/02/23 22:14:03 ad Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.76 2020/04/10 22:34:36 ad Exp $	*/
 
 /*-
  * Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.75 2020/02/23 22:14:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.76 2020/04/10 22:34:36 ad Exp $");
 
 #include 
 #include 
@@ -1245,14 +1245,13 @@ done:
 
 		/*
 		 * Get the vnode for '/'.  Set cwdi0.cwdi_cdir to
-		 * reference it.
+		 * reference it, and donate it the reference grabbed
+		 * with VFS_ROOT().
 		 */
-		error = VFS_ROOT(mp, LK_SHARED, );
+		error = VFS_ROOT(mp, LK_NONE, );
 		if (error)
 			panic("cannot find root vnode, error=%d", error);
 		cwdi0.cwdi_cdir = rootvnode;
-		vref(cwdi0.cwdi_cdir);
-		VOP_UNLOCK(rootvnode);
 		cwdi0.cwdi_rdir = NULL;
 
 		/*



CVS commit: src/common/lib/libc/gen

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 21:56:41 UTC 2020

Modified Files:
src/common/lib/libc/gen: radixtree.c

Log Message:
Rename radix_tree_node_clean_p() to radix_tree_node_sum() and have it return
the computed sum.  Use to replace any_children_tagmask().  Simpler & faster.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/common/lib/libc/gen/radixtree.c

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

Modified files:

Index: src/common/lib/libc/gen/radixtree.c
diff -u src/common/lib/libc/gen/radixtree.c:1.23 src/common/lib/libc/gen/radixtree.c:1.24
--- src/common/lib/libc/gen/radixtree.c:1.23	Tue Jan 28 22:20:45 2020
+++ src/common/lib/libc/gen/radixtree.c	Fri Apr 10 21:56:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $	*/
+/*	$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $	*/
 
 /*-
  * Copyright (c)2011,2012,2013 YAMAMOTO Takashi,
@@ -112,7 +112,7 @@
 #include 
 
 #if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $");
 #include 
 #include 
 #include 
@@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: radixtree.c,
 #include 
 #endif /* defined(_STANDALONE) */
 #else /* defined(_KERNEL) || defined(_STANDALONE) */
-__RCSID("$NetBSD: radixtree.c,v 1.23 2020/01/28 22:20:45 ad Exp $");
+__RCSID("$NetBSD: radixtree.c,v 1.24 2020/04/10 21:56:41 ad Exp $");
 #include 
 #include 
 #include 
@@ -198,25 +198,6 @@ struct radix_tree_node {
 };
 
 /*
- * any_children_tagmask:
- *
- * return OR'ed tagmask of the given node's children.
- */
-
-static unsigned int
-any_children_tagmask(const struct radix_tree_node *n)
-{
-	unsigned int mask;
-	int i;
-
-	mask = 0;
-	for (i = 0; i < RADIX_TREE_PTR_PER_NODE; i++) {
-		mask |= (unsigned int)(uintptr_t)n->n_ptrs[i];
-	}
-	return mask & RADIX_TREE_TAG_MASK;
-}
-
-/*
  * p_refs[0].pptr == >t_root
  *	:
  * p_refs[n].pptr == &(*p_refs[n-1])->n_ptrs[x]
@@ -368,18 +349,24 @@ radix_tree_await_memory(void)
 
 #endif /* defined(_KERNEL) */
 
-static bool __unused
-radix_tree_node_clean_p(const struct radix_tree_node *n)
+/*
+ * radix_tree_node_sum:
+ *
+ * return the logical sum of all entries in the given node.  used to quickly
+ * check for tag masks or empty nodes.
+ */
+
+static uintptr_t
+radix_tree_node_sum(const struct radix_tree_node *n)
 {
 #if RADIX_TREE_PTR_PER_NODE > 16
-	unsigned int i;
+	uintptr_t sum;
+	unsigned i;
 
-	for (i = 0; i < RADIX_TREE_PTR_PER_NODE; i++) {
-		if (n->n_ptrs[i] != NULL) {
-			return false;
-		}
+	for (i = 0, sum = 0; i < RADIX_TREE_PTR_PER_NODE; i++) {
+		sum |= (uintptr_t)n->n_ptrs[i];
 	}
-	return true;
+	return sum;
 #else /* RADIX_TREE_PTR_PER_NODE > 16 */
 	uintptr_t sum;
 
@@ -409,7 +396,7 @@ radix_tree_node_clean_p(const struct rad
 	sum |= (uintptr_t)n->n_ptrs[14];
 	sum |= (uintptr_t)n->n_ptrs[15];
 #endif
-	return sum == 0;
+	return sum;
 #endif /* RADIX_TREE_PTR_PER_NODE > 16 */
 }
 
@@ -444,7 +431,7 @@ radix_tree_alloc_node(void)
 		radix_tree_node_init(n);
 	}
 #endif /* defined(_KERNEL) */
-	KASSERT(n == NULL || radix_tree_node_clean_p(n));
+	KASSERT(n == NULL || radix_tree_node_sum(n) == 0);
 	return n;
 }
 
@@ -452,7 +439,7 @@ static void
 radix_tree_free_node(struct radix_tree_node *n)
 {
 
-	KASSERT(radix_tree_node_clean_p(n));
+	KASSERT(radix_tree_node_sum(n) == 0);
 #if defined(_KERNEL)
 	pool_cache_put(radix_tree_node_cache, n);
 #elif defined(_STANDALONE)
@@ -687,7 +674,7 @@ radix_tree_remove_node(struct radix_tree
 		entry = *pptr;
 		n = entry_ptr(entry);
 		KASSERT(n != NULL);
-		if (!radix_tree_node_clean_p(n)) {
+		if (radix_tree_node_sum(n) != 0) {
 			break;
 		}
 		radix_tree_free_node(n);
@@ -714,8 +701,8 @@ radix_tree_remove_node(struct radix_tree
 		entry = *pptr;
 		n = entry_ptr(entry);
 		KASSERT(n != NULL);
-		KASSERT(!radix_tree_node_clean_p(n));
-		newmask = any_children_tagmask(n);
+		KASSERT(radix_tree_node_sum(n) != 0);
+		newmask = radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK;
 		if (newmask == entry_tagmask(entry)) {
 			break;
 		}
@@ -1091,7 +1078,7 @@ radix_tree_clear_tag(struct radix_tree *
 		if (0 < i) {
 			struct radix_tree_node *n = path_node(t, , i - 1);
 
-			if ((any_children_tagmask(n) & tagmask) != 0) {
+			if ((radix_tree_node_sum(n) & tagmask) != 0) {
 break;
 			}
 		}
@@ -1124,7 +,8 @@ radix_tree_dump_node(const struct radix_
 		return;
 	}
 	n = entry_ptr(vp);
-	assert(any_children_tagmask(n) == entry_tagmask(vp));
+	assert((radix_tree_node_sum(n) & RADIX_TREE_TAG_MASK) ==
+	entry_tagmask(vp));
 	printf(" (%u children)\n", radix_tree_node_count_ptrs(n));
 	for (i = 0; i < __arraycount(n->n_ptrs); i++) {
 		void *c;



CVS commit: src/usr.bin/audio/play

2020-04-10 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Fri Apr 10 21:33:27 UTC 2020

Modified Files:
src/usr.bin/audio/play: audioplay.1

Log Message:
audioplay.1: generalize a reference to web browsers


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/audio/play/audioplay.1

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/audio/play/audioplay.1
diff -u src/usr.bin/audio/play/audioplay.1:1.29 src/usr.bin/audio/play/audioplay.1:1.30
--- src/usr.bin/audio/play/audioplay.1:1.29	Tue Nov 12 12:50:30 2019
+++ src/usr.bin/audio/play/audioplay.1	Fri Apr 10 21:33:27 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audioplay.1,v 1.29 2019/11/12 12:50:30 wiz Exp $
+.\"	$NetBSD: audioplay.1,v 1.30 2020/04/10 21:33:27 gutteridge Exp $
 .\"
 .\" Copyright (c) 1998, 1999, 2002, 2010, 2019 Matthew R. Green
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 8, 2019
+.Dd April 10, 2020
 .Dt AUDIOPLAY 1
 .Os
 .Sh NAME
@@ -169,9 +169,8 @@ program can be used to show the availabl
 .Nm
 can be used to play Sun/NeXT audio files, and also RIFF WAVE audio files.
 .Nm
-can be configured in the
-.Dq Netscape
-web browser as the program to use when playing audio files.
+can be configured in a web browser as the program to use when playing audio
+files.
 .Pp
 In addition to the audio driver encodings list in the EXAMPLES section,
 .Nm



CVS commit: src/sys/arch/xen/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 21:03:21 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xengnt.c

Log Message:
gnttab_get_status_frames frame_list is array if uint64_t values, not u_long
like gnttab_setup_table, fix to use uint64_t

fixes compilation on i386 with XEN3PAE_DOM[0U], pointed out by kre@


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/xen/xen/xengnt.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/xen/xen/xengnt.c
diff -u src/sys/arch/xen/xen/xengnt.c:1.32 src/sys/arch/xen/xen/xengnt.c:1.33
--- src/sys/arch/xen/xen/xengnt.c:1.32	Fri Apr 10 08:35:52 2020
+++ src/sys/arch/xen/xen/xengnt.c	Fri Apr 10 21:03:20 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xengnt.c,v 1.32 2020/04/10 08:35:52 jdolecek Exp $  */
+/*  $NetBSD: xengnt.c,v 1.33 2020/04/10 21:03:20 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.32 2020/04/10 08:35:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.33 2020/04/10 21:03:20 jdolecek Exp $");
 
 #include 
 #include 
@@ -186,7 +186,7 @@ static int
 xengnt_map_status(void)
 {
 	gnttab_get_status_frames_t getstatus;
-	u_long *pages;
+	uint64_t *pages;
 	size_t sz;
 
 	KASSERT(mutex_owned(_lock));



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

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 20:56:56 UTC 2020

Modified Files:
src/sys/arch/i386/conf: XEN3PAE_DOM0 XEN3PAE_DOMU

Log Message:
remove commented out __XEN_INTERFACE_VERSION__ option, it comes via std.xen


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/conf/XEN3PAE_DOM0
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/conf/XEN3PAE_DOMU

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

Modified files:

Index: src/sys/arch/i386/conf/XEN3PAE_DOM0
diff -u src/sys/arch/i386/conf/XEN3PAE_DOM0:1.22 src/sys/arch/i386/conf/XEN3PAE_DOM0:1.23
--- src/sys/arch/i386/conf/XEN3PAE_DOM0:1.22	Thu Apr  9 14:39:10 2020
+++ src/sys/arch/i386/conf/XEN3PAE_DOM0	Fri Apr 10 20:56:56 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: XEN3PAE_DOM0,v 1.22 2020/04/09 14:39:10 jdolecek Exp $
+#	$NetBSD: XEN3PAE_DOM0,v 1.23 2020/04/10 20:56:56 jdolecek Exp $
 #
 #	XEN3_0: Xen 3.0 domain0 kernel
 
@@ -18,7 +18,6 @@ maxusers	32		# estimated number of users
 #
 options 	XEN
 options 	PAE
-#options 	__XEN_INTERFACE_VERSION__=0x00030205 # Xen 3.1 interface
 
 # boot messages with MPBIOS, acpi and ioapic can be quite large
 options 	MSGBUFSIZE=24576

Index: src/sys/arch/i386/conf/XEN3PAE_DOMU
diff -u src/sys/arch/i386/conf/XEN3PAE_DOMU:1.9 src/sys/arch/i386/conf/XEN3PAE_DOMU:1.10
--- src/sys/arch/i386/conf/XEN3PAE_DOMU:1.9	Thu Apr  9 14:39:10 2020
+++ src/sys/arch/i386/conf/XEN3PAE_DOMU	Fri Apr 10 20:56:56 2020
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3PAE_DOMU,v 1.9 2020/04/09 14:39:10 jdolecek Exp $
+# $NetBSD: XEN3PAE_DOMU,v 1.10 2020/04/10 20:56:56 jdolecek Exp $
 
 include 	"arch/i386/conf/std.xen"
 
@@ -150,7 +150,6 @@ options 	NFS_BOOT_DHCP,NFS_BOOT_BOOTPARA
 #options 	NFS_BOOTSTATIC_SERVADDR="\"169.254.1.1\""
 #options 	NFS_BOOTSTATIC_SERVER="\"server:/path/to/root\""
 
-#options 	__XEN_INTERFACE_VERSION__=0x00030205 # Xen 3.1 interface
 options 	MAXPHYS=32768	#xbd doesn't handle 64k transfers
 
 config		netbsd	root on ? type ?



CVS commit: [is-mlppp] src/sys/net

2020-04-10 Thread Ignatios Souvatzis
Module Name:src
Committed By:   is
Date:   Fri Apr 10 19:45:24 UTC 2020

Modified Files:
src/sys/net [is-mlppp]: if_spppsubr.c

Log Message:
syntax fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.187.2.4 -r1.187.2.5 src/sys/net/if_spppsubr.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/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.187.2.4 src/sys/net/if_spppsubr.c:1.187.2.5
--- src/sys/net/if_spppsubr.c:1.187.2.4	Fri Apr 10 17:28:37 2020
+++ src/sys/net/if_spppsubr.c	Fri Apr 10 19:45:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.187.2.4 2020/04/10 17:28:37 is Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.187.2.5 2020/04/10 19:45:24 is Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.187.2.4 2020/04/10 17:28:37 is Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.187.2.5 2020/04/10 19:45:24 is Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -539,7 +539,6 @@ sppp_ml_defrag(struct sppp *sp, struct m
 	u_int8_t flags;
 	u_int32_t seqid;
 	u_int16_t protocol;
-	u_int16_t *m_protop;
 	int newflen;
 
 	if (*protocolp != PPP_MP)
@@ -554,7 +553,7 @@ sppp_ml_defrag(struct sppp *sp, struct m
 	if (m->m_len < 4) {
 		m = m_pullup(m, 4);
 		if (m == NULL) {
-			if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1);
+			if_statadd2(>pp_if, if_ierrors, 1, if_iqdrops, 1);
 			return NULL;
 		}
 	}
@@ -569,15 +568,15 @@ sppp_ml_defrag(struct sppp *sp, struct m
 
 	if (flags & 0x80) {
 		/* Beginning fragment. */
-		sp->lcp.ml_seq_expected=seqid+1;	/* next expected */
+		sp->lcp.ml_seq_xpctd=seqid+1;	/* next expected */
 		
 		/* TODO: if prefix, count dropped? */
 
 		m_freem(sp->lcp.ml_prefix);
 		sp->lcp.ml_prefix = m;
 
-	} else if (seqid == sp->lcp.ml_seq_expected) {
-		sp->lcp.ml_seq_expected=seqid+1;	/* next expected */
+	} else if (seqid == sp->lcp.ml_seq_xpctd) {
+		sp->lcp.ml_seq_xpctd=seqid+1;	/* next expected */
 		if (sp->lcp.ml_prefix == 0) {
 			/* didn't see B frame.	*/
 		 	/* TODO: count as dropped. */
@@ -590,7 +589,7 @@ sppp_ml_defrag(struct sppp *sp, struct m
 		 */
 		newflen = m->m_pkthdr.len;
 		m_cat(sp->lcp.ml_prefix, m);
-		lcp.ml_prefix->m_pkthdr.len += newflen;
+		sp->lcp.ml_prefix->m_pkthdr.len += newflen;
 
 	} else {
 		/*
@@ -612,14 +611,14 @@ sppp_ml_defrag(struct sppp *sp, struct m
 		sp->lcp.ml_prefix = NULL;
 
 		if (m->m_len < 2) {
-			m = m_pullup(m,2)
+			m = m_pullup(m,2);
 			if (m == NULL) {
-			 	* TODO: count as dropped.
+			 	/* TODO: count as dropped. */
 return NULL;
 			}
 		}
 		/* RFC 1990 2.: don't assume no protocol field compression */
-		p = mtod(m, u_int8_t);
+		p = mtod(m, u_int8_t *);
 		protocol = *p;
 		
 		if (protocol & 1) {
@@ -2351,7 +2350,7 @@ sppp_lcp_up(struct sppp *sp)
 	/* Initialize mlppp state */
 	sp->lcp.mrru = sp->lcp.their_mrru = 0;
 	sp->lcp.ml_prefix = NULL;
-	sp->lcp.ml_seq_expected = 0;
+	sp->lcp.ml_seq_xpctd = 0;
 
 	/*
 	 * If this interface is passive or dial-on-demand, and we are



CVS commit: src/sys/arch/xen/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 19:08:10 UTC 2020

Modified Files:
src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
use ETHER_ADDR_LEN on one more place


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/arch/xen/xen/if_xennet_xenbus.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/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.110 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.111
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.110	Fri Apr 10 18:03:06 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Fri Apr 10 19:08:10 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.110 2020/04/10 18:03:06 jdolecek Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.111 2020/04/10 19:08:10 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.110 2020/04/10 18:03:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.111 2020/04/10 19:08:10 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -167,7 +167,7 @@ struct xennet_rxreq {
 struct xennet_xenbus_softc {
 	device_t sc_dev;
 	struct ethercom sc_ethercom;
-	uint8_t sc_enaddr[6];
+	uint8_t sc_enaddr[ETHER_ADDR_LEN];
 	struct xenbus_device *sc_xbusd;
 	bus_dma_tag_t sc_dmat;
 



CVS commit: src/sys/dev/pci

2020-04-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 10 18:32:12 UTC 2020

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.1392 -r1.1393 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1391 -r1.1392 src/sys/dev/pci/pcidevs_data.h

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

Modified files:

Index: src/sys/dev/pci/pcidevs.h
diff -u src/sys/dev/pci/pcidevs.h:1.1392 src/sys/dev/pci/pcidevs.h:1.1393
--- src/sys/dev/pci/pcidevs.h:1.1392	Tue Apr  7 08:32:02 2020
+++ src/sys/dev/pci/pcidevs.h	Fri Apr 10 14:32:11 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1392 2020/04/07 12:32:02 christos Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1393 2020/04/10 18:32:11 christos Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1404 2020/04/07 12:31:13 christos Exp
+ *	NetBSD: pcidevs,v 1.1405 2020/04/10 18:23:22 christos Exp
  */
 
 /*
@@ -7092,7 +7092,7 @@
 #define	PCI_PRODUCT_RDC_R6021_HB	0x6021		/* R6021 Host */
 #define	PCI_PRODUCT_RDC_R6023_HB	0x6023		/* R6023 Host */
 #define	PCI_PRODUCT_RDC_R6025_HB	0x6025		/* R6025 Host */
-#define	PCI_PRODUCT_RDC_R6026_HB	0x6026i		/* R6026 Host */
+#define	PCI_PRODUCT_RDC_R6026_HB	0x6026		/* R6026 Host */
 #define	PCI_PRODUCT_RDC_R6031_PCIB	0x6031		/* R6031 PCI-ISA bridge */
 #define	PCI_PRODUCT_RDC_R6035_PCIB	0x6035		/* R6035 PCI-ISA bridge */
 #define	PCI_PRODUCT_RDC_R6036_PCIB	0x6036		/* R6036 PCI-ISA bridge */

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1391 src/sys/dev/pci/pcidevs_data.h:1.1392
--- src/sys/dev/pci/pcidevs_data.h:1.1391	Tue Apr  7 08:32:02 2020
+++ src/sys/dev/pci/pcidevs_data.h	Fri Apr 10 14:32:11 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1391 2020/04/07 12:32:02 christos Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1392 2020/04/10 18:32:11 christos Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1404 2020/04/07 12:31:13 christos Exp
+ *	NetBSD: pcidevs,v 1.1405 2020/04/10 18:23:22 christos Exp
  */
 
 /*



CVS commit: src/sys/dev/pci

2020-04-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 10 18:32:00 UTC 2020

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

Log Message:
Fix all the random __SHIFTOUT casts by introducing an intermediate macho,
and then deleting and fixing the rest.


To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 src/sys/dev/pci/pci_subr.c

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

Modified files:

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.222 src/sys/dev/pci/pci_subr.c:1.223
--- src/sys/dev/pci/pci_subr.c:1.222	Sat Mar 21 13:09:29 2020
+++ src/sys/dev/pci/pci_subr.c	Fri Apr 10 14:32:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.222 2020/03/21 17:09:29 thorpej Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.223 2020/04/10 18:32:00 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.222 2020/03/21 17:09:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.223 2020/04/10 18:32:00 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -73,6 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v
 static int pci_conf_find_cap(const pcireg_t *, unsigned int, int *);
 static int pci_conf_find_extcap(const pcireg_t *, unsigned int, int *);
 static void pci_conf_print_pcie_power(uint8_t, unsigned int);
+#define PCIREG_SHIFTOUT(a, b) ((pcireg_t)__SHIFTOUT((a), (b)))
 
 /*
  * Descriptions of known PCI classes and subclasses.
@@ -721,7 +722,8 @@ pci_aprint_devinfo_fancy(const struct pc
 
 #define	i2o(i)	((i) * 4)
 #define	o2i(o)	((o) / 4)
-#define	onoff2(str, rval, bit, onstr, offstr)  \
+#define	onoff2(str, rval, bit, onstr, offstr)\
+	/*CONSTCOND*/			\
 	printf("  %s: %s\n", (str), ((rval) & (bit)) ? onstr : offstr);
 #define	onoff(str, rval, bit)	onoff2(str, rval, bit, "on", "off")
 
@@ -806,7 +808,7 @@ pci_conf_print_common(
 		printf("unknown/reserved");	/* XXX */
 		break;
 	}
-	printf(" (0x%x)\n", __SHIFTOUT(rval, PCI_STATUS_DEVSEL_MASK));
+	printf(" (0x%x)\n", PCIREG_SHIFTOUT(rval, PCI_STATUS_DEVSEL_MASK));
 
 	onoff("Slave signaled Target Abort", rval,
 	PCI_STATUS_TARGET_TARGET_ABORT);
@@ -1101,12 +1103,12 @@ pci_conf_print_agp_cap(const pcireg_t *r
 
 	rval = regs[o2i(capoff + PCI_AGP_STATUS)];
 	printf("Status register: 0x%04x\n", rval);
-	printf("  RQ: %d\n",
-	(unsigned int)__SHIFTOUT(rval, AGP_MODE_RQ) + 1);
-	printf("  ARQSZ: %d\n",
-	(unsigned int)__SHIFTOUT(rval, AGP_MODE_ARQSZ));
+	printf("  RQ: %u\n",
+	PCIREG_SHIFTOUT(rval, AGP_MODE_RQ) + 1);
+	printf("  ARQSZ: %u\n",
+	PCIREG_SHIFTOUT(rval, AGP_MODE_ARQSZ));
 	printf("  CAL cycle: %s\n",
-	   pci_conf_print_agp_calcycle(__SHIFTOUT(rval, AGP_MODE_CAL)));
+	   pci_conf_print_agp_calcycle(PCIREG_SHIFTOUT(rval, AGP_MODE_CAL)));
 	onoff("SBA", rval, AGP_MODE_SBA);
 	onoff("htrans#", rval, AGP_MODE_HTRANS);
 	onoff("Over 4G", rval, AGP_MODE_4G);
@@ -1118,12 +1120,12 @@ pci_conf_print_agp_cap(const pcireg_t *r
 
 	rval = regs[o2i(capoff + PCI_AGP_COMMAND)];
 	printf("Command register: 0x%08x\n", rval);
-	printf("  PRQ: %d\n",
-	(unsigned int)__SHIFTOUT(rval, AGP_MODE_RQ) + 1);
-	printf("  PARQSZ: %d\n",
-	(unsigned int)__SHIFTOUT(rval, AGP_MODE_ARQSZ));
+	printf("  PRQ: %u\n",
+	PCIREG_SHIFTOUT(rval, AGP_MODE_RQ) + 1);
+	printf("  PARQSZ: %u\n",
+	PCIREG_SHIFTOUT(rval, AGP_MODE_ARQSZ));
 	printf("  PCAL cycle: %s\n",
-	   pci_conf_print_agp_calcycle(__SHIFTOUT(rval, AGP_MODE_CAL)));
+	   pci_conf_print_agp_calcycle(PCIREG_SHIFTOUT(rval, AGP_MODE_CAL)));
 	onoff("SBA", rval, AGP_MODE_SBA);
 	onoff("AGP", rval, AGP_MODE_AGP);
 	onoff("Over 4G", rval, AGP_MODE_4G);
@@ -1200,16 +1202,16 @@ pci_conf_print_pcipm_cap(const pcireg_t 
 	printf("  PME# assertion: %sabled\n",
 	(pmcsr & PCI_PMCSR_PME_EN) ? "en" : "dis");
 	printf("  Data Select: %d\n",
-	__SHIFTOUT(pmcsr, PCI_PMCSR_DATASEL_MASK));
+	PCIREG_SHIFTOUT(pmcsr, PCI_PMCSR_DATASEL_MASK));
 	printf("  Data Scale: %d\n",
-	__SHIFTOUT(pmcsr, PCI_PMCSR_DATASCL_MASK));
+	PCIREG_SHIFTOUT(pmcsr, PCI_PMCSR_DATASCL_MASK));
 	onoff("PME# status", pmcsr, PCI_PMCSR_PME_STS);
 	printf("Bridge Support Extensions register: 0x%02x\n",
 	(pmcsr >> 16) & 0xff);
 	onoff("B2/B3 support", pmcsr, PCI_PMCSR_B2B3_SUPPORT);
 	onoff("Bus Power/Clock Control Enable", pmcsr, PCI_PMCSR_BPCC_EN);
 	printf("Data register: 0x%02x\n",
-	   __SHIFTOUT(pmcsr, PCI_PMCSR_DATA));
+	   PCIREG_SHIFTOUT(pmcsr, PCI_PMCSR_DATA));
 }
 
 /* XXX pci_conf_print_vpd_cap */
@@ -1222,8 +1224,8 @@ pci_conf_print_msi_cap(const pcireg_t *r
 
 	regs += o2i(capoff);
 	ctl = *regs++;
-	mmc = __SHIFTOUT(ctl, PCI_MSI_CTL_MMC_MASK);
-	mme = __SHIFTOUT(ctl, PCI_MSI_CTL_MME_MASK);
+	mmc = PCIREG_SHIFTOUT(ctl, PCI_MSI_CTL_MMC_MASK);
+	mme = 

CVS commit: src/sys/dev/pci

2020-04-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 10 18:23:22 UTC 2020

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.1404 -r1.1405 src/sys/dev/pci/pcidevs

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/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1404 src/sys/dev/pci/pcidevs:1.1405
--- src/sys/dev/pci/pcidevs:1.1404	Tue Apr  7 08:31:13 2020
+++ src/sys/dev/pci/pcidevs	Fri Apr 10 14:23:22 2020
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1404 2020/04/07 12:31:13 christos Exp $
+$NetBSD: pcidevs,v 1.1405 2020/04/10 18:23:22 christos Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -7085,7 +7085,7 @@ product RDC	R6013_PCIB	0x6013	R6013 PCI-
 product RDC	R6021_HB	0x6021	R6021 Host
 product RDC	R6023_HB	0x6023	R6023 Host
 product RDC	R6025_HB	0x6025	R6025 Host
-product RDC	R6026_HB	0x6026i	R6026 Host
+product RDC	R6026_HB	0x6026	R6026 Host
 product RDC	R6031_PCIB	0x6031	R6031 PCI-ISA bridge
 product RDC	R6035_PCIB	0x6035	R6035 PCI-ISA bridge
 product RDC	R6036_PCIB	0x6036	R6036 PCI-ISA bridge



CVS commit: src/sys/uvm

2020-04-10 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Apr 10 18:17:57 UTC 2020

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

Log Message:
Update a link to "CLOCK-Pro" paper.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/uvm/uvm_pdpolicy_clockpro.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_pdpolicy_clockpro.c
diff -u src/sys/uvm/uvm_pdpolicy_clockpro.c:1.24 src/sys/uvm/uvm_pdpolicy_clockpro.c:1.25
--- src/sys/uvm/uvm_pdpolicy_clockpro.c:1.24	Sat Mar 14 13:53:26 2020
+++ src/sys/uvm/uvm_pdpolicy_clockpro.c	Fri Apr 10 18:17:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_pdpolicy_clockpro.c,v 1.24 2020/03/14 13:53:26 ad Exp $	*/
+/*	$NetBSD: uvm_pdpolicy_clockpro.c,v 1.25 2020/04/10 18:17:56 tsutsui Exp $	*/
 
 /*-
  * Copyright (c)2005, 2006 YAMAMOTO Takashi,
@@ -28,7 +28,7 @@
 
 /*
  * CLOCK-Pro replacement policy:
- *	http://www.cs.wm.edu/hpcs/WWW/HTML/publications/abs05-3.html
+ *	http://web.cse.ohio-state.edu/hpcs/WWW/HTML/publications/abs05-3.html
  *
  * approximation of the list of non-resident pages using hash:
  *	http://linux-mm.org/ClockProApproximation
@@ -43,7 +43,7 @@
 #else /* defined(PDSIM) */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clockpro.c,v 1.24 2020/03/14 13:53:26 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clockpro.c,v 1.25 2020/04/10 18:17:56 tsutsui Exp $");
 
 #include "opt_ddb.h"
 



CVS commit: src/sys/arch/xen/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 18:03:06 UTC 2020

Modified Files:
src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
convert to bus_dma(9), remove now not necessary XENPVHVM redefines


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/xen/xen/if_xennet_xenbus.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/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.109 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.110
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.109	Tue Apr  7 11:47:06 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Fri Apr 10 18:03:06 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.109 2020/04/07 11:47:06 jdolecek Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.110 2020/04/10 18:03:06 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.109 2020/04/07 11:47:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.110 2020/04/10 18:03:06 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -143,21 +143,6 @@ int xennet_debug = 0xff;
 #define DPRINTFN(n,x)
 #endif
 
-#ifdef XENPVHVM
-/* Glue for p2m table stuff. Should be removed eventually */
-#define xpmap_mtop_masked(mpa) (mpa & ~PAGE_MASK)
-#define xpmap_mtop(mpa) (mpa & ~PTE_4KFRAME)
-#define xpmap_ptom_masked(mpa) (mpa & ~PAGE_MASK)
-#define xpmap_ptom(mpa) (mpa & ~PTE_4KFRAME)
-#define xpmap_ptom_map(ppa, mpa)
-#define xpmap_ptom_unmap(ppa)
-#define xpmap_ptom_isvalid 1 /* XXX: valid PA check */
-#define xpmap_pg_nx pmap_pg_nx /* We use the native setting */
-#define xpq_flush_queue() tlbflush()
-#endif /* XENPVHVM */
-
-extern pt_entry_t xpmap_pg_nx;
-
 #define GRANT_INVALID_REF -1 /* entry is free */
 
 #define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
@@ -168,15 +153,15 @@ struct xennet_txreq {
 	uint16_t txreq_id; /* ID passed to backend */
 	grant_ref_t txreq_gntref; /* grant ref of this request */
 	struct mbuf *txreq_m; /* mbuf being transmitted */
+	bus_dmamap_t txreq_dmamap;
 };
 
 struct xennet_rxreq {
 	SLIST_ENTRY(xennet_rxreq) rxreq_next;
 	uint16_t rxreq_id; /* ID passed to backend */
 	grant_ref_t rxreq_gntref; /* grant ref of this request */
-/* va/pa for this receive buf. ma will be provided by backend */
-	paddr_t rxreq_pa;
-	vaddr_t rxreq_va;
+	struct mbuf *rxreq_m;
+	bus_dmamap_t rxreq_dmamap;
 };
 
 struct xennet_xenbus_softc {
@@ -184,6 +169,7 @@ struct xennet_xenbus_softc {
 	struct ethercom sc_ethercom;
 	uint8_t sc_enaddr[6];
 	struct xenbus_device *sc_xbusd;
+	bus_dma_tag_t sc_dmat;
 
 	netif_tx_front_ring_t sc_tx_ring;
 	netif_rx_front_ring_t sc_rx_ring;
@@ -272,17 +258,13 @@ xennet_xenbus_attach(device_t parent, de
 	unsigned long uval;
 	extern int ifqmaxlen; /* XXX */
 	char mac[32];
-#ifdef XENNET_DEBUG
-	char **dir;
-	int dir_n = 0;
-	char id_str[20];
-#endif
 
 	aprint_normal(": Xen Virtual Network Interface\n");
 	sc->sc_dev = self;
 
 	sc->sc_xbusd = xa->xa_xbusd;
 	sc->sc_xbusd->xbusd_otherend_changed = xennet_backend_changed;
+	sc->sc_dmat = xa->xa_dmat;
 
 	/* xenbus ensure 2 devices can't be probed at the same time */
 	if (if_xennetrxbuf_cache_inited == 0) {
@@ -295,7 +277,14 @@ xennet_xenbus_attach(device_t parent, de
 	mutex_init(>sc_tx_lock, MUTEX_DEFAULT, IPL_NET);
 	SLIST_INIT(>sc_txreq_head);
 	for (i = 0; i < NET_TX_RING_SIZE; i++) {
-		sc->sc_txreqs[i].txreq_id = i;
+		struct xennet_txreq *txreq = >sc_txreqs[i];
+	
+		txreq->txreq_id = i;
+		if (bus_dmamap_create(sc->sc_dmat, PAGE_SIZE, 1, PAGE_SIZE,
+		PAGE_SIZE, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
+		>txreq_dmamap) != 0)
+			break;
+
 		SLIST_INSERT_HEAD(>sc_txreq_head, >sc_txreqs[i],
 		txreq_next);
 	}
@@ -305,9 +294,9 @@ xennet_xenbus_attach(device_t parent, de
 	for (i = 0; i < NET_RX_RING_SIZE; i++) {
 		struct xennet_rxreq *rxreq = >sc_rxreqs[i];
 		rxreq->rxreq_id = i;
-		rxreq->rxreq_va = (vaddr_t)pool_cache_get_paddr(
-		if_xennetrxbuf_cache, PR_WAITOK, >rxreq_pa);
-		if (rxreq->rxreq_va == 0)
+		if (bus_dmamap_create(sc->sc_dmat, PAGE_SIZE, 1, PAGE_SIZE,
+		PAGE_SIZE, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW,
+		>rxreq_dmamap) != 0)
 			break;
 		rxreq->rxreq_gntref = GRANT_INVALID_REF;
 		SLIST_INSERT_HEAD(>sc_rxreq_head, rxreq, rxreq_next);
@@ -443,10 +432,9 @@ xennet_xenbus_detach(device_t self, int 
 	xennet_free_rx_buffer(sc);
 	for (i = 0; i < NET_RX_RING_SIZE; i++) {
 		struct xennet_rxreq *rxreq = >sc_rxreqs[i];
-		if (rxreq->rxreq_va != 0) {
-			pool_cache_put_paddr(if_xennetrxbuf_cache,
-			(void *)rxreq->rxreq_va, rxreq->rxreq_pa);
-			rxreq->rxreq_va = 0;
+		if (rxreq->rxreq_m != NULL) {
+			m_freem(rxreq->rxreq_m);
+			rxreq->rxreq_m = NULL;
 		}
 	}
 	mutex_exit(>sc_rx_lock);
@@ -692,7 +680,6 @@ static void 

CVS commit: [is-mlppp] src/sys/net

2020-04-10 Thread Ignatios Souvatzis
Module Name:src
Committed By:   is
Date:   Fri Apr 10 17:28:37 UTC 2020

Modified Files:
src/sys/net [is-mlppp]: if_spppsubr.c if_spppvar.h

Log Message:
first part of defragmentation code. No dropping/sequence error statistics
yet, and no MRRU negotiation so not active.


To generate a diff of this commit:
cvs rdiff -u -r1.187.2.3 -r1.187.2.4 src/sys/net/if_spppsubr.c
cvs rdiff -u -r1.22.12.2 -r1.22.12.3 src/sys/net/if_spppvar.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/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.187.2.3 src/sys/net/if_spppsubr.c:1.187.2.4
--- src/sys/net/if_spppsubr.c:1.187.2.3	Tue Apr  7 19:26:44 2020
+++ src/sys/net/if_spppsubr.c	Fri Apr 10 17:28:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.187.2.3 2020/04/07 19:26:44 is Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.187.2.4 2020/04/10 17:28:37 is Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.187.2.3 2020/04/07 19:26:44 is Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.187.2.4 2020/04/10 17:28:37 is Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -336,6 +336,9 @@ static void sppp_lcp_scr(struct sppp *sp
 static void sppp_lcp_check_and_close(struct sppp *sp);
 static int sppp_ncp_check(struct sppp *sp);
 
+static struct mbuf *sppp_ml_defrag(struct sppp *sp, struct mbuf *m,
+u_int16_t *protocolp);
+
 static void sppp_ipcp_init(struct sppp *sp);
 static void sppp_ipcp_up(struct sppp *sp);
 static void sppp_ipcp_down(struct sppp *sp);
@@ -517,6 +520,123 @@ sppp_change_phase(struct sppp *sp, int p
 	}
 }
 
+
+/*
+ * Defragment an MP packet. 
+ *
+ * Returns NULL or an assembled packet or the original,
+ * and adjusts the passed protocol to the inner one.
+ *
+ * Called with and returns a packet without PPP header, 
+ * but with MP fragment header.
+ *
+ * Called and returns with lock held.
+ */
+static struct mbuf *
+sppp_ml_defrag(struct sppp *sp, struct mbuf *m, u_int16_t *protocolp)
+{
+	u_int8_t *p;
+	u_int8_t flags;
+	u_int32_t seqid;
+	u_int16_t protocol;
+	u_int16_t *m_protop;
+	int newflen;
+
+	if (*protocolp != PPP_MP)
+		return m; 	/* not ours */
+
+	if (sp->lcp.mrru == 0)
+		return m; 	/*
+ * ours, but we're not ready.
+ * sppp_input will arrange for rejection.
+ */
+
+	if (m->m_len < 4) {
+		m = m_pullup(m, 4);
+		if (m == NULL) {
+			if_statadd2(ifp, if_ierrors, 1, if_iqdrops, 1);
+			return NULL;
+		}
+	}
+	p = mtod(m, u_int8_t *);
+	flags = *p; 
+	seqid = (p[1]<<16) + (p[2]<<8) + p[3];
+
+	m_adj(m, 4);
+
+	/* We're manipulating the defragmentation state below: */
+	SPPP_UPGRADE(sp);
+
+	if (flags & 0x80) {
+		/* Beginning fragment. */
+		sp->lcp.ml_seq_expected=seqid+1;	/* next expected */
+		
+		/* TODO: if prefix, count dropped? */
+
+		m_freem(sp->lcp.ml_prefix);
+		sp->lcp.ml_prefix = m;
+
+	} else if (seqid == sp->lcp.ml_seq_expected) {
+		sp->lcp.ml_seq_expected=seqid+1;	/* next expected */
+		if (sp->lcp.ml_prefix == 0) {
+			/* didn't see B frame.	*/
+		 	/* TODO: count as dropped. */
+			m_freem(m);
+			return NULL;
+		}
+		/*
+		 * m_cat might free the first mbuf (with pkthdr)
+		 * in 2nd chain; therefore:
+		 */
+		newflen = m->m_pkthdr.len;
+		m_cat(sp->lcp.ml_prefix, m);
+		lcp.ml_prefix->m_pkthdr.len += newflen;
+
+	} else {
+		/*
+		 * sequence error. 
+		 *
+		 * For now, only drop this fragment, and don't touch state-
+		 * might be from the long past or future, and we could still
+		 * finish our current prefix.
+		 *
+		 * TODO: count as dropped.
+		 */
+		 m_freem(sp->lcp.ml_prefix);
+		 return NULL;
+	}
+	/* Successfully got the Beginning or appended a non-B packet.*/
+	if (flags & 0x40) {
+		/* B/next was E packet. Unwrap gift and deliver. */
+		m = sp->lcp.ml_prefix;
+		sp->lcp.ml_prefix = NULL;
+
+		if (m->m_len < 2) {
+			m = m_pullup(m,2)
+			if (m == NULL) {
+			 	* TODO: count as dropped.
+return NULL;
+			}
+		}
+		/* RFC 1990 2.: don't assume no protocol field compression */
+		p = mtod(m, u_int8_t);
+		protocol = *p;
+		
+		if (protocol & 1) {
+			m_adj(m, 1);
+		} else {
+			protocol = (protocol << 8) + p[1];
+			m_adj(m, 2);
+		}
+		*protocolp = protocol;
+
+		return m;
+	}
+
+	return NULL;
+}
+
+
 /*
  * Exported functions, comprising our interface to the lower layer.
  */
@@ -627,6 +747,12 @@ sppp_input(struct ifnet *ifp, struct mbu
 		protocol = ntohs(h->protocol);
 	}
 
+	m = sppp_ml_defrag(sp, m, );
+	if (m == 0) {
+		SPPP_UNLOCK(sp);
+		return;
+	}
+
 	switch (protocol) {
 	default:
 		if (sp->state[IDX_LCP] == STATE_OPENED) {
@@ -,6 +2348,11 @@ sppp_lcp_up(struct sppp *sp)
 	/* Initialize activity timestamp: opening a connection is an activity */
 	sp->pp_last_receive = sp->pp_last_activity = time_uptime;
 
+	/* Initialize mlppp state */
+	sp->lcp.mrru = sp->lcp.their_mrru = 0;
+	sp->lcp.ml_prefix 

CVS commit: src/sys/uvm

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 17:26:47 UTC 2020

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

Log Message:
uvmspace_exec(): set VM_MAP_DYING for the duration, so pmap_update() is not
called until the pmap has been totally cleared out after pmap_remove_all(),
or it can confuse some pmap implementations.


To generate a diff of this commit:
cvs rdiff -u -r1.377 -r1.378 src/sys/uvm/uvm_map.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_map.c
diff -u src/sys/uvm/uvm_map.c:1.377 src/sys/uvm/uvm_map.c:1.378
--- src/sys/uvm/uvm_map.c:1.377	Sat Apr  4 21:17:02 2020
+++ src/sys/uvm/uvm_map.c	Fri Apr 10 17:26:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_map.c,v 1.377 2020/04/04 21:17:02 ad Exp $	*/
+/*	$NetBSD: uvm_map.c,v 1.378 2020/04/10 17:26:46 ad Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.377 2020/04/04 21:17:02 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.378 2020/04/10 17:26:46 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_pax.h"
@@ -2266,7 +2266,10 @@ uvm_unmap_remove(struct vm_map *map, vad
 
 			/*
 			 * note: if map is dying, leave pmap_update() for
-			 * pmap_destroy(), which will be called later.
+			 * later.  if the map is to be reused (exec) then
+			 * pmap_update() will be called.  if the map is
+			 * being disposed of (exit) then pmap_destroy()
+			 * will be called.
 			 */
 
 			if ((map->flags & VM_MAP_DYING) == 0) {
@@ -4167,11 +4170,23 @@ uvmspace_exec(struct lwp *l, vaddr_t sta
 		map->flags &= ~VM_MAP_WIREFUTURE;
 
 		/*
-		 * now unmap the old program
+		 * now unmap the old program.
+		 * 
+		 * XXX set VM_MAP_DYING for the duration, so pmap_update()
+		 * is not called until the pmap has been totally cleared out
+		 * after pmap_remove_all(), or it can confuse some pmap
+		 * implementations.  it would be nice to handle this by
+		 * deferring the pmap_update() while it is known the address
+		 * space is not visible to any user LWP other than curlwp,
+		 * but there isn't an elegant way of inferring that right
+		 * now.
 		 */
 
 		flags = pmap_remove_all(map->pmap) ? UVM_FLAG_VAONLY : 0;
+		map->flags |= VM_MAP_DYING;
 		uvm_unmap1(map, vm_map_min(map), vm_map_max(map), flags);
+		map->flags &= ~VM_MAP_DYING;
+		pmap_update(map->pmap);
 		KASSERT(map->header.prev == >header);
 		KASSERT(map->nentries == 0);
 



CVS commit: src/sys

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 17:18:04 UTC 2020

Modified Files:
src/sys/kern: vfs_bio.c
src/sys/sys: buf.h

Log Message:
Remove buffer reference counting, now that it's safe to destroy b_busy after
waking any waiters.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.131 -r1.132 src/sys/sys/buf.h

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

Modified files:

Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.290 src/sys/kern/vfs_bio.c:1.291
--- src/sys/kern/vfs_bio.c:1.290	Sat Mar 14 18:08:39 2020
+++ src/sys/kern/vfs_bio.c	Fri Apr 10 17:18:04 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: vfs_bio.c,v 1.290 2020/03/14 18:08:39 ad Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.291 2020/04/10 17:18:04 ad Exp $	*/
 
 /*-
- * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -123,7 +123,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.290 2020/03/14 18:08:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.291 2020/04/10 17:18:04 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -228,8 +228,6 @@ static int checkfreelist(buf_t *, struct
 #endif
 static void biointr(void *);
 static void biodone2(buf_t *);
-static void bref(buf_t *);
-static void brele(buf_t *);
 static void sysctl_kern_buf_setup(void);
 static void sysctl_vm_buf_setup(void);
 
@@ -411,38 +409,6 @@ bremfree(buf_t *bp)
 }
 
 /*
- * Add a reference to an buffer structure that came from buf_cache.
- */
-static inline void
-bref(buf_t *bp)
-{
-
-	KASSERT(mutex_owned(_lock));
-	KASSERT(bp->b_refcnt > 0);
-
-	bp->b_refcnt++;
-}
-
-/*
- * Free an unused buffer structure that came from buf_cache.
- */
-static inline void
-brele(buf_t *bp)
-{
-
-	KASSERT(mutex_owned(_lock));
-	KASSERT(bp->b_refcnt > 0);
-
-	if (bp->b_refcnt-- == 1) {
-		buf_destroy(bp);
-#ifdef DEBUG
-		memset((char *)bp, 0, sizeof(*bp));
-#endif
-		pool_cache_put(buf_cache, bp);
-	}
-}
-
-/*
  * note that for some ports this is used by pmap bootstrap code to
  * determine kva size.
  */
@@ -1054,7 +1020,6 @@ brelsel(buf_t *bp, int set)
 	KASSERT(bp != NULL);
 	KASSERT(mutex_owned(_lock));
 	KASSERT(!cv_has_waiters(>b_done));
-	KASSERT(bp->b_refcnt > 0);
 
 	SET(bp->b_cflags, set);
 
@@ -1175,14 +1140,19 @@ already_queued:
 	 * prevent a thundering herd: many LWPs simultaneously awakening and
 	 * competing for the buffer's lock.  Testing in 2019 revealed this
 	 * to reduce contention on bufcache_lock tenfold during a kernel
-	 * compile.  Elsewhere, when the buffer is changing identity, being
-	 * disposed of, or moving from one list to another, we wake all lock
-	 * requestors.
+	 * compile.  Here and elsewhere, when the buffer is changing
+	 * identity, being disposed of, or moving from one list to another,
+	 * we wake all lock requestors.
 	 */
-	cv_signal(>b_busy);
-
-	if (bp->b_bufsize <= 0)
-		brele(bp);
+	if (bp->b_bufsize <= 0) {
+		cv_broadcast(>b_busy);
+		buf_destroy(bp);
+#ifdef DEBUG
+		memset((char *)bp, 0, sizeof(*bp));
+#endif
+		pool_cache_put(buf_cache, bp);
+	} else
+		cv_signal(>b_busy);
 }
 
 void
@@ -1494,7 +1464,6 @@ getnewbuf(int slpflag, int slptimeo, int
 	}
 
 	KASSERT(ISSET(bp->b_cflags, BC_BUSY));
-	KASSERT(bp->b_refcnt > 0);
 	KASSERT(!cv_has_waiters(>b_done));
 
 	/*
@@ -1603,7 +1572,6 @@ biowait(buf_t *bp)
 	BIOHIST_FUNC(__func__);
 
 	KASSERT(ISSET(bp->b_cflags, BC_BUSY));
-	KASSERT(bp->b_refcnt > 0);
 
 	SDT_PROBE1(io, kernel, , wait__start, bp);
 
@@ -2172,7 +2140,6 @@ buf_init(buf_t *bp)
 	bp->b_oflags = 0;
 	bp->b_objlock = _lock;
 	bp->b_iodone = NULL;
-	bp->b_refcnt = 1;
 	bp->b_dev = NODEV;
 	bp->b_vnbufs.le_next = NOLIST;
 	BIO_SETPRIO(bp, BPRIO_DEFAULT);
@@ -2201,7 +2168,6 @@ bbusy(buf_t *bp, bool intr, int timo, km
 			goto out;
 		}
 		bp->b_cflags |= BC_WANTED;
-		bref(bp);
 		if (interlock != NULL)
 			mutex_exit(interlock);
 		if (intr) {
@@ -2211,16 +2177,18 @@ bbusy(buf_t *bp, bool intr, int timo, km
 			error = cv_timedwait(>b_busy, _lock,
 			timo);
 		}
-		brele(bp);
+		/*
+		 * At this point the buffer may be gone: don't touch it
+		 * again.  The caller needs to find it again and retry.
+		 */
 		if (interlock != NULL)
 			mutex_enter(interlock);
-		if (error != 0)
-			goto out;
-		error = EPASSTHROUGH;
-		goto out;
+		if (error == 0)
+			error = EPASSTHROUGH;
+	} else {
+		bp->b_cflags |= BC_BUSY;
+		error = 0;
 	}
-	bp->b_cflags |= BC_BUSY;
-	error = 0;
 
 out:	SDT_PROBE5(io, kernel, , bbusy__done,
 	bp, intr, timo, interlock, error);

Index: src/sys/sys/buf.h
diff -u src/sys/sys/buf.h:1.131 src/sys/sys/buf.h:1.132
--- src/sys/sys/buf.h:1.131	Mon Aug 26 10:24:39 2019
+++ src/sys/sys/buf.h	Fri Apr 10 17:18:04 2020
@@ -1,4 +1,4 

CVS commit: src

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 17:16:22 UTC 2020

Modified Files:
src/share/man/man9: condvar.9
src/sys/kern: kern_condvar.c kern_sleepq.c subr_lockdebug.c
src/sys/sys: lockdebug.h lwp.h

Log Message:
- Make this needed sequence always work for condvars, by not touching the CV
  again after wakeup.  Previously it could panic because cv_signal() could
  be called by cv_wait_sig() + others:

cv_broadcast(cv);
cv_destroy(cv);

- In support of the above, if an LWP doing a timed wait is awoken by
  cv_broadcast() or cv_signal(), don't return an error if the timer
  fires after the fact, i.e. either succeed or fail, not both.

- Remove LOCKDEBUG code for CVs which never worked properly and is of
  questionable use.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/condvar.9
cvs rdiff -u -r1.44 -r1.45 src/sys/kern/kern_condvar.c
cvs rdiff -u -r1.63 -r1.64 src/sys/kern/kern_sleepq.c
cvs rdiff -u -r1.75 -r1.76 src/sys/kern/subr_lockdebug.c
cvs rdiff -u -r1.21 -r1.22 src/sys/sys/lockdebug.h
cvs rdiff -u -r1.205 -r1.206 src/sys/sys/lwp.h

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

Modified files:

Index: src/share/man/man9/condvar.9
diff -u src/share/man/man9/condvar.9:1.21 src/share/man/man9/condvar.9:1.22
--- src/share/man/man9/condvar.9:1.21	Thu Dec 12 02:34:55 2019
+++ src/share/man/man9/condvar.9	Fri Apr 10 17:16:21 2020
@@ -1,6 +1,6 @@
-.\"	$NetBSD: condvar.9,v 1.21 2019/12/12 02:34:55 pgoyette Exp $
+.\"	$NetBSD: condvar.9,v 1.22 2020/04/10 17:16:21 ad Exp $
 .\"
-.\" Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 12, 2019
+.Dd April 9, 2020
 .Dt CONDVAR 9
 .Os
 .Sh NAME
@@ -116,7 +116,9 @@ to display.
 .It Fn cv_destroy "cv"
 .Pp
 Release resources used by a CV.
-The CV must not be in use when it is destroyed, and must not be used afterwards.
+If there could be waiters, they should be awoken first with
+.Fn cv_broadcast .
+The CV must not be be used afterwards.
 .It Fn cv_wait "cv" "mtx"
 .Pp
 Cause the current LWP to wait non-interruptably for access to a resource,
@@ -145,10 +147,11 @@ as available until the calling LWP has b
 Non-interruptable waits have the potential to deadlock the system, and so must
 be kept short (typically, under one second).
 .Pp
-Upon being awakened, the calling LWP should verify the availability
-of the resource (or other condition).
-It should not blindly assume that the resource is now available.
-If the resource is still not available, the calling LWP may call
+.Fn cv_wait
+is typically used within a loop or restartable code sequence, because it
+may awaken spuriously.
+The calling LWP should re-check the condition that caused the wait.
+If necessary, the calling LWP may call
 .Fn cv_wait
 again to continue waiting.
 .It Fn cv_wait_sig "cv" "mtx"
@@ -234,8 +237,12 @@ more than
 .Fa bt Li "+" Fa epsilon .
 .It Fn cv_signal "cv"
 .Pp
-Awaken one LWP (potentially among many) that is waiting on the specified
-condition variable.
+Awaken one LWP waiting on the specified condition variable.
+Where there are waiters sleeping non-interruptaby, more than one
+LWP may be awoken.
+This can be used to avoid a "thundering herd" problem, where a large
+number of LWPs are awoken following an event, but only one LWP can
+process the event.
 The mutex passed to the wait function
 .Po Fa mtx Pc
 must also be held when calling

Index: src/sys/kern/kern_condvar.c
diff -u src/sys/kern/kern_condvar.c:1.44 src/sys/kern/kern_condvar.c:1.45
--- src/sys/kern/kern_condvar.c:1.44	Thu Mar 26 19:46:42 2020
+++ src/sys/kern/kern_condvar.c	Fri Apr 10 17:16:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_condvar.c,v 1.44 2020/03/26 19:46:42 ad Exp $	*/
+/*	$NetBSD: kern_condvar.c,v 1.45 2020/04/10 17:16:21 ad Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.44 2020/03/26 19:46:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.45 2020/04/10 17:16:21 ad Exp $");
 
 #include 
 #include 
@@ -77,41 +77,7 @@ syncobj_t cv_syncobj = {
 	.sobj_owner	= syncobj_noowner,
 };
 
-lockops_t cv_lockops = {
-	.lo_name = "Condition variable",
-	.lo_type = LOCKOPS_CV,
-	.lo_dump = NULL,
-};
-
 static const char deadcv[] = "deadcv";
-#ifdef LOCKDEBUG
-static const char nodebug[] = "nodebug";
-
-#define CV_LOCKDEBUG_HANDOFF(l, cv) cv_lockdebug_handoff(l, cv)
-#define CV_LOCKDEBUG_PROCESS(l, cv) cv_lockdebug_process(l, cv)
-
-static inline void
-cv_lockdebug_handoff(lwp_t *l, kcondvar_t *cv)

CVS commit: src/distrib/notes/common

2020-04-10 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Apr 10 17:02:33 UTC 2020

Modified Files:
src/distrib/notes/common: legal.common

Log Message:
Drop the entry for Yasushi Yamasaki, per recent ad clause removal.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/distrib/notes/common/legal.common

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

Modified files:

Index: src/distrib/notes/common/legal.common
diff -u src/distrib/notes/common/legal.common:1.124 src/distrib/notes/common/legal.common:1.125
--- src/distrib/notes/common/legal.common:1.124	Tue Dec  3 16:45:21 2019
+++ src/distrib/notes/common/legal.common	Fri Apr 10 17:02:33 2020
@@ -1,4 +1,4 @@
-.\" $NetBSD: legal.common,v 1.124 2019/12/03 16:45:21 uwe Exp $
+.\" $NetBSD: legal.common,v 1.125 2020/04/10 17:02:33 tsutsui Exp $
 .\"
 .\" Copyright (c) 1999-2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -400,8 +400,6 @@ its contributors.
 .It
 This product includes software developed by Winning Strategies, Inc.
 .It
-This product includes software developed by Yasushi Yamasaki
-.It
 This product includes software developed by Yen Yen Lim and
 North Dakota State University
 .It



CVS commit: src/sys/kern

2020-04-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Apr 10 16:55:40 UTC 2020

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

Log Message:
Cosmetic changes


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/kern/vfs_cache.c

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

Modified files:

Index: src/sys/kern/vfs_cache.c
diff -u src/sys/kern/vfs_cache.c:1.137 src/sys/kern/vfs_cache.c:1.138
--- src/sys/kern/vfs_cache.c:1.137	Sat Apr  4 20:49:30 2020
+++ src/sys/kern/vfs_cache.c	Fri Apr 10 16:55:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_cache.c,v 1.137 2020/04/04 20:49:30 ad Exp $	*/
+/*	$NetBSD: vfs_cache.c,v 1.138 2020/04/10 16:55:40 ad Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -172,7 +172,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.137 2020/04/04 20:49:30 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.138 2020/04/10 16:55:40 ad Exp $");
 
 #define __NAMECACHE_PRIVATE
 #ifdef _KERNEL_OPT
@@ -241,7 +241,7 @@ struct nchcpu {
 static callout_t cache_stat_callout;
 static kmutex_t cache_stat_lock __cacheline_aligned;
 
-#define	COUNT(f)	do { \
+#define	COUNT(f) do { \
 	lwp_t *l = curlwp; \
 	KPREEMPT_DISABLE(l); \
 	((struct nchstats_percpu *)curcpu()->ci_data.cpu_nch)->f++; \
@@ -417,10 +417,10 @@ cache_lookup_entry(struct vnode *dvp, co
 		if (__predict_false(RB_SENTINEL_P(node))) {
 			return NULL;
 		}
-		KASSERT((void *)>nc_tree == (void *)ncp);
 		ncp = (struct namecache *)node;
+		KASSERT((void *)>nc_tree == (void *)ncp);
 		KASSERT(ncp->nc_dvp == dvp);
-		if (__predict_false(ncp->nc_key == key)) {
+		if (ncp->nc_key == key) {
 			KASSERT(ncp->nc_nlen == namelen);
 			diff = memcmp(ncp->nc_name, name, namelen);
 			if (__predict_true(diff == 0)) {



CVS commit: xsrc/external/mit

2020-04-10 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Fri Apr 10 16:49:37 UTC 2020

Modified Files:
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k: x68k.h
x68kConfig.c x68kFb.c x68kGraph.c x68kInit.c x68kIo.c x68kKbd.c
x68kKeyMap.c x68kMouse.c x68kReg.h x68kText.c
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k: x68k.h x68kConfig.c
x68kFb.c x68kGraph.c x68kInit.c x68kIo.c x68kKbd.c x68kKeyMap.c
x68kMouse.c x68kReg.h x68kText.c

Log Message:
Remove clause 3 and 4 from X68k server files written by Yasushi Yamasaki.

I've finally contacted with Yamasaki-san and he kindly answered
"no objection to change them to 2 clause license" in private mail.
Diffs to be committed have also been confirmed by him.
We appreciate all his contribution to early NetBSD/x68k.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68k.h \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kFb.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kGraph.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kInit.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kIo.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKbd.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kKeyMap.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kMouse.c \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kReg.h \
xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kText.c
cvs rdiff -u -r1.3 -r1.4 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68k.h \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kConfig.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kInit.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c
cvs rdiff -u -r1.2 -r1.3 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kFb.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kText.c
cvs rdiff -u -r1.4 -r1.5 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c
cvs rdiff -u -r1.1 -r1.2 \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kIo.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKeyMap.c \
xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kReg.h

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

Modified files:

Index: xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68k.h
diff -u xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68k.h:1.1.1.1 xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68k.h:1.2
--- xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68k.h:1.1.1.1	Thu Jun  9 09:07:59 2016
+++ xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68k.h	Fri Apr 10 16:49:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x68k.h,v 1.1.1.1 2016/06/09 09:07:59 mrg Exp $ */
+/* $NetBSD: x68k.h,v 1.2 2020/04/10 16:49:36 tsutsui Exp $ */
 /*-
  * Copyright (c) 1996 Yasushi Yamasaki
  * All rights reserved.
@@ -11,11 +11,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *must display the following acknowledgement:
- *  This product includes software developed by Yasushi Yamasaki
- * 4. The name of the author may not be used to endorse or promote products
- *derived from this software without specific prior written permission
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Index: xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c
diff -u xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c:1.1.1.1 xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c:1.2
--- xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c:1.1.1.1	Thu Jun  9 09:07:59 2016
+++ xsrc/external/mit/xorg-server.old/dist/hw/netbsd/x68k/x68kConfig.c	Fri Apr 10 16:49:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: x68kConfig.c,v 1.1.1.1 2016/06/09 09:07:59 mrg Exp $ */
+/* $NetBSD: x68kConfig.c,v 1.2 2020/04/10 16:49:36 tsutsui Exp $ */
 /*-
  * Copyright (c) 1996 Yasushi Yamasaki
  * All rights reserved.
@@ -11,11 +11,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or 

CVS commit: src/sys/arch/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 14:54:34 UTC 2020

Modified Files:
src/sys/arch/xen/include: xenbus.h
src/sys/arch/xen/x86: xen_bus_dma.c
src/sys/arch/xen/xen: hypervisor.c
src/sys/arch/xen/xenbus: xenbus_probe.c

Log Message:
add and pass dma tag to PV drivers attached to xenbus, so thay can
use bus_dmamap_load_mbuf() et.al.

due to XENPV override, _BUS_BUS_TO_PHYS() dmamap segment ds_addr
gets filled with ma, so value can be directly used for e.g. grant calls


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/xen/include/xenbus.h
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/xen/x86/xen_bus_dma.c
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/xen/xen/hypervisor.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/xen/xenbus/xenbus_probe.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/xen/include/xenbus.h
diff -u src/sys/arch/xen/include/xenbus.h:1.22 src/sys/arch/xen/include/xenbus.h:1.23
--- src/sys/arch/xen/include/xenbus.h:1.22	Tue Apr  7 16:10:48 2020
+++ src/sys/arch/xen/include/xenbus.h	Fri Apr 10 14:54:34 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus.h,v 1.22 2020/04/07 16:10:48 jdolecek Exp $ */
+/* $NetBSD: xenbus.h,v 1.23 2020/04/10 14:54:34 jdolecek Exp $ */
 /**
  * xenbus.h
  *
@@ -33,6 +33,7 @@
 #define _ASM_XEN_XENBUS_H
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,6 +44,7 @@
 struct xenbus_attach_args {
 	const char 		*xa_device;
 	int			xa_handle;
+	bus_dma_tag_t		xa_dmat;
 };
 
 /* devices to xenbus attach */
@@ -50,6 +52,7 @@ struct xenbusdev_attach_args {
 	const char		*xa_type;
 	int 			xa_id;
 	struct xenbus_device	*xa_xbusd;
+	bus_dma_tag_t		xa_dmat;
 };
 
 /* Register callback to watch this node. */

Index: src/sys/arch/xen/x86/xen_bus_dma.c
diff -u src/sys/arch/xen/x86/xen_bus_dma.c:1.29 src/sys/arch/xen/x86/xen_bus_dma.c:1.30
--- src/sys/arch/xen/x86/xen_bus_dma.c:1.29	Thu Apr  9 19:26:37 2020
+++ src/sys/arch/xen/x86/xen_bus_dma.c	Fri Apr 10 14:54:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: xen_bus_dma.c,v 1.29 2020/04/09 19:26:37 jdolecek Exp $	*/
+/*	$NetBSD: xen_bus_dma.c,v 1.30 2020/04/10 14:54:33 jdolecek Exp $	*/
 /*	NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */
 
 /*-
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.29 2020/04/09 19:26:37 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.30 2020/04/10 14:54:33 jdolecek Exp $");
 
 #include 
 #include 
@@ -47,6 +47,15 @@ __KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.
 
 extern paddr_t avail_end;
 
+/* No special needs */
+struct x86_bus_dma_tag xenbus_bus_dma_tag = {
+	._tag_needs_free	= 0,
+	._bounce_thresh		= 0,
+	._bounce_alloc_lo	= 0,
+	._bounce_alloc_hi	= 0,
+	._may_bounce		= NULL,
+};
+
 /* Pure 2^n version of get_order */
 static inline int get_order(unsigned long size)
 {

Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.73 src/sys/arch/xen/xen/hypervisor.c:1.74
--- src/sys/arch/xen/xen/hypervisor.c:1.73	Tue Apr  7 08:14:42 2020
+++ src/sys/arch/xen/xen/hypervisor.c	Fri Apr 10 14:54:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */
+/* $NetBSD: hypervisor.c,v 1.74 2020/04/10 14:54:33 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.74 2020/04/10 14:54:33 jdolecek Exp $");
 
 #include 
 #include 
@@ -415,7 +415,7 @@ hypervisor_match(device_t parent, cfdata
 	bi.common.len = sizeof(struct btinfo_rootdevice);
 
 	/* From i386/multiboot.c */
-	/*	$NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $	*/
+	/*	$NetBSD: hypervisor.c,v 1.74 2020/04/10 14:54:33 jdolecek Exp $	*/
 	int i, len;
 	vaddr_t data;
 	extern struct bootinfo	bootinfo;
@@ -545,8 +545,10 @@ hypervisor_attach(device_t parent, devic
 #endif /* MULTIPROCESSOR */
 
 #if NXENBUS > 0
+	extern struct x86_bus_dma_tag xenbus_bus_dma_tag;
 	memset(, 0, sizeof(hac));
 	hac.hac_xenbus.xa_device = "xenbus";
+	hac.hac_xenbus.xa_dmat = _bus_dma_tag;
 	config_found_ia(self, "xendevbus", _xenbus, hypervisor_print);
 #endif
 #if NXENCONS > 0

Index: src/sys/arch/xen/xenbus/xenbus_probe.c
diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.47 src/sys/arch/xen/xenbus/xenbus_probe.c:1.48
--- src/sys/arch/xen/xenbus/xenbus_probe.c:1.47	Fri Apr 10 12:38:40 2020
+++ src/sys/arch/xen/xenbus/xenbus_probe.c	Fri Apr 10 14:54:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_probe.c,v 1.47 2020/04/10 12:38:40 jdolecek Exp $ */
+/* $NetBSD: xenbus_probe.c,v 1.48 2020/04/10 14:54:33 jdolecek Exp $ */
 /**
  * Talks to Xen Store to figure out 

CVS commit: [bouyer-xenpvh] src/sys/arch

2020-04-10 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Apr 10 14:42:00 UTC 2020

Modified Files:
src/sys/arch/amd64/amd64 [bouyer-xenpvh]: spl.S vector.S
src/sys/arch/amd64/conf [bouyer-xenpvh]: XEN3_PVHVM
src/sys/arch/i386/conf [bouyer-xenpvh]: XEN3PAE_PVHVM
src/sys/arch/i386/i386 [bouyer-xenpvh]: spl.S vector.S
src/sys/arch/x86/include [bouyer-xenpvh]: intr.h

Log Message:
spllower(): Also check Xen pending events
hypervisor_pvhvm_callback(): exit via Xdoreti, so that pending interrupts
are checked.
disable __HAVE_FAST_SOFTINTS only for XENPV, it now works for PVHVM.
We still have to disable PREEMPTION, until we support MULTIPROCESSOR


To generate a diff of this commit:
cvs rdiff -u -r1.43.4.2 -r1.43.4.3 src/sys/arch/amd64/amd64/spl.S
cvs rdiff -u -r1.73 -r1.73.6.1 src/sys/arch/amd64/amd64/vector.S
cvs rdiff -u -r1.3.2.1 -r1.3.2.2 src/sys/arch/amd64/conf/XEN3_PVHVM
cvs rdiff -u -r1.3.2.1 -r1.3.2.2 src/sys/arch/i386/conf/XEN3PAE_PVHVM
cvs rdiff -u -r1.50 -r1.50.4.1 src/sys/arch/i386/i386/spl.S
cvs rdiff -u -r1.85 -r1.85.6.1 src/sys/arch/i386/i386/vector.S
cvs rdiff -u -r1.61 -r1.61.6.1 src/sys/arch/x86/include/intr.h

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

Modified files:

Index: src/sys/arch/amd64/amd64/spl.S
diff -u src/sys/arch/amd64/amd64/spl.S:1.43.4.2 src/sys/arch/amd64/amd64/spl.S:1.43.4.3
--- src/sys/arch/amd64/amd64/spl.S:1.43.4.2	Thu Apr  9 21:01:33 2020
+++ src/sys/arch/amd64/amd64/spl.S	Fri Apr 10 14:41:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.43.4.2 2020/04/09 21:01:33 bouyer Exp $	*/
+/*	$NetBSD: spl.S,v 1.43.4.3 2020/04/10 14:41:59 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -91,7 +91,7 @@ ENTRY(splraise)
 	ret
 END(splraise)
 
-#ifndef XEN
+#ifndef XENPV
 /*
  * Xsoftintr()
  *
@@ -242,6 +242,11 @@ ENTRY(spllower)
 	cli
 	testl	CPUVAR(IPENDING),%edx
 	jnz	2f
+#if defined(XEN)
+	movl	CPUVAR(XUNMASK)(,%rdi,4),%edx
+	testl	CPUVAR(XPENDING),%edx
+	jnz	2f
+#endif
 	movl	%edi,CPUVAR(ILEVEL)
 	popf
 1:

Index: src/sys/arch/amd64/amd64/vector.S
diff -u src/sys/arch/amd64/amd64/vector.S:1.73 src/sys/arch/amd64/amd64/vector.S:1.73.6.1
--- src/sys/arch/amd64/amd64/vector.S:1.73	Mon Dec 30 23:32:29 2019
+++ src/sys/arch/amd64/amd64/vector.S	Fri Apr 10 14:41:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.73 2019/12/30 23:32:29 thorpej Exp $	*/
+/*	$NetBSD: vector.S,v 1.73.6.1 2020/04/10 14:41:59 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -815,7 +815,6 @@ ENTRY(hypervisor_callback)
 	movq	(%rsp),%rcx
 	movq	8(%rsp),%r11
 	addq	$16,%rsp
-IDTVEC(hypervisor_pvhvm_callback)
 	pushq	$0		/* Dummy error code */
 	pushq	$T_ASTFLT
 	INTRENTRY
@@ -827,8 +826,21 @@ IDTVEC(hypervisor_pvhvm_callback)
 	jnz	doreti_checkast
 1:
 	INTRFASTEXIT
-IDTVEC_END(hypervisor_pvhvm_callback)
 END(hypervisor_callback)
+
+IDTVEC(hypervisor_pvhvm_callback)
+	pushq	$0		/* Dummy error code */
+	pushq	$T_ASTFLT
+	INTRENTRY
+	movlCPUVAR(ILEVEL),%edi
+	pushq   %rdi /* for Xdoreti */
+	/* sti?? */
+	movq	%rsp,%rdi
+	subq	$8,%rdi;	/* don't forget if_ppl */
+	call	do_hypervisor_callback
+	incl	CPUVAR(IDEPTH)
+	jmp 	_C_LABEL(Xdoreti)
+IDTVEC_END(hypervisor_pvhvm_callback)
 #endif /* XEN */
 
 #ifdef XENPV

Index: src/sys/arch/amd64/conf/XEN3_PVHVM
diff -u src/sys/arch/amd64/conf/XEN3_PVHVM:1.3.2.1 src/sys/arch/amd64/conf/XEN3_PVHVM:1.3.2.2
--- src/sys/arch/amd64/conf/XEN3_PVHVM:1.3.2.1	Wed Apr  8 17:56:08 2020
+++ src/sys/arch/amd64/conf/XEN3_PVHVM	Fri Apr 10 14:42:00 2020
@@ -1,10 +1,11 @@
-# $NetBSD: XEN3_PVHVM,v 1.3.2.1 2020/04/08 17:56:08 bouyer Exp $
+# $NetBSD: XEN3_PVHVM,v 1.3.2.2 2020/04/10 14:42:00 bouyer Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
 options		XENPVHVM
 
 #options 	MULTIPROCESSOR	# Not yet.
+options 	NO_PREEMPTION
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -12,7 +13,7 @@ options 	INCLUDE_CONFIG_FILE	# embed con
 #options 	UVMHIST_PRINT
 #options 	SYSCALL_DEBUG
 
-#ident		"XEN3_PVHVM-$Revision: 1.3.2.1 $"
+#ident		"XEN3_PVHVM-$Revision: 1.3.2.2 $"
 
 maxusers	32		# estimated number of users
 options 	MAXPHYS=32768	#xbd doesn't handle 64k transfers

Index: src/sys/arch/i386/conf/XEN3PAE_PVHVM
diff -u src/sys/arch/i386/conf/XEN3PAE_PVHVM:1.3.2.1 src/sys/arch/i386/conf/XEN3PAE_PVHVM:1.3.2.2
--- src/sys/arch/i386/conf/XEN3PAE_PVHVM:1.3.2.1	Wed Apr  8 17:56:08 2020
+++ src/sys/arch/i386/conf/XEN3PAE_PVHVM	Fri Apr 10 14:42:00 2020
@@ -1,10 +1,11 @@
-# $NetBSD: XEN3PAE_PVHVM,v 1.3.2.1 2020/04/08 17:56:08 bouyer Exp $
+# $NetBSD: XEN3PAE_PVHVM,v 1.3.2.2 2020/04/10 14:42:00 bouyer Exp $
 
 include 	"arch/xen/conf/std.xen"
 
 options		XENPVHVM		# PVHVM domU support
 
 #options 	MULTIPROCESSOR	# Not yet.
+options 	NO_PREEMPTION
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
@@ -115,7 +116,7 @@ hypervisor*	at mainbus?		# Xen hyperviso
 #vcpu*		at hypervisor?		# Xen 

CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen

2020-04-10 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Apr 10 14:38:19 UTC 2020

Modified Files:
src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c

Log Message:
Remove extra assignement


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/arch/xen/xen/evtchn.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/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.88 src/sys/arch/xen/xen/evtchn.c:1.88.2.1
--- src/sys/arch/xen/xen/evtchn.c:1.88	Mon Apr  6 19:26:00 2020
+++ src/sys/arch/xen/xen/evtchn.c	Fri Apr 10 14:38:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.88 2020/04/06 19:26:00 jdolecek Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.88.2.1 2020/04/10 14:38:19 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88 2020/04/06 19:26:00 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.1 2020/04/10 14:38:19 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -942,7 +942,6 @@ event_set_iplhandler(struct cpu_info *ci
 		KM_NOSLEEP);
 		if (ipls == NULL)
 			panic("can't allocate fixed interrupt source");
-		ipls->is_recurse = xenev_stubs[level].ist_entry;
 		ipls->is_recurse = xenev_stubs[level].ist_recurse;
 		ipls->is_resume = xenev_stubs[level].ist_resume;
 		ipls->is_handlers = ih;



CVS commit: [bouyer-xenpvh] src/sys/arch/x86

2020-04-10 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Apr 10 14:37:54 UTC 2020

Modified Files:
src/sys/arch/x86/include [bouyer-xenpvh]: cpu.h
src/sys/arch/x86/x86 [bouyer-xenpvh]: cpu.c patch.c

Log Message:
Skip cx8_spllower patch if we're running on any form of Xen PV,
we can't handle PV interrupts with a single atomic op here.
Enable x86_patch() for Xen too.


To generate a diff of this commit:
cvs rdiff -u -r1.117.4.1 -r1.117.4.2 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.181 -r1.181.4.1 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.37 -r1.37.6.1 src/sys/arch/x86/x86/patch.c

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

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.117.4.1 src/sys/arch/x86/include/cpu.h:1.117.4.2
--- src/sys/arch/x86/include/cpu.h:1.117.4.1	Wed Apr  8 17:59:16 2020
+++ src/sys/arch/x86/include/cpu.h	Fri Apr 10 14:37:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.117.4.1 2020/04/08 17:59:16 bouyer Exp $	*/
+/*	$NetBSD: cpu.h,v 1.117.4.2 2020/04/10 14:37:54 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -507,6 +507,19 @@ typedef enum vm_guest {
 } vm_guest_t;
 extern vm_guest_t vm_guest;
 
+static __inline bool __unused
+vm_guest_is_xenpv(void)
+{
+	switch(vm_guest) {
+	case VM_GUEST_XENPV:
+	case VM_GUEST_XENPVH:
+	case VM_GUEST_XENPVHVM:
+		return true;
+	default:
+		return false;
+	}
+}
+
 /* cpu_topology.c */
 void	x86_cpu_topology(struct cpu_info *);
 

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.181 src/sys/arch/x86/x86/cpu.c:1.181.4.1
--- src/sys/arch/x86/x86/cpu.c:1.181	Tue Jan 14 01:41:37 2020
+++ src/sys/arch/x86/x86/cpu.c	Fri Apr 10 14:37:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.181 2020/01/14 01:41:37 pgoyette Exp $	*/
+/*	$NetBSD: cpu.c,v 1.181.4.1 2020/04/10 14:37:54 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.181 2020/01/14 01:41:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.181.4.1 2020/04/10 14:37:54 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -720,10 +720,8 @@ cpu_boot_secondary_processors(void)
 	kcpuset_t *cpus;
 	u_long i;
 
-#ifndef XEN
 	/* Now that we know the number of CPUs, patch the text segment. */
 	x86_patch(false);
-#endif
 
 #if NACPICA > 0
 	/* Finished with NUMA info for now. */

Index: src/sys/arch/x86/x86/patch.c
diff -u src/sys/arch/x86/x86/patch.c:1.37 src/sys/arch/x86/x86/patch.c:1.37.6.1
--- src/sys/arch/x86/x86/patch.c:1.37	Wed Sep 18 15:07:08 2019
+++ src/sys/arch/x86/x86/patch.c	Fri Apr 10 14:37:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: patch.c,v 1.37 2019/09/18 15:07:08 kamil Exp $	*/
+/*	$NetBSD: patch.c,v 1.37.6.1 2020/04/10 14:37:54 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.37 2019/09/18 15:07:08 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.37.6.1 2020/04/10 14:37:54 bouyer Exp $");
 
 #include "opt_lockdebug.h"
 #ifdef i386
@@ -250,7 +250,8 @@ x86_patch(bool early)
 #endif	/* i386 */
 
 #if !defined(SPLDEBUG)
-	if (!early && (cpu_feature[0] & CPUID_CX8) != 0) {
+	if (!early && (cpu_feature[0] & CPUID_CX8) != 0 &&
+	!vm_guest_is_xenpv()) {
 		/* Faster splx(), mutex_spin_exit(). */
 		patchfunc(
 		cx8_spllower, cx8_spllower_end,



CVS commit: src/sys/arch/x86

2020-04-10 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Apr 10 14:35:26 UTC 2020

Modified Files:
src/sys/arch/x86/include: cpu.h
src/sys/arch/x86/x86: cpu.c patch.c

Log Message:
Revert, wrong branch


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.182 -r1.183 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/x86/patch.c

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

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.118 src/sys/arch/x86/include/cpu.h:1.119
--- src/sys/arch/x86/include/cpu.h:1.118	Fri Apr 10 14:34:27 2020
+++ src/sys/arch/x86/include/cpu.h	Fri Apr 10 14:35:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.118 2020/04/10 14:34:27 bouyer Exp $	*/
+/*	$NetBSD: cpu.h,v 1.119 2020/04/10 14:35:26 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -505,19 +505,6 @@ typedef enum vm_guest {
 } vm_guest_t;
 extern vm_guest_t vm_guest;
 
-static __inline bool __unused
-vm_guest_is_xenpv(void)
-{
-	switch(vm_guest) {
-	case VM_GUEST_XENPV:
-	case VM_GUEST_XENPVH:
-	case VM_GUEST_XENPVHVM:
-		return true;
-	default:
-		return false;
-	}
-}
-
 /* cpu_topology.c */
 void	x86_cpu_topology(struct cpu_info *);
 

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.182 src/sys/arch/x86/x86/cpu.c:1.183
--- src/sys/arch/x86/x86/cpu.c:1.182	Fri Apr 10 14:34:27 2020
+++ src/sys/arch/x86/x86/cpu.c	Fri Apr 10 14:35:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.182 2020/04/10 14:34:27 bouyer Exp $	*/
+/*	$NetBSD: cpu.c,v 1.183 2020/04/10 14:35:26 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.182 2020/04/10 14:34:27 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.183 2020/04/10 14:35:26 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -720,8 +720,10 @@ cpu_boot_secondary_processors(void)
 	kcpuset_t *cpus;
 	u_long i;
 
+#ifndef XEN
 	/* Now that we know the number of CPUs, patch the text segment. */
 	x86_patch(false);
+#endif
 
 #if NACPICA > 0
 	/* Finished with NUMA info for now. */

Index: src/sys/arch/x86/x86/patch.c
diff -u src/sys/arch/x86/x86/patch.c:1.38 src/sys/arch/x86/x86/patch.c:1.39
--- src/sys/arch/x86/x86/patch.c:1.38	Fri Apr 10 14:34:27 2020
+++ src/sys/arch/x86/x86/patch.c	Fri Apr 10 14:35:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: patch.c,v 1.38 2020/04/10 14:34:27 bouyer Exp $	*/
+/*	$NetBSD: patch.c,v 1.39 2020/04/10 14:35:26 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.38 2020/04/10 14:34:27 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.39 2020/04/10 14:35:26 bouyer Exp $");
 
 #include "opt_lockdebug.h"
 #ifdef i386
@@ -250,8 +250,7 @@ x86_patch(bool early)
 #endif	/* i386 */
 
 #if !defined(SPLDEBUG)
-	if (!early && (cpu_feature[0] & CPUID_CX8) != 0 &&
-	!vm_guest_is_xenpv()) {
+	if (!early && (cpu_feature[0] & CPUID_CX8) != 0) {
 		/* Faster splx(), mutex_spin_exit(). */
 		patchfunc(
 		cx8_spllower, cx8_spllower_end,



CVS commit: src/sys/arch/x86

2020-04-10 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Apr 10 14:34:28 UTC 2020

Modified Files:
src/sys/arch/x86/include: cpu.h
src/sys/arch/x86/x86: cpu.c patch.c

Log Message:
Skip cx8_spllower patch if we're running on any form of Xen PV,
we can't handle PV interrupts with a single atomic op here.
Enable x86_patch() for Xen too.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.181 -r1.182 src/sys/arch/x86/x86/cpu.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/x86/x86/patch.c

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

Modified files:

Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.117 src/sys/arch/x86/include/cpu.h:1.118
--- src/sys/arch/x86/include/cpu.h:1.117	Wed Jan 15 13:22:03 2020
+++ src/sys/arch/x86/include/cpu.h	Fri Apr 10 14:34:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.117 2020/01/15 13:22:03 ad Exp $	*/
+/*	$NetBSD: cpu.h,v 1.118 2020/04/10 14:34:27 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -505,6 +505,19 @@ typedef enum vm_guest {
 } vm_guest_t;
 extern vm_guest_t vm_guest;
 
+static __inline bool __unused
+vm_guest_is_xenpv(void)
+{
+	switch(vm_guest) {
+	case VM_GUEST_XENPV:
+	case VM_GUEST_XENPVH:
+	case VM_GUEST_XENPVHVM:
+		return true;
+	default:
+		return false;
+	}
+}
+
 /* cpu_topology.c */
 void	x86_cpu_topology(struct cpu_info *);
 

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.181 src/sys/arch/x86/x86/cpu.c:1.182
--- src/sys/arch/x86/x86/cpu.c:1.181	Tue Jan 14 01:41:37 2020
+++ src/sys/arch/x86/x86/cpu.c	Fri Apr 10 14:34:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.181 2020/01/14 01:41:37 pgoyette Exp $	*/
+/*	$NetBSD: cpu.c,v 1.182 2020/04/10 14:34:27 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.181 2020/01/14 01:41:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.182 2020/04/10 14:34:27 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -720,10 +720,8 @@ cpu_boot_secondary_processors(void)
 	kcpuset_t *cpus;
 	u_long i;
 
-#ifndef XEN
 	/* Now that we know the number of CPUs, patch the text segment. */
 	x86_patch(false);
-#endif
 
 #if NACPICA > 0
 	/* Finished with NUMA info for now. */

Index: src/sys/arch/x86/x86/patch.c
diff -u src/sys/arch/x86/x86/patch.c:1.37 src/sys/arch/x86/x86/patch.c:1.38
--- src/sys/arch/x86/x86/patch.c:1.37	Wed Sep 18 15:07:08 2019
+++ src/sys/arch/x86/x86/patch.c	Fri Apr 10 14:34:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: patch.c,v 1.37 2019/09/18 15:07:08 kamil Exp $	*/
+/*	$NetBSD: patch.c,v 1.38 2020/04/10 14:34:27 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.37 2019/09/18 15:07:08 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.38 2020/04/10 14:34:27 bouyer Exp $");
 
 #include "opt_lockdebug.h"
 #ifdef i386
@@ -250,7 +250,8 @@ x86_patch(bool early)
 #endif	/* i386 */
 
 #if !defined(SPLDEBUG)
-	if (!early && (cpu_feature[0] & CPUID_CX8) != 0) {
+	if (!early && (cpu_feature[0] & CPUID_CX8) != 0 &&
+	!vm_guest_is_xenpv()) {
 		/* Faster splx(), mutex_spin_exit(). */
 		patchfunc(
 		cx8_spllower, cx8_spllower_end,



CVS commit: src/sbin/ifconfig

2020-04-10 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Apr 10 14:32:50 UTC 2020

Modified Files:
src/sbin/ifconfig: af_inet.c

Log Message:
trim extraneous return statement


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sbin/ifconfig/af_inet.c

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

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.26 src/sbin/ifconfig/af_inet.c:1.27
--- src/sbin/ifconfig/af_inet.c:1.26	Fri Aug 16 10:33:17 2019
+++ src/sbin/ifconfig/af_inet.c	Fri Apr 10 14:32:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.26 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.27 2020/04/10 14:32:50 plunky Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.26 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.27 2020/04/10 14:32:50 plunky Exp $");
 #endif /* not lint */
 
 #include 
@@ -219,7 +219,6 @@ in_addr_flags(struct ifaddrs *ifa, int f
 	if (prog_ioctl(s, SIOCGIFAFLAG_IN, ) == -1)
 		err(EXIT_FAILURE, "SIOCGIFAFLAG_IN");
 	return ifr.ifr_addrflags & flags ? true : false;
-	return false;
 }
 #endif
 



CVS commit: src/sys/arch/xen/xenbus

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 12:38:40 UTC 2020

Modified Files:
src/sys/arch/xen/xenbus: xenbus_probe.c

Log Message:
g/c unused xenwatch_mutex extern, and streq()


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/xen/xenbus/xenbus_probe.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/xen/xenbus/xenbus_probe.c
diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.46 src/sys/arch/xen/xenbus/xenbus_probe.c:1.47
--- src/sys/arch/xen/xenbus/xenbus_probe.c:1.46	Tue Apr  7 15:59:57 2020
+++ src/sys/arch/xen/xenbus/xenbus_probe.c	Fri Apr 10 12:38:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_probe.c,v 1.46 2020/04/07 15:59:57 jdolecek Exp $ */
+/* $NetBSD: xenbus_probe.c,v 1.47 2020/04/10 12:38:40 jdolecek Exp $ */
 /**
  * Talks to Xen Store to figure out what devices we have.
  *
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.46 2020/04/07 15:59:57 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.47 2020/04/10 12:38:40 jdolecek Exp $");
 
 #if 0
 #define DPRINTK(fmt, args...) \
@@ -55,10 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
 
 #include "xenbus_comms.h"
 
-extern struct semaphore xenwatch_mutex;
-
-#define streq(a, b) (strcmp((a), (b)) == 0)
-
 static int  xenbus_match(device_t, cfdata_t, void *);
 static void xenbus_attach(device_t, device_t, void *);
 static int  xenbus_print(void *, const char *);



CVS commit: src/sys/arch/xen/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 11:41:04 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xbd_xenbus.c

Log Message:
update comment for DIOCGCACHE (no DKCACHE_READ)


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/arch/xen/xen/xbd_xenbus.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/xen/xen/xbd_xenbus.c
diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.99 src/sys/arch/xen/xen/xbd_xenbus.c:1.100
--- src/sys/arch/xen/xen/xbd_xenbus.c:1.99	Fri Apr 10 10:32:18 2020
+++ src/sys/arch/xen/xen/xbd_xenbus.c	Fri Apr 10 11:41:04 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbd_xenbus.c,v 1.99 2020/04/10 10:32:18 jdolecek Exp $  */
+/*  $NetBSD: xbd_xenbus.c,v 1.100 2020/04/10 11:41:04 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.99 2020/04/10 10:32:18 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.100 2020/04/10 11:41:04 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -853,10 +853,7 @@ xbdioctl(dev_t dev, u_long cmd, void *da
 	switch (cmd) {
 	case DIOCGCACHE:
 	{
-		/*
-		 * Assume there is read & write cache if cache-flush is
-		 * supported.
-		 */
+		/* Assume there is write cache if cache-flush is supported */
 		int *bitsp = (int *)data;
 		*bitsp = 0;
 		if (sc->sc_features & BLKIF_FEATURE_CACHE_FLUSH)



CVS commit: src/sys/dev

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 10:53:02 UTC 2020

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

Log Message:
add support for DIOCGSTRATEGY and DIOCGCACHE

only allow DIOCCACHESYNC if open for writing, same as everything supporting
DIOCCACHESYNC


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.274 src/sys/dev/vnd.c:1.275
--- src/sys/dev/vnd.c:1.274	Sun Feb 23 15:46:39 2020
+++ src/sys/dev/vnd.c	Fri Apr 10 10:53:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.274 2020/02/23 15:46:39 ad Exp $	*/
+/*	$NetBSD: vnd.c,v 1.275 2020/04/10 10:53:02 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.274 2020/02/23 15:46:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.275 2020/04/10 10:53:02 jdolecek Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -1216,6 +1216,7 @@ vndioctl(dev_t dev, u_long cmd, void *da
 #endif
 	case DIOCKLABEL:
 	case DIOCWLABEL:
+	case DIOCCACHESYNC:
 		if ((flag & FWRITE) == 0)
 			return EBADF;
 	}
@@ -1231,6 +1232,8 @@ vndioctl(dev_t dev, u_long cmd, void *da
 	case DIOCKLABEL:
 	case DIOCWLABEL:
 	case DIOCGDEFLABEL:
+	case DIOCGCACHE:
+	case DIOCGSTRATEGY:
 	case DIOCCACHESYNC:
 #ifdef __HAVE_OLD_DISKLABEL
 	case ODIOCGDINFO:
@@ -1645,6 +1648,23 @@ unlock_and_exit:
 		break;
 #endif
 
+	case DIOCGSTRATEGY:
+	{
+		struct disk_strategy *dks = (void *)data;
+
+		/* No lock needed, never changed */
+		strlcpy(dks->dks_name,
+		bufq_getstrategyname(vnd->sc_tab),
+		sizeof(dks->dks_name));
+		dks->dks_paramlen = 0;
+		break;
+	}
+	case DIOCGCACHE:
+	{
+		int *bits = (int *)data;
+		*bits |= DKCACHE_READ | DKCACHE_WRITE;
+		break;
+	}
 	case DIOCCACHESYNC:
 		vn_lock(vnd->sc_vp, LK_EXCLUSIVE | LK_RETRY);
 		error = VOP_FSYNC(vnd->sc_vp, vnd->sc_cred,



CVS commit: src/sys/arch/xen/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 10:32:19 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xbd_xenbus.c

Log Message:
allow DIOCSSTRATEGY, there is no particular reason why it should be
restricted for xbd(4)


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/xen/xen/xbd_xenbus.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/xen/xen/xbd_xenbus.c
diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.98 src/sys/arch/xen/xen/xbd_xenbus.c:1.99
--- src/sys/arch/xen/xen/xbd_xenbus.c:1.98	Fri Apr 10 10:30:10 2020
+++ src/sys/arch/xen/xen/xbd_xenbus.c	Fri Apr 10 10:32:18 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbd_xenbus.c,v 1.98 2020/04/10 10:30:10 jdolecek Exp $  */
+/*  $NetBSD: xbd_xenbus.c,v 1.99 2020/04/10 10:32:18 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.98 2020/04/10 10:30:10 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.99 2020/04/10 10:32:18 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -851,9 +851,6 @@ xbdioctl(dev_t dev, u_long cmd, void *da
 	dksc = >sc_dksc;
 
 	switch (cmd) {
-	case DIOCSSTRATEGY:
-		error = EOPNOTSUPP;
-		break;
 	case DIOCGCACHE:
 	{
 		/*



CVS commit: src/sys/arch/xen/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 10:30:10 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xbd_xenbus.c

Log Message:
implement DIOCGCACHE - assume if CACHE_FLUSH is supported, write cache
is enabled

convert the sc_cache_flush flag to a feature bit field, and recognize
also barrier and persistent features; print the recognized features
on boot, and remove the warning on DIOCCACHESYNC


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/xen/xen/xbd_xenbus.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/xen/xen/xbd_xenbus.c
diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.97 src/sys/arch/xen/xen/xbd_xenbus.c:1.98
--- src/sys/arch/xen/xen/xbd_xenbus.c:1.97	Tue Apr  7 11:47:06 2020
+++ src/sys/arch/xen/xen/xbd_xenbus.c	Fri Apr 10 10:30:10 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbd_xenbus.c,v 1.97 2020/04/07 11:47:06 jdolecek Exp $  */
+/*  $NetBSD: xbd_xenbus.c,v 1.98 2020/04/10 10:30:10 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.97 2020/04/07 11:47:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c,v 1.98 2020/04/10 10:30:10 jdolecek Exp $");
 
 #include "opt_xen.h"
 
@@ -150,7 +150,12 @@ struct xbd_xenbus_softc {
 	uint64_t sc_xbdsize; /* size of disk in DEV_BSIZE */
 	u_long sc_info; /* VDISK_* */
 	u_long sc_handle; /* from backend */
-	int sc_cache_flush; /* backend supports BLKIF_OP_FLUSH_DISKCACHE */
+	int sc_features;
+#define BLKIF_FEATURE_CACHE_FLUSH	0x1
+#define BLKIF_FEATURE_BARRIER		0x2
+#define BLKIF_FEATURE_PERSISTENT	0x4
+#define BLKIF_FEATURE_BITS		\
+	"\20\1CACHE-FLUSH\2BARRIER\3PERSISTENT"
 	struct evcnt sc_cnt_map_unalign;
 };
 
@@ -509,7 +514,7 @@ xbd_backend_changed(void *arg, XenbusSta
 	struct xbd_xenbus_softc *sc = device_private((device_t)arg);
 	struct disk_geom *dg;
 
-	char buf[9];
+	char buf[32];
 	int s;
 	DPRINTF(("%s: new backend state %d\n",
 	device_xname(sc->sc_dksc.sc_dev), new_state));
@@ -569,6 +574,9 @@ xbd_backend_changed(void *arg, XenbusSta
 		aprint_normal_dev(sc->sc_dksc.sc_dev,
 "%s, %d bytes/sect x %" PRIu64 " sectors\n",
 buf, (int)dg->dg_secsize, sc->sc_xbdsize);
+		snprintb(buf, sizeof(buf), BLKIF_FEATURE_BITS,
+		sc->sc_features);
+		aprint_normal_dev(sc->sc_dksc.sc_dev, "features %s\n", buf);
 
 		/* Discover wedges on this disk. */
 		dkwedge_discover(>sc_dksc.sc_dkdev);
@@ -588,7 +596,7 @@ xbd_connect(struct xbd_xenbus_softc *sc)
 {
 	int err;
 	unsigned long long sectors;
-	u_long cache_flush;
+	u_long val;
 
 	err = xenbus_read_ul(NULL,
 	sc->sc_xbusd->xbusd_path, "virtual-device", >sc_handle, 10);
@@ -618,13 +626,25 @@ xbd_connect(struct xbd_xenbus_softc *sc)
 		sc->sc_xbusd->xbusd_otherend);
 
 	err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
-	"feature-flush-cache", _flush, 10);
+	"feature-flush-cache", , 10);
 	if (err)
-		cache_flush = 0;
-	if (cache_flush > 0)
-		sc->sc_cache_flush = 1;
-	else
-		sc->sc_cache_flush = 0;
+		val = 0;
+	if (val > 0)
+		sc->sc_features |= BLKIF_FEATURE_CACHE_FLUSH;
+
+	err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
+	"feature-barrier", , 10);
+	if (err)
+		val = 0;
+	if (val > 0)
+		sc->sc_features |= BLKIF_FEATURE_BARRIER;
+
+	err = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
+	"feature-persistent", , 10);
+	if (err)
+		val = 0;
+	if (val > 0)
+		sc->sc_features |= BLKIF_FEATURE_PERSISTENT;
 
 	xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateConnected);
 }
@@ -834,16 +854,22 @@ xbdioctl(dev_t dev, u_long cmd, void *da
 	case DIOCSSTRATEGY:
 		error = EOPNOTSUPP;
 		break;
+	case DIOCGCACHE:
+	{
+		/*
+		 * Assume there is read & write cache if cache-flush is
+		 * supported.
+		 */
+		int *bitsp = (int *)data;
+		*bitsp = 0;
+		if (sc->sc_features & BLKIF_FEATURE_CACHE_FLUSH)
+			*bitsp |= DKCACHE_WRITE;
+		error = 0;
+		break;
+	}
 	case DIOCCACHESYNC:
-		if (sc->sc_cache_flush <= 0) {
-			if (sc->sc_cache_flush == 0) {
-aprint_verbose_dev(sc->sc_dksc.sc_dev,
-"WARNING: cache flush not supported "
-"by backend\n");
-sc->sc_cache_flush = -1;
-			}
+		if ((sc->sc_features & BLKIF_FEATURE_CACHE_FLUSH) == 0)
 			return EOPNOTSUPP;
-		}
 
 		s = splbio(); /* XXXSMP */
 



CVS commit: src/sys/arch/xen/xen

2020-04-10 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 10 08:35:52 UTC 2020

Modified Files:
src/sys/arch/xen/xen: xengnt.c

Log Message:
add KASSERT() for owned grant_lock in xengnt_get_entry()


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/xen/xen/xengnt.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/xen/xen/xengnt.c
diff -u src/sys/arch/xen/xen/xengnt.c:1.31 src/sys/arch/xen/xen/xengnt.c:1.32
--- src/sys/arch/xen/xen/xengnt.c:1.31	Thu Apr  9 19:26:38 2020
+++ src/sys/arch/xen/xen/xengnt.c	Fri Apr 10 08:35:52 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: xengnt.c,v 1.31 2020/04/09 19:26:38 jdolecek Exp $  */
+/*  $NetBSD: xengnt.c,v 1.32 2020/04/10 08:35:52 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.31 2020/04/09 19:26:38 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.32 2020/04/10 08:35:52 jdolecek Exp $");
 
 #include 
 #include 
@@ -336,6 +336,8 @@ xengnt_get_entry(void)
 	static struct timeval xengnt_nonmemtime;
 	static const struct timeval xengnt_nonmemintvl = {5,0};
 
+	KASSERT(mutex_owned(_lock));
+
 	if (__predict_false(last_gnt_entry == 0)) {
 		if (ratecheck(_nonmemtime, _nonmemintvl))
 			printf("xengnt_get_entry: out of grant "