Re: CVS commit: src/sys/kern

2019-11-29 Thread Rin Okuyama

On 2019/11/30 5:50, Andrew Doran wrote:

Module Name:src
Committed By:   ad
Date:   Fri Nov 29 20:50:54 UTC 2019

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

Log Message:
A couple more tweaks to avoid reading the lock word.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/kern/kern_rwlock.c

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


Hi,

After this commit, GENERIC64 kernel on evbarm-aarch64 does no longer
boot multiuser anymore with rwlock related panics:

panic: kernel diagnostic assertion "vm_map_locked_p(map)" failed: file 
"../../../../uvm/uvm_map.c", line 1315

or

panic: kernel diagnostic assertion "rw_write_held(>lock)" failed: file 
"../../../../uvm/uvm_map.c", line 701

By reverting kern_rwlock.c to rev 1.56, panics disappear as far as
I can see.

Thanks,
rin

...
Starting nfsd.
[  24.5728628] panic: kernel diagnostic assertion "vm_map_locked_p(map)" failed: file 
"../../../../uvm/uvm_map.c", line 1315
[  24.5880334] cpu0: Begin traceback...
[  24.5880334] trace fp ffc033453aa0
[  24.5954047] fp ffc033453ac0 vpanic() at ffc0004892d0 
netbsd:vpanic+0x160
[  24.6054105] fp ffc033453b30 kern_assert() at ffc0005bc1ac 
netbsd:kern_assert+0x5c
[  24.6154460] fp ffc033453bc0 uvm_map_enter() at ffc000402fb0 
netbsd:uvm_map_enter+0x3b8
[  24.6254813] fp ffc033453c60 uvm_map() at ffc00040351c 
netbsd:uvm_map+0x9c
[  24.6355640] fp ffc033453cf0 uvm_mmap.part.0() at ffc000405ccc 
netbsd:uvm_mmap.part.0+0x13c
[  24.6454881] fp ffc033453d70 sys_mmap() at ffc000406390 
netbsd:sys_mmap+0x1d8
[  24.6570928] fp ffc033453e20 syscall() at ffc787dc 
netbsd:syscall+0x18c
[  24.6683611] tf ffc033453ed0 el0_trap() at ffc76e88 
netbsd:el0_trap
[  24.6794682]  trapframe 0xffc033453ed0 (304 bytes) 
...

...
Starting postfix.
[  30.0175876] panic: kernel diagnostic assertion "rw_write_held(>lock)" failed: 
file "../../../../uvm/uvm_map.c", line 701
[  30.0275865] cpu1: Begin traceback...
[  30.0275865] trace fp ffc034b0edf0
[  30.0375913] fp ffc034b0ee10 vpanic() at ffc0004892d0 
netbsd:vpanic+0x160
[  30.0475892] fp ffc034b0ee80 kern_assert() at ffc0005bc1ac 
netbsd:kern_assert+0x5c
[  30.0575897] fp ffc034b0ef10 vm_map_unlock() at ffc0003ff6c4 
netbsd:vm_map_unlock+0x94
[  30.0675928] fp ffc034b0ef30 uvm_map_enter() at ffc000402f04 
netbsd:uvm_map_enter+0x30c
[  30.0775928] fp ffc034b0efd0 uvm_map() at ffc00040351c 
netbsd:uvm_map+0x9c
[  30.0775928] fp ffc034b0f060 uvm_pagermapin() at ffc00040b69c 
netbsd:uvm_pagermapin+0xac
[  30.0975934] fp ffc034b0f0e0 genfs_getpages() at ffc0004f5ff8 
netbsd:genfs_getpages+0xbb8
[  30.1075948] fp ffc034b0f270 VOP_GETPAGES() at ffc0004f38b4 
netbsd:VOP_GETPAGES+0x44
[  30.1175956] fp ffc034b0f2e0 ubc_fault() at ffc0003f6f30 
netbsd:ubc_fault+0x168
[  30.1275959] fp ffc034b0f370 uvm_fault_internal() at ffc0003f9a18 
netbsd:uvm_fault_internal+0x478
[  30.1375967] fp ffc034b0f580 data_abort_handler() at ffc79f88 
netbsd:data_abort_handler+0x100
[  30.1475968] tf ffc034b0f600 el1_trap() at ffc76e24 
netbsd:el1_trap
[  30.1575982]  trapframe 0xffc034b0f600 (304 bytes) 
...


CVS commit: src/sys/dev/dm

2019-11-29 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Sat Nov 30 05:35:57 UTC 2019

Modified Files:
src/sys/dev/dm: dm_ioctl.c

Log Message:
dm: Always initialize target's status string

Explicitly clear status string to prevent dmsetup(8) from
printing binary junk to stdout. Similar change has been
applied to DragonFlyBSD since 2015.

https://github.com/DragonFlyBSD/DragonFlyBSD/commit/a6cf54187fd7c3e994c573215806ec03572c038e

taken-from: DragonFlyBSD


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_ioctl.c

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



CVS commit: src/sys/dev/dm

2019-11-29 Thread Tomohiro Kusumi
Module Name:src
Committed By:   tkusumi
Date:   Sat Nov 30 05:35:57 UTC 2019

Modified Files:
src/sys/dev/dm: dm_ioctl.c

Log Message:
dm: Always initialize target's status string

Explicitly clear status string to prevent dmsetup(8) from
printing binary junk to stdout. Similar change has been
applied to DragonFlyBSD since 2015.

https://github.com/DragonFlyBSD/DragonFlyBSD/commit/a6cf54187fd7c3e994c573215806ec03572c038e

taken-from: DragonFlyBSD


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/dm/dm_ioctl.c

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

Modified files:

Index: src/sys/dev/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.33 src/sys/dev/dm/dm_ioctl.c:1.34
--- src/sys/dev/dm/dm_ioctl.c:1.33	Sun Nov 11 10:21:11 2018
+++ src/sys/dev/dm/dm_ioctl.c	Sat Nov 30 05:35:57 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.33 2018/11/11 10:21:11 mlelstv Exp $  */
+/* $NetBSD: dm_ioctl.c,v 1.34 2019/11/30 05:35:57 tkusumi Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.33 2018/11/11 10:21:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.34 2019/11/30 05:35:57 tkusumi Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -927,6 +927,12 @@ dm_table_status_ioctl(prop_dictionary_t 
 		prop_dictionary_set_int32(target_dict, DM_TABLE_STAT,
 		dmv->table_head.cur_active_table);
 
+		/*
+		 * Explicitly clear DM_TABLE_PARAMS to prevent dmsetup(8) from
+		 * printing junk when DM_TABLE_PARAMS was never initialized.
+		 */
+		prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, "");
+
 		if (flags & DM_STATUS_TABLE_FLAG) {
 			params = table_en->target->status
 			(table_en->target_config);



CVS commit: src/sys/arch/x86

2019-11-29 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Nov 30 05:28:28 UTC 2019

Modified Files:
src/sys/arch/x86/include: genfb_machdep.h
src/sys/arch/x86/x86: genfb_machdep.c hyperv.c

Log Message:
Prevent panic when attaching genfb if using a serial console with Hyper-V Gen.2.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/genfb_machdep.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/x86/genfb_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/hyperv.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/genfb_machdep.h
diff -u src/sys/arch/x86/include/genfb_machdep.h:1.3 src/sys/arch/x86/include/genfb_machdep.h:1.4
--- src/sys/arch/x86/include/genfb_machdep.h:1.3	Wed Feb  9 13:24:23 2011
+++ src/sys/arch/x86/include/genfb_machdep.h	Sat Nov 30 05:28:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: genfb_machdep.h,v 1.3 2011/02/09 13:24:23 jmcneill Exp $ */
+/* $NetBSD: genfb_machdep.h,v 1.4 2019/11/30 05:28:28 nonaka Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -29,6 +29,7 @@
 #ifndef _X86_GENFB_MACHDEP_H
 #define _X86_GENFB_MACHDEP_H
 
+int	x86_genfb_init(void);
 int	x86_genfb_cnattach(void);
 void	x86_genfb_mtrr_init(uint64_t, uint32_t);
 void	x86_genfb_set_console_dev(device_t);

Index: src/sys/arch/x86/x86/genfb_machdep.c
diff -u src/sys/arch/x86/x86/genfb_machdep.c:1.14 src/sys/arch/x86/x86/genfb_machdep.c:1.15
--- src/sys/arch/x86/x86/genfb_machdep.c:1.14	Tue Oct  1 18:00:08 2019
+++ src/sys/arch/x86/x86/genfb_machdep.c	Sat Nov 30 05:28:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: genfb_machdep.c,v 1.14 2019/10/01 18:00:08 chs Exp $ */
+/* $NetBSD: genfb_machdep.c,v 1.15 2019/11/30 05:28:28 nonaka Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.14 2019/10/01 18:00:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb_machdep.c,v 1.15 2019/11/30 05:28:28 nonaka Exp $");
 
 #include "opt_mtrr.h"
 
@@ -136,23 +136,19 @@ x86_genfb_mtrr_init(uint64_t physaddr, u
 }
 
 int
-x86_genfb_cnattach(void)
+x86_genfb_init(void)
 {
-	static int ncalls = 0;
+	static int inited, attached;
 	struct rasops_info *ri = _genfb_console_screen.scr_ri;
 	const struct btinfo_framebuffer *fbinfo;
 	bus_space_tag_t t = x86_bus_space_mem;
 	bus_space_handle_t h;
 	void *bits;
-	long defattr;
 	int err;
 
-	/* XXX jmcneill
-	 *  Defer console initialization until UVM is initialized
-	 */
-	++ncalls;
-	if (ncalls < 3)
-		return -1;
+	if (inited)
+		return attached;
+	inited = 1;
 
 	memset(_genfb_console_screen, 0, sizeof(x86_genfb_console_screen));
 
@@ -202,6 +198,27 @@ x86_genfb_cnattach(void)
 	x86_genfb_stdscreen.textops = >ri_ops;
 	x86_genfb_stdscreen.capabilities = ri->ri_caps;
 
+	attached = 1;
+	return 1;
+}
+
+int
+x86_genfb_cnattach(void)
+{
+	static int ncalls = 0;
+	struct rasops_info *ri = _genfb_console_screen.scr_ri;
+	long defattr;
+
+	/* XXX jmcneill
+	 *  Defer console initialization until UVM is initialized
+	 */
+	++ncalls;
+	if (ncalls < 3)
+		return -1;
+
+	if (!x86_genfb_init())
+		return 0;
+
 	ri->ri_ops.allocattr(ri, 0, 0, 0, );
 	wsdisplay_preattach(_genfb_stdscreen, ri, 0, 0, defattr);
 
@@ -209,6 +226,12 @@ x86_genfb_cnattach(void)
 }
 #else	/* NWSDISPLAY > 0 && NGENFB > 0 */
 int
+x86_genfb_init(void)
+{
+	return 0;
+}
+
+int
 x86_genfb_cnattach(void)
 {
 	return 0;

Index: src/sys/arch/x86/x86/hyperv.c
diff -u src/sys/arch/x86/x86/hyperv.c:1.4 src/sys/arch/x86/x86/hyperv.c:1.5
--- src/sys/arch/x86/x86/hyperv.c:1.4	Mon Jun  3 09:51:04 2019
+++ src/sys/arch/x86/x86/hyperv.c	Sat Nov 30 05:28:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: hyperv.c,v 1.4 2019/06/03 09:51:04 nonaka Exp $	*/
+/*	$NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012,2016-2017 Microsoft Corp.
@@ -33,7 +33,7 @@
  */
 #include 
 #ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.4 2019/06/03 09:51:04 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperv.c,v 1.5 2019/11/30 05:28:28 nonaka Exp $");
 #endif
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hyperv.c 331757 2018-03-30 02:25:12Z emaste $");
@@ -70,7 +70,7 @@ __FBSDID("$FreeBSD: head/sys/dev/hyperv/
 #include 
 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -1103,6 +1103,9 @@ device_hyperv_register(device_t dev, voi
 		sizeof(*aa->aa_type)) == 0) {
 			prop_dictionary_t dict = device_properties(dev);
 
+			/* Initialize genfb for serial console */
+			x86_genfb_init();
+
 			/*
 			 * framebuffer drivers other than genfb can work
 			 * without the address property



CVS commit: src/sys/arch/x86

2019-11-29 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Nov 30 05:28:28 UTC 2019

Modified Files:
src/sys/arch/x86/include: genfb_machdep.h
src/sys/arch/x86/x86: genfb_machdep.c hyperv.c

Log Message:
Prevent panic when attaching genfb if using a serial console with Hyper-V Gen.2.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/include/genfb_machdep.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/x86/genfb_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/hyperv.c

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



Re: CVS commit: src/external/apache2/llvm

2019-11-29 Thread Joerg Sonnenberger
On Fri, Nov 29, 2019 at 11:28:31AM +, m...@netbsd.org wrote:
> On Thu, Nov 28, 2019 at 11:01:22PM +, Joerg Sonnenberger wrote:
> > Log Message:
> > Use -fno-strict-aliasing unconditionally for the cross compiler.
> 
> What's the context for that?

This was meant to be part of the earlier change to build clang and
associated things with it when using GCC. The same problem applies for
the cross-compiler when the host compiler is a new enough GCC.

Joerg


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

2019-11-29 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Nov 30 04:06:23 UTC 2019

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

Log Message:
Add the new unit-tests for make(1) to the sets list, fixing the build.


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

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



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

2019-11-29 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Nov 30 04:06:23 UTC 2019

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

Log Message:
Add the new unit-tests for make(1) to the sets list, fixing the build.


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

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.822 src/distrib/sets/lists/tests/mi:1.823
--- src/distrib/sets/lists/tests/mi:1.822	Sat Oct  5 18:06:16 2019
+++ src/distrib/sets/lists/tests/mi	Sat Nov 30 04:06:22 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.822 2019/10/05 18:06:16 jhigh Exp $
+# $NetBSD: mi,v 1.823 2019/11/30 04:06:22 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4177,6 +4177,8 @@
 ./usr/tests/usr.bin/make/unit-tests/varcmd.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmisc.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmisc.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-edge.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-edge.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varquote.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varquote.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varshell.exp	tests-usr.bin-tests	compattestfile,atf



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 03:53:45 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Demonstrate some more edge cases for the :M modifier


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

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



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 03:53:45 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Demonstrate some more edge cases for the :M modifier


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.2 src/usr.bin/make/unit-tests/varmod-edge.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.2	Sat Nov 30 02:31:19 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Nov 30 03:53:45 2019
@@ -1,8 +1,11 @@
 make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
 ok M-paren
 ok M-mixed
+ok M-unescape
 ok M-nest-mix
 ok M-nest-brk
 ok M-pat-err
 ok M-bsbs
+ok M-bs1-par
+ok M-bs2-par
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.3 src/usr.bin/make/unit-tests/varmod-edge.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.3	Sat Nov 30 02:55:47 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 03:53:45 2019
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.3 2019/11/30 02:55:47 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.4 2019/11/30 03:53:45 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -24,6 +24,18 @@ INP.M-mixed=	(paren-brace} (
 MOD.M-mixed=	${INP.M-mixed:M(*}}
 EXP.M-mixed=	(paren-brace}
 
+# After the :M modifier has parsed the pattern, only the closing brace
+# and the colon are unescaped. The other characters are left as-is.
+# To actually see this effect, the backslashes in the :M modifier need
+# to be doubled since single backslashes would simply be unescaped by
+# Str_Match.
+#
+# XXX: This is unexpected. The opening brace should also be unescaped.
+TESTS+=		M-unescape
+INP.M-unescape=	({}): \(\{\}\)\: \(\{}\):
+MOD.M-unescape=	${INP.M-unescape:M\\(\\{\\}\\)\\:}
+EXP.M-unescape=	\(\{}\):
+
 # When the :M and :N modifiers are parsed, the pattern finishes as soon
 # as open_parens + open_braces == closing_parens + closing_braces. This
 # means that ( and } form a matching pair.
@@ -76,6 +88,27 @@ MOD.M-bsbs=	${INP.M-bsbs:M\\(}}
 EXP.M-bsbs=	\(}
 #EXP.M-bsbs=	(}	# If the first backslash were to escape ...
 
+# The backslash in \( does not escape the parenthesis, therefore it
+# counts for the nesting level and matches with the first closing brace.
+# The second closing brace closes the variable, and the third is copied
+# literally.
+#
+# The second :M in the pattern is nested between ( and }, therefore it
+# does not start a new modifier.
+TESTS+=		M-bs1-par
+INP.M-bs1-par=	( (:M (:M} \( \(:M \(:M}
+MOD.M-bs1-par=	${INP.M-bs1-par:M\(:M*}}}
+EXP.M-bs1-par=	(:M}}
+
+# The double backslash is passed verbatim to the pattern matcher.
+# The Str_Match pattern is \\(:M*}, and there the backslash is unescaped.
+# Again, the ( takes place in the nesting level, and there is no way to
+# prevent this, no matter how many backslashes are used.
+TESTS+=		M-bs2-par
+INP.M-bs2-par=	( (:M (:M} \( \(:M \(:M}
+MOD.M-bs2-par=	${INP.M-bs2-par:M\\(:M*}}}
+EXP.M-bs2-par=	\(:M}}
+
 all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:55:47 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.mk

Log Message:
Fix unit test for edge case in :M modifier


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.2 src/usr.bin/make/unit-tests/varmod-edge.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.2	Sat Nov 30 02:31:19 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 02:55:47 2019
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.2 2019/11/30 02:31:19 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.3 2019/11/30 02:55:47 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -68,11 +68,13 @@ EXP.M-pat-err=	[
 # If the first backslash were to escape the second backslash, the first
 # closing brace would match the opening parenthesis (see M-mixed), and
 # the second closing brace would be needed to close the variable.
+# After that, the remaining backslash would escape the parenthesis in
+# the pattern, therefore (} would match.
 TESTS+=		M-bsbs
-INP.M-bsbs=	\( \(}
+INP.M-bsbs=	(} \( \(}
 MOD.M-bsbs=	${INP.M-bsbs:M\\(}}
 EXP.M-bsbs=	\(}
-#EXP.M-bsbs=	\(	# If the first backslash were to escape ...
+#EXP.M-bsbs=	(}	# If the first backslash were to escape ...
 
 all:
 .for test in ${TESTS}



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:55:47 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.mk

Log Message:
Fix unit test for edge case in :M modifier


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

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



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:47:14 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9 uvm_hotplug.9
src/usr.sbin/i2cscan: i2cscan.8
src/usr.sbin/pcictl: pcictl.8

Log Message:
Use .Sy, not .Em, for bold-faced WARNING of impending doom.

Underline and, worse, italic aren't as good at catching the eye.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/atomic_loadstore.9
cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/uvm_hotplug.9
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/i2cscan/i2cscan.8
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/pcictl/pcictl.8

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



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:47:14 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9 uvm_hotplug.9
src/usr.sbin/i2cscan: i2cscan.8
src/usr.sbin/pcictl: pcictl.8

Log Message:
Use .Sy, not .Em, for bold-faced WARNING of impending doom.

Underline and, worse, italic aren't as good at catching the eye.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/atomic_loadstore.9
cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/uvm_hotplug.9
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/i2cscan/i2cscan.8
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/pcictl/pcictl.8

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/atomic_loadstore.9
diff -u src/share/man/man9/atomic_loadstore.9:1.2 src/share/man/man9/atomic_loadstore.9:1.3
--- src/share/man/man9/atomic_loadstore.9:1.2	Sat Nov 30 02:38:44 2019
+++ src/share/man/man9/atomic_loadstore.9	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: atomic_loadstore.9,v 1.2 2019/11/30 02:38:44 riastradh Exp $
+.\"	$NetBSD: atomic_loadstore.9,v 1.3 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright (c) 2019 The NetBSD Foundation
 .\" All rights reserved.
@@ -655,7 +655,7 @@ and
 functions like a acquire operation on
 .Fa obj .
 .Pp
-.Em WARNING :
+.Sy WARNING :
 The combination of
 .Fn atomic_load_relaxed
 and

Index: src/share/man/man9/uvm_hotplug.9
diff -u src/share/man/man9/uvm_hotplug.9:1.4 src/share/man/man9/uvm_hotplug.9:1.5
--- src/share/man/man9/uvm_hotplug.9:1.4	Sat Dec 24 08:05:47 2016
+++ src/share/man/man9/uvm_hotplug.9	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: uvm_hotplug.9,v 1.4 2016/12/24 08:05:47 wiz Exp $
+.\"	$NetBSD: uvm_hotplug.9,v 1.5 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright (c) 2016 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -95,7 +95,7 @@ They must
 never be used after
 .Xr uvm_init 9 .
 .Pp
-.Em WARNING :
+.Sy WARNING :
 This is an experimental feature and should not be used in production
 environments.
 Furthermore, attempting to "hotplug" without

Index: src/usr.sbin/i2cscan/i2cscan.8
diff -u src/usr.sbin/i2cscan/i2cscan.8:1.6 src/usr.sbin/i2cscan/i2cscan.8:1.7
--- src/usr.sbin/i2cscan/i2cscan.8:1.6	Thu Nov 26 23:29:05 2015
+++ src/usr.sbin/i2cscan/i2cscan.8	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: i2cscan.8,v 1.6 2015/11/26 23:29:05 wiz Exp $
+.\"	$NetBSD: i2cscan.8,v 1.7 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright (c) 2011, 2013 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -61,7 +61,7 @@ Available options:
 scan using 1 byte reads instead of quick writes.
 .El
 .Pp
-.Em WARNING !
+.Sy WARNING :
 Using this utility can access some devices in such a
 manner as to leave them in an unstable or unusable state.
 It can also lock up the entire

Index: src/usr.sbin/pcictl/pcictl.8
diff -u src/usr.sbin/pcictl/pcictl.8:1.19 src/usr.sbin/pcictl/pcictl.8:1.20
--- src/usr.sbin/pcictl/pcictl.8:1.19	Tue Sep 27 16:44:04 2016
+++ src/usr.sbin/pcictl/pcictl.8	Sat Nov 30 02:47:14 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pcictl.8,v 1.19 2016/09/27 16:44:04 mrg Exp $
+.\"	$NetBSD: pcictl.8,v 1.20 2019/11/30 02:47:14 riastradh Exp $
 .\"
 .\" Copyright 2001 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -96,7 +96,7 @@ If the bus is not specified, it defaults
 PCI bus specified on the command line.
 If the function is not specified, it defaults to 0.
 .Pp
-.Em WARNING :
+.Sy WARNING :
 .Nm
 .Cm read
 is a dangerous command that can damage hardware and panic the operating
@@ -118,7 +118,7 @@ If the bus is not specified, it defaults
 PCI bus specified on the command line.
 If the function is not specified, it defaults to 0.
 .Pp
-.Em WARNING :
+.Sy WARNING :
 .Nm
 .Cm write
 is a dangerous command that can damage hardware and panic the operating



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:38:44 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9

Log Message:
Document relation to atomic_ops(3) and membar_ops(3).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man9/atomic_loadstore.9

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/atomic_loadstore.9
diff -u src/share/man/man9/atomic_loadstore.9:1.1 src/share/man/man9/atomic_loadstore.9:1.2
--- src/share/man/man9/atomic_loadstore.9:1.1	Fri Nov 29 22:17:23 2019
+++ src/share/man/man9/atomic_loadstore.9	Sat Nov 30 02:38:44 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: atomic_loadstore.9,v 1.1 2019/11/29 22:17:23 riastradh Exp $
+.\"	$NetBSD: atomic_loadstore.9,v 1.2 2019/11/30 02:38:44 riastradh Exp $
 .\"
 .\" Copyright (c) 2019 The NetBSD Foundation
 .\" All rights reserved.
@@ -621,6 +621,60 @@ They do not require
 to be at most the largest size of available atomic loads and stores on
 the host architecture.
 .El
+.Sh MEMORY BARRIERS AND ATOMIC READ/MODIFY/WRITE
+The atomic read/modify/write operations in
+.Xr atomic_ops 3
+have relaxed ordering by default, but can be combined with the memory
+barriers in
+.Xr membar_ops 3
+for the same effect as an acquire operation and a release operation for
+the purposes of pairing with
+.Fn atomic_store_release
+and
+.Fn atomic_load_acquire
+or
+.Fn atomic_load_consume :
+If
+.Fn atomic_r/m/w
+is an atomic read/modify/write operation in
+.Xr atomic_ops 3 ,
+then
+.Bd -literal
+	membar_exit();
+	atomic_r/m/w(obj, ...);
+.Ed
+.Pp
+functions like a release operation on
+.Fa obj ,
+and
+.Bd -literal
+	atomic_r/m/w(obj, ...);
+	membar_enter();
+.Ed
+.Pp
+functions like a acquire operation on
+.Fa obj .
+.Pp
+.Em WARNING :
+The combination of
+.Fn atomic_load_relaxed
+and
+.Xr membar_enter 3
+.Em does not
+make an acquire operation; only read/modify/write atomics may be
+combined with
+.Xr membar_enter 3
+this way.
+.Pp
+On architectures where
+.Dv __HAVE_ATOMIC_AS_MEMBAR
+is defined, all the
+.Xr atomic_ops 3
+imply release and acquire operations, so the
+.Xr membar_enter 3
+and
+.Xr membar_exit 3
+are redundant.
 .Sh EXAMPLES
 Maintaining lossy counters.
 These may lose some counts, because the read/modify/write cycle as a



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:38:44 UTC 2019

Modified Files:
src/share/man/man9: atomic_loadstore.9

Log Message:
Document relation to atomic_ops(3) and membar_ops(3).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/share/man/man9/atomic_loadstore.9

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



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:35:28 UTC 2019

Added Files:
src/usr.bin/make/unit-tests: .cvsignore

Log Message:
Ignore temporary files from running the unit tests


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/.cvsignore

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



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:35:28 UTC 2019

Added Files:
src/usr.bin/make/unit-tests: .cvsignore

Log Message:
Ignore temporary files from running the unit tests


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/.cvsignore

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

Added files:

Index: src/usr.bin/make/unit-tests/.cvsignore
diff -u /dev/null src/usr.bin/make/unit-tests/.cvsignore:1.1
--- /dev/null	Sat Nov 30 02:35:28 2019
+++ src/usr.bin/make/unit-tests/.cvsignore	Sat Nov 30 02:35:28 2019
@@ -0,0 +1,3 @@
+*.out
+*.rawout
+*.status



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:31:19 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add another unit test for the :M modifier


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.1 src/usr.bin/make/unit-tests/varmod-edge.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.1	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Nov 30 02:31:19 2019
@@ -4,4 +4,5 @@ ok M-mixed
 ok M-nest-mix
 ok M-nest-brk
 ok M-pat-err
+ok M-bsbs
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.1 src/usr.bin/make/unit-tests/varmod-edge.mk:1.2
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.1	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 02:31:19 2019
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.1 2019/11/30 00:38:51 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.2 2019/11/30 02:31:19 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -54,11 +54,26 @@ EXP.M-nest-brk=	[
 # No error is reported though, and the pattern is closed implicitly.
 #
 # XXX: It is unexpected that no error is reported.
+# See str.c, function Str_Match.
 TESTS+=		M-pat-err
 INP.M-pat-err=	[ [[ [[[
 MOD.M-pat-err=	${INP.M-pat-err:M${:U[[}}
 EXP.M-pat-err=	[
 
+# The first backslash does not escape the second backslash.
+# Therefore, the second backslash escapes the parenthesis.
+# This means that the pattern ends there.
+# The final } in the output comes from the end of MOD.M-bsbs.
+#
+# If the first backslash were to escape the second backslash, the first
+# closing brace would match the opening parenthesis (see M-mixed), and
+# the second closing brace would be needed to close the variable.
+TESTS+=		M-bsbs
+INP.M-bsbs=	\( \(}
+MOD.M-bsbs=	${INP.M-bsbs:M\\(}}
+EXP.M-bsbs=	\(}
+#EXP.M-bsbs=	\(	# If the first backslash were to escape ...
+
 all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:31:19 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add another unit test for the :M modifier


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

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



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:22:23 UTC 2019

Modified Files:
src/share/man/man9: xcall.9

Log Message:
Document xc_barrier.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/xcall.9

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



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 02:22:23 UTC 2019

Modified Files:
src/share/man/man9: xcall.9

Log Message:
Document xc_barrier.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/share/man/man9/xcall.9

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/xcall.9
diff -u src/share/man/man9/xcall.9:1.15 src/share/man/man9/xcall.9:1.16
--- src/share/man/man9/xcall.9:1.15	Sun Oct  6 17:21:28 2019
+++ src/share/man/man9/xcall.9	Sat Nov 30 02:22:23 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: xcall.9,v 1.15 2019/10/06 17:21:28 uwe Exp $
+.\" $NetBSD: xcall.9,v 1.16 2019/11/30 02:22:23 riastradh Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,14 +27,15 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 1, 2018
+.Dd November 29, 2019
 .Dt XCALL 9
 .Os
 .Sh NAME
 .Nm xcall ,
 .Nm xc_broadcast ,
 .Nm xc_unicast ,
-.Nm xc_wait
+.Nm xc_wait ,
+.Nm xc_barrier
 .Nd cross-call interface
 .Sh SYNOPSIS
 .In sys/xcall.h
@@ -45,6 +46,8 @@
 .Fn xc_unicast "u_int flags" "xcfunc_t func" "void *arg1" "void *arg2" "struct cpu_info *ci"
 .Ft void
 .Fn xc_wait "uint64_t where"
+.Ft void
+.Fn xc_barrier "u_int flags"
 .Sh DESCRIPTION
 The machine-independent
 .Nm
@@ -143,6 +146,29 @@ or
 for the corresponding cross-call to complete.
 .Fn xc_wait
 should be called from a thread context.
+.It Fn xc_barrier "flags"
+Issue a broadcast cross-call that does nothing, using
+.Fa flags ,
+and wait for it to complete.
+This has two effects:
+.Bl -dash -compact
+.It
+This waits for the interrupt priority level to transition to
+.Dv IPL_NONE
+at least once on all CPUs.
+.It
+This functions like a memory barrier that forces all prior operations
+in program order to globally happen before all subsequent operations in
+program order, as witnessed by every CPU.
+.El
+.Pp
+.Fn xc_barrier
+is much more expensive than
+.Xr membar_ops 3 ,
+so it should be used sparingly, only to publish information
+infrequently \(em for example, during module load and unload \(em when
+the cost of a memory barrier on the consumer side would be
+prohibitive.
 .El
 .Sh CODE REFERENCES
 The
@@ -151,6 +177,7 @@ interface is implemented within the file
 .Pa sys/kern/subr_xcall.c .
 .\" .Sh EXAMPLES
 .Sh SEE ALSO
+.Xr membar_ops 3 ,
 .Xr kpreempt 9 ,
 .Xr percpu 9 ,
 .Xr softint 9



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 00:38:51 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add unit tests for variable modifiers like :M and :N


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-edge.exp \
src/usr.bin/make/unit-tests/varmod-edge.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.53 src/usr.bin/make/unit-tests/Makefile:1.54
--- src/usr.bin/make/unit-tests/Makefile:1.53	Thu May 24 00:25:44 2018
+++ src/usr.bin/make/unit-tests/Makefile	Sat Nov 30 00:38:51 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.53 2018/05/24 00:25:44 christos Exp $
+# $NetBSD: Makefile,v 1.54 2019/11/30 00:38:51 rillig Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -50,6 +50,7 @@ TESTNAMES= \
 	unexport-env \
 	varcmd \
 	varmisc \
+	varmod-edge \
 	varquote \
 	varshell
 

Added files:

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-edge.exp:1.1
--- /dev/null	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Nov 30 00:38:51 2019
@@ -0,0 +1,7 @@
+make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
+ok M-paren
+ok M-mixed
+ok M-nest-mix
+ok M-nest-brk
+ok M-pat-err
+exit status 0
Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-edge.mk:1.1
--- /dev/null	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 00:38:51 2019
@@ -0,0 +1,70 @@
+# $NetBSD: varmod-edge.mk,v 1.1 2019/11/30 00:38:51 rillig Exp $
+#
+# Tests for edge cases in variable modifiers.
+#
+# These tests demonstrate the current implementation in small examples.
+# They may contain surprising behavior.
+#
+# Each test consists of:
+# - INP, the input to the test
+# - MOD, the expression for testing the modifier
+# - EXP, the expected output
+
+TESTS+=		M-paren
+INP.M-paren=	(parentheses) {braces} (opening closing) ()
+MOD.M-paren=	${INP.M-paren:M(*)}
+EXP.M-paren=	(parentheses) ()
+
+# The first closing brace matches the opening parenthesis.
+# The second closing brace actually ends the variable expression.
+#
+# XXX: This is unexpected but rarely occurs in practice.
+TESTS+=		M-mixed
+INP.M-mixed=	(paren-brace} (
+MOD.M-mixed=	${INP.M-mixed:M(*}}
+EXP.M-mixed=	(paren-brace}
+
+# When the :M and :N modifiers are parsed, the pattern finishes as soon
+# as open_parens + open_braces == closing_parens + closing_braces. This
+# means that ( and } form a matching pair.
+#
+# Nested variable expressions are not parsed as such. Instead, only the
+# parentheses and braces are counted. This leads to a parse error since
+# the nested expression is not "${:U*)}" but only "${:U*)", which is
+# missing the closing brace. The expression is evaluated anyway.
+# The final brace in the output comes from the end of M.nest-mix.
+#
+# XXX: This is unexpected but rarely occurs in practice.
+TESTS+=		M-nest-mix
+INP.M-nest-mix=	(parentheses)
+MOD.M-nest-mix=	${INP.M-nest-mix:M${:U*)}}
+EXP.M-nest-mix=	(parentheses)}
+
+# In contrast to parentheses and braces, the brackets are not counted
+# when the :M modifier is parsed since Makefile variables only take the
+# ${VAR} or $(VAR) forms, but not $[VAR].
+#
+# The final ] in the pattern is needed to close the character class.
+TESTS+=		M-nest-brk
+INP.M-nest-brk=	[ [[ [[[
+MOD.M-nest-brk=	${INP.M-nest-brk:M${:U[]}}
+EXP.M-nest-brk=	[
+
+# The pattern in the nested variable has an unclosed character class.
+# No error is reported though, and the pattern is closed implicitly.
+#
+# XXX: It is unexpected that no error is reported.
+TESTS+=		M-pat-err
+INP.M-pat-err=	[ [[ [[[
+MOD.M-pat-err=	${INP.M-pat-err:M${:U[[}}
+EXP.M-pat-err=	[
+
+all:
+.for test in ${TESTS}
+.  if ${MOD.${test}} == ${EXP.${test}}
+	@printf 'ok %s\n' ${test:Q}''
+.  else
+	@printf 'error in %s: expected %s, got %s\n' \
+		${test:Q}'' ${EXP.${test}:Q}'' ${MOD.${test}:Q}''
+.  endif
+.endfor



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

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 00:38:51 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add unit tests for variable modifiers like :M and :N


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-edge.exp \
src/usr.bin/make/unit-tests/varmod-edge.mk

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



CVS commit: src/distrib/notes

2019-11-29 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Nov 30 00:28:27 UTC 2019

Modified Files:
src/distrib/notes: Makefile.inc
src/distrib/notes/common: macros

Log Message:
Improve table of contents.

For .txt and .more drop meaningless page numbers, those formats are
not paginated (with all due respect to line printers, 80s are over).

For .ps use actual formatting with proportional font and properly
aligned page numbers.  Thanks to kre@ for his help with some of the
darker corners of troff (with all due respect to my 80s self, he/I
should have paid more attention).


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/distrib/notes/Makefile.inc
cvs rdiff -u -r1.53 -r1.54 src/distrib/notes/common/macros

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/Makefile.inc
diff -u src/distrib/notes/Makefile.inc:1.51 src/distrib/notes/Makefile.inc:1.52
--- src/distrib/notes/Makefile.inc:1.51	Thu Nov 28 00:06:39 2019
+++ src/distrib/notes/Makefile.inc	Sat Nov 30 00:28:27 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.51 2019/11/28 00:06:39 uwe Exp $
+#	$NetBSD: Makefile.inc,v 1.52 2019/11/30 00:28:27 uwe Exp $
 #
 
 # Ross Harvey 
@@ -103,9 +103,9 @@ ${TARG}.more: ${SRCS} ${TOC.more} ${DIST
 	${TOOL_GROFF} ${ARGS_MORE} -mdoc  ${MAIN} > $@
 
 
-# Rules to build the table of contents (.toc) files.
-# They are generated twice to take into account the
-# space taken by the TOC itself.
+# Rules to build the table of contents (.toc) files.  For the
+# PostScript version it's generated twice to take into account the
+# space taken by the TOC itself.  Other versions are not paginated.
 
 ${TARG}.PostScript.toc: ${SRCS}
 	${TOOL_GROFF} -dTOC=1 ${ARGS_PS} -mdoc ${MAIN} > /dev/null
@@ -116,8 +116,6 @@ ${TARG}.PostScript.toc: ${SRCS}
 ${TARG}.ASCII.toc: ${SRCS}
 	${TOOL_GROFF} -dTOC=1 ${ARGS_TXT} -mdoc ${MAIN} > /dev/null
 	mv -f $@.tmp $@
-	${TOOL_GROFF} -dTOC=1 ${ARGS_TXT} -mdoc ${MAIN} > /dev/null
-	mv -f $@.tmp $@
 
 ${TARG}.HTML.toc: ${SRCS}
 	${TOOL_GROFF} -dTOC=1 ${ARGS_HTML} -mdoc ${MAIN} > /dev/null
@@ -126,8 +124,6 @@ ${TARG}.HTML.toc: ${SRCS}
 ${TARG}.more.toc: ${SRCS}
 	${TOOL_GROFF} -dTOC=1 ${ARGS_MORE} -mdoc ${MAIN} > /dev/null
 	mv -f $@.tmp $@
-	${TOOL_GROFF} -dTOC=1 ${ARGS_MORE} -mdoc ${MAIN} > /dev/null
-	mv -f $@.tmp $@
 
 
 release: check_RELEASEDIR .WAIT ${TARGS}

Index: src/distrib/notes/common/macros
diff -u src/distrib/notes/common/macros:1.53 src/distrib/notes/common/macros:1.54
--- src/distrib/notes/common/macros:1.53	Fri Nov 29 16:33:44 2019
+++ src/distrib/notes/common/macros	Sat Nov 30 00:28:27 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: macros,v 1.53 2019/11/29 16:33:44 uwe Exp $
+.\"	$NetBSD: macros,v 1.54 2019/11/30 00:28:27 uwe Exp $
 .\"
 .\" Copyright (c) 1999-2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -342,11 +342,42 @@
 .if rHTML 
 .if dTOC .mktoc \\n[To-toc-level] \\$@
 ..
+.
+.\" .Tc and .Ti for PostScript
+.
+.ie '\*[format]'PostScript' \{\
+.de Ti
+.nr Ti-toc-level \\$1
+.nr Ti-page \\$2
+.shift 2
+.nr Ti-indent (\\n[Tc-saved-indent]+(3n*\\n[Ti-toc-level]))
+.in \\n[Ti-indent]u
+\\$* \c
+'nr Ti-eol-pos (\\n(.l-\\n(.i-\\n(.k)
+'ta (\\n[Ti-eol-pos]u-\w'099'u)R (\\n[Ti-eol-pos]u)R
+\a\t\\n[Ti-page]
+.br
+..
+.
+.de Tc
+.nr Tc-saved-indent \\n(.i
+.tm ...reading \*[toc-file]
+.\" Use so-real here because toc-file is in objdir not .CURDIR
+.so-real \*[toc-file]
+.in \\n[Tc-saved-indent]u
+..
+.\}
+.
 .\"  .Tc and .Ti for HTML
-.ie rHTML \{\
+.
+.el .ie rHTML \{\
 .de Ti
-\h'3n*\\$1u' \\$3
+.nr Ti-toc-level \\$1
+.\"nr Ti-page \\$2
+.shift 2
+\h'3n*\\n[Ti-toc-level]u' \\$*
 ..
+.
 .de Tc
 .tm ...reading \*[toc-file]
 .nf
@@ -355,16 +386,20 @@
 .fi
 ..
 .\}
-.\"  .Tc and .Ti for text and postscript
+.
+.\" .Tc and .Ti for unpaginated text
+.
 .el \{\
 .de Ti
-\h'3n*\\$1u' \\$3\a\\$2
+.nr Ti-toc-level \\$1
+.\"nr Ti-page \\$2
+.shift 2
+\h'3n*\\n[Ti-toc-level]u'\\$*
+.br
 ..
 .de Tc
 .Bd -literal
-.ta (\n(.lu)R
 .tm ...reading \*[toc-file]
-.   Pp
 .\" Use so-real here because toc-file is in objdir not .CURDIR
 .so-real \*[toc-file]
 .Ed



CVS commit: src/distrib/notes

2019-11-29 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Nov 30 00:28:27 UTC 2019

Modified Files:
src/distrib/notes: Makefile.inc
src/distrib/notes/common: macros

Log Message:
Improve table of contents.

For .txt and .more drop meaningless page numbers, those formats are
not paginated (with all due respect to line printers, 80s are over).

For .ps use actual formatting with proportional font and properly
aligned page numbers.  Thanks to kre@ for his help with some of the
darker corners of troff (with all due respect to my 80s self, he/I
should have paid more attention).


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/distrib/notes/Makefile.inc
cvs rdiff -u -r1.53 -r1.54 src/distrib/notes/common/macros

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



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

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 00:02:15 UTC 2019

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

Log Message:
Missed another spot.

Marked mb.9 obsolete but forgot to mark mb_memory.9  too.


To generate a diff of this commit:
cvs rdiff -u -r1.2294 -r1.2295 src/distrib/sets/lists/comp/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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2294 src/distrib/sets/lists/comp/mi:1.2295
--- src/distrib/sets/lists/comp/mi:1.2294	Fri Nov 29 22:17:23 2019
+++ src/distrib/sets/lists/comp/mi	Sat Nov 30 00:02:15 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2294 2019/11/29 22:17:23 riastradh Exp $
+#	$NetBSD: mi,v 1.2295 2019/11/30 00:02:15 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -11394,9 +11394,9 @@
 ./usr/share/man/cat9/malloc_type_detach.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/malloc_type_setlimit.0	comp-obsolete		obsolete
 ./usr/share/man/cat9/mb.0			comp-obsolete		obsolete
-./usr/share/man/cat9/mb_memory.0		comp-sys-catman		.cat
-./usr/share/man/cat9/mb_read.0			comp-sys-catman		.cat
-./usr/share/man/cat9/mb_write.0			comp-sys-catman		.cat
+./usr/share/man/cat9/mb_memory.0		comp-obsolete		obsolete
+./usr/share/man/cat9/mb_read.0			comp-obsolete		obsolete
+./usr/share/man/cat9/mb_write.0			comp-obsolete		obsolete
 ./usr/share/man/cat9/mbuf.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/mca.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/mca_conf_read.0		comp-sys-catman		.cat
@@ -19323,9 +19323,9 @@
 ./usr/share/man/html9/malloc_type_detach.html	comp-sys-htmlman	html
 ./usr/share/man/html9/malloc_type_setlimit.html comp-obsolete	obsolete
 ./usr/share/man/html9/mb.html			comp-obsolete	obsolete
-./usr/share/man/html9/mb_memory.html		comp-sys-htmlman	html
-./usr/share/man/html9/mb_read.html		comp-sys-htmlman	html
-./usr/share/man/html9/mb_write.html		comp-sys-htmlman	html
+./usr/share/man/html9/mb_memory.html		comp-obsolete	obsolete
+./usr/share/man/html9/mb_read.html		comp-obsolete	obsolete
+./usr/share/man/html9/mb_write.html		comp-obsolete	obsolete
 ./usr/share/man/html9/mbuf.html			comp-sys-htmlman	html
 ./usr/share/man/html9/mca.html			comp-sys-htmlman	html
 ./usr/share/man/html9/mca_conf_read.html	comp-sys-htmlman	html
@@ -27405,9 +27405,9 @@
 ./usr/share/man/man9/malloc_type_detach.9	comp-sys-man		.man
 ./usr/share/man/man9/malloc_type_setlimit.9	comp-obsolete		obsolete
 ./usr/share/man/man9/mb.9			comp-obsolete		obsolete
-./usr/share/man/man9/mb_memory.9		comp-sys-man		.man
-./usr/share/man/man9/mb_read.9			comp-sys-man		.man
-./usr/share/man/man9/mb_write.9			comp-sys-man		.man
+./usr/share/man/man9/mb_memory.9		comp-obsolete		obsolete
+./usr/share/man/man9/mb_read.9			comp-obsolete		obsolete
+./usr/share/man/man9/mb_write.9			comp-obsolete		obsolete
 ./usr/share/man/man9/mbuf.9			comp-sys-man		.man
 ./usr/share/man/man9/mca.9			comp-sys-man		.man
 ./usr/share/man/man9/mca_conf_read.9		comp-sys-man		.man



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

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 30 00:02:15 UTC 2019

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

Log Message:
Missed another spot.

Marked mb.9 obsolete but forgot to mark mb_memory.9  too.


To generate a diff of this commit:
cvs rdiff -u -r1.2294 -r1.2295 src/distrib/sets/lists/comp/mi

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



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:55:34 UTC 2019

Modified Files:
src/sys/arch/alpha/include: mutex.h
src/sys/arch/arm/include: mutex.h
src/sys/arch/ia64/include: mutex.h
src/sys/arch/m68k/include: mutex.h
src/sys/arch/mips/include: mutex.h
src/sys/arch/or1k/include: mutex.h
src/sys/arch/powerpc/include: mutex.h
src/sys/arch/riscv/include: mutex.h
src/sys/arch/sh3/include: mutex.h
src/sys/arch/sparc/include: mutex.h
src/sys/arch/sparc64/include: mutex.h
src/sys/arch/usermode/include: mutex.h
src/sys/arch/vax/include: mutex.h
src/sys/arch/x86/include: mutex.h

Log Message:
Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/include/mutex.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/include/mutex.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ia64/include/mutex.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/include/mutex.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/include/mutex.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/include/mutex.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/include/mutex.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sh3/include/mutex.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/mutex.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/mutex.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/vax/include/mutex.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/mutex.h

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



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:55:34 UTC 2019

Modified Files:
src/sys/arch/alpha/include: mutex.h
src/sys/arch/arm/include: mutex.h
src/sys/arch/ia64/include: mutex.h
src/sys/arch/m68k/include: mutex.h
src/sys/arch/mips/include: mutex.h
src/sys/arch/or1k/include: mutex.h
src/sys/arch/powerpc/include: mutex.h
src/sys/arch/riscv/include: mutex.h
src/sys/arch/sh3/include: mutex.h
src/sys/arch/sparc/include: mutex.h
src/sys/arch/sparc64/include: mutex.h
src/sys/arch/usermode/include: mutex.h
src/sys/arch/vax/include: mutex.h
src/sys/arch/x86/include: mutex.h

Log Message:
Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/include/mutex.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/include/mutex.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ia64/include/mutex.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/include/mutex.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/mips/include/mutex.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/include/mutex.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/include/mutex.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sh3/include/mutex.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/mutex.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/mutex.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/mutex.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/vax/include/mutex.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/include/mutex.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/alpha/include/mutex.h
diff -u src/sys/arch/alpha/include/mutex.h:1.5 src/sys/arch/alpha/include/mutex.h:1.6
--- src/sys/arch/alpha/include/mutex.h:1.5	Fri Nov 29 20:05:07 2019
+++ src/sys/arch/alpha/include/mutex.h	Fri Nov 29 22:55:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:05:07 riastradh Exp $	*/
+/*	$NetBSD: mutex.h,v 1.6 2019/11/29 22:55:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
@@ -60,9 +60,6 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		__asm __volatile("mb" : : : "memory")
-#define	MUTEX_GIVE(mtx)			__asm __volatile("mb" : : : "memory")
-
 #define	MUTEX_CAS(p, o, n)		_lock_cas((p), (o), (n))
 
 int	_lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);

Index: src/sys/arch/arm/include/mutex.h
diff -u src/sys/arch/arm/include/mutex.h:1.20 src/sys/arch/arm/include/mutex.h:1.21
--- src/sys/arch/arm/include/mutex.h:1.20	Wed Feb 25 13:52:42 2015
+++ src/sys/arch/arm/include/mutex.h	Fri Nov 29 22:55:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.20 2015/02/25 13:52:42 joerg Exp $	*/
+/*	$NetBSD: mutex.h,v 1.21 2019/11/29 22:55:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -84,30 +84,6 @@ struct kmutex {
 #endif
 #define	__HAVE_SIMPLE_MUTEXES		1
 
-/*
- * MUTEX_{GIVE,RECEIVE}: no memory barrier is required in the UP case;
- * we're synchronizing against interrupts, not multiple processors.
- */
-#ifdef MULTIPROCESSOR
-#ifdef _ARM_ARCH_7
-#define	MUTEX_RECEIVE(mtx)		__asm __volatile("dmb" ::: "memory")
-#else
-#define	MUTEX_RECEIVE(mtx)		membar_consumer()
-#endif
-#else
-#define	MUTEX_RECEIVE(mtx)		/* nothing */
-#endif
-
-#ifdef MULTIPROCESSOR
-#ifdef _ARM_ARCH_7
-#define	MUTEX_GIVE(mtx)			__asm __volatile("dsb" ::: "memory")
-#else
-#define	MUTEX_GIVE(mtx)			membar_producer()
-#endif
-#else
-#define	MUTEX_GIVE(mtx)			/* nothing */
-#endif
-
 #define	MUTEX_CAS(p, o, n)		\
 (atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o))
 #ifdef MULTIPROCESSOR

Index: src/sys/arch/ia64/include/mutex.h
diff -u src/sys/arch/ia64/include/mutex.h:1.4 src/sys/arch/ia64/include/mutex.h:1.5
--- src/sys/arch/ia64/include/mutex.h:1.4	Mon Jul 20 04:41:37 2009
+++ src/sys/arch/ia64/include/mutex.h	Fri Nov 29 22:55:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2009/07/20 04:41:37 kiyohara Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 22:55:33 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -56,16 +56,6 @@ struct kmutex {
 */
 #define	__HAVE_SIMPLE_MUTEXES		1
 
-/*
- * MUTEX_RECEIVE: no memory barrier required, atomic_cas implies a load fence.
- */
-#define	MUTEX_RECEIVE(mtx)		/* nothing */
-
-/*
- * MUTEX_GIVE: no memory barrier required, as _lock_cas() will take care of it.
- */
-#define	MUTEX_GIVE(mtx)			/* nothing */
-
 #define	MUTEX_CAS(ptr, old, new)		\
 (atomic_cas_ulong((volatile unsigned long *)(ptr), (old), (new)) == (old))
 

Index: src/sys/arch/m68k/include/mutex.h
diff -u src/sys/arch/m68k/include/mutex.h:1.8 src/sys/arch/m68k/include/mutex.h:1.9
--- src/sys/arch/m68k/include/mutex.h:1.8	Fri 

CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:38:28 UTC 2019

Modified Files:
src/share/man/man9: Makefile

Log Message:
Missed a spot: delete mb.9 from MLINKS too.


To generate a diff of this commit:
cvs rdiff -u -r1.443 -r1.444 src/share/man/man9/Makefile

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/Makefile
diff -u src/share/man/man9/Makefile:1.443 src/share/man/man9/Makefile:1.444
--- src/share/man/man9/Makefile:1.443	Fri Nov 29 22:17:23 2019
+++ src/share/man/man9/Makefile	Fri Nov 29 22:38:28 2019
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.443 2019/11/29 22:17:23 riastradh Exp $
+#   $NetBSD: Makefile,v 1.444 2019/11/29 22:38:28 riastradh Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -494,7 +494,6 @@ MLINKS+=malloc.9 malloc_type_attach.9
 MLINKS+=malloc.9 malloc_type_detach.9
 MLINKS+=malloc.9 MALLOC_DEFINE.9
 MLINKS+=malloc.9 MALLOC_DECLARE.9
-MLINKS+=mb.9 mb_memory.9 mb.9 mb_read.9 mb.9 mb_write.9
 MLINKS+=mbuf.9 m_get.9 mbuf.9 m_gethdr.9 mbuf.9 m_devget.9 \
 	mbuf.9 m_copym.9 mbuf.9 m_copypacket.9 mbuf.9 m_copydata.9 \
 	mbuf.9 m_copyback.9 mbuf.9 m_cat.9 mbuf.9 m_dup.9 mbuf.9 m_prepend.9 \



CVS commit: src/share/man/man9

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:38:28 UTC 2019

Modified Files:
src/share/man/man9: Makefile

Log Message:
Missed a spot: delete mb.9 from MLINKS too.


To generate a diff of this commit:
cvs rdiff -u -r1.443 -r1.444 src/share/man/man9/Makefile

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



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:17:24 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile
src/sys/sys: atomic.h
Added Files:
src/share/man/man9: atomic_loadstore.9

Log Message:
New atomic load/store operations for the kernel.

Guarantee no fusing and no tearing, and can optionally impose
ordering relative to other memory operations.

Unordered:
- atomic_load_relaxed
- atomic_store_relaxed

Ordered:
- atomic_load_acquire
- atomic_load_consume
- atomic_store_release

These are intended to match C11 semantics, and can be defined in
terms of the C11 atomic API when ready.


To generate a diff of this commit:
cvs rdiff -u -r1.2293 -r1.2294 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.442 -r1.443 src/share/man/man9/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man9/atomic_loadstore.9
cvs rdiff -u -r1.17 -r1.18 src/sys/sys/atomic.h

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



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 22:17:24 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile
src/sys/sys: atomic.h
Added Files:
src/share/man/man9: atomic_loadstore.9

Log Message:
New atomic load/store operations for the kernel.

Guarantee no fusing and no tearing, and can optionally impose
ordering relative to other memory operations.

Unordered:
- atomic_load_relaxed
- atomic_store_relaxed

Ordered:
- atomic_load_acquire
- atomic_load_consume
- atomic_store_release

These are intended to match C11 semantics, and can be defined in
terms of the C11 atomic API when ready.


To generate a diff of this commit:
cvs rdiff -u -r1.2293 -r1.2294 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.442 -r1.443 src/share/man/man9/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man9/atomic_loadstore.9
cvs rdiff -u -r1.17 -r1.18 src/sys/sys/atomic.h

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2293 src/distrib/sets/lists/comp/mi:1.2294
--- src/distrib/sets/lists/comp/mi:1.2293	Fri Nov 29 20:31:35 2019
+++ src/distrib/sets/lists/comp/mi	Fri Nov 29 22:17:23 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2293 2019/11/29 20:31:35 riastradh Exp $
+#	$NetBSD: mi,v 1.2294 2019/11/29 22:17:23 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -10704,6 +10704,12 @@
 ./usr/share/man/cat9/arp_ifinit.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/arpintr.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/arpresolve.0		comp-sys-catman		.cat
+./usr/share/man/cat9/atomic_load_acquire.0	comp-sys-catman		.cat
+./usr/share/man/cat9/atomic_load_consume.0	comp-sys-catman		.cat
+./usr/share/man/cat9/atomic_load_relaxed.0	comp-sys-catman		.cat
+./usr/share/man/cat9/atomic_loadstore.0		comp-sys-catman		.cat
+./usr/share/man/cat9/atomic_store_relaxed.0	comp-sys-catman		.cat
+./usr/share/man/cat9/atomic_store_release.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/atop.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/audio.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/audio_system.0		comp-sys-catman		obsolete
@@ -18652,6 +18658,12 @@
 ./usr/share/man/html9/arp_ifinit.html		comp-sys-htmlman	html
 ./usr/share/man/html9/arpintr.html		comp-sys-htmlman	html
 ./usr/share/man/html9/arpresolve.html		comp-sys-htmlman	html
+./usr/share/man/html9/atomic_load_acquire.html	comp-sys-htmlman	html
+./usr/share/man/html9/atomic_load_consume.html	comp-sys-htmlman	html
+./usr/share/man/html9/atomic_load_relaxed.html	comp-sys-htmlman	html
+./usr/share/man/html9/atomic_loadstore.html	comp-sys-htmlman	html
+./usr/share/man/html9/atomic_store_relaxed.html	comp-sys-htmlman	html
+./usr/share/man/html9/atomic_store_release.html	comp-sys-htmlman	html
 ./usr/share/man/html9/atop.html			comp-sys-htmlman	html
 ./usr/share/man/html9/audio.html		comp-sys-htmlman	html
 ./usr/share/man/html9/audio_system.html		comp-sys-htmlman	obsolete
@@ -26703,6 +26715,12 @@
 ./usr/share/man/man9/arp_ifinit.9		comp-sys-man		.man
 ./usr/share/man/man9/arpintr.9			comp-sys-man		.man
 ./usr/share/man/man9/arpresolve.9		comp-sys-man		.man
+./usr/share/man/man9/atomic_load_acquire.9	comp-sys-man		.man
+./usr/share/man/man9/atomic_load_consume.9	comp-sys-man		.man
+./usr/share/man/man9/atomic_load_relaxed.9	comp-sys-man		.man
+./usr/share/man/man9/atomic_loadstore.9		comp-sys-man		.man
+./usr/share/man/man9/atomic_store_relaxed.9	comp-sys-man		.man
+./usr/share/man/man9/atomic_store_release.9	comp-sys-man		.man
 ./usr/share/man/man9/atop.9			comp-sys-man		.man
 ./usr/share/man/man9/audio.9			comp-sys-man		.man
 ./usr/share/man/man9/audio_system.9		comp-sys-man		obsolete

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.442 src/share/man/man9/Makefile:1.443
--- src/share/man/man9/Makefile:1.442	Fri Nov 29 20:31:35 2019
+++ src/share/man/man9/Makefile	Fri Nov 29 22:17:23 2019
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.442 2019/11/29 20:31:35 riastradh Exp $
+#   $NetBSD: Makefile,v 1.443 2019/11/29 22:17:23 riastradh Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -67,6 +67,13 @@ MAN=	accept_filter.9 accf_data.9 accf_ht
 	wsbell.9 wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9 \
 	xcall.9
 
+MAN+=	atomic_loadstore.9
+MLINKS+=atomic_loadstore.9 atomic_load_acquire.9 \
+	atomic_loadstore.9 atomic_load_consume.9 \
+	atomic_loadstore.9 atomic_load_relaxed.9 \
+	atomic_loadstore.9 atomic_store_relaxed.9 \
+	atomic_loadstore.9 atomic_store_release.9
+
 MAN+=	boothowto.9
 MLINKS+=boothowto.9 BOOT_FLAG.9
 

Index: src/sys/sys/atomic.h
diff -u src/sys/sys/atomic.h:1.17 src/sys/sys/atomic.h:1.18
--- src/sys/sys/atomic.h:1.17	Thu Nov 14 16:23:53 2019
+++ src/sys/sys/atomic.h	Fri Nov 29 22:17:23 2019
@@ -1,4 

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

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:17 UTC 2019

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

Log Message:
Add tiwdt


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/evbarm/conf/GENERIC

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



CVS commit: src/sys/arch/arm/ti

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_wdt.c

Log Message:
Add TI OMAP watchdog timer driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.c

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



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

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:17 UTC 2019

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

Log Message:
Add tiwdt


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/evbarm/conf/GENERIC

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

Modified files:

Index: src/sys/arch/evbarm/conf/GENERIC
diff -u src/sys/arch/evbarm/conf/GENERIC:1.67 src/sys/arch/evbarm/conf/GENERIC:1.68
--- src/sys/arch/evbarm/conf/GENERIC:1.67	Sun Nov  3 22:59:24 2019
+++ src/sys/arch/evbarm/conf/GENERIC	Fri Nov 29 20:54:17 2019
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC,v 1.67 2019/11/03 22:59:24 jmcneill Exp $
+#	$NetBSD: GENERIC,v 1.68 2019/11/29 20:54:17 jmcneill Exp $
 #
 #	GENERIC ARM (aarch32) kernel
 #
@@ -401,10 +401,11 @@ sunxihstimer* 	at fdt?			# Allwinner Hig
 tegratimer* 	at fdt?			# Timers
 
 # Watchdog
+bcmpmwdog* 	at fdt?			# Broadcom BCM283x watchdog
 dwcwdt* 	at fdt?			# DesignWare watchdog
 mesonwdt* 	at fdt?			# Amlogic Meson watchdog
 sunxiwdt* 	at fdt?			# Allwinner watchdog
-bcmpmwdog* 	at fdt?			# Broadcom BCM283x watchdog
+tiwdt*		at fdt?			# TI OMAP watchdog
 
 # Interrupt controller
 gic*		at fdt? pass 1		# ARM GIC



CVS commit: src/sys/arch/arm/ti

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_wdt.c

Log Message:
Add TI OMAP watchdog timer driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.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/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.11 src/sys/arch/arm/ti/am3_prcm.c:1.12
--- src/sys/arch/arm/ti/am3_prcm.c:1.11	Wed Nov 27 23:02:54 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Fri Nov 29 20:54:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $");
 
 #include 
 #include 
@@ -169,6 +169,8 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"),
 
+	AM3_PRCM_HWMOD_WKUP("wd_timer2", 0xd4, "FIXED_32K"),
+
 	AM3_PRCM_HWMOD_PER("mmc1", 0x3c, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc2", 0xf4, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc3", 0xf8, "MMC_CLK"),

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.20 src/sys/arch/arm/ti/files.ti:1.21
--- src/sys/arch/arm/ti/files.ti:1.20	Sun Nov  3 22:59:06 2019
+++ src/sys/arch/arm/ti/files.ti	Fri Nov 29 20:54:00 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.20 2019/11/03 22:59:06 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.21 2019/11/29 20:54:00 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_cpufreq.c	soc_ti
@@ -131,6 +131,11 @@ device	omapnand: nandbus
 attach	omapnand at fdt
 file	arch/arm/ti/omap2_nand.c	omapnand
 
+# Watchdog timer
+device	tiwdt: sysmon_wdog
+attach	tiwdt at fdt with ti_wdt
+file	arch/arm/ti/ti_wdt.c		ti_wdt
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_AM33XX: SOC_TI

Added files:

Index: src/sys/arch/arm/ti/ti_wdt.c
diff -u /dev/null src/sys/arch/arm/ti/ti_wdt.c:1.1
--- /dev/null	Fri Nov 29 20:54:00 2019
+++ src/sys/arch/arm/ti/ti_wdt.c	Fri Nov 29 20:54:00 2019
@@ -0,0 +1,259 @@
+/* $NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR 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 
+__KERNEL_RCSID(0, "$NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
+#define	WDT_WDSC		0x10
+#define	 WDSC_SOFTRESET		__BIT(1)
+#define	WDT_WDST		0x14
+#define	WDT_WISR		0x18
+#define	WDT_WIER		0x1c
+#define	WDT_WCLR		0x24
+#define	 WCLR_PRE		__BIT(5)
+#define	 WCLR_PTV		__BITS(4,2)
+#define	WDT_WCRR		0x28
+#define	WDT_WLDR		0x2c
+#define	WDT_WTGR		0x30
+#define	WDT_WWPS		0x34
+#define	 WWPS_W_PEND_WDLY	__BIT(5)
+#define	 WWPS_W_PEND_WSPR	__BIT(4)
+#define	 WWPS_W_PEND_WTGR	__BIT(3)
+#define	 WWPS_W_PEND_WLDR	__BIT(2)
+#define	 WWPS_W_PEND_WCRR	__BIT(1)
+#define	 WWPS_W_PEND_WCLR	__BIT(0)
+#define	 WWPS_W_PEND_MASK	__BITS(5,0)
+#define	WDT_WDLY		0x44
+#define	WDT_WSPR		0x48
+#define	WDT_WIRQSTATRAW		0x54
+#define	WDT_WIRQSTAT		0x58
+#define	WDT_WIRQENSET		0x5c
+#define	WDT_WIRQENCLR		0x60
+#define	 WIRQ_EVENT_DLY		__BIT(1)
+#define	 WIRQ_EVENT_OVF		__BIT(0)
+
+#define	

CVS commit: src/sys/kern

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 20:50:54 UTC 2019

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

Log Message:
A couple more tweaks to avoid reading the lock word.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/kern/kern_rwlock.c

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

Modified files:

Index: src/sys/kern/kern_rwlock.c
diff -u src/sys/kern/kern_rwlock.c:1.56 src/sys/kern/kern_rwlock.c:1.57
--- src/sys/kern/kern_rwlock.c:1.56	Fri Nov 29 20:04:54 2019
+++ src/sys/kern/kern_rwlock.c	Fri Nov 29 20:50:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rwlock.c,v 1.56 2019/11/29 20:04:54 riastradh Exp $	*/
+/*	$NetBSD: kern_rwlock.c,v 1.57 2019/11/29 20:50:54 ad Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.56 2019/11/29 20:04:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.57 2019/11/29 20:50:54 ad Exp $");
 
 #define	__RWLOCK_PRIVATE
 
@@ -417,10 +417,11 @@ rw_vector_enter(krwlock_t *rw, const krw
 		 * No need for a memory barrier because of context switch.
 		 * If not handed the lock, then spin again.
 		 */
-		if (op == RW_READER || (rw->rw_owner & RW_THREAD) == curthread)
+		if (op == RW_READER)
 			break;
-
 		owner = rw->rw_owner;
+		if ((owner & RW_THREAD) == curthread)
+			break;
 	}
 	KPREEMPT_ENABLE(curlwp);
 
@@ -476,14 +477,13 @@ rw_vector_exit(krwlock_t *rw)
 	 * lock would become unowned.
 	 */
 	RW_MEMBAR_EXIT();
-	for (;;) {
+	for (;; owner = next) {
 		newown = (owner - decr);
 		if ((newown & (RW_THREAD | RW_HAS_WAITERS)) == RW_HAS_WAITERS)
 			break;
 		next = rw_cas(rw, owner, newown);
 		if (__predict_true(next == owner))
 			return;
-		owner = next;
 	}
 
 	/*
@@ -568,15 +568,15 @@ rw_vector_tryenter(krwlock_t *rw, const 
 		need_wait = RW_WRITE_LOCKED | RW_THREAD;
 	}
 
-	for (owner = rw->rw_owner;; owner = next) {
-		if (__predict_false((owner & need_wait) != 0))
-			return 0;
+	for (owner = 0;; owner = next) {
 		next = rw_cas(rw, owner, owner + incr);
 		if (__predict_true(next == owner)) {
 			/* Got it! */
 			RW_MEMBAR_ENTER();
 			break;
 		}
+		if (__predict_false((owner & need_wait) != 0))
+			return 0;
 	}
 
 	RW_WANTLOCK(rw, op);



CVS commit: src/sys/kern

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 20:50:54 UTC 2019

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

Log Message:
A couple more tweaks to avoid reading the lock word.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/kern/kern_rwlock.c

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



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:31:35 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile
Removed Files:
src/share/man/man9: mb.9

Log Message:
Nix obsolete mb(9) man page.


To generate a diff of this commit:
cvs rdiff -u -r1.2292 -r1.2293 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.441 -r1.442 src/share/man/man9/Makefile
cvs rdiff -u -r1.8 -r0 src/share/man/man9/mb.9

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/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2292 src/distrib/sets/lists/comp/mi:1.2293
--- src/distrib/sets/lists/comp/mi:1.2292	Mon Nov 11 22:44:56 2019
+++ src/distrib/sets/lists/comp/mi	Fri Nov 29 20:31:35 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2292 2019/11/11 22:44:56 joerg Exp $
+#	$NetBSD: mi,v 1.2293 2019/11/29 20:31:35 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -11387,7 +11387,7 @@
 ./usr/share/man/cat9/malloc_type_attach.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/malloc_type_detach.0	comp-sys-catman		.cat
 ./usr/share/man/cat9/malloc_type_setlimit.0	comp-obsolete		obsolete
-./usr/share/man/cat9/mb.0			comp-sys-catman		.cat
+./usr/share/man/cat9/mb.0			comp-obsolete		obsolete
 ./usr/share/man/cat9/mb_memory.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/mb_read.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/mb_write.0			comp-sys-catman		.cat
@@ -19310,7 +19310,7 @@
 ./usr/share/man/html9/malloc_type_attach.html	comp-sys-htmlman	html
 ./usr/share/man/html9/malloc_type_detach.html	comp-sys-htmlman	html
 ./usr/share/man/html9/malloc_type_setlimit.html comp-obsolete	obsolete
-./usr/share/man/html9/mb.html			comp-sys-htmlman	html
+./usr/share/man/html9/mb.html			comp-obsolete	obsolete
 ./usr/share/man/html9/mb_memory.html		comp-sys-htmlman	html
 ./usr/share/man/html9/mb_read.html		comp-sys-htmlman	html
 ./usr/share/man/html9/mb_write.html		comp-sys-htmlman	html
@@ -27386,7 +27386,7 @@
 ./usr/share/man/man9/malloc_type_attach.9	comp-sys-man		.man
 ./usr/share/man/man9/malloc_type_detach.9	comp-sys-man		.man
 ./usr/share/man/man9/malloc_type_setlimit.9	comp-obsolete		obsolete
-./usr/share/man/man9/mb.9			comp-sys-man		.man
+./usr/share/man/man9/mb.9			comp-obsolete		obsolete
 ./usr/share/man/man9/mb_memory.9		comp-sys-man		.man
 ./usr/share/man/man9/mb_read.9			comp-sys-man		.man
 ./usr/share/man/man9/mb_write.9			comp-sys-man		.man

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.441 src/share/man/man9/Makefile:1.442
--- src/share/man/man9/Makefile:1.441	Wed Oct  2 08:21:08 2019
+++ src/share/man/man9/Makefile	Fri Nov 29 20:31:35 2019
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.441 2019/10/02 08:21:08 rin Exp $
+#   $NetBSD: Makefile,v 1.442 2019/11/29 20:31:35 riastradh Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -34,7 +34,7 @@ MAN=	accept_filter.9 accf_data.9 accf_ht
 	kprintf.9 kthread.9 linedisc.9 lock.9 locking.9 log.9 ltsleep.9 \
 	localcount.9 LWP_CACHE_CREDS.9 \
 	makeiplcookie.9 \
-	malloc.9 mb.9 mbuf.9 mca.9 memcmp.9 memcpy.9 memoryallocators.9 \
+	malloc.9 mbuf.9 mca.9 memcmp.9 memcpy.9 memoryallocators.9 \
 	memmove.9 memset.9 \
 	microseq.9 microtime.9 microuptime.9 mi_switch.9 module.9 \
 	mstohz.9 mutex.9 m_tag.9 namecache.9 \



CVS commit: src

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:31:35 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man9: Makefile
Removed Files:
src/share/man/man9: mb.9

Log Message:
Nix obsolete mb(9) man page.


To generate a diff of this commit:
cvs rdiff -u -r1.2292 -r1.2293 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.441 -r1.442 src/share/man/man9/Makefile
cvs rdiff -u -r1.8 -r0 src/share/man/man9/mb.9

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



CVS commit: src/sys/arch/vax/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:44 UTC 2019

Modified Files:
src/sys/arch/vax/include: lock.h

Log Message:
Nix mb_* on vax.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/vax/include/lock.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/vax/include/lock.h
diff -u src/sys/arch/vax/include/lock.h:1.31 src/sys/arch/vax/include/lock.h:1.32
--- src/sys/arch/vax/include/lock.h:1.31	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/vax/include/lock.h	Fri Nov 29 20:06:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.31 2017/09/17 00:01:08 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.32 2019/11/29 20:06:44 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2000 Ludd, University of Lule}, Sweden.
@@ -160,15 +160,4 @@ do {	\
 } while (/*CONSTCOND*/0)
 #endif /* MULTIPROCESSOR */
 
-static __inline void mb_read(void);
-static __inline void
-mb_read(void)
-{
-}
-
-static __inline void mb_write(void);
-static __inline void
-mb_write(void)
-{
-}
 #endif /* _VAX_LOCK_H_ */



CVS commit: src/sys/arch/vax/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:44 UTC 2019

Modified Files:
src/sys/arch/vax/include: lock.h

Log Message:
Nix mb_* on vax.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/vax/include/lock.h

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



CVS commit: src/sys/arch/powerpc/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:59 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: lock.h mutex.h

Log Message:
Nix mb_* on powerpc.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/mutex.h

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



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:34 UTC 2019

Modified Files:
src/sys/arch/sparc/include: lock.h
src/sys/arch/sparc64/include: mutex.h

Log Message:
Nix mb_* on sparc and sparc64.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/include/mutex.h

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



CVS commit: src/sys/arch

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:34 UTC 2019

Modified Files:
src/sys/arch/sparc/include: lock.h
src/sys/arch/sparc64/include: mutex.h

Log Message:
Nix mb_* on sparc and sparc64.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/include/mutex.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/sparc/include/lock.h
diff -u src/sys/arch/sparc/include/lock.h:1.32 src/sys/arch/sparc/include/lock.h:1.33
--- src/sys/arch/sparc/include/lock.h:1.32	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/sparc/include/lock.h	Fri Nov 29 20:06:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.32 2017/09/17 00:01:08 christos Exp $ */
+/*	$NetBSD: lock.h,v 1.33 2019/11/29 20:06:34 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2006 The NetBSD Foundation, Inc.
@@ -140,46 +140,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-#if defined(__sparc_v9__)
-static __inline void
-mb_read(void)
-{
-	__asm __volatile("membar #LoadLoad" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm __volatile("" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm __volatile("membar #MemIssue" : : : "memory");
-}
-#else	/* __sparc_v9__ */
-static __inline void
-mb_read(void)
-{
-	static volatile int junk;
-	__asm volatile("st %%g0,[%0]"
-	:
-	: "r" ()
-	: "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__insn_barrier();
-}
-
-static __inline void
-mb_memory(void)
-{
-	mb_read();
-}
-#endif	/* __sparc_v9__ */
-
 #endif /* _MACHINE_LOCK_H */

Index: src/sys/arch/sparc64/include/mutex.h
diff -u src/sys/arch/sparc64/include/mutex.h:1.4 src/sys/arch/sparc64/include/mutex.h:1.5
--- src/sys/arch/sparc64/include/mutex.h:1.4	Mon Apr 28 20:23:37 2008
+++ src/sys/arch/sparc64/include/mutex.h	Fri Nov 29 20:06:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2008/04/28 20:23:37 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:06:34 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -55,7 +55,11 @@ struct kmutex {
 #define __HAVE_MUTEX_STUBS		1
 #define	__HAVE_SIMPLE_MUTEXES		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
+/*
+ * XXX Should this be LoadLoad|LoadStore, or does the assumption of a
+ * preceding atomic r/m/w operation obviate the need for that?
+ */
+#define	MUTEX_RECEIVE(mtx) __asm __volatile("membar #LoadLoad" : : : "memory")
 
 /*
  * MUTEX_GIVE: no memory barrier required, as _lock_cas() will take care of it.



CVS commit: src/sys/arch/powerpc/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:59 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: lock.h mutex.h

Log Message:
Nix mb_* on powerpc.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/mutex.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/powerpc/include/lock.h
diff -u src/sys/arch/powerpc/include/lock.h:1.13 src/sys/arch/powerpc/include/lock.h:1.14
--- src/sys/arch/powerpc/include/lock.h:1.13	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/powerpc/include/lock.h	Fri Nov 29 20:05:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.13 2017/09/17 00:01:08 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.14 2019/11/29 20:05:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -120,22 +120,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__asm volatile ("isync" ::: "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm volatile ("sync" ::: "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm volatile ("sync" ::: "memory");
-}
-
 #endif /* _POWERPC_LOCK_H_ */

Index: src/sys/arch/powerpc/include/mutex.h
diff -u src/sys/arch/powerpc/include/mutex.h:1.4 src/sys/arch/powerpc/include/mutex.h:1.5
--- src/sys/arch/powerpc/include/mutex.h:1.4	Mon Apr 28 20:23:32 2008
+++ src/sys/arch/powerpc/include/mutex.h	Fri Nov 29 20:05:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2008/04/28 20:23:32 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:05:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -61,8 +61,8 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
-#define	MUTEX_GIVE(mtx)			mb_memory()
+#define	MUTEX_RECEIVE(mtx)		__asm __volatile("isync" ::: "memory")
+#define	MUTEX_GIVE(mtx)			__asm __volatile("sync" ::: "memory")
 
 #define	MUTEX_CAS(p, o, n)		_lock_cas((p), (o), (n))
 



CVS commit: src/sys/arch/arm/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:19 UTC 2019

Modified Files:
src/sys/arch/arm/include: lock.h

Log Message:
Nix mb_* on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/lock.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/arm/include/lock.h
diff -u src/sys/arch/arm/include/lock.h:1.33 src/sys/arch/arm/include/lock.h:1.34
--- src/sys/arch/arm/include/lock.h:1.33	Sun Sep 17 00:01:07 2017
+++ src/sys/arch/arm/include/lock.h	Fri Nov 29 20:05:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.33 2017/09/17 00:01:07 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.34 2019/11/29 20:05:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -66,11 +66,8 @@ __cpu_simple_lock_set(__cpu_simple_lock_
 }
 
 #ifdef _KERNEL
+/* XXX Formerly included for obsolete mb_* API, maybe no longer needed.  */
 #include 
-
-#define	mb_read		drain_writebuf		/* in cpufunc.h */
-#define	mb_write	drain_writebuf		/* in cpufunc.h */
-#define	mb_memory	drain_writebuf		/* in cpufunc.h */
 #endif
 
 #ifdef _ARM_ARCH_6



CVS commit: src/sys/arch/arm/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:19 UTC 2019

Modified Files:
src/sys/arch/arm/include: lock.h

Log Message:
Nix mb_* on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/include/lock.h

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



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

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:29 UTC 2019

Modified Files:
src/sys/arch/hppa/include: lock.h mutex.h

Log Message:
Nix mb_* on hppa.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/hppa/include/lock.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/include/mutex.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/hppa/include/lock.h
diff -u src/sys/arch/hppa/include/lock.h:1.21 src/sys/arch/hppa/include/lock.h:1.22
--- src/sys/arch/hppa/include/lock.h:1.21	Tue Apr 16 12:25:17 2019
+++ src/sys/arch/hppa/include/lock.h	Fri Nov 29 20:05:29 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: lock.h,v 1.21 2019/04/16 12:25:17 skrll Exp $	*/
+/* 	$NetBSD: lock.h,v 1.22 2019/11/29 20:05:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -141,22 +141,4 @@ __cpu_simple_lock_clear(__cpu_simple_loc
 	*__aptr = __SIMPLELOCK_RAW_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__sync();
-}
-
-static __inline void
-mb_write(void)
-{
-	__sync();
-}
-
-static __inline void
-mb_memory(void)
-{
-	__sync();
-}
-
 #endif /* _HPPA_LOCK_H_ */

Index: src/sys/arch/hppa/include/mutex.h
diff -u src/sys/arch/hppa/include/mutex.h:1.13 src/sys/arch/hppa/include/mutex.h:1.14
--- src/sys/arch/hppa/include/mutex.h:1.13	Wed Oct  4 23:04:42 2017
+++ src/sys/arch/hppa/include/mutex.h	Fri Nov 29 20:05:29 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.13 2017/10/04 23:04:42 christos Exp $	*/
+/*	$NetBSD: mutex.h,v 1.14 2019/11/29 20:05:29 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -99,9 +99,9 @@ MUTEX_OWNED(uintptr_t owner)
 static inline int
 MUTEX_SET_WAITERS(struct kmutex *mtx, uintptr_t owner)
 {
-	mb_write();
+	__sync();		/* formerly mb_read */
 	mtx->mtx_waiters = 1;
-	mb_memory();
+	__sync();		/* formerly mb_memory */
 	return mtx->mtx_owner != MUTEX_ADAPTIVE_UNOWNED;
 }
 



CVS commit: src/sys/arch/m68k/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:49 UTC 2019

Modified Files:
src/sys/arch/m68k/include: lock.h mutex.h

Log Message:
Nix mb_* on m68k.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/include/lock.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/include/mutex.h

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



CVS commit: src/sys/arch/ia64/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:38 UTC 2019

Modified Files:
src/sys/arch/ia64/include: lock.h

Log Message:
Nix mb_* on ia64.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/include/lock.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/ia64/include/lock.h
diff -u src/sys/arch/ia64/include/lock.h:1.7 src/sys/arch/ia64/include/lock.h:1.8
--- src/sys/arch/ia64/include/lock.h:1.7	Thu Jan 10 17:05:56 2019
+++ src/sys/arch/ia64/include/lock.h	Fri Nov 29 20:05:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.7 2019/01/10 17:05:56 scole Exp $	*/
+/*	$NetBSD: lock.h,v 1.8 2019/11/29 20:05:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -117,24 +117,6 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 }
 
 static __inline void
-mb_read(void)
-{
-	__asm __volatile("mf	\n" ::: "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm __volatile("mf	\n" ::: "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm __volatile("mf	\n" ::: "memory");
-}
-
-static __inline void
 ia64_pause(void)
 {
 	__asm __volatile("hint @pause" ::: "memory");



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

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:29 UTC 2019

Modified Files:
src/sys/arch/hppa/include: lock.h mutex.h

Log Message:
Nix mb_* on hppa.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/hppa/include/lock.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/include/mutex.h

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



CVS commit: src/sys/arch/ia64/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:38 UTC 2019

Modified Files:
src/sys/arch/ia64/include: lock.h

Log Message:
Nix mb_* on ia64.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/include/lock.h

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



CVS commit: src/sys/arch/sh3/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:08 UTC 2019

Modified Files:
src/sys/arch/sh3/include: lock.h

Log Message:
Nix mb_* on sh3.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sh3/include/lock.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/sh3/include/lock.h
diff -u src/sys/arch/sh3/include/lock.h:1.17 src/sys/arch/sh3/include/lock.h:1.18
--- src/sys/arch/sh3/include/lock.h:1.17	Sun Sep 17 00:01:08 2017
+++ src/sys/arch/sh3/include/lock.h	Fri Nov 29 20:06:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.17 2017/09/17 00:01:08 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.18 2019/11/29 20:06:08 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -110,22 +110,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
 #endif /* !_SH3_LOCK_H_ */



CVS commit: src/sys/arch/sh3/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:06:08 UTC 2019

Modified Files:
src/sys/arch/sh3/include: lock.h

Log Message:
Nix mb_* on sh3.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sh3/include/lock.h

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



CVS commit: src/sys/arch/m68k/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:49 UTC 2019

Modified Files:
src/sys/arch/m68k/include: lock.h mutex.h

Log Message:
Nix mb_* on m68k.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/include/lock.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/m68k/include/mutex.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/m68k/include/lock.h
diff -u src/sys/arch/m68k/include/lock.h:1.15 src/sys/arch/m68k/include/lock.h:1.16
--- src/sys/arch/m68k/include/lock.h:1.15	Sun Sep 17 00:01:07 2017
+++ src/sys/arch/m68k/include/lock.h	Fri Nov 29 20:05:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.15 2017/09/17 00:01:07 christos Exp $	*/
+/*	$NetBSD: lock.h,v 1.16 2019/11/29 20:05:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,22 +101,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t 
 	*alp = __SIMPLELOCK_UNLOCKED;
 }
 
-static __inline void
-mb_read(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm volatile("" : : : "memory");
-}
-
 #endif /* _M68K_LOCK_H_ */

Index: src/sys/arch/m68k/include/mutex.h
diff -u src/sys/arch/m68k/include/mutex.h:1.7 src/sys/arch/m68k/include/mutex.h:1.8
--- src/sys/arch/m68k/include/mutex.h:1.7	Mon Apr 28 20:23:26 2008
+++ src/sys/arch/m68k/include/mutex.h	Fri Nov 29 20:05:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.7 2008/04/28 20:23:26 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.8 2019/11/29 20:05:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -62,8 +62,8 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
-#define	MUTEX_GIVE(mtx)			mb_memory()
+#define	MUTEX_RECEIVE(mtx)		__insn_barrier()
+#define	MUTEX_GIVE(mtx)			__insn_barrier()
 
 #define	MUTEX_CAS(p, o, n)		(atomic_cas_uint((p), (o), (n)) == (o))
 



CVS commit: src/sys

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:04:54 UTC 2019

Modified Files:
src/sys/arch/alpha/include: rwlock.h
src/sys/arch/arm/include: rwlock.h
src/sys/arch/hppa/include: rwlock.h
src/sys/arch/ia64/include: rwlock.h
src/sys/arch/m68k/include: rwlock.h
src/sys/arch/mips/include: rwlock.h
src/sys/arch/or1k/include: rwlock.h
src/sys/arch/powerpc/include: rwlock.h
src/sys/arch/riscv/include: rwlock.h
src/sys/arch/sh3/include: rwlock.h
src/sys/arch/sparc/include: rwlock.h
src/sys/arch/sparc64/include: rwlock.h
src/sys/arch/usermode/include: rwlock.h
src/sys/arch/vax/include: rwlock.h
src/sys/arch/x86/include: rwlock.h
src/sys/kern: kern_rwlock.c
src/sys/sys: rwlock.h

Log Message:
Largely eliminate the MD rwlock.h header file.

This was full of definitions that have been obsolete for over a
decade.  The file still remains for __HAVE_RW_STUBS but that's all.
Used only internally in kern_rwlock.c now, not by .


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/rwlock.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/include/rwlock.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/rwlock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sh3/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/rwlock.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/rwlock.h
cvs rdiff -u -r1.55 -r1.56 src/sys/kern/kern_rwlock.c
cvs rdiff -u -r1.10 -r1.11 src/sys/sys/rwlock.h

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



CVS commit: src/sys/arch/alpha/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:08 UTC 2019

Modified Files:
src/sys/arch/alpha/include: lock.h mutex.h

Log Message:
Nix mb_* on alpha.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/mutex.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/alpha/include/lock.h
diff -u src/sys/arch/alpha/include/lock.h:1.29 src/sys/arch/alpha/include/lock.h:1.30
--- src/sys/arch/alpha/include/lock.h:1.29	Sun Sep 17 00:01:07 2017
+++ src/sys/arch/alpha/include/lock.h	Fri Nov 29 20:05:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.29 2017/09/17 00:01:07 christos Exp $ */
+/* $NetBSD: lock.h,v 1.30 2019/11/29 20:05:07 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -174,23 +174,4 @@ do {	\
 #define	SPINLOCK_BACKOFF_HOOK	(void)nullop((void *)0)
 #endif /* MULTIPROCESSOR */
 
-static __inline void
-mb_read(void)
-{
-	__asm __volatile("mb" : : : "memory");
-}
-
-static __inline void
-mb_write(void)
-{
-	/* XXX wmb */
-	__asm __volatile("mb" : : : "memory");
-}
-
-static __inline void
-mb_memory(void)
-{
-	__asm __volatile("mb" : : : "memory");
-}
-
 #endif /* _ALPHA_LOCK_H_ */

Index: src/sys/arch/alpha/include/mutex.h
diff -u src/sys/arch/alpha/include/mutex.h:1.4 src/sys/arch/alpha/include/mutex.h:1.5
--- src/sys/arch/alpha/include/mutex.h:1.4	Mon Apr 28 20:23:11 2008
+++ src/sys/arch/alpha/include/mutex.h	Fri Nov 29 20:05:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.4 2008/04/28 20:23:11 martin Exp $	*/
+/*	$NetBSD: mutex.h,v 1.5 2019/11/29 20:05:07 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
@@ -60,8 +60,8 @@ struct kmutex {
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
 
-#define	MUTEX_RECEIVE(mtx)		mb_read()
-#define	MUTEX_GIVE(mtx)			mb_memory()
+#define	MUTEX_RECEIVE(mtx)		__asm __volatile("mb" : : : "memory")
+#define	MUTEX_GIVE(mtx)			__asm __volatile("mb" : : : "memory")
 
 #define	MUTEX_CAS(p, o, n)		_lock_cas((p), (o), (n))
 



CVS commit: src/sys

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:04:54 UTC 2019

Modified Files:
src/sys/arch/alpha/include: rwlock.h
src/sys/arch/arm/include: rwlock.h
src/sys/arch/hppa/include: rwlock.h
src/sys/arch/ia64/include: rwlock.h
src/sys/arch/m68k/include: rwlock.h
src/sys/arch/mips/include: rwlock.h
src/sys/arch/or1k/include: rwlock.h
src/sys/arch/powerpc/include: rwlock.h
src/sys/arch/riscv/include: rwlock.h
src/sys/arch/sh3/include: rwlock.h
src/sys/arch/sparc/include: rwlock.h
src/sys/arch/sparc64/include: rwlock.h
src/sys/arch/usermode/include: rwlock.h
src/sys/arch/vax/include: rwlock.h
src/sys/arch/x86/include: rwlock.h
src/sys/kern: kern_rwlock.c
src/sys/sys: rwlock.h

Log Message:
Largely eliminate the MD rwlock.h header file.

This was full of definitions that have been obsolete for over a
decade.  The file still remains for __HAVE_RW_STUBS but that's all.
Used only internally in kern_rwlock.c now, not by .


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/rwlock.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/ia64/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/include/rwlock.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/mips/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/rwlock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/include/rwlock.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sh3/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/include/rwlock.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/rwlock.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/include/rwlock.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/include/rwlock.h
cvs rdiff -u -r1.55 -r1.56 src/sys/kern/kern_rwlock.c
cvs rdiff -u -r1.10 -r1.11 src/sys/sys/rwlock.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/alpha/include/rwlock.h
diff -u src/sys/arch/alpha/include/rwlock.h:1.4 src/sys/arch/alpha/include/rwlock.h:1.5
--- src/sys/arch/alpha/include/rwlock.h:1.4	Mon Apr 28 20:23:11 2008
+++ src/sys/arch/alpha/include/rwlock.h	Fri Nov 29 20:04:52 2019
@@ -1,52 +1 @@
-/*	$NetBSD: rwlock.h,v 1.4 2008/04/28 20:23:11 martin Exp $	*/
-
-/*-
- * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe and Andrew Doran.
- *
- * 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.
- */
-
-#ifndef _ALPHA_RWLOCK_H_
-#define	_ALPHA_RWLOCK_H_
-
-struct krwlock {
-	volatile uintptr_t	rw_owner;
-};
-
-#ifdef __RWLOCK_PRIVATE
-
-#define	__HAVE_SIMPLE_RW_LOCKS		1
-
-#define	RW_RECEIVE(rw)			/* nothing */
-#define	RW_GIVE(rw)			/* nothing */
-
-#define	RW_CAS(p, o, n)			_lock_cas((p), (o), (n))
-
-int	_lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
-
-#endif	/* __RWLOCK_PRIVATE */
-
-#endif /* _ALPHA_RWLOCK_H_ */
+/*	$NetBSD: rwlock.h,v 1.5 2019/11/29 20:04:52 riastradh Exp $	*/

Index: src/sys/arch/arm/include/rwlock.h
diff -u src/sys/arch/arm/include/rwlock.h:1.9 src/sys/arch/arm/include/rwlock.h:1.10
--- src/sys/arch/arm/include/rwlock.h:1.9	Wed Feb 25 13:52:42 2015
+++ src/sys/arch/arm/include/rwlock.h	Fri Nov 29 20:04:52 2019
@@ -1,61 +1 @@
-/*	$NetBSD: rwlock.h,v 1.9 2015/02/25 13:52:42 joerg Exp $	*/
-
-/*-

CVS commit: src/sys/arch/alpha/include

2019-11-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Nov 29 20:05:08 UTC 2019

Modified Files:
src/sys/arch/alpha/include: lock.h mutex.h

Log Message:
Nix mb_* on alpha.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/include/lock.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/include/mutex.h

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



CVS commit: src/sys/kern

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 19:44:59 UTC 2019

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

Log Message:
Get rid of MUTEX_RECEIVE/MUTEX_GIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/kern/kern_mutex.c

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



CVS commit: src/sys/kern

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 19:44:59 UTC 2019

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

Log Message:
Get rid of MUTEX_RECEIVE/MUTEX_GIVE.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/kern/kern_mutex.c

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

Modified files:

Index: src/sys/kern/kern_mutex.c
diff -u src/sys/kern/kern_mutex.c:1.79 src/sys/kern/kern_mutex.c:1.80
--- src/sys/kern/kern_mutex.c:1.79	Thu May  9 05:00:31 2019
+++ src/sys/kern/kern_mutex.c	Fri Nov 29 19:44:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_mutex.c,v 1.79 2019/05/09 05:00:31 ozaki-r Exp $	*/
+/*	$NetBSD: kern_mutex.c,v 1.80 2019/11/29 19:44:59 ad Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #define	__MUTEX_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.79 2019/05/09 05:00:31 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.80 2019/11/29 19:44:59 ad Exp $");
 
 #include 
 #include 
@@ -168,6 +168,17 @@ do {	\
 } while (/* CONSTCOND */ 0)
 
 /*
+ * Memory barriers.
+ */
+#ifdef __HAVE_ATOMIC_AS_MEMBAR
+#define	MUTEX_MEMBAR_ENTER()
+#define	MUTEX_MEMBAR_EXIT()
+#else
+#define	MUTEX_MEMBAR_ENTER()		membar_enter()
+#define	MUTEX_MEMBAR_EXIT()		membar_exit()
+#endif
+
+/*
  * For architectures that provide 'simple' mutexes: they provide a
  * CAS function that is either MP-safe, or does not need to be MP
  * safe.  Adaptive mutexes on these architectures do not require an
@@ -225,7 +236,7 @@ MUTEX_ACQUIRE(kmutex_t *mtx, uintptr_t c
 	MUTEX_INHERITDEBUG(oldown, mtx->mtx_owner);
 	MUTEX_INHERITDEBUG(newown, oldown);
 	rv = MUTEX_CAS(>mtx_owner, oldown, newown);
-	MUTEX_RECEIVE(mtx);
+	MUTEX_MEMBAR_ENTER();
 	return rv;
 }
 
@@ -234,7 +245,7 @@ MUTEX_SET_WAITERS(kmutex_t *mtx, uintptr
 {
 	int rv;
 	rv = MUTEX_CAS(>mtx_owner, owner, owner | MUTEX_BIT_WAITERS);
-	MUTEX_RECEIVE(mtx);
+	MUTEX_MEMBAR_ENTER();
 	return rv;
 }
 
@@ -243,7 +254,7 @@ MUTEX_RELEASE(kmutex_t *mtx)
 {
 	uintptr_t newown;
 
-	MUTEX_GIVE(mtx);
+	MUTEX_MEMBAR_EXIT();
 	newown = 0;
 	MUTEX_INHERITDEBUG(newown, mtx->mtx_owner);
 	mtx->mtx_owner = newown;



CVS commit: src/sys/kern

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 18:29:45 UTC 2019

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

Log Message:
Don't try to kpreempt a CPU hog unless __HAVE_PREEMPTION (oops).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/sched_4bsd.c

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

Modified files:

Index: src/sys/kern/sched_4bsd.c
diff -u src/sys/kern/sched_4bsd.c:1.37 src/sys/kern/sched_4bsd.c:1.38
--- src/sys/kern/sched_4bsd.c:1.37	Sat Nov 23 22:35:08 2019
+++ src/sys/kern/sched_4bsd.c	Fri Nov 29 18:29:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sched_4bsd.c,v 1.37 2019/11/23 22:35:08 ad Exp $	*/
+/*	$NetBSD: sched_4bsd.c,v 1.38 2019/11/29 18:29:45 ad Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2019
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.37 2019/11/23 22:35:08 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sched_4bsd.c,v 1.38 2019/11/29 18:29:45 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -128,8 +128,12 @@ sched_tick(struct cpu_info *ci)
 		break;
 	case SCHED_RR:
 		/* Force it into mi_switch() to look for other jobs to run. */
+#ifdef __HAVE_PREEMPTION
 		atomic_or_uint(>l_dopreempt, DOPREEMPT_ACTIVE);
 		cpu_need_resched(ci, l, RESCHED_KPREEMPT);
+#else
+		cpu_need_resched(ci, l, RESCHED_UPREEMPT);
+#endif
 		break;
 	default:
 		if (spc->spc_flags & SPCF_SHOULDYIELD) {
@@ -138,8 +142,12 @@ sched_tick(struct cpu_info *ci)
 			 * due to buggy or inefficient code.  Force a
 			 * kernel preemption.
 			 */
+#ifdef __HAVE_PREEMPTION
 			atomic_or_uint(>l_dopreempt, DOPREEMPT_ACTIVE);
 			cpu_need_resched(ci, l, RESCHED_KPREEMPT);
+#else
+			cpu_need_resched(ci, l, RESCHED_UPREEMPT);
+#endif
 		} else if (spc->spc_flags & SPCF_SEENRR) {
 			/*
 			 * The process has already been through a roundrobin



CVS commit: src/sys/kern

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 18:29:45 UTC 2019

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

Log Message:
Don't try to kpreempt a CPU hog unless __HAVE_PREEMPTION (oops).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/sched_4bsd.c

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



CVS commit: src/sys/arch

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 18:27:33 UTC 2019

Modified Files:
src/sys/arch/hppa/hppa: trap.c
src/sys/arch/sh3/include: userret.h
src/sys/arch/sh3/sh3: exception.c
src/sys/arch/sparc/include: userret.h
src/sys/arch/usermode/usermode: trap.c

Log Message:
PR port-sparc/54718 (sparc install hangs since recent scheduler changes)

- userret() must be called every time we return to user, it's not optional.
- If clearing the AST with interrupts off, you must loop over userret().


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/hppa/hppa/trap.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sh3/include/userret.h
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/sh3/sh3/exception.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/userret.h
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/usermode/usermode/trap.c

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



CVS commit: src/sys/arch

2019-11-29 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Nov 29 18:27:33 UTC 2019

Modified Files:
src/sys/arch/hppa/hppa: trap.c
src/sys/arch/sh3/include: userret.h
src/sys/arch/sh3/sh3: exception.c
src/sys/arch/sparc/include: userret.h
src/sys/arch/usermode/usermode: trap.c

Log Message:
PR port-sparc/54718 (sparc install hangs since recent scheduler changes)

- userret() must be called every time we return to user, it's not optional.
- If clearing the AST with interrupts off, you must loop over userret().


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/hppa/hppa/trap.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sh3/include/userret.h
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/sh3/sh3/exception.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/userret.h
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/usermode/usermode/trap.c

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

Modified files:

Index: src/sys/arch/hppa/hppa/trap.c
diff -u src/sys/arch/hppa/hppa/trap.c:1.112 src/sys/arch/hppa/hppa/trap.c:1.113
--- src/sys/arch/hppa/hppa/trap.c:1.112	Thu Nov 21 19:24:00 2019
+++ src/sys/arch/hppa/hppa/trap.c	Fri Nov 29 18:27:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.112 2019/11/21 19:24:00 ad Exp $	*/
+/*	$NetBSD: trap.c,v 1.113 2019/11/29 18:27:32 ad Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.112 2019/11/21 19:24:00 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.113 2019/11/29 18:27:32 ad Exp $");
 
 /* #define INTRDEBUG */
 /* #define TRAPDEBUG */
@@ -202,10 +202,11 @@ userret(struct lwp *l, register_t pc, u_
 {
 	struct proc *p = l->l_proc;
 
-	l->l_md.md_astpending = 0;
-	//curcpu()->ci_data.cpu_nast++;
-
-	mi_userret(l);
+	do {
+		l->l_md.md_astpending = 0;
+		//curcpu()->ci_data.cpu_nast++;
+		mi_userret(l);
+	} while (l->l_md.md_astpending);
 
 	/*
 	 * If profiling, charge recent system time to the trapped pc.

Index: src/sys/arch/sh3/include/userret.h
diff -u src/sys/arch/sh3/include/userret.h:1.14 src/sys/arch/sh3/include/userret.h:1.15
--- src/sys/arch/sh3/include/userret.h:1.14	Wed Nov  2 00:11:59 2016
+++ src/sys/arch/sh3/include/userret.h	Fri Nov 29 18:27:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: userret.h,v 1.14 2016/11/02 00:11:59 pgoyette Exp $	*/
+/*	$NetBSD: userret.h,v 1.15 2019/11/29 18:27:32 ad Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -52,7 +52,16 @@ userret(struct lwp *l)
 {
 
 	/* Invoke MI userret code */
-	mi_userret(l);
+	do {
+		//curcpu()->ci_data.cpu_nast++;
+		l->l_md.md_astpending = 0;
+		mi_userret(l);
+	} while (l->l_md.md_astpending);
+
+	if (l->l_pflag & LP_OWEUPC) {
+		l->l_pflag &= ~LP_OWEUPC;
+		ADDUPROF(l);
+	}
 
 #ifdef PTRACE_HOOKS
 	/* Check if lwp is being PT_STEP'ed */

Index: src/sys/arch/sh3/sh3/exception.c
diff -u src/sys/arch/sh3/sh3/exception.c:1.68 src/sys/arch/sh3/sh3/exception.c:1.69
--- src/sys/arch/sh3/sh3/exception.c:1.68	Thu Nov 21 19:24:01 2019
+++ src/sys/arch/sh3/sh3/exception.c	Fri Nov 29 18:27:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: exception.c,v 1.68 2019/11/21 19:24:01 ad Exp $	*/
+/*	$NetBSD: exception.c,v 1.69 2019/11/29 18:27:33 ad Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.68 2019/11/21 19:24:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.69 2019/11/29 18:27:33 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -471,15 +471,5 @@ ast(struct lwp *l, struct trapframe *tf)
 	KDASSERT(l != NULL);
 	KDASSERT(l->l_md.md_regs == tf);
 
-	while (l->l_md.md_astpending) {
-		//curcpu()->ci_data.cpu_nast++;
-		l->l_md.md_astpending = 0;
-
-		if (l->l_pflag & LP_OWEUPC) {
-			l->l_pflag &= ~LP_OWEUPC;
-			ADDUPROF(l);
-		}
-
-		userret(l);
-	}
+	userret(l);
 }

Index: src/sys/arch/sparc/include/userret.h
diff -u src/sys/arch/sparc/include/userret.h:1.10 src/sys/arch/sparc/include/userret.h:1.11
--- src/sys/arch/sparc/include/userret.h:1.10	Sat Nov 23 16:50:39 2019
+++ src/sys/arch/sparc/include/userret.h	Fri Nov 29 18:27:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: userret.h,v 1.10 2019/11/23 16:50:39 ad Exp $ */
+/*	$NetBSD: userret.h,v 1.11 2019/11/29 18:27:33 ad Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -63,13 +63,14 @@ userret(struct lwp *l, int pc, u_quad_t 
 {
 	struct proc *p = l->l_proc;
 
-	while (cpuinfo.ci_want_ast) {
+	do {
 		cpuinfo.ci_want_ast = 0;
 		mi_userret(l);
-		if (l->l_pflag & LP_OWEUPC) {
-			l->l_pflag &= ~LP_OWEUPC;
-			ADDUPROF(l);
-		}
+	} while (cpuinfo.ci_want_ast);
+
+	if (l->l_pflag & LP_OWEUPC) {
+		l->l_pflag &= ~LP_OWEUPC;
+		ADDUPROF(l);
 	}
 
 	/*

Index: src/sys/arch/usermode/usermode/trap.c
diff -u src/sys/arch/usermode/usermode/trap.c:1.71 src/sys/arch/usermode/usermode/trap.c:1.72
--- 

CVS commit: src/sys/arch/arm/broadcom

2019-11-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov 29 17:44:27 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
Account for the IRQ offset on the bcm2836.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/broadcom/bcm2835_intr.c

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



CVS commit: src/sys/arch/arm/broadcom

2019-11-29 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov 29 17:44:27 UTC 2019

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_intr.c

Log Message:
Account for the IRQ offset on the bcm2836.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/broadcom/bcm2835_intr.c

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

Modified files:

Index: src/sys/arch/arm/broadcom/bcm2835_intr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26 src/sys/arch/arm/broadcom/bcm2835_intr.c:1.27
--- src/sys/arch/arm/broadcom/bcm2835_intr.c:1.26	Thu Nov 28 15:35:51 2019
+++ src/sys/arch/arm/broadcom/bcm2835_intr.c	Fri Nov 29 17:44:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $	*/
+/*	$NetBSD: bcm2835_intr.c,v 1.27 2019/11/29 17:44:27 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012, 2015, 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.26 2019/11/28 15:35:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_intr.c,v 1.27 2019/11/29 17:44:27 thorpej Exp $");
 
 #define _INTR_PRIVATE
 
@@ -467,15 +467,16 @@ bcm2835_icu_fdt_establish(device_t dev, 
 	struct bcm2835icu_irq *firq;
 	struct bcm2835icu_irqhandler *firqh;
 	int iflags = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
-	int irq;
+	int irq, irqidx;
 
 	irq = bcm2835_icu_fdt_decode_irq(specifier);
 	if (irq == -1)
 		return NULL;
+	irqidx = irq - BCM2835_INT_BASE;
 
-	KASSERT(irq < BCM2835_NIRQ);
+	KASSERT(irqidx < BCM2835_NIRQ);
 
-	firq = sc->sc_irq[irq];
+	firq = sc->sc_irq[irqidx];
 	if (firq == NULL) {
 		firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
 		firq->intr_sc = sc;
@@ -496,7 +497,7 @@ bcm2835_icu_fdt_establish(device_t dev, 
 			kmem_free(firq, sizeof(*firq));
 			return NULL;
 		}
-		sc->sc_irq[irq] = firq;
+		sc->sc_irq[irqidx] = firq;
 	} else {
 		if (firq->intr_arg == NULL || arg == NULL) {
 			device_printf(dev,
@@ -549,6 +550,7 @@ bcm2835_icu_fdt_disestablish(device_t de
 			continue;
 
 		KASSERT(firq->intr_refcnt > 0);
+		KASSERT(n == (firq->intr_irq - BCM2835_INT_BASE));
 
 		/* XXX see above */
 		if (firq->intr_refcnt > 1)
@@ -560,7 +562,7 @@ bcm2835_icu_fdt_disestablish(device_t de
 		TAILQ_REMOVE(>intr_handlers, firqh, ih_next);
 		kmem_free(firqh, sizeof(*firqh));
 
-		sc->sc_irq[firq->intr_irq] = NULL;
+		sc->sc_irq[n] = NULL;
 		kmem_free(firq, sizeof(*firq));
 
 		return;



CVS commit: src/sys/netatalk

2019-11-29 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Nov 29 17:40:16 UTC 2019

Modified Files:
src/sys/netatalk: ddp_usrreq.c

Log Message:
Add sanity check, only sat_len bytes got copied in, the rest is
uninitialized. Found by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/netatalk/ddp_usrreq.c

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

Modified files:

Index: src/sys/netatalk/ddp_usrreq.c
diff -u src/sys/netatalk/ddp_usrreq.c:1.73 src/sys/netatalk/ddp_usrreq.c:1.74
--- src/sys/netatalk/ddp_usrreq.c:1.73	Sun Feb 24 07:20:33 2019
+++ src/sys/netatalk/ddp_usrreq.c	Fri Nov 29 17:40:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ddp_usrreq.c,v 1.73 2019/02/24 07:20:33 maxv Exp $	 */
+/*	$NetBSD: ddp_usrreq.c,v 1.74 2019/11/29 17:40:16 maxv Exp $	 */
 
 /*
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.73 2019/02/24 07:20:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.74 2019/11/29 17:40:16 maxv Exp $");
 
 #include "opt_mbuftrace.h"
 #include "opt_atalk.h"
@@ -97,6 +97,8 @@ at_pcbsetaddr(struct ddpcb *ddp, struct 
 
 		if (sat->sat_family != AF_APPLETALK)
 			return (EAFNOSUPPORT);
+		if (sat->sat_len != sizeof(*sat))
+			return EINVAL;
 
 		if (sat->sat_addr.s_node != ATADDR_ANYNODE ||
 		sat->sat_addr.s_net != ATADDR_ANYNET) {



CVS commit: src/sys/netatalk

2019-11-29 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Nov 29 17:40:16 UTC 2019

Modified Files:
src/sys/netatalk: ddp_usrreq.c

Log Message:
Add sanity check, only sat_len bytes got copied in, the rest is
uninitialized. Found by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/netatalk/ddp_usrreq.c

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



CVS commit: src/sys/arch/arm/arm32

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:33:43 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: fault.c

Log Message:
if Thumb-32 bit instruction located on a page boundariy, also need to consider 
the pc + 2 address.

Fix PR/54720. more detail and PoC are descrived in the PR.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/arm/arm32/fault.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/arm/arm32/fault.c
diff -u src/sys/arch/arm/arm32/fault.c:1.108 src/sys/arch/arm/arm32/fault.c:1.109
--- src/sys/arch/arm/arm32/fault.c:1.108	Sat Apr  6 03:06:25 2019
+++ src/sys/arch/arm/arm32/fault.c	Fri Nov 29 17:33:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fault.c,v 1.108 2019/04/06 03:06:25 thorpej Exp $	*/
+/*	$NetBSD: fault.c,v 1.109 2019/11/29 17:33:43 ryo Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -81,7 +81,7 @@
 #include "opt_kgdb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.108 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.109 2019/11/29 17:33:43 ryo Exp $");
 
 #include 
 #include 
@@ -838,6 +838,9 @@ prefetch_abort_handler(trapframe_t *tf)
 	UVMHIST_LOG(maphist, " (pc=0x%jx, l=0x%#jx, tf=0x%#jx)",
 	fault_pc, (uintptr_t)l, (uintptr_t)tf, 0);
 
+#ifdef THUMB_CODE
+ recheck:
+#endif
 	/* Ok validate the address, can only execute in USER space */
 	if (__predict_false(fault_pc >= VM_MAXUSER_ADDRESS ||
 	(fault_pc < VM_MIN_ADDRESS && vector_page == ARM_VECTORS_LOW))) {
@@ -897,6 +900,18 @@ do_trapsignal:
 	call_trapsignal(l, tf, );
 
 out:
+
+#ifdef THUMB_CODE
+#define THUMB_32BIT(hi) (((hi) & 0xe000) == 0xe000 && ((hi) & 0x1800))
+	/* thumb-32 instruction was located on page boundary? */
+	if ((tf->tf_spsr & PSR_T_bit) &&
+	((fault_pc & PAGE_MASK) == (PAGE_SIZE - THUMB_INSN_SIZE)) &&
+	THUMB_32BIT(*(uint16_t *)tf->tf_pc)) {
+		fault_pc = tf->tf_pc + THUMB_INSN_SIZE;
+		goto recheck;
+	}
+#endif /* THUMB_CODE */
+
 	KASSERT(!TRAP_USERMODE(tf) || VALID_R15_PSR(tf->tf_pc, tf->tf_spsr));
 	userret(l);
 }



CVS commit: src/sys/arch/arm/arm32

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:33:43 UTC 2019

Modified Files:
src/sys/arch/arm/arm32: fault.c

Log Message:
if Thumb-32 bit instruction located on a page boundariy, also need to consider 
the pc + 2 address.

Fix PR/54720. more detail and PoC are descrived in the PR.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/arm/arm32/fault.c

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



CVS commit: src/sys/net

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:29:32 UTC 2019

Modified Files:
src/sys/net: bpf.c

Log Message:
bpf can send a packet greater than MCLBYTES (JumboFrame) using multiple mbuf.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/net/bpf.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/bpf.c
diff -u src/sys/net/bpf.c:1.231 src/sys/net/bpf.c:1.232
--- src/sys/net/bpf.c:1.231	Fri Sep 13 06:39:29 2019
+++ src/sys/net/bpf.c	Fri Nov 29 17:29:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.231 2019/09/13 06:39:29 maxv Exp $	*/
+/*	$NetBSD: bpf.c,v 1.232 2019/11/29 17:29:31 ryo Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.231 2019/09/13 06:39:29 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.232 2019/11/29 17:29:31 ryo Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -321,7 +321,7 @@ static int
 bpf_movein(struct uio *uio, int linktype, uint64_t mtu, struct mbuf **mp,
 	   struct sockaddr *sockp)
 {
-	struct mbuf *m;
+	struct mbuf *m, *m0, *n;
 	int error;
 	size_t len;
 	size_t hlen;
@@ -395,15 +395,7 @@ bpf_movein(struct uio *uio, int linktype
 	if (len - hlen > mtu)
 		return (EMSGSIZE);
 
-	/*
-	 * XXX Avoid complicated buffer chaining ---
-	 * bail if it won't fit in a single mbuf.
-	 * (Take into account possible alignment bytes)
-	 */
-	if (len + align > MCLBYTES)
-		return (EIO);
-
-	m = m_gethdr(M_WAIT, MT_DATA);
+	m0 = m = m_gethdr(M_WAIT, MT_DATA);
 	m_reset_rcvif(m);
 	m->m_pkthdr.len = (int)(len - hlen);
 	if (len + align > MHLEN) {
@@ -415,25 +407,39 @@ bpf_movein(struct uio *uio, int linktype
 	}
 
 	/* Insure the data is properly aligned */
-	if (align > 0) {
+	if (align > 0)
 		m->m_data += align;
-		m->m_len -= (int)align;
+
+	for (;;) {
+		len = M_TRAILINGSPACE(m);
+		if (len > uio->uio_resid)
+			len = uio->uio_resid;
+		error = uiomove(mtod(m, void *), len, uio);
+		if (error)
+			goto bad;
+		m->m_len = len;
+
+		if (uio->uio_resid == 0)
+			break;
+
+		n = m_get(M_WAIT, MT_DATA);
+		m_clget(n, M_WAIT);	/* if fails, there is no problem */
+		m->m_next = n;
+		m = n;
 	}
 
-	error = uiomove(mtod(m, void *), len, uio);
-	if (error)
-		goto bad;
 	if (hlen != 0) {
-		memcpy(sockp->sa_data, mtod(m, void *), hlen);
-		m->m_data += hlen; /* XXX */
-		len -= hlen;
+		/* move link level header in the top of mbuf to sa_data */
+		memcpy(sockp->sa_data, mtod(m0, void *), hlen);
+		m0->m_data += hlen;
+		m0->m_len -= hlen;
 	}
-	m->m_len = (int)len;
-	*mp = m;
+
+	*mp = m0;
 	return (0);
 
 bad:
-	m_freem(m);
+	m_freem(m0);
 	return (error);
 }
 



CVS commit: src/sys/net

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:29:32 UTC 2019

Modified Files:
src/sys/net: bpf.c

Log Message:
bpf can send a packet greater than MCLBYTES (JumboFrame) using multiple mbuf.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/net/bpf.c

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



CVS commit: src/sys/arch/arm/imx

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:20:30 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c

Log Message:
set the multicast filter properly.

don't always IFF_ALLMULTI if multicast is configured.
fix the handling of GAUR and GALR.


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

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



CVS commit: src/sys/arch/arm/imx

2019-11-29 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Nov 29 17:20:30 UTC 2019

Modified Files:
src/sys/arch/arm/imx: if_enet.c

Log Message:
set the multicast filter properly.

don't always IFF_ALLMULTI if multicast is configured.
fix the handling of GAUR and GALR.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/imx/if_enet.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/arm/imx/if_enet.c
diff -u src/sys/arch/arm/imx/if_enet.c:1.28 src/sys/arch/arm/imx/if_enet.c:1.29
--- src/sys/arch/arm/imx/if_enet.c:1.28	Tue Nov 12 05:09:29 2019
+++ src/sys/arch/arm/imx/if_enet.c	Fri Nov 29 17:20:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet.c,v 1.28 2019/11/12 05:09:29 hkenken Exp $	*/
+/*	$NetBSD: if_enet.c,v 1.29 2019/11/29 17:20:30 ryo Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu 
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.28 2019/11/12 05:09:29 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.29 2019/11/29 17:20:30 ryo Exp $");
 
 #include "vlan.h"
 
@@ -714,15 +714,14 @@ enet_setmulti(struct enet_softc *sc)
 	struct ifnet *ifp = >ec_if;
 	struct ether_multi *enm;
 	struct ether_multistep step;
-	int promisc;
-	uint32_t crc;
+	uint32_t crc, hashidx;
 	uint32_t gaddr[2];
 
-	promisc = 0;
-	if ((ifp->if_flags & IFF_PROMISC) || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
-			promisc = 1;
+	if (ifp->if_flags & IFF_PROMISC) {
+		/* receive all unicast packet */
+		ENET_REG_WRITE(sc, ENET_IAUR, 0x);
+		ENET_REG_WRITE(sc, ENET_IALR, 0x);
+		/* receive all multicast packet */
 		gaddr[0] = gaddr[1] = 0x;
 	} else {
 		gaddr[0] = gaddr[1] = 0;
@@ -730,25 +729,38 @@ enet_setmulti(struct enet_softc *sc)
 		ETHER_LOCK(ec);
 		ETHER_FIRST_MULTI(step, ec, enm);
 		while (enm != NULL) {
+			if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
+			ETHER_ADDR_LEN)) {
+/*
+ * if specified by range, give up setting hash,
+ * and fallback to allmulti.
+ */
+gaddr[0] = gaddr[1] = 0x;
+break;
+			}
+
 			crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
-			gaddr[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+			hashidx = __SHIFTOUT(crc, __BITS(30,26));
+			gaddr[__SHIFTOUT(crc, __BIT(31))] |= __BIT(hashidx);
+
 			ETHER_NEXT_MULTI(step, enm);
 		}
 		ETHER_UNLOCK(ec);
-	}
-
-	ENET_REG_WRITE(sc, ENET_GAUR, gaddr[0]);
-	ENET_REG_WRITE(sc, ENET_GALR, gaddr[1]);
 
-	if (promisc) {
-		/* match all packet */
-		ENET_REG_WRITE(sc, ENET_IAUR, 0x);
-		ENET_REG_WRITE(sc, ENET_IALR, 0x);
-	} else {
-		/* don't match any packet */
+		/* dont't receive any unicast packet (except own address) */
 		ENET_REG_WRITE(sc, ENET_IAUR, 0);
 		ENET_REG_WRITE(sc, ENET_IALR, 0);
 	}
+
+	if (gaddr[0] == 0x && gaddr[1] == 0x)
+		ifp->if_flags |= IFF_ALLMULTI;
+	else
+		ifp->if_flags &= ~IFF_ALLMULTI;
+
+	/* receive multicast packets according to multicast filter */
+	ENET_REG_WRITE(sc, ENET_GAUR, gaddr[1]);
+	ENET_REG_WRITE(sc, ENET_GALR, gaddr[0]);
+
 }
 
 static void



CVS commit: src/distrib/notes/common

2019-11-29 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Nov 29 16:33:44 UTC 2019

Modified Files:
src/distrib/notes/common: macros

Log Message:
Oops, fix typo in .el in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/distrib/notes/common/macros

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



CVS commit: src/distrib/notes/common

2019-11-29 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Nov 29 16:33:44 UTC 2019

Modified Files:
src/distrib/notes/common: macros

Log Message:
Oops, fix typo in .el in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/distrib/notes/common/macros

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/macros
diff -u src/distrib/notes/common/macros:1.52 src/distrib/notes/common/macros:1.53
--- src/distrib/notes/common/macros:1.52	Fri Nov 29 16:15:09 2019
+++ src/distrib/notes/common/macros	Fri Nov 29 16:33:44 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: macros,v 1.52 2019/11/29 16:15:09 uwe Exp $
+.\"	$NetBSD: macros,v 1.53 2019/11/29 16:33:44 uwe Exp $
 .\"
 .\" Copyright (c) 1999-2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -356,7 +356,7 @@
 ..
 .\}
 .\"  .Tc and .Ti for text and postscript
-.ei \{\
+.el \{\
 .de Ti
 \h'3n*\\$1u' \\$3\a\\$2
 ..



CVS commit: src/distrib/notes/common

2019-11-29 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Nov 29 16:15:09 UTC 2019

Modified Files:
src/distrib/notes/common: macros

Log Message:
Provide separate .Tc and .Ti definitions for HTML and non-HTML.

Change HTML definition of .Tc to enclose TOC into simple .nf/.fi that
also give us  in the output.

This frees our hands to redefine non-HTML case to use better
formatting (work in progress).


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/distrib/notes/common/macros

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/macros
diff -u src/distrib/notes/common/macros:1.51 src/distrib/notes/common/macros:1.52
--- src/distrib/notes/common/macros:1.51	Thu Nov 28 19:59:48 2019
+++ src/distrib/notes/common/macros	Fri Nov 29 16:15:09 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: macros,v 1.51 2019/11/28 19:59:48 uwe Exp $
+.\"	$NetBSD: macros,v 1.52 2019/11/29 16:15:09 uwe Exp $
 .\"
 .\" Copyright (c) 1999-2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -342,11 +342,23 @@
 .if rHTML 
 .if dTOC .mktoc \\n[To-toc-level] \\$@
 ..
-.de Ti
+.\"  .Tc and .Ti for HTML
 .ie rHTML \{\
+.de Ti
 \h'3n*\\$1u' \\$3
+..
+.de Tc
+.tm ...reading \*[toc-file]
+.nf
+.\" Use so-real here because toc-file is in objdir not .CURDIR
+.so-real \*[toc-file]
+.fi
+..
 .\}
-.el \h'3n*\\$1u' \\$3\a\\$2
+.\"  .Tc and .Ti for text and postscript
+.ei \{\
+.de Ti
+\h'3n*\\$1u' \\$3\a\\$2
 ..
 .de Tc
 .Bd -literal
@@ -357,6 +369,7 @@
 .so-real \*[toc-file]
 .Ed
 ..
+.\}
 .
 .
 .\"	  MISC  



CVS commit: src/distrib/notes/common

2019-11-29 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Nov 29 16:15:09 UTC 2019

Modified Files:
src/distrib/notes/common: macros

Log Message:
Provide separate .Tc and .Ti definitions for HTML and non-HTML.

Change HTML definition of .Tc to enclose TOC into simple .nf/.fi that
also give us  in the output.

This frees our hands to redefine non-HTML case to use better
formatting (work in progress).


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/distrib/notes/common/macros

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



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:24:22 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 DisplayPort clocks


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/rockchip/rk3399_cru.c

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



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:24:22 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 DisplayPort clocks


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/rockchip/rk3399_cru.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/arm/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.15 src/sys/arch/arm/rockchip/rk3399_cru.c:1.16
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.15	Fri Nov 29 15:20:28 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Fri Nov 29 15:24:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.16 2019/11/29 15:24:21 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.16 2019/11/29 15:24:21 jakllsch Exp $");
 
 #include 
 #include 
@@ -353,6 +353,7 @@ static const char * mux_pll_src_cpll_gpl
 static const char * mux_pll_src_cpll_gpll_upll_parents[] = { "cpll", "gpll", "upll" };
 static const char * mux_pll_src_cpll_gpll_npll_24m_parents[] = { "cpll", "gpll", "npll", "xin24m" };
 static const char * mux_pll_src_cpll_gpll_npll_ppll_upll_24m_parents[] = { "cpll", "gpll", "npll", "ppll", "upll", "xin24m" };
+static const char * mux_pll_src_npll_cpll_gpll_parents[] = { "npll", "cpll", "gpll" };
 static const char * mux_pll_src_vpll_cpll_gpll_parents[] = { "vpll", "cpll", "gpll" };
 static const char * mux_pll_src_vpll_cpll_gpll_npll_parents[] = { "vpll", "cpll", "gpll", "npll" };
 static const char * mux_aclk_perilp0_parents[] = { "cpll_aclk_perilp0_src", "gpll_aclk_perilp0_src" };
@@ -1005,6 +1006,15 @@ static struct rk_cru_clk rk3399_cru_clks
 	RK_GATE(RK3399_PCLK_EDP_NOC, "pclk_edp_noc", "pclk_edp", CLKGATE_CON(32), 12),
 	RK_GATE(RK3399_PCLK_EDP_CTRL, "pclk_edp_ctrl", "pclk_edp", CLKGATE_CON(32), 13),
 
+	RK_COMPOSITE(RK3399_SCLK_DP_CORE, "clk_dp_core", mux_pll_src_npll_cpll_gpll_parents,
+		 CLKSEL_CON(46),	/* muxdiv_reg */
+		 __BITS(7,6),	/* mux_mask */
+		 __BITS(4,0),	/* div_mask */
+		 CLKGATE_CON(11),	/* gate_reg */
+		 __BIT(8),		/* gate_mask */
+		 0),
+	RK_GATE(RK3399_PCLK_DP_CTRL, "pclk_dp_ctrl", "pclk_hdcp", CLKGATE_CON(29), 7),
+
 };
 
 static const struct rk3399_init_param {



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:20:28 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 eDP clocks


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/rockchip/rk3399_cru.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/arm/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.14 src/sys/arch/arm/rockchip/rk3399_cru.c:1.15
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.14	Fri Nov 29 15:00:20 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Fri Nov 29 15:20:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.15 2019/11/29 15:20:28 jakllsch Exp $");
 
 #include 
 #include 
@@ -993,6 +993,18 @@ static struct rk_cru_clk rk3399_cru_clks
 		 CLKGATE_CON(8),	/* gate_reg */
 		 __BIT(12),		/* gate_mask */
 		 RK_COMPOSITE_SET_RATE_PARENT),
+
+	/* eDP */
+	RK_COMPOSITE(RK3399_PCLK_EDP, "pclk_edp", mux_pll_src_cpll_gpll_parents,
+		 CLKSEL_CON(44),	/* muxdiv_reg */
+		 __BIT(15),		/* mux_mask */
+		 __BITS(13,8),	/* div_mask */
+		 CLKGATE_CON(11),	/* gate_reg */
+		 __BIT(11),		/* gate_mask */
+		 0),
+	RK_GATE(RK3399_PCLK_EDP_NOC, "pclk_edp_noc", "pclk_edp", CLKGATE_CON(32), 12),
+	RK_GATE(RK3399_PCLK_EDP_CTRL, "pclk_edp_ctrl", "pclk_edp", CLKGATE_CON(32), 13),
+
 };
 
 static const struct rk3399_init_param {



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:20:28 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
add RK3399 eDP clocks


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/rockchip/rk3399_cru.c

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



CVS commit: src/sys/dev/pci

2019-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 29 15:17:14 UTC 2019

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

Log Message:
Set if_baudrate.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/if_mcx.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/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.8 src/sys/dev/pci/if_mcx.c:1.9
--- src/sys/dev/pci/if_mcx.c:1.8	Thu Nov 28 16:02:07 2019
+++ src/sys/dev/pci/if_mcx.c	Fri Nov 29 15:17:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.8 2019/11/28 16:02:07 msaitoh Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.9 2019/11/29 15:17:14 msaitoh Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -6653,6 +6653,7 @@ mcx_port_change(struct work *wk, void *x
 	struct ifnet *ifp = >sc_ec.ec_if;
 	struct mcx_reg_paos paos;
 	int link_state = LINK_STATE_DOWN;
+	struct ifmediareq ifmr;
 
 	memset(, 0, sizeof(paos));
 	paos.rp_local_port = 1;
@@ -6660,6 +6661,8 @@ mcx_port_change(struct work *wk, void *x
 	sizeof(paos)) == 0) {
 		if (paos.rp_oper_status == MCX_REG_PAOS_OPER_STATUS_UP)
 			link_state = LINK_STATE_UP;
+		mcx_media_status(ifp, );
+		ifp->if_baudrate = ifmedia_baudrate(ifmr.ifm_active);
 	}
 
 	if (link_state != ifp->if_link_state) {



CVS commit: src/sys/dev/pci

2019-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 29 15:17:14 UTC 2019

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

Log Message:
Set if_baudrate.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/if_mcx.c

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



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:00:20 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
fix copy/paste error in mux_pll_src_cpll_gpll_ppll_parents[]


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/rockchip/rk3399_cru.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/arm/rockchip/rk3399_cru.c
diff -u src/sys/arch/arm/rockchip/rk3399_cru.c:1.13 src/sys/arch/arm/rockchip/rk3399_cru.c:1.14
--- src/sys/arch/arm/rockchip/rk3399_cru.c:1.13	Sat Nov 16 13:23:13 2019
+++ src/sys/arch/arm/rockchip/rk3399_cru.c	Fri Nov 29 15:00:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_cru.c,v 1.13 2019/11/16 13:23:13 jmcneill Exp $ */
+/* $NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.13 2019/11/16 13:23:13 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk3399_cru.c,v 1.14 2019/11/29 15:00:20 jakllsch Exp $");
 
 #include 
 #include 
@@ -349,7 +349,7 @@ static const char * armclkb_parents[] = 
 static const char * mux_clk_tsadc_parents[] = { "xin24m", "xin32k" };
 static const char * mux_pll_src_cpll_gpll_parents[] = { "cpll", "gpll" };
 static const char * mux_pll_src_cpll_gpll_npll_parents[] = { "cpll", "gpll", "npll" };
-static const char * mux_pll_src_cpll_gpll_ppll_parents[] = { "cpll", "gpll", "npll" };
+static const char * mux_pll_src_cpll_gpll_ppll_parents[] = { "cpll", "gpll", "ppll" };
 static const char * mux_pll_src_cpll_gpll_upll_parents[] = { "cpll", "gpll", "upll" };
 static const char * mux_pll_src_cpll_gpll_npll_24m_parents[] = { "cpll", "gpll", "npll", "xin24m" };
 static const char * mux_pll_src_cpll_gpll_npll_ppll_upll_24m_parents[] = { "cpll", "gpll", "npll", "ppll", "upll", "xin24m" };



CVS commit: src/sys/arch/arm/rockchip

2019-11-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 29 15:00:20 UTC 2019

Modified Files:
src/sys/arch/arm/rockchip: rk3399_cru.c

Log Message:
fix copy/paste error in mux_pll_src_cpll_gpll_ppll_parents[]


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/rockchip/rk3399_cru.c

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



CVS commit: src/sys/dev/usb

2019-11-29 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Nov 29 14:15:42 UTC 2019

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

Log Message:
Preserve the toggleCarry bit in the Endpoint Descriptor in
ohci_abort_xfer().  Fixes the OHCI part of PR kern/50278.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/dev/usb/ohci.c

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



CVS commit: src/sys/dev/usb

2019-11-29 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Nov 29 14:15:42 UTC 2019

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

Log Message:
Preserve the toggleCarry bit in the Endpoint Descriptor in
ohci_abort_xfer().  Fixes the OHCI part of PR kern/50278.


To generate a diff of this commit:
cvs rdiff -u -r1.291 -r1.292 src/sys/dev/usb/ohci.c

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

Modified files:

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.291 src/sys/dev/usb/ohci.c:1.292
--- src/sys/dev/usb/ohci.c:1.291	Fri Nov 29 14:13:04 2019
+++ src/sys/dev/usb/ohci.c	Fri Nov 29 14:15:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $	*/
+/*	$NetBSD: ohci.c,v 1.292 2019/11/29 14:15:41 gson Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.292 2019/11/29 14:15:41 gson Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2349,7 +2349,9 @@ ohci_abort_xfer(struct usbd_xfer *xfer, 
 	if (hit) {
 		DPRINTFN(1, "set hd=0x%08jx, tl=0x%08jx",  (int)p->physaddr,
 		(int)O32TOH(sed->ed.ed_tailp), 0, 0);
-		sed->ed.ed_headp = HTOO32(p->physaddr); /* unlink TDs */
+		/* unlink TDs, preserving toggle carry */
+		sed->ed.ed_headp = HTOO32(p->physaddr |
+		(O32TOH(sed->ed.ed_headp) & OHCI_TOGGLECARRY));
 		usb_syncmem(>dma,
 		sed->offs + offsetof(ohci_ed_t, ed_headp),
 		sizeof(sed->ed.ed_headp),



CVS commit: src/sys/dev/usb

2019-11-29 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Nov 29 14:13:04 UTC 2019

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

Log Message:
Preserve the toggleCarry bit in the Endpoint Descriptor when handling
a DataUnderrun condition.  Fixes PR kern/54070.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/dev/usb/ohci.c

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



CVS commit: src/sys/dev/usb

2019-11-29 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Nov 29 14:13:04 UTC 2019

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

Log Message:
Preserve the toggleCarry bit in the Endpoint Descriptor when handling
a DataUnderrun condition.  Fixes PR kern/54070.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/dev/usb/ohci.c

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

Modified files:

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.290 src/sys/dev/usb/ohci.c:1.291
--- src/sys/dev/usb/ohci.c:1.290	Sun Aug 11 22:55:03 2019
+++ src/sys/dev/usb/ohci.c	Fri Nov 29 14:13:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.290 2019/08/11 22:55:03 mrg Exp $	*/
+/*	$NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.290 2019/08/11 22:55:03 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.291 2019/11/29 14:13:04 gson Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1515,8 +1515,9 @@ ohci_softintr(void *v)
 
 			ohci_soft_ed_t *sed = opipe->sed;
 
-			/* clear halt and TD chain */
-			sed->ed.ed_headp = HTOO32(p->physaddr);
+			/* clear halt and TD chain, preserving toggle carry */
+			sed->ed.ed_headp = HTOO32(p->physaddr |
+			(O32TOH(sed->ed.ed_headp) & OHCI_TOGGLECARRY));
 			usb_syncmem(>dma,
 			sed->offs + offsetof(ohci_ed_t, ed_headp),
 			sizeof(sed->ed.ed_headp),



CVS commit: src/sys/dev/i2c

2019-11-29 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 29 12:42:54 UTC 2019

Modified Files:
src/sys/dev/i2c: motoi2c.c

Log Message:
Add wait for stop condition.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/motoi2c.c

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



CVS commit: src/sys/dev/i2c

2019-11-29 Thread Kenichi Hashimoto
Module Name:src
Committed By:   hkenken
Date:   Fri Nov 29 12:42:54 UTC 2019

Modified Files:
src/sys/dev/i2c: motoi2c.c

Log Message:
Add wait for stop condition.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/motoi2c.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/i2c/motoi2c.c
diff -u src/sys/dev/i2c/motoi2c.c:1.5 src/sys/dev/i2c/motoi2c.c:1.6
--- src/sys/dev/i2c/motoi2c.c:1.5	Mon Aug  5 12:21:00 2019
+++ src/sys/dev/i2c/motoi2c.c	Fri Nov 29 12:42:53 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: motoi2c.c,v 1.5 2019/08/05 12:21:00 hkenken Exp $ */
+/* $NetBSD: motoi2c.c,v 1.6 2019/11/29 12:42:53 hkenken Exp $ */
 
 /*-
  * Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.5 2019/08/05 12:21:00 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motoi2c.c,v 1.6 2019/11/29 12:42:53 hkenken Exp $");
 
 #if defined(__arm__) || defined(__aarch64__)
 #include "opt_fdt.h"
@@ -163,6 +163,24 @@ motoi2c_release_bus(void *v, int flags)
 	mutex_exit(>sc_buslock);
 }
 
+static int
+motoi2c_stop_wait(struct motoi2c_softc *sc)
+{
+	u_int timo;
+	int error = 0;
+
+	timo = 1000;
+	while ((I2C_READ(I2CSR) & SR_MBB) != 0 && --timo)
+		DELAY(1);
+
+	if (timo == 0) {
+		DPRINTF(("%s: timeout (sr=%#x)\n", __func__, I2C_READ(I2CSR)));
+		error = ETIMEDOUT;
+	}
+
+	return error;
+}
+
 /* busy waiting for byte data transfer completion */
 static int
 motoi2c_busy_wait(struct motoi2c_softc *sc, uint8_t cr)
@@ -224,15 +242,9 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 
 	if ((cr & CR_MSTA) == 0 && (sr & SR_MBB) != 0) {
 		/* wait for bus becoming available */
-		u_int timo = 100;
-		do {
-			DELAY(10);
-		} while (--timo > 0 && ((sr = I2C_READ(I2CSR)) & SR_MBB) != 0);
-
-		if (timo == 0) {
-			DPRINTF(("%s: bus is busy (%#x)\n", __func__, sr));
+		error = motoi2c_stop_wait(sc);
+		if (error)
 			return ETIMEDOUT;
-		}
 	}
 
 	/* reset interrupt and arbitration-lost flags (all others are RO) */
@@ -240,12 +252,10 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 	sr = I2C_READ(I2CSR);
 
 	/*
-	 * Generate start (or restart) condition
+	 * Generate start condition
 	 */
-	/* CR_RTSA is write-only and transitory */
-	uint8_t rsta = (cr & CR_MSTA ? CR_RSTA : 0);
 	cr = CR_MEN | CR_MTX | CR_MSTA;
-	I2C_WRITE(I2CCR, cr | rsta);
+	I2C_WRITE(I2CCR, cr);
 
 	DPRINTF(("%s: started: sr=%#x cr=%#x/%#x\n",
 	__func__, I2C_READ(I2CSR), cr, I2C_READ(I2CCR)));
@@ -339,14 +349,14 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 cr |= CR_TXAK;
 I2C_WRITE(I2CCR, cr);
 			} else if (i == datalen - 1 && I2C_OP_STOP_P(op)) {
-cr = CR_MEN;
+cr = CR_MEN | CR_TXAK;
 I2C_WRITE(I2CCR, cr);
 			}
 			*dataptr++ = I2C_READ(I2CDR);
 		}
 		if (datalen == 0) {
 			if (I2C_OP_STOP_P(op)) {
-cr = CR_MEN;
+cr = CR_MEN | CR_TXAK;
 I2C_WRITE(I2CCR, cr);
 			}
 			(void)I2C_READ(I2CDR);	/* dummy read */
@@ -378,6 +388,7 @@ motoi2c_exec(void *v, i2c_op_t op, i2c_a
 	if (error || (cr & CR_TXAK) || ((cr & CR_MSTA) && I2C_OP_STOP_P(op))) {
 		cr = CR_MEN;
 		I2C_WRITE(I2CCR, cr);
+		motoi2c_stop_wait(sc);
 		DPRINTF(("%s: stopping: cr=%#x/%#x\n", __func__,
 		cr, I2C_READ(I2CCR)));
 	}



CVS commit: src/sys/arch/powerpc/include

2019-11-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 29 12:04:32 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: ptrace.h

Log Message:
Add illegal asm and breakpoint


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/include/ptrace.h

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



CVS commit: src/sys/arch/powerpc/include

2019-11-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 29 12:04:32 UTC 2019

Modified Files:
src/sys/arch/powerpc/include: ptrace.h

Log Message:
Add illegal asm and breakpoint


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/include/ptrace.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/powerpc/include/ptrace.h
diff -u src/sys/arch/powerpc/include/ptrace.h:1.14 src/sys/arch/powerpc/include/ptrace.h:1.15
--- src/sys/arch/powerpc/include/ptrace.h:1.14	Tue Jun 18 21:18:12 2019
+++ src/sys/arch/powerpc/include/ptrace.h	Fri Nov 29 12:04:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.14 2019/06/18 21:18:12 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.15 2019/11/29 12:04:32 martin Exp $	*/
 
 #ifndef _POWERPC_PTRACE_H
 #define	_POWERPC_PTRACE_H
@@ -71,4 +71,10 @@ int procfs_machdep_validvecregs(struct l
 #endif /* ALTIVEC || PPC_HAVE_SPE */
 #endif /* _KERNEL */
 
+#define PTRACE_ILLEGAL_ASM	__asm __volatile (".long 0" : : : "memory")
+
+#define PTRACE_BREAKPOINT	((const uint8_t[]) { 0x7f, 0xe0, 0x00, 0x08 })
+#define PTRACE_BREAKPOINT_ASM	__asm __volatile("trap")
+#define PTRACE_BREAKPOINT_SIZE	4
+
 #endif /* _POWERPC_PTRACE_H */



Re: CVS commit: src/external/apache2/llvm

2019-11-29 Thread maya
On Thu, Nov 28, 2019 at 11:01:22PM +, Joerg Sonnenberger wrote:
> Log Message:
> Use -fno-strict-aliasing unconditionally for the cross compiler.

What's the context for that?

Thanks!


CVS commit: src/sys/opencrypto

2019-11-29 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Fri Nov 29 08:30:31 UTC 2019

Modified Files:
src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): accept CRYPTO_SHA2_384_HMAC and CRYPTO_SHA2_512_HMAC.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/opencrypto/cryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.101 src/sys/opencrypto/cryptodev.c:1.102
--- src/sys/opencrypto/cryptodev.c:1.101	Thu Jun 13 02:02:45 2019
+++ src/sys/opencrypto/cryptodev.c	Fri Nov 29 08:30:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.101 2019/06/13 02:02:45 christos Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.102 2019/11/29 08:30:30 hikaru Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.101 2019/06/13 02:02:45 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.102 2019/11/29 08:30:30 hikaru Exp $");
 
 #include 
 #include 
@@ -1644,6 +1644,12 @@ cryptodev_session(struct fcrypt *fcr, st
 			return EINVAL;
 		}
 		break;
+	case CRYPTO_SHA2_384_HMAC:
+		thash = _hash_hmac_sha2_384;
+		break;
+	case CRYPTO_SHA2_512_HMAC:
+		thash = _hash_hmac_sha2_512;
+		break;
 	case CRYPTO_RIPEMD160_HMAC:
 		thash = _hash_hmac_ripemd_160;
 		break;



  1   2   >