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

2023-02-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Feb 23 05:21:27 UTC 2023

Added Files:
src/usr.bin/make/unit-tests: meta-ignore.inc

Log Message:
Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR


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

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/meta-ignore.inc
diff -u /dev/null src/usr.bin/make/unit-tests/meta-ignore.inc:1.1
--- /dev/null	Thu Feb 23 05:21:27 2023
+++ src/usr.bin/make/unit-tests/meta-ignore.inc	Thu Feb 23 05:21:27 2023
@@ -0,0 +1,61 @@
+# $NetBSD: meta-ignore.inc,v 1.1 2023/02/23 05:21:27 sjg Exp $
+
+# common logic for testing .MAKE.META.IGNORE_*
+
+# we want a directory outside of .OBJDIR to drop a file
+# that our meta file refers to.
+IGNORE:= ${TMPDIR}/ignore
+OBJ:=	${TMPDIR}/obj
+
+# this is always ignored so make sure it isn't used above
+TMPDIR= /tmp/nothanks
+
+all:	one two three
+
+setup:
+	@mkdir -p ${IGNORE} ${OBJ}
+	@echo > ${IGNORE}/check
+	@rm -f ${OBJ}/check-ignore
+
+makefile:= ${.INCLUDEDFROMDIR}/${.INCLUDEDFROMFILE}
+TEST:= ${.INCLUDEDFROMFILE:R}
+
+DESC.one= Initialize check-ignore.meta
+DESC.two= Use .MAKE.META.IGNORE_* - check-ignore is up to date
+DESC.three= Skip .MAKE.META.IGNORE_* - check-ignore is out of date
+
+# just in case someone runs us with -jN
+.ORDER: one two three
+one two three: .MAKE setup
+	@echo "${DESC.${.TARGET}}"; \
+	${MAKE} -C ${.CURDIR} -f ${makefile} check-ignore parent=${.TARGET}
+
+.if make(check-ignore)
+.MAKEFLAGS: -dM
+.MAKE.MODE = meta verbose silent=yes
+.OBJDIR: ${OBJ}
+.if ${parent} == "two"
+.if ${TEST:M*ignore_paths} != ""
+# this is a prefix list - any path that matches
+# one of these prefixes will be ignored
+.MAKE.META.IGNORE_PATHS = ${IGNORE}
+.elif ${TEST:M*ignore_patterns} != ""
+# more flexible but more expensive
+# this example is equivalent to M*/ignore/*
+# a match means ignore
+.MAKE.META.IGNORE_PATTERNS = */ignore/*
+.elif ${TEST:M*ignore_filter} != ""
+# this is the most flexible, but also most expensive
+# if this expands to nothing - ignore the path
+.MAKE.META.IGNORE_FILTER = N${IGNORE}/*
+.endif
+.endif
+
+# : < just reads from ${IGNORE}/check
+# so that our filemon trace will have a reference to it
+# we ensure it is always newer than the target.
+check-ignore: .META .NOPATH
+	@: < ${IGNORE}/check > ${.TARGET}
+	@sleep 1; echo ${.TARGET} > ${IGNORE}/check
+
+.endif



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

2023-02-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Feb 23 05:21:27 UTC 2023

Added Files:
src/usr.bin/make/unit-tests: meta-ignore.inc

Log Message:
Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR


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

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

2023-02-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Feb 23 05:20:45 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: Makefile
varname-dot-make-meta-ignore_filter.exp
varname-dot-make-meta-ignore_filter.mk
varname-dot-make-meta-ignore_paths.exp
varname-dot-make-meta-ignore_paths.mk
varname-dot-make-meta-ignore_patterns.exp
varname-dot-make-meta-ignore_patterns.mk

Log Message:
Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR


To generate a diff of this commit:
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.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.331 src/usr.bin/make/unit-tests/Makefile:1.332
--- src/usr.bin/make/unit-tests/Makefile:1.331	Tue Jan 24 00:24:02 2023
+++ src/usr.bin/make/unit-tests/Makefile	Thu Feb 23 05:20:45 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.331 2023/01/24 00:24:02 sjg Exp $
+# $NetBSD: Makefile,v 1.332 2023/02/23 05:20:45 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -405,12 +405,14 @@ TESTS+=		varname-dot-make-makefiles
 TESTS+=		varname-dot-make-meta-bailiwick
 TESTS+=		varname-dot-make-meta-created
 TESTS+=		varname-dot-make-meta-files
+.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == ""
 TESTS+=		varname-dot-make-meta-ignore_filter
 TESTS+=		varname-dot-make-meta-ignore_paths
 TESTS+=		varname-dot-make-meta-ignore_patterns
+TESTS+=		varname-dot-make-path_filemon
+.endif
 TESTS+=		varname-dot-make-meta-prefix
 TESTS+=		varname-dot-make-mode
-TESTS+=		varname-dot-make-path_filemon
 TESTS+=		varname-dot-make-pid
 TESTS+=		varname-dot-make-ppid
 TESTS+=		varname-dot-make-save_dollars
@@ -501,6 +503,10 @@ SED_CMDS.job-output-long-lines= \
 	${:D marker should always be at the beginning of the line. } \
 	-e '/^aa*--- job-b ---$$/d' \
 	-e '/^bb*--- job-a ---$$/d'
+
+# meta line numbers can vary based on filemon implementation
+SED_CMDS.meta-ignore= -e 's,\(\.meta:\) [1-9][0-9]*:,\1 :,'
+
 SED_CMDS.opt-chdir=		-e 's,\(nonexistent\).[1-9][0-9]*,\1,'
 SED_CMDS.opt-debug-graph1=	${STD_SED_CMDS.dg1}
 SED_CMDS.opt-debug-graph2=	${STD_SED_CMDS.dg2}
@@ -533,6 +539,9 @@ SED_CMDS.var-op-shell+=		-e '/command/s,
 SED_CMDS.vardebug+=		-e 's,${.SHELL},,'
 SED_CMDS.varmod-subst-regex+=	${STD_SED_CMDS.regex}
 SED_CMDS.varparse-errors+=	${STD_SED_CMDS.timestamp}
+SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore}
+SED_CMDS.varname-dot-make-meta-ignore_paths+= ${SED_CMDS.meta-ignore}
+SED_CMDS.varname-dot-make-meta-ignore_patterns+= ${SED_CMDS.meta-ignore}
 SED_CMDS.varname-dot-parsedir=	-e '/in some cases/ s,^make: "[^"]*,make: ",'
 SED_CMDS.varname-dot-parsefile=	-e '/in some cases/ s,^make: "[^"]*,make: ",'
 SED_CMDS.varname-dot-shell=	-e 's, = /[^ ]*, = (details omitted),g'
@@ -713,23 +722,23 @@ LIMIT_RESOURCES?=	:
 
 # Postprocess the test output to make the output platform-independent.
 #
-# always pretend .MAKE was called 'make'
-_SED_CMDS+=	-e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
-_SED_CMDS+=	-e 's,${TEST_MAKE:S,.,\\.,g},make,'
-_SED_CMDS+=	-e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
-# replace anything after 'stopped in' with unit-tests
+# Replace anything after 'stopped in' with unit-tests
 _SED_CMDS+=	-e '/stopped/s, /.*, unit-tests,'
 # Allow the test files to be placed anywhere.
 _SED_CMDS+=	-e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = ,'
 _SED_CMDS+=	-e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = ,'
-_SED_CMDS+=	-e 's,${TMPDIR},,g'
+_SED_CMDS+=	-e 's,${TMPDIR},,g' -e 's,${TMPDIR:tA},,g'
 # canonicalize ${.OBJDIR} and ${.CURDIR}
+_SED_CMDS+=	-e 's,${.CURDIR},,g'
 .if ${.OBJDIR} != ${.CURDIR}
 # yes this is inaccurate but none of the tests expect  anywhere
 # which we get depending on how MAKEOBJDIR is set.
-_SED_CMDS+=	-e 's,${.OBJDIR},,g'
+_SED_CMDS+=	-e 's,${.OBJDIR},,g' -e 's,${.OBJDIR:tA},,g'
 .endif
-_SED_CMDS+=	-e 's,${.CURDIR},,g'

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

2023-02-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Feb 23 05:20:45 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: Makefile
varname-dot-make-meta-ignore_filter.exp
varname-dot-make-meta-ignore_filter.mk
varname-dot-make-meta-ignore_paths.exp
varname-dot-make-meta-ignore_paths.mk
varname-dot-make-meta-ignore_patterns.exp
varname-dot-make-meta-ignore_patterns.mk

Log Message:
Add unit-tests for .MAKE.META.IGNORE_*

These unit-tests should only be run if TEST_MAKE
has a valid .MAKE.PATH_FILEMON to indicate that filemon is
supported.

All three tests use the same meta-ignore.inc
which runs three sub-makes

one to initialize the target .meta file
two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER}
three to verify that without .MAKE.META.IGNORE_* the target is out of date.

Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in
.OBJDIR


To generate a diff of this commit:
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk \
src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk

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



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:03:58 UTC 2023

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

Log Message:
pcq(9): KASSERT(A && B) -> KASSERT(A); KASSERT(B)


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/kern/subr_pcq.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:03:58 UTC 2023

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

Log Message:
pcq(9): KASSERT(A && B) -> KASSERT(A); KASSERT(B)


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

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

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.18 src/sys/kern/subr_pcq.c:1.19
--- src/sys/kern/subr_pcq.c:1.18	Thu Feb 23 03:03:45 2023
+++ src/sys/kern/subr_pcq.c	Thu Feb 23 03:03:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pcq.c,v 1.18 2023/02/23 03:03:45 riastradh Exp $	*/
+/*	$NetBSD: subr_pcq.c,v 1.19 2023/02/23 03:03:58 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2019 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.18 2023/02/23 03:03:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.19 2023/02/23 03:03:58 riastradh Exp $");
 
 #include 
 #include 
@@ -290,7 +290,8 @@ pcq_create(size_t nitems, km_flag_t kmfl
 {
 	pcq_t *pcq;
 
-	KASSERT(nitems > 0 && nitems <= PCQ_MAXLEN);
+	KASSERT(nitems > 0);
+	KASSERT(nitems <= PCQ_MAXLEN);
 
 	pcq = kmem_zalloc(offsetof(pcq_t, pcq_items[nitems]), kmflags);
 	if (pcq != NULL) {



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:03:45 UTC 2023

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

Log Message:
pcq(9): Sketch correctness proof for some critical properties.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/subr_pcq.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:03:45 UTC 2023

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

Log Message:
pcq(9): Sketch correctness proof for some critical properties.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/subr_pcq.c

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

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.17 src/sys/kern/subr_pcq.c:1.18
--- src/sys/kern/subr_pcq.c:1.17	Thu Feb 23 03:01:49 2023
+++ src/sys/kern/subr_pcq.c	Thu Feb 23 03:03:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pcq.c,v 1.17 2023/02/23 03:01:49 riastradh Exp $	*/
+/*	$NetBSD: subr_pcq.c,v 1.18 2023/02/23 03:03:45 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2019 The NetBSD Foundation, Inc.
@@ -31,10 +31,94 @@
 
 /*
  * Lockless producer/consumer queue.
+ *
+ * Summary of the producer algorithm in pcq_put (may run many in
+ * parallel with each other and with a consumer):
+ *
+ *	P1. initialize an item
+ *
+ *	P2. atomic_cas(&pcq->pcq_pc) loop to advance the producer
+ *	pointer, reserving a space at c (fails if not enough space)
+ *
+ *	P3. atomic_store_release(&pcq->pcq_items[c], item) to publish
+ *	the item in the space it reserved
+ *
+ * Summary of the consumer algorithm in pcq_get (must be serialized by
+ * caller with other consumers, may run in parallel with any number of
+ * producers):
+ *
+ *	C1. atomic_load_relaxed(&pcq->pcq_pc) to get the consumer
+ *	pointer and a snapshot of the producer pointer, which may
+ *	point to null items or point to initialized items (fails if
+ *	no space reserved for published items yet)
+ *
+ *	C2. atomic_load_consume(&pcq->pcq_items[c]) to get the next
+ *	unconsumed but potentially published item (fails if item
+ *	not published yet)
+ *
+ *	C3. pcq->pcq_items[c] = NULL to consume the next unconsumed but
+ *	published item
+ *
+ *	C4. membar_producer
+ *
+ *	C5. atomic_cas(&pcq->pcq_pc) loop to advance the consumer
+ *	pointer
+ *
+ *	C6. use the item
+ *
+ * Note that there is a weird bare membar_producer which is not matched
+ * by membar_consumer.  This is one of the rare cases of a memory
+ * barrier on one side that is not matched by a memory barrier on
+ * another side, but the ordering works out, with a somewhat more
+ * involved proof.
+ *
+ * Some properties that need to be proved:
+ *
+ *	Theorem 1.  For pcq_put call that leads into pcq_get:
+ *	Initializing item at P1 is dependency-ordered before usage of
+ *	item at C6, so items placed by pcq_put can be safely used by
+ *	the caller of pcq_get.
+ *
+ *	Proof sketch.
+ *
+ *		Assume load/store P2 synchronizes with load/store C1
+ *		(if not, pcq_get fails in `if (p == c) return NULL').
+ *
+ *		Assume store-release P3 synchronizes with load-consume
+ *		C2 (if not, pcq_get fails in `if (item == NULL) return
+ *		NULL').
+ *
+ *		Then:
+ *
+ *		- P1 is sequenced before store-release P3
+ *		- store-release P3 synchronizes with load-consume C2
+ *		- load-consume C2 is dependency-ordered before C6
+ *
+ *		Hence transitively, P1 is dependency-ordered before C6,
+ *		QED.
+ *
+ *	Theorem 2.  For pcq_get call followed by pcq_put: Nulling out
+ *	location at store C3 happens before placing a new item in the
+ *	same location at store P3, so items are not lost.
+ *
+ *	Proof sketch.
+ *
+ *		Assume load/store C5 synchronizes with load/store P2
+ *		(otherwise pcq_peek starts over the CAS loop or fails).
+ *
+ *		Then:
+ *
+ *		- store C3 is sequenced before membar_producer C4
+ *		- membar_producer C4 is sequenced before load/store C5
+ *		- load/store C5 synchronizes with load/store P2 at &pcq->pcq_pc
+ *		- P2 is sequenced before store-release P3
+ *
+ *		Hence transitively, store C3 happens before
+ *		store-release P3, QED.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.17 2023/02/23 03:01:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.18 2023/02/23 03:03:45 riastradh Exp $");
 
 #include 
 #include 
@@ -186,7 +270,8 @@ pcq_get(pcq_t *pcq)
 	 * because the only load we need to ensure happens first is the
 	 * load of pcq->pcq_items[c], but that necessarily happens
 	 * before the store to pcq->pcq_items[c] to null it out because
-	 * it is at the same memory location.
+	 * it is at the same memory location.  Yes, this is a bare
+	 * membar_producer with no matching membar_consumer.
 	 */
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_producer();



CVS commit: src/share/man/man9

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:03:23 UTC 2023

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

Log Message:
pcq(9): Document memory ordering guarantees.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/share/man/man9/pcq.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/pcq.9
diff -u src/share/man/man9/pcq.9:1.8 src/share/man/man9/pcq.9:1.9
--- src/share/man/man9/pcq.9:1.8	Thu Feb  8 09:03:23 2018
+++ src/share/man/man9/pcq.9	Thu Feb 23 03:03:23 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: pcq.9,v 1.8 2018/02/08 09:03:23 dholland Exp $
+.\" $NetBSD: pcq.9,v 1.9 2023/02/23 03:03:23 riastradh Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -118,6 +118,63 @@ otherwise, return
 The item must not have the value of
 .Dv NULL .
 .El
+.Ss Memory ordering
+Any memory operations sequenced before
+.Fn pcq_put
+of an item in one thread happen before all memory operations with data
+dependencies on the item returned by
+.Fn pcq_get
+or
+.Fn pcq_peek
+in another thread.
+For example:
+.Bd -literal -offset indent
+int mumble;
+
+/* producer */
+mumble = 42;			// A
+foo->x = 123;			// B
+refcnt = foo->refcnt;		// C
+pcq_put(pcq, foo);
+KASSERT(refcnt == 0);
+
+/* consumer */
+foo = pcq_get(pcq);
+if (foo == NULL)
+	return;
+atomic_inc_uint(&foo->refcnt);	// D
+x = foo->x;			// E
+if (x == 123)
+	KASSERT(mumble == 42);	// F
+.Ed
+.Pp
+In this example, memory operations B and C happen-before D and E.
+However, no ordering is guaranteed for A or F relative to any other
+memory operations, because the memory location of
+.Fa mumble
+is independent of the pointer
+.Fa foo
+returned by
+.Fn pcq_get .
+.Pp
+If you must guarantee A happens before F, then on the consumer side,
+after
+.Fn pcq_get
+or
+.Fn pcq_peek ,
+you can call
+.Fn membar_acquire
+to turn it into an acquire operation instead of a consume operation;
+.Fn pcq_put
+serves as the matching release operation.
+.Po
+This is a little dicey.
+Perhaps there should be separate
+.Fn pcq_peek_acq
+and
+.Fn pcq_get_acq
+operations if this semantics is necessary.
+.Pc
 .Sh CODE REFERENCES
 The
 .Nm



CVS commit: src/share/man/man9

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:03:23 UTC 2023

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

Log Message:
pcq(9): Document memory ordering guarantees.


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

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



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:01:49 UTC 2023

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

Log Message:
pcq(9): Explain why membar_release isn't needed in pcq_get.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/kern/subr_pcq.c

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

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.16 src/sys/kern/subr_pcq.c:1.17
--- src/sys/kern/subr_pcq.c:1.16	Thu Feb 23 03:01:35 2023
+++ src/sys/kern/subr_pcq.c	Thu Feb 23 03:01:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pcq.c,v 1.16 2023/02/23 03:01:35 riastradh Exp $	*/
+/*	$NetBSD: subr_pcq.c,v 1.17 2023/02/23 03:01:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.16 2023/02/23 03:01:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.17 2023/02/23 03:01:49 riastradh Exp $");
 
 #include 
 #include 
@@ -177,10 +177,16 @@ pcq_get(pcq_t *pcq)
 	nv = pcq_combine(p, c);
 
 	/*
-	 * Ensure that update to pcq_items[] becomes globally visible
+	 * Ensure that update to pcq_items[c] becomes globally visible
 	 * before the update to pcq_pc.  If it were reordered to occur
 	 * after it, we could in theory wipe out a modification made
-	 * to pcq_items[] by pcq_put().
+	 * to pcq_items[c] by pcq_put().
+	 *
+	 * No need for load-before-store ordering of membar_release
+	 * because the only load we need to ensure happens first is the
+	 * load of pcq->pcq_items[c], but that necessarily happens
+	 * before the store to pcq->pcq_items[c] to null it out because
+	 * it is at the same memory location.
 	 */
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
 	membar_producer();



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:01:49 UTC 2023

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

Log Message:
pcq(9): Explain why membar_release isn't needed in pcq_get.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/kern/subr_pcq.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:01:35 UTC 2023

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

Log Message:
pcq(9): Explain why store need not be atomic in pcq_get.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_pcq.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:01:35 UTC 2023

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

Log Message:
pcq(9): Explain why store need not be atomic in pcq_get.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_pcq.c

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

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.15 src/sys/kern/subr_pcq.c:1.16
--- src/sys/kern/subr_pcq.c:1.15	Thu Feb 23 03:01:22 2023
+++ src/sys/kern/subr_pcq.c	Thu Feb 23 03:01:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pcq.c,v 1.15 2023/02/23 03:01:22 riastradh Exp $	*/
+/*	$NetBSD: subr_pcq.c,v 1.16 2023/02/23 03:01:35 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.15 2023/02/23 03:01:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.16 2023/02/23 03:01:35 riastradh Exp $");
 
 #include 
 #include 
@@ -168,6 +168,10 @@ pcq_get(pcq_t *pcq)
 		 */
 		return NULL;
 	}
+	/*
+	 * We have exclusive access to this slot, so no need for
+	 * atomic_store_*.
+	 */
 	pcq->pcq_items[c] = NULL;
 	c = pcq_advance(pcq, c);
 	nv = pcq_combine(p, c);



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:01:22 UTC 2023

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

Log Message:
pcq(9): Fix consume operation in pcq_peek/get.

These use atomic_load_consume to match the atomic_store_release in
pcq_put for pcq->pcq_items[c].

Reading the snapshot of pcq->pcq_pc need not be ordered:

- The consumer side (pcq_peek/get) is serialized by the API contract
  (single-consumer, multi-producer), so no ordering is necessary.

- The producer side updates pcq->pcq_pc first; if the consumer side
  sees that before the producer side has stored pcq->pcq_items[c],
  there's no problem -- it's as if the consumer had happened just a
  moment earlier and the producer hadn't entered pcq_put yet.

However, it should be an atomic load, not a plain load.  So use
atomic_load_relaxed, if for no other reason than to pacify thread
sanitizers.

XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/subr_pcq.c

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

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.14 src/sys/kern/subr_pcq.c:1.15
--- src/sys/kern/subr_pcq.c:1.14	Thu Feb 23 03:00:53 2023
+++ src/sys/kern/subr_pcq.c	Thu Feb 23 03:01:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pcq.c,v 1.14 2023/02/23 03:00:53 riastradh Exp $	*/
+/*	$NetBSD: subr_pcq.c,v 1.15 2023/02/23 03:01:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.14 2023/02/23 03:00:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.15 2023/02/23 03:01:22 riastradh Exp $");
 
 #include 
 #include 
@@ -100,7 +100,7 @@ pcq_put(pcq_t *pcq, void *item)
 	KASSERT(item != NULL);
 
 	do {
-		v = pcq->pcq_pc;
+		v = atomic_load_relaxed(&pcq->pcq_pc);
 		pcq_split(v, &op, &c);
 		p = pcq_advance(pcq, op);
 		if (p == c) {
@@ -132,14 +132,13 @@ pcq_put(pcq_t *pcq, void *item)
 void *
 pcq_peek(pcq_t *pcq)
 {
-	const uint32_t v = pcq->pcq_pc;
+	const uint32_t v = atomic_load_relaxed(&pcq->pcq_pc);
 	u_int p, c;
 
 	pcq_split(v, &p, &c);
 
 	/* See comment on race below in pcq_get(). */
-	return (p == c) ? NULL :
-	(membar_datadep_consumer(), pcq->pcq_items[c]);
+	return (p == c) ? NULL : atomic_load_consume(&pcq->pcq_items[c]);
 }
 
 /*
@@ -154,15 +153,13 @@ pcq_get(pcq_t *pcq)
 	u_int p, c;
 	void *item;
 
-	v = pcq->pcq_pc;
+	v = atomic_load_relaxed(&pcq->pcq_pc);
 	pcq_split(v, &p, &c);
 	if (p == c) {
 		/* Queue is empty: nothing to return. */
 		return NULL;
 	}
-	/* Make sure we read pcq->pcq_pc before pcq->pcq_items[c].  */
-	membar_datadep_consumer();
-	item = pcq->pcq_items[c];
+	item = atomic_load_consume(&pcq->pcq_items[c]);
 	if (item == NULL) {
 		/*
 		 * Raced with sender: we rely on a notification (e.g. softint
@@ -185,7 +182,7 @@ pcq_get(pcq_t *pcq)
 	membar_producer();
 #endif
 	while (__predict_false(atomic_cas_32(&pcq->pcq_pc, v, nv) != v)) {
-		v = pcq->pcq_pc;
+		v = atomic_load_relaxed(&pcq->pcq_pc);
 		pcq_split(v, &p, &c);
 		c = pcq_advance(pcq, c);
 		nv = pcq_combine(p, c);



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:01:22 UTC 2023

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

Log Message:
pcq(9): Fix consume operation in pcq_peek/get.

These use atomic_load_consume to match the atomic_store_release in
pcq_put for pcq->pcq_items[c].

Reading the snapshot of pcq->pcq_pc need not be ordered:

- The consumer side (pcq_peek/get) is serialized by the API contract
  (single-consumer, multi-producer), so no ordering is necessary.

- The producer side updates pcq->pcq_pc first; if the consumer side
  sees that before the producer side has stored pcq->pcq_items[c],
  there's no problem -- it's as if the consumer had happened just a
  moment earlier and the producer hadn't entered pcq_put yet.

However, it should be an atomic load, not a plain load.  So use
atomic_load_relaxed, if for no other reason than to pacify thread
sanitizers.

XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/subr_pcq.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:00:53 UTC 2023

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

Log Message:
pcq(9): Make pcq_put a release operation, in memory ordering.

Otherwise, for example, the following assertion could fail:

/* publisher */
nusers = foo->nusers;
pcq_put(pcq, foo);
KASSERT(nusers == 0);

/* user */
foo = pcq_get(pcq);
if (foo != NULL)
atomic_inc_uint(&foo->nusers);

XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_pcq.c

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

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.13 src/sys/kern/subr_pcq.c:1.14
--- src/sys/kern/subr_pcq.c:1.13	Mon Feb  8 09:31:05 2021
+++ src/sys/kern/subr_pcq.c	Thu Feb 23 03:00:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pcq.c,v 1.13 2021/02/08 09:31:05 wiz Exp $	*/
+/*	$NetBSD: subr_pcq.c,v 1.14 2023/02/23 03:00:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.13 2021/02/08 09:31:05 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.14 2023/02/23 03:00:53 riastradh Exp $");
 
 #include 
 #include 
@@ -116,10 +116,7 @@ pcq_put(pcq_t *pcq, void *item)
 	 * that the caller made to the data item are globally visible
 	 * before we put it onto the list.
 	 */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
-	membar_producer();
-#endif
-	pcq->pcq_items[op] = item;
+	atomic_store_release(&pcq->pcq_items[op], item);
 
 	/*
 	 * Synchronization activity to wake up the consumer will ensure



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:00:53 UTC 2023

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

Log Message:
pcq(9): Make pcq_put a release operation, in memory ordering.

Otherwise, for example, the following assertion could fail:

/* publisher */
nusers = foo->nusers;
pcq_put(pcq, foo);
KASSERT(nusers == 0);

/* user */
foo = pcq_get(pcq);
if (foo != NULL)
atomic_inc_uint(&foo->nusers);

XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_pcq.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:00:15 UTC 2023

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

Log Message:
kern_descrip.c: Change membar_enter to membar_acquire in fd_getfile.

membar_acquire is cheaper on many CPUs, and unlikely to be costlier
on any CPUs, than the legacy membar_enter.

Add a long comment explaining the interaction between fd_getfile and
fd_close and why membar_acquire is safe.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/sys/kern/kern_descrip.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_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.253 src/sys/kern/kern_descrip.c:1.254
--- src/sys/kern/kern_descrip.c:1.253	Thu Feb 23 02:58:40 2023
+++ src/sys/kern/kern_descrip.c	Thu Feb 23 03:00:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.253 2023/02/23 02:58:40 riastradh Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.254 2023/02/23 03:00:15 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.253 2023/02/23 02:58:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.254 2023/02/23 03:00:15 riastradh Exp $");
 
 #include 
 #include 
@@ -392,10 +392,45 @@ fd_getfile(unsigned fd)
 		 * Multi threaded: issue a memory barrier to ensure that we
 		 * acquire the file pointer _after_ adding a reference.  If
 		 * no memory barrier, we could fetch a stale pointer.
+		 *
+		 * In particular, we must coordinate the following four
+		 * memory operations:
+		 *
+		 *	A. fd_close store ff->ff_file = NULL
+		 *	B. fd_close refcnt = atomic_dec_uint_nv(&ff->ff_refcnt)
+		 *	C. fd_getfile atomic_inc_uint(&ff->ff_refcnt)
+		 *	D. fd_getfile load fp = ff->ff_file
+		 *
+		 * If the order is D;A;B;C:
+		 *
+		 *	1. D: fp = ff->ff_file
+		 *	2. A: ff->ff_file = NULL
+		 *	3. B: refcnt = atomic_dec_uint_nv(&ff->ff_refcnt)
+		 *	4. C: atomic_inc_uint(&ff->ff_refcnt)
+		 *
+		 * then fd_close determines that there are no more
+		 * references and decides to free fp immediately, at
+		 * the same that fd_getfile ends up with an fp that's
+		 * about to be freed.  *boom*
+		 *
+		 * By making B a release operation in fd_close, and by
+		 * making C an acquire operation in fd_getfile, since
+		 * they are atomic operations on the same object, which
+		 * has a total modification order, we guarantee either:
+		 *
+		 *	- B happens before C.  Then since A is
+		 *	  sequenced before B in fd_close, and C is
+		 *	  sequenced before D in fd_getfile, we
+		 *	  guarantee A happens before D, so fd_getfile
+		 *	  reads a null fp and safely fails.
+		 *
+		 *	- C happens before B.  Then fd_getfile may read
+		 *	  null or nonnull, but either way, fd_close
+		 *	  will safely wait for references to drain.
 		 */
 		atomic_inc_uint(&ff->ff_refcnt);
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-		membar_enter();
+		membar_acquire();
 #endif
 	}
 



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 03:00:15 UTC 2023

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

Log Message:
kern_descrip.c: Change membar_enter to membar_acquire in fd_getfile.

membar_acquire is cheaper on many CPUs, and unlikely to be costlier
on any CPUs, than the legacy membar_enter.

Add a long comment explaining the interaction between fd_getfile and
fd_close and why membar_acquire is safe.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/sys/kern/kern_descrip.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:58:41 UTC 2023

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

Log Message:
kern_descrip.c: Use atomic_store_relaxed/release for ff->ff_file.

1. atomic_store_relaxed in fd_close avoids the appearance of race in
   sanitizers (minor bug).

2. atomic_store_release in fd_affix is necessary because the lock
   activity was not, in fact, enough to guarantee ordering (real bug
   some architectures like aarch64).

   The premise appears to have been that the mutex_enter/exit earlier
   in fd_affix is enough to guarantee that initialization of fp (A)
   happens before use of fp by a user once fp is published (B):

fp->f_... = ...;// A

/* fd_affix */
mutex_enter(&fp->f_lock);
fp->f_count++;
mutex_exit(&fp->f_lock);
...
ff->ff_file = fp;   // B

   But actually mutex_enter/exit allow the following reordering by
   the CPU:

mutex_enter(&fp->f_lock);
ff->ff_file = fp;   // B
fp->f_count++;
fp->f_... = ...;// A
mutex_exit(&fp->f_lock);

   The only constraints they imply are:

1. fp->f_count++ and B cannot precede mutex_enter
2. mutex_exit cannot precede A and fp->f_count++

   They imply no constraint on the relative ordering of A, B, and
   fp->f_count++ amongst each other, however.

   This affects any architecture that has a native load-acquire or
   store-release operation in mutex_enter/exit, like aarch64, instead
   of explicit load-before-load/store and load/store-before-store
   barrier.

No need for atomic_store_* in fd_copy or fd_free because we have
exclusive access to ff as is.

XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/sys/kern/kern_descrip.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_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.252 src/sys/kern/kern_descrip.c:1.253
--- src/sys/kern/kern_descrip.c:1.252	Thu Feb 23 02:58:28 2023
+++ src/sys/kern/kern_descrip.c	Thu Feb 23 02:58:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.252 2023/02/23 02:58:28 riastradh Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.253 2023/02/23 02:58:40 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.252 2023/02/23 02:58:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.253 2023/02/23 02:58:40 riastradh Exp $");
 
 #include 
 #include 
@@ -624,7 +624,7 @@ fd_close(unsigned fd)
 	 * will prevent them from adding additional uses to this file
 	 * while we are closing it.
 	 */
-	ff->ff_file = NULL;
+	atomic_store_relaxed(&ff->ff_file, NULL);
 	ff->ff_exclose = false;
 
 	/*
@@ -1152,12 +1152,6 @@ fd_affix(proc_t *p, file_t *fp, unsigned
 
 	/*
 	 * Insert the new file into the descriptor slot.
-	 *
-	 * The memory barriers provided by lock activity in this routine
-	 * ensure that any updates to the file structure become globally
-	 * visible before the file becomes visible to other LWPs in the
-	 * current process; otherwise we would set ff->ff_file with
-	 * atomic_store_release(&ff->ff_file, fp) at the bottom.
 	 */
 	fdp = p->p_fd;
 	dt = atomic_load_consume(&fdp->fd_dt);
@@ -1170,7 +1164,7 @@ fd_affix(proc_t *p, file_t *fp, unsigned
 	KASSERT(fd >= NDFDFILE || ff == (fdfile_t *)fdp->fd_dfdfile[fd]);
 
 	/* No need to lock in order to make file initially visible. */
-	ff->ff_file = fp;
+	atomic_store_release(&ff->ff_file, fp);
 }
 
 /*



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:58:41 UTC 2023

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

Log Message:
kern_descrip.c: Use atomic_store_relaxed/release for ff->ff_file.

1. atomic_store_relaxed in fd_close avoids the appearance of race in
   sanitizers (minor bug).

2. atomic_store_release in fd_affix is necessary because the lock
   activity was not, in fact, enough to guarantee ordering (real bug
   some architectures like aarch64).

   The premise appears to have been that the mutex_enter/exit earlier
   in fd_affix is enough to guarantee that initialization of fp (A)
   happens before use of fp by a user once fp is published (B):

fp->f_... = ...;// A

/* fd_affix */
mutex_enter(&fp->f_lock);
fp->f_count++;
mutex_exit(&fp->f_lock);
...
ff->ff_file = fp;   // B

   But actually mutex_enter/exit allow the following reordering by
   the CPU:

mutex_enter(&fp->f_lock);
ff->ff_file = fp;   // B
fp->f_count++;
fp->f_... = ...;// A
mutex_exit(&fp->f_lock);

   The only constraints they imply are:

1. fp->f_count++ and B cannot precede mutex_enter
2. mutex_exit cannot precede A and fp->f_count++

   They imply no constraint on the relative ordering of A, B, and
   fp->f_count++ amongst each other, however.

   This affects any architecture that has a native load-acquire or
   store-release operation in mutex_enter/exit, like aarch64, instead
   of explicit load-before-load/store and load/store-before-store
   barrier.

No need for atomic_store_* in fd_copy or fd_free because we have
exclusive access to ff as is.

XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/sys/kern/kern_descrip.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:58:28 UTC 2023

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

Log Message:
kern_descrip.c: Fix membars around reference count decrement.

In general, the `last one out hit the lights' style of reference
counting (as opposed to the `whoever's destroying must wait for
pending users to finish' style) requires memory barriers like so:

... usage of resources associated with object ...
membar_release();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_acquire();
... freeing of resources associated with object ...

This way, all usage happens-before all freeing.  This fixes several
errors:

- fd_close failed to ensure whatever its caller did would
  happen-before the freeing, in the case where another thread is
  concurrently trying to close the fd (ff->ff_file == NULL).

  Fix: Add membar_release before atomic_dec_uint(&ff->ff_refcnt) in
  that branch.

- fd_close failed to ensure all loads its caller had issued will have
  happened-before the freeing, in the case where the fd is still in
  use by another thread (fdp->fd_refcnt > 1 and ff->ff_refcnt-- > 0).

  Fix: Change membar_producer to membar_release before
  atomic_dec_uint(&ff->ff_refcnt).

- fd_close failed to ensure that any usage of fp by other callers
  would happen-before any freeing it does.

  Fix: Add membar_acquire after atomic_dec_uint_nv(&ff->ff_refcnt).

- fd_free failed to ensure that any usage of fdp by other callers
  would happen-before any freeing it does.

  Fix: Add membar_acquire after atomic_dec_uint_nv(&fdp->fd_refcnt).

While here, change membar_exit -> membar_release.  No semantic
change, just updating away from the legacy API.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/kern/kern_descrip.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_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.251 src/sys/kern/kern_descrip.c:1.252
--- src/sys/kern/kern_descrip.c:1.251	Tue Jun 29 22:40:53 2021
+++ src/sys/kern/kern_descrip.c	Thu Feb 23 02:58:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.251 2021/06/29 22:40:53 dholland Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.252 2023/02/23 02:58:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.251 2021/06/29 22:40:53 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.252 2023/02/23 02:58:28 riastradh Exp $");
 
 #include 
 #include 
@@ -451,7 +451,7 @@ fd_putfile(unsigned fd)
 	 * CPU.
 	 */
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-	membar_exit();
+	membar_release();
 #endif
 
 	/*
@@ -602,6 +602,9 @@ fd_close(unsigned fd)
 		 * waiting for other users of the file to drain.  Release
 		 * our reference, and wake up the closer.
 		 */
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+		membar_release();
+#endif
 		atomic_dec_uint(&ff->ff_refcnt);
 		cv_broadcast(&ff->ff_closing);
 		mutex_exit(&fdp->fd_lock);
@@ -637,9 +640,12 @@ fd_close(unsigned fd)
 	} else {
 		/* Multi threaded. */
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-		membar_producer();
+		membar_release();
 #endif
 		refcnt = atomic_dec_uint_nv(&ff->ff_refcnt);
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+		membar_acquire();
+#endif
 	}
 	if (__predict_false(refcnt != 0)) {
 		/*
@@ -1532,10 +1538,13 @@ fd_free(void)
 	KASSERT(fdp->fd_dtbuiltin.dt_link == NULL);
 
 #ifndef __HAVE_ATOMIC_AS_MEMBAR
-	membar_exit();
+	membar_release();
 #endif
 	if (atomic_dec_uint_nv(&fdp->fd_refcnt) > 0)
 		return;
+#ifndef __HAVE_ATOMIC_AS_MEMBAR
+	membar_acquire();
+#endif
 
 	/*
 	 * Close any files that the process holds open.



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:58:28 UTC 2023

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

Log Message:
kern_descrip.c: Fix membars around reference count decrement.

In general, the `last one out hit the lights' style of reference
counting (as opposed to the `whoever's destroying must wait for
pending users to finish' style) requires memory barriers like so:

... usage of resources associated with object ...
membar_release();
if (atomic_dec_uint_nv(&obj->refcnt) != 0)
return;
membar_acquire();
... freeing of resources associated with object ...

This way, all usage happens-before all freeing.  This fixes several
errors:

- fd_close failed to ensure whatever its caller did would
  happen-before the freeing, in the case where another thread is
  concurrently trying to close the fd (ff->ff_file == NULL).

  Fix: Add membar_release before atomic_dec_uint(&ff->ff_refcnt) in
  that branch.

- fd_close failed to ensure all loads its caller had issued will have
  happened-before the freeing, in the case where the fd is still in
  use by another thread (fdp->fd_refcnt > 1 and ff->ff_refcnt-- > 0).

  Fix: Change membar_producer to membar_release before
  atomic_dec_uint(&ff->ff_refcnt).

- fd_close failed to ensure that any usage of fp by other callers
  would happen-before any freeing it does.

  Fix: Add membar_acquire after atomic_dec_uint_nv(&ff->ff_refcnt).

- fd_free failed to ensure that any usage of fdp by other callers
  would happen-before any freeing it does.

  Fix: Add membar_acquire after atomic_dec_uint_nv(&fdp->fd_refcnt).

While here, change membar_exit -> membar_release.  No semantic
change, just updating away from the legacy API.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/kern/kern_descrip.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:57:17 UTC 2023

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

Log Message:
itimer(9): Sprinkle some more assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/kern/kern_time.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_time.c
diff -u src/sys/kern/kern_time.c:1.220 src/sys/kern/kern_time.c:1.221
--- src/sys/kern/kern_time.c:1.220	Thu Feb 23 02:56:25 2023
+++ src/sys/kern/kern_time.c	Thu Feb 23 02:57:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.220 2023/02/23 02:56:25 riastradh Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.221 2023/02/23 02:57:17 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009, 2020
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.220 2023/02/23 02:56:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.221 2023/02/23 02:57:17 riastradh Exp $");
 
 #include 
 #include 
@@ -809,7 +809,10 @@ itimer_decr(struct itimer *it, int nsec)
 static void
 itimer_arm_real(struct itimer * const it)
 {
+
 	KASSERT(!it->it_dying);
+	KASSERT(!CLOCK_VIRTUAL_P(it->it_clockid));
+	KASSERT(!callout_pending(&it->it_ch));
 
 	/*
 	 * Don't need to check tshzto() return value, here.
@@ -907,6 +910,7 @@ itimer_settime(struct itimer *it)
 	struct itlist *itl;
 
 	KASSERT(itimer_lock_held());
+	KASSERT(!it->it_dying);
 
 	if (!CLOCK_VIRTUAL_P(it->it_clockid)) {
 		/*
@@ -918,6 +922,7 @@ itimer_settime(struct itimer *it)
 		 */
 		if (callout_halt(&it->it_ch, &itimer_mutex))
 			return ERESTART;
+		KASSERT(!it->it_dying);
 
 		/* Now we can touch it and start it up again. */
 		if (timespecisset(&it->it_time.it_value))
@@ -973,6 +978,7 @@ itimer_gettime(const struct itimer *it, 
 	struct itimer *itn;
 
 	KASSERT(itimer_lock_held());
+	KASSERT(!it->it_dying);
 
 	*aits = it->it_time;
 	if (!CLOCK_VIRTUAL_P(it->it_clockid)) {



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:57:17 UTC 2023

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

Log Message:
itimer(9): Sprinkle some more assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/kern/kern_time.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:56:25 UTC 2023

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

Log Message:
itimer(9): Use callout_setfunc/schedule instead of callout_reset.

No semantic change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/sys/kern/kern_time.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_time.c
diff -u src/sys/kern/kern_time.c:1.219 src/sys/kern/kern_time.c:1.220
--- src/sys/kern/kern_time.c:1.219	Sat Feb 18 14:04:17 2023
+++ src/sys/kern/kern_time.c	Thu Feb 23 02:56:25 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.219 2023/02/18 14:04:17 thorpej Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.220 2023/02/23 02:56:25 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009, 2020
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.219 2023/02/18 14:04:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.220 2023/02/23 02:56:25 riastradh Exp $");
 
 #include 
 #include 
@@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_time.c,
 kmutex_t	itimer_mutex __cacheline_aligned;	/* XXX static */
 static struct itlist itimer_realtime_changed_notify;
 
+static void	itimer_callout(void *);
 static void	ptimer_intr(void *);
 static void	*ptimer_sih __read_mostly;
 static TAILQ_HEAD(, ptimer) ptimer_queue;
@@ -685,6 +686,7 @@ itimer_init(struct itimer * const it, co
 	if (!CLOCK_VIRTUAL_P(id)) {
 		KASSERT(itl == NULL);
 		callout_init(&it->it_ch, CALLOUT_MPSAFE);
+		callout_setfunc(&it->it_ch, itimer_callout, it);
 		if (id == CLOCK_REALTIME && ops->ito_realtime_changed != NULL) {
 			LIST_INSERT_HEAD(&itimer_realtime_changed_notify,
 			it, it_rtchgq);
@@ -799,8 +801,6 @@ itimer_decr(struct itimer *it, int nsec)
 	return true;
 }
 
-static void itimer_callout(void *);
-
 /*
  * itimer_arm_real:
  *
@@ -813,13 +813,12 @@ itimer_arm_real(struct itimer * const it
 
 	/*
 	 * Don't need to check tshzto() return value, here.
-	 * callout_reset() does it for us.
+	 * callout_schedule() does it for us.
 	 */
-	callout_reset(&it->it_ch,
+	callout_schedule(&it->it_ch,
 	(it->it_clockid == CLOCK_MONOTONIC
 		? tshztoup(&it->it_time.it_value)
-		: tshzto(&it->it_time.it_value)),
-	itimer_callout, it);
+		: tshzto(&it->it_time.it_value)));
 }
 
 /*



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:56:25 UTC 2023

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

Log Message:
itimer(9): Use callout_setfunc/schedule instead of callout_reset.

No semantic change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/sys/kern/kern_time.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/nvmm/x86

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:54:02 UTC 2023

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

Log Message:
nvmm: Filter CR4 bits on x86 SVM (AMD).

In particular, prohibit PKE, Protection Key Enable, which requires
some additional management of CPU state by nvmm.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/nvmm/x86/nvmm_x86_svm.c

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

Modified files:

Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.84 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.85
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.84	Sat Aug 20 23:48:51 2022
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Thu Feb 23 02:54:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.84 2022/08/20 23:48:51 riastradh Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.85 2023/02/23 02:54:02 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.84 2022/08/20 23:48:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.85 2023/02/23 02:54:02 riastradh Exp $");
 
 #include 
 #include 
@@ -523,6 +523,33 @@ static uint64_t svm_xcr0_mask __read_mos
 #define CR4_TLB_FLUSH \
 	(CR4_PSE|CR4_PAE|CR4_PGE|CR4_PCIDE|CR4_SMEP)
 
+#define CR4_VALID \
+	(CR4_VME |			\
+	 CR4_PVI |			\
+	 CR4_TSD |			\
+	 CR4_DE |			\
+	 CR4_PSE |			\
+	 CR4_PAE |			\
+	 CR4_MCE |			\
+	 CR4_PGE |			\
+	 CR4_PCE |			\
+	 CR4_OSFXSR |			\
+	 CR4_OSXMMEXCPT |		\
+	 CR4_UMIP |			\
+	 /* CR4_LA57 excluded */	\
+	 /* bit 13 reserved on AMD */	\
+	 /* bit 14 reserved on AMD */	\
+	 /* bit 15 reserved on AMD */	\
+	 CR4_FSGSBASE |			\
+	 CR4_PCIDE |			\
+	 CR4_OSXSAVE |			\
+	 /* bit 19 reserved on AMD */	\
+	 CR4_SMEP |			\
+	 CR4_SMAP			\
+	 /* CR4_PKE excluded */		\
+	 /* CR4_CET excluded */		\
+	 /* bits 24:63 reserved on AMD */)
+
 /* -- */
 
 struct svm_machdata {
@@ -1853,6 +1880,7 @@ svm_vcpu_setstate(struct nvmm_cpu *vcpu)
 		vmcb->state.cr2 = state->crs[NVMM_X64_CR_CR2];
 		vmcb->state.cr3 = state->crs[NVMM_X64_CR_CR3];
 		vmcb->state.cr4 = state->crs[NVMM_X64_CR_CR4];
+		vmcb->state.cr4 &= CR4_VALID;
 
 		vmcb->ctrl.v &= ~VMCB_CTRL_V_TPR;
 		vmcb->ctrl.v |= __SHIFTIN(state->crs[NVMM_X64_CR_CR8],



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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:54:02 UTC 2023

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

Log Message:
nvmm: Filter CR4 bits on x86 SVM (AMD).

In particular, prohibit PKE, Protection Key Enable, which requires
some additional management of CPU state by nvmm.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/nvmm/x86/nvmm_x86_svm.c

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



CVS commit: src/sys/dev/wscons

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:48:07 UTC 2023

Modified Files:
src/sys/dev/wscons: wsemul_vt100.c wsemul_vt100_subr.c

Log Message:
wscons(4): Paranoia: Clamp numbers of rows and columns.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/wscons/wsemul_vt100.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/wscons/wsemul_vt100_subr.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/wscons

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:48:07 UTC 2023

Modified Files:
src/sys/dev/wscons: wsemul_vt100.c wsemul_vt100_subr.c

Log Message:
wscons(4): Paranoia: Clamp numbers of rows and columns.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/wscons/wsemul_vt100.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/wscons/wsemul_vt100_subr.c

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

Modified files:

Index: src/sys/dev/wscons/wsemul_vt100.c
diff -u src/sys/dev/wscons/wsemul_vt100.c:1.49 src/sys/dev/wscons/wsemul_vt100.c:1.50
--- src/sys/dev/wscons/wsemul_vt100.c:1.49	Sun Jan  2 23:46:21 2022
+++ src/sys/dev/wscons/wsemul_vt100.c	Thu Feb 23 02:48:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsemul_vt100.c,v 1.49 2022/01/02 23:46:21 uwe Exp $	*/
+/*	$NetBSD: wsemul_vt100.c,v 1.50 2023/02/23 02:48:06 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.49 2022/01/02 23:46:21 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.50 2023/02/23 02:48:06 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_wsmsgattrs.h"
@@ -293,8 +293,14 @@ wsemul_vt100_resize(void * cookie, const
 {
 	struct wsemul_vt100_emuldata *edp = cookie;
 
-	edp->bd.nrows = type->nrows;
-	edp->bd.ncols = type->ncols;
+	/* XXX match malloc size in wsemul_vt100_attach */
+	KASSERT(type->nrows >= 0);
+	KASSERT(type->ncols >= 0);
+	KASSERT(type->nrows <= 1024);
+	KASSERT(type->ncols <= 1024);
+
+	edp->bd.nrows = MAX(0, MIN(type->nrows, 1024));
+	edp->bd.ncols = MAX(0, MIN(type->ncols, 1024));
 	wsemul_vt100_reset(edp);
 	wsemul_vt100_resetop(cookie, WSEMUL_CLEARSCREEN);
 }

Index: src/sys/dev/wscons/wsemul_vt100_subr.c
diff -u src/sys/dev/wscons/wsemul_vt100_subr.c:1.27 src/sys/dev/wscons/wsemul_vt100_subr.c:1.28
--- src/sys/dev/wscons/wsemul_vt100_subr.c:1.27	Thu Feb 23 02:47:52 2023
+++ src/sys/dev/wscons/wsemul_vt100_subr.c	Thu Feb 23 02:48:06 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wsemul_vt100_subr.c,v 1.27 2023/02/23 02:47:52 riastradh Exp $ */
+/* $NetBSD: wsemul_vt100_subr.c,v 1.28 2023/02/23 02:48:06 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_subr.c,v 1.27 2023/02/23 02:47:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_subr.c,v 1.28 2023/02/23 02:48:06 riastradh Exp $");
 
 #include 
 #include 
@@ -767,6 +767,8 @@ wsemul_vt100_handle_dcs(struct vt100base
 		return;
 	case DCSTYPE_TABRESTORE:
 		KASSERT(edp->tabs != 0);
+		KASSERT(edp->ncols >= 0);
+		KASSERT(edp->ncols <= 1024);
 		memset(edp->tabs, 0, edp->ncols);
 		pos = 0;
 		for (i = 0; i < edp->dcspos; i++) {



CVS commit: src/sys/dev/wscons

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:47:52 UTC 2023

Modified Files:
src/sys/dev/wscons: wsemul_vt100_subr.c

Log Message:
wscons(4): Ignore nonsense tab stops in vt100 emulation.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/wscons/wsemul_vt100_subr.c

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

Modified files:

Index: src/sys/dev/wscons/wsemul_vt100_subr.c
diff -u src/sys/dev/wscons/wsemul_vt100_subr.c:1.26 src/sys/dev/wscons/wsemul_vt100_subr.c:1.27
--- src/sys/dev/wscons/wsemul_vt100_subr.c:1.26	Wed Jan 18 17:02:17 2023
+++ src/sys/dev/wscons/wsemul_vt100_subr.c	Thu Feb 23 02:47:52 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wsemul_vt100_subr.c,v 1.26 2023/01/18 17:02:17 christos Exp $ */
+/* $NetBSD: wsemul_vt100_subr.c,v 1.27 2023/02/23 02:47:52 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_subr.c,v 1.26 2023/01/18 17:02:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_subr.c,v 1.27 2023/02/23 02:47:52 riastradh Exp $");
 
 #include 
 #include 
@@ -773,12 +773,22 @@ wsemul_vt100_handle_dcs(struct vt100base
 			char c = edp->dcsarg[i];
 			switch (c) {
 			case '0': case '1': case '2': case '3': case '4':
-			case '5': case '6': case '7': case '8': case '9':
-pos = pos * 10 + (edp->dcsarg[i] - '0');
+			case '5': case '6': case '7': case '8': case '9': {
+const int c0 = c - '0';
+if (pos < 0 ||
+pos > INT_MAX/10 ||
+pos * 10 > edp->ncols - c0) {
+	pos = -1;
+	break;
+}
+pos = pos * 10 + c0;
 break;
+			}
 			case '/':
-if (pos > 0)
+if (pos > 0) {
+	KASSERT(pos <= edp->ncols);
 	edp->tabs[pos - 1] = 1;
+}
 pos = 0;
 break;
 			default:
@@ -788,8 +798,10 @@ wsemul_vt100_handle_dcs(struct vt100base
 break;
 			}
 		}
-		if (pos > 0)
+		if (pos > 0) {
+			KASSERT(pos <= edp->ncols);
 			edp->tabs[pos - 1] = 1;
+		}
 		break;
 	default:
 		panic("wsemul_vt100_handle_dcs: bad type %d", edp->dcstype);



CVS commit: src/sys/dev/wscons

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 02:47:52 UTC 2023

Modified Files:
src/sys/dev/wscons: wsemul_vt100_subr.c

Log Message:
wscons(4): Ignore nonsense tab stops in vt100 emulation.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/wscons/wsemul_vt100_subr.c

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



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

2023-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb 22 23:55:05 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: README.md

Log Message:
lint: document limitations


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/README.md

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



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

2023-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb 22 23:55:05 UTC 2023

Modified Files:
src/usr.bin/xlint/lint1: README.md

Log Message:
lint: document limitations


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/README.md

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

Modified files:

Index: src/usr.bin/xlint/lint1/README.md
diff -u src/usr.bin/xlint/lint1/README.md:1.11 src/usr.bin/xlint/lint1/README.md:1.12
--- src/usr.bin/xlint/lint1/README.md:1.11	Sun Feb  5 13:06:36 2023
+++ src/usr.bin/xlint/lint1/README.md	Wed Feb 22 23:55:05 2023
@@ -1,4 +1,4 @@
-[//]: # ($NetBSD: README.md,v 1.11 2023/02/05 13:06:36 rillig Exp $)
+[//]: # ($NetBSD: README.md,v 1.12 2023/02/22 23:55:05 rillig Exp $)
 
 # Introduction
 
@@ -64,6 +64,19 @@ or just informational depends on several
 * The option `-q` enables additional queries that are not suitable as regular
   warnings but may be interesting to look at on a case-by-case basis.
 
+# Limitations
+
+Lint operates on the level of individual expressions.
+
+* It does not build an AST of the statements of a function, therefore it
+  cannot reliably analyze the control flow in a single function.
+* It does not store the control flow properties of functions, therefore it
+  cannot relate argument nullability with the return value.
+* It does not have information about functions, except for their prototypes,
+  therefore it cannot relate them across translation units.
+* It does not store detailed information about complex data types, therefore
+  it cannot cross-check them across translation units.
+
 # Fundamental types
 
 Lint mainly analyzes expressions (`tnode_t`), which are formed from operators



CVS commit: src

2023-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb 22 22:30:40 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230_uchar.c
platform_schar.c
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: fix confusing message about nonportable character constants


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_schar.c
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.504 -r1.505 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_230.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.11 src/tests/usr.bin/xlint/lint1/msg_230.c:1.12
--- src/tests/usr.bin/xlint/lint1/msg_230.c:1.11	Sat Feb 26 11:13:01 2022
+++ src/tests/usr.bin/xlint/lint1/msg_230.c	Wed Feb 22 22:30:40 2023
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_230.c,v 1.11 2022/02/26 11:13:01 rillig Exp $	*/
+/*	$NetBSD: msg_230.c,v 1.12 2023/02/22 22:30:40 rillig Exp $	*/
 # 3 "msg_230.c"
 
-// Test for message: nonportable character comparison '%s %d' [230]
+// Test for message: nonportable character comparison '%s' [230]
 
 /* lint1-flags: -S -g -p -w */
 /* lint1-only-if: schar */
@@ -46,26 +46,26 @@ compare_plain_char(char c)
 void
 compare_plain_char_yoda(char c)
 {
-	/* expect+1: warning: nonportable character comparison '== -129' [230] */
+	/* expect+1: warning: nonportable character comparison '-129 == ?' [230] */
 	if (-129 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== -128' [230] */
+	/* expect+1: warning: nonportable character comparison '-128 == ?' [230] */
 	if (-128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== -1' [230] */
+	/* expect+1: warning: nonportable character comparison '-1 == ?' [230] */
 	if (-1 == c)
 		return;
 	if (0 == c)
 		return;
 	if (127 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 128' [230] */
+	/* expect+1: warning: nonportable character comparison '128 == ?' [230] */
 	if (128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 255' [230] */
+	/* expect+1: warning: nonportable character comparison '255 == ?' [230] */
 	if (255 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 256' [230] */
+	/* expect+1: warning: nonportable character comparison '256 == ?' [230] */
 	if (256 == c)
 		return;
 }

Index: src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.9 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.10
--- src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.9	Wed Jun 22 19:23:18 2022
+++ src/tests/usr.bin/xlint/lint1/msg_230_uchar.c	Wed Feb 22 22:30:40 2023
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_230_uchar.c,v 1.9 2022/06/22 19:23:18 rillig Exp $	*/
+/*	$NetBSD: msg_230_uchar.c,v 1.10 2023/02/22 22:30:40 rillig Exp $	*/
 # 3 "msg_230_uchar.c"
 
-// Test for message: nonportable character comparison '%s %d' [230]
+// Test for message: nonportable character comparison '%s' [230]
 
 /* lint1-flags: -S -g -p -w */
 /* lint1-only-if: uchar */
@@ -46,26 +46,26 @@ compare_plain_char(char c)
 void
 compare_plain_char_yoda(char c)
 {
-	/* expect+1: warning: nonportable character comparison '== -129' [230] */
+	/* expect+1: warning: nonportable character comparison '? == -129' [230] */
 	if (-129 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== -128' [230] */
+	/* expect+1: warning: nonportable character comparison '? == -128' [230] */
 	if (-128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== -1' [230] */
+	/* expect+1: warning: nonportable character comparison '? == -1' [230] */
 	if (-1 == c)
 		return;
 	if (0 == c)
 		return;
 	if (127 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 128' [230] */
+	/* expect+1: warning: nonportable character comparison '? == 128' [230] */
 	if (128 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 255' [230] */
+	/* expect+1: warning: nonportable character comparison '? == 255' [230] */
 	if (255 == c)
 		return;
-	/* expect+1: warning: nonportable character comparison '== 256' [230] */
+	/* expect+1: warning: nonportable character comparison '? == 256' [230] */
 	if (256 == c)
 		return;
 }

Index: src/tests/usr.bin/xlint/lint1/platform_schar.c
diff -u src/tests/usr.bin/xlint/lint1/platform_schar.c:1.3 src/tests/usr.bin/xlint/lint1/platform_schar.c:1.4
--- src/tests/usr.bin/xlint/lint1/platform_schar.c:1.3	Wed Feb 22 22:12:35 2023
+++ src/tests/usr.bin/xlint/lint1/platform_schar.c	Wed Feb 22 22:30:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_schar.c,v 1.3 2023/02/22 2

CVS commit: src

2023-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb 22 22:30:40 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230_uchar.c
platform_schar.c
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: fix confusing message about nonportable character constants


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_schar.c
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.504 -r1.505 src/usr.bin/xlint/lint1/tree.c

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



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

2023-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb 22 22:12:35 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_ilp32.c platform_ldbl128.c
platform_ldbl64.c platform_ldbl96.c platform_lp64.c
platform_schar.c platform_uchar.c

Log Message:
tests/lint: add platform-specific tests


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/platform_ilp32.c \
src/tests/usr.bin/xlint/lint1/platform_ldbl128.c \
src/tests/usr.bin/xlint/lint1/platform_ldbl64.c \
src/tests/usr.bin/xlint/lint1/platform_ldbl96.c \
src/tests/usr.bin/xlint/lint1/platform_schar.c \
src/tests/usr.bin/xlint/lint1/platform_uchar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_lp64.c

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



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

2023-02-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb 22 22:12:35 UTC 2023

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_ilp32.c platform_ldbl128.c
platform_ldbl64.c platform_ldbl96.c platform_lp64.c
platform_schar.c platform_uchar.c

Log Message:
tests/lint: add platform-specific tests


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/platform_ilp32.c \
src/tests/usr.bin/xlint/lint1/platform_ldbl128.c \
src/tests/usr.bin/xlint/lint1/platform_ldbl64.c \
src/tests/usr.bin/xlint/lint1/platform_ldbl96.c \
src/tests/usr.bin/xlint/lint1/platform_schar.c \
src/tests/usr.bin/xlint/lint1/platform_uchar.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_lp64.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/platform_ilp32.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ilp32.c:1.2 src/tests/usr.bin/xlint/lint1/platform_ilp32.c:1.3
--- src/tests/usr.bin/xlint/lint1/platform_ilp32.c:1.2	Sun Sep 26 14:28:22 2021
+++ src/tests/usr.bin/xlint/lint1/platform_ilp32.c	Wed Feb 22 22:12:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_ilp32.c,v 1.2 2021/09/26 14:28:22 rillig Exp $	*/
+/*	$NetBSD: platform_ilp32.c,v 1.3 2023/02/22 22:12:35 rillig Exp $	*/
 # 3 "platform_ilp32.c"
 
 /*
@@ -9,7 +9,20 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ilp32 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
+int s32;
+unsigned int u32;
+long sl32;
+unsigned long ul32;
 
-/* expect+1: warning: empty translation unit [272] */
+void
+convert_between_int_and_long(void)
+{
+	/*
+	 * No warning about possible loss of accuracy, as the types have the
+	 * same size.
+	 */
+	s32 = sl32;
+	sl32 = s32;
+	u32 = ul32;
+	ul32 = u32;
+}
Index: src/tests/usr.bin/xlint/lint1/platform_ldbl128.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ldbl128.c:1.2 src/tests/usr.bin/xlint/lint1/platform_ldbl128.c:1.3
--- src/tests/usr.bin/xlint/lint1/platform_ldbl128.c:1.2	Sun Sep 26 14:28:22 2021
+++ src/tests/usr.bin/xlint/lint1/platform_ldbl128.c	Wed Feb 22 22:12:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_ldbl128.c,v 1.2 2021/09/26 14:28:22 rillig Exp $	*/
+/*	$NetBSD: platform_ldbl128.c,v 1.3 2023/02/22 22:12:35 rillig Exp $	*/
 # 3 "platform_ldbl128.c"
 
 /*
@@ -8,7 +8,6 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ldbl-128 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
+typedef int bytes_per_long_double[sizeof(long double) == 16 ? 1 : -1];
Index: src/tests/usr.bin/xlint/lint1/platform_ldbl64.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ldbl64.c:1.2 src/tests/usr.bin/xlint/lint1/platform_ldbl64.c:1.3
--- src/tests/usr.bin/xlint/lint1/platform_ldbl64.c:1.2	Sun Sep 26 14:28:22 2021
+++ src/tests/usr.bin/xlint/lint1/platform_ldbl64.c	Wed Feb 22 22:12:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_ldbl64.c,v 1.2 2021/09/26 14:28:22 rillig Exp $	*/
+/*	$NetBSD: platform_ldbl64.c,v 1.3 2023/02/22 22:12:35 rillig Exp $	*/
 # 3 "platform_ldbl64.c"
 
 /*
@@ -8,7 +8,6 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ldbl-64 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
+typedef int bytes_per_long_double[sizeof(long double) == 8 ? 1 : -1];
Index: src/tests/usr.bin/xlint/lint1/platform_ldbl96.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ldbl96.c:1.2 src/tests/usr.bin/xlint/lint1/platform_ldbl96.c:1.3
--- src/tests/usr.bin/xlint/lint1/platform_ldbl96.c:1.2	Sun Sep 26 14:28:22 2021
+++ src/tests/usr.bin/xlint/lint1/platform_ldbl96.c	Wed Feb 22 22:12:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_ldbl96.c,v 1.2 2021/09/26 14:28:22 rillig Exp $	*/
+/*	$NetBSD: platform_ldbl96.c,v 1.3 2023/02/22 22:12:35 rillig Exp $	*/
 # 3 "platform_ldbl96.c"
 
 /*
@@ -8,7 +8,6 @@
 /* lint1-extra-flags: -c -h -a -p -b -r -z */
 /* lint1-only-if: ldbl-96 */
 
-// TODO: Add some code that passes.
-// TODO: Add some code that fails.
-
-/* expect+1: warning: empty translation unit [272] */
+/* CONSTCOND */
+typedef int bits_per_byte[((unsigned char)-1) == 255 ? 1 : -1];
+typedef int bytes_per_long_double[sizeof(long double) == 12 ? 1 : -1];
Index: src/tests/usr.bin/xlint/lint1/platform_schar.c
diff -u src/tests/usr.bin/xlint/lint1/platform_schar.c:1.2 src/tests/usr.bin/xlint/lint1/platform_schar.c:1.3
--- src/tests/usr.bin/xlint/lint1/platform_schar.c:1.2	Sun Sep 26 14:28:22 2021
+++ src/tests/usr.bin/xlint/lint1/platform_schar.c	Wed Feb 22 22:12:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_schar.c,v 1.2 2021/09

CVS commit: src/sys/ufs/ufs

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:49:45 UTC 2023

Modified Files:
src/sys/ufs/ufs: quota1_subr.c quota2.h quota2_subr.c ufs_acl.c
ufs_extattr.c ufs_lookup.c ufs_quota.c ufs_quota1.c ufs_quota2.c
ufs_vfsops.c

Log Message:
ufs: Nix trailing whitespace and tidy up some other minor KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ufs/quota1_subr.c
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/quota2.h
cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ufs/quota2_subr.c
cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ufs/ufs_acl.c
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ufs/ufs_extattr.c
cvs rdiff -u -r1.156 -r1.157 src/sys/ufs/ufs/ufs_lookup.c
cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/ufs/ufs_quota.c
cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/ufs_quota1.c
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ufs/ufs_quota2.c
cvs rdiff -u -r1.60 -r1.61 src/sys/ufs/ufs/ufs_vfsops.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/ufs/ufs/quota1_subr.c
diff -u src/sys/ufs/ufs/quota1_subr.c:1.7 src/sys/ufs/ufs/quota1_subr.c:1.8
--- src/sys/ufs/ufs/quota1_subr.c:1.7	Sun Jan 29 06:23:20 2012
+++ src/sys/ufs/ufs/quota1_subr.c	Wed Feb 22 21:49:45 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp $ */
+/* $NetBSD: quota1_subr.c,v 1.8 2023/02/22 21:49:45 riastradh Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.7 2012/01/29 06:23:20 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.8 2023/02/22 21:49:45 riastradh Exp $");
 
 #include 
 #include 
@@ -54,7 +54,7 @@ q2e2dqblk_limit(uint64_t lim)
 
 void
 dqblk_to_quotavals(const struct dqblk *dqblk,
-		   struct quotaval *blocks, struct quotaval *files)
+struct quotaval *blocks, struct quotaval *files)
 {
 	/* XXX is qv_grace getting handled correctly? */
 
@@ -71,7 +71,7 @@ dqblk_to_quotavals(const struct dqblk *d
 
 void
 quotavals_to_dqblk(const struct quotaval *blocks, const struct quotaval *files,
-		   struct dqblk *dqblk)
+struct dqblk *dqblk)
 {
 	/* XXX is qv_grace getting handled correctly? */
 
@@ -85,4 +85,3 @@ quotavals_to_dqblk(const struct quotaval
 	dqblk->dqb_curinodes  = files->qv_usage;
 	dqblk->dqb_itime  = files->qv_expiretime;
 }
-

Index: src/sys/ufs/ufs/quota2.h
diff -u src/sys/ufs/ufs/quota2.h:1.10 src/sys/ufs/ufs/quota2.h:1.11
--- src/sys/ufs/ufs/quota2.h:1.10	Wed Oct 25 18:06:01 2017
+++ src/sys/ufs/ufs/quota2.h	Wed Feb 22 21:49:45 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: quota2.h,v 1.10 2017/10/25 18:06:01 jdolecek Exp $ */
+/* $NetBSD: quota2.h,v 1.11 2023/02/22 21:49:45 riastradh Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -115,7 +115,7 @@ void quota2_ufs_rwq2e(const struct quota
 #define QL_S_ALLOW_SOFT	0x01 /* over soft limit */
 #define QL_S_DENY_GRACE	0x02 /* over soft limit, grace time expired */
 #define QL_S_DENY_HARD	0x03 /* over hard limit */
- 
+
 #define QL_F_CROSS	0x80 /* crossing soft limit */
 
 #define QL_STATUS(x)	((x) & 0x0f)

Index: src/sys/ufs/ufs/quota2_subr.c
diff -u src/sys/ufs/ufs/quota2_subr.c:1.5 src/sys/ufs/ufs/quota2_subr.c:1.6
--- src/sys/ufs/ufs/quota2_subr.c:1.5	Sun Feb  5 14:19:04 2012
+++ src/sys/ufs/ufs/quota2_subr.c	Wed Feb 22 21:49:45 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: quota2_subr.c,v 1.5 2012/02/05 14:19:04 dholland Exp $ */
+/* $NetBSD: quota2_subr.c,v 1.6 2023/02/22 21:49:45 riastradh Exp $ */
 /*-
   * Copyright (c) 2010, 2011 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.5 2012/02/05 14:19:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.6 2023/02/22 21:49:45 riastradh Exp $");
 
 #include 
 #include 
@@ -87,7 +87,8 @@ quota2_create_blk0(uint64_t bsize, void 
 }
 
 void
-quota2_ufs_rwq2v(const struct quota2_val *s, struct quota2_val *d, int needswap)
+quota2_ufs_rwq2v(const struct quota2_val *s, struct quota2_val *d,
+int needswap)
 {
 	d->q2v_hardlimit = ufs_rw64(s->q2v_hardlimit, needswap);
 	d->q2v_softlimit = ufs_rw64(s->q2v_softlimit, needswap);
@@ -98,7 +99,7 @@ quota2_ufs_rwq2v(const struct quota2_val
 
 void
 quota2_ufs_rwq2e(const struct quota2_entry *s, struct quota2_entry *d,
-int needswap)
+int needswap)
 {
 	quota2_ufs_rwq2v(&s->q2e_val[QL_BLOCK], &d->q2e_val[QL_BLOCK],
 	needswap);
@@ -110,7 +111,7 @@ int needswap)
 int
 quota_check_limit(uint64_t cur, uint64_t change, uint64_t soft, uint64_t hard,
 time_t expire, time_t now)
-{ 
+{
 	if (cur + change > hard) {
 		if (cur <= soft)
 			return (QL_F_CROSS | QL_S_DENY_HARD);
@@ -124,4 +125,4 @@ quota_check_limit(uint64_t cur, uint64_t
 		return QL_S_ALLOW_SOFT;
 	}
 	return QL_S_ALLOW_OK;
-} 
+}

Index: src/sys/ufs/ufs/ufs_acl.c
diff -u src/sys/ufs/ufs/ufs_acl.c:1.4 src/sys/uf

CVS commit: src/sys/ufs/ufs

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:49:45 UTC 2023

Modified Files:
src/sys/ufs/ufs: quota1_subr.c quota2.h quota2_subr.c ufs_acl.c
ufs_extattr.c ufs_lookup.c ufs_quota.c ufs_quota1.c ufs_quota2.c
ufs_vfsops.c

Log Message:
ufs: Nix trailing whitespace and tidy up some other minor KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ufs/quota1_subr.c
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/quota2.h
cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ufs/quota2_subr.c
cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ufs/ufs_acl.c
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ufs/ufs_extattr.c
cvs rdiff -u -r1.156 -r1.157 src/sys/ufs/ufs/ufs_lookup.c
cvs rdiff -u -r1.117 -r1.118 src/sys/ufs/ufs/ufs_quota.c
cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/ufs_quota1.c
cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ufs/ufs_quota2.c
cvs rdiff -u -r1.60 -r1.61 src/sys/ufs/ufs/ufs_vfsops.c

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



CVS commit: src/sys/rump/librump/rumpkern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:44:45 UTC 2023

Modified Files:
src/sys/rump/librump/rumpkern: lwproc.c

Log Message:
rump: Nix membar_enter/exit after/before RUMPUSER_LWP_CREATE/DESTROY.

These make no sense and are obviously not needed for any of the
rumpuser implementations in-tree.  (For single-threaded fiber and
pth_dummy, no barriers needed; for pth, RUMPUSER_LWP_CREATE/DESTROY
use pthread_mutex so don't need any barriers.)

It _might_ make sense to do membar_release/acquire around just
RUMPUSER_LWP_DESTROY, perhaps if there's some reference-counting
business involved.  But if a rumpuser implementation really needs
that it can do it itself.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/rump/librump/rumpkern/lwproc.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/rump/librump/rumpkern/lwproc.c
diff -u src/sys/rump/librump/rumpkern/lwproc.c:1.53 src/sys/rump/librump/rumpkern/lwproc.c:1.54
--- src/sys/rump/librump/rumpkern/lwproc.c:1.53	Wed Feb 22 21:44:33 2023
+++ src/sys/rump/librump/rumpkern/lwproc.c	Wed Feb 22 21:44:45 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: lwproc.c,v 1.53 2023/02/22 21:44:33 riastradh Exp $	*/
+/*  $NetBSD: lwproc.c,v 1.54 2023/02/22 21:44:45 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #define RUMP__CURLWP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.53 2023/02/22 21:44:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.54 2023/02/22 21:44:45 riastradh Exp $");
 
 #include 
 #include 
@@ -334,7 +334,6 @@ lwproc_freelwp(struct lwp *l)
 	lwp_finispecific(l);
 
 	lwproc_curlwpop(RUMPUSER_LWP_DESTROY, l);
-	membar_exit();
 	kmem_free(l, sizeof(*l));
 
 	if (p->p_stat == SDEAD)
@@ -379,7 +378,6 @@ lwproc_makelwp(struct proc *p, bool dosw
 	lwp_initspecific(l);
 	PSREF_DEBUG_INIT_LWP(l);
 
-	membar_enter();
 	lwproc_curlwpop(RUMPUSER_LWP_CREATE, l);
 	if (doswitch) {
 		rump_lwproc_switch(l);



CVS commit: src/sys/rump/librump/rumpkern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:44:45 UTC 2023

Modified Files:
src/sys/rump/librump/rumpkern: lwproc.c

Log Message:
rump: Nix membar_enter/exit after/before RUMPUSER_LWP_CREATE/DESTROY.

These make no sense and are obviously not needed for any of the
rumpuser implementations in-tree.  (For single-threaded fiber and
pth_dummy, no barriers needed; for pth, RUMPUSER_LWP_CREATE/DESTROY
use pthread_mutex so don't need any barriers.)

It _might_ make sense to do membar_release/acquire around just
RUMPUSER_LWP_DESTROY, perhaps if there's some reference-counting
business involved.  But if a rumpuser implementation really needs
that it can do it itself.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/rump/librump/rumpkern/lwproc.c

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



CVS commit: src/sys/rump/librump/rumpkern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:44:34 UTC 2023

Modified Files:
src/sys/rump/librump/rumpkern: lwproc.c

Log Message:
rumpkern/lwproc.c: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/rump/librump/rumpkern/lwproc.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/rump/librump/rumpkern/lwproc.c
diff -u src/sys/rump/librump/rumpkern/lwproc.c:1.52 src/sys/rump/librump/rumpkern/lwproc.c:1.53
--- src/sys/rump/librump/rumpkern/lwproc.c:1.52	Wed Nov  2 09:01:42 2022
+++ src/sys/rump/librump/rumpkern/lwproc.c	Wed Feb 22 21:44:33 2023
@@ -1,4 +1,4 @@
-/*  $NetBSD: lwproc.c,v 1.52 2022/11/02 09:01:42 ozaki-r Exp $	*/
+/*  $NetBSD: lwproc.c,v 1.53 2023/02/22 21:44:33 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #define RUMP__CURLWP_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.52 2022/11/02 09:01:42 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.53 2023/02/22 21:44:33 riastradh Exp $");
 
 #include 
 #include 
@@ -73,7 +73,7 @@ lwp_unsleep(lwp_t *l, bool cleanup)
 
 /*
  * Look up a live LWP within the specified process.
- * 
+ *
  * Must be called with p->p_lock held.
  */
 struct lwp *
@@ -338,7 +338,7 @@ lwproc_freelwp(struct lwp *l)
 	kmem_free(l, sizeof(*l));
 
 	if (p->p_stat == SDEAD)
-		lwproc_proc_free(p);	
+		lwproc_proc_free(p);
 }
 
 extern kmutex_t unruntime_lock;



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:44:21 UTC 2023

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

Log Message:
_vstate_assert: Use atomic_load/store_relaxed.  Omit membar_enter.

Can't find anything this is supposed to pair with.  Pretty sure this
is just an optimistic unlocked test, not actually reliant on memory
ordering.  But as it is unlocked, it needs to be coordinated with
atomic_load/store_relaxed, not ordinary loads or stores, if for no
other reason than to pacify sanitizers.

No need in vnalloc_marker or vcache_alloc because these still have
exclusive access to the vnode at that point.

XXX Should deduplicate the logic in vstate_assert_change and
vstate_change.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/kern/vfs_vnode.c

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.147 src/sys/kern/vfs_vnode.c:1.148
--- src/sys/kern/vfs_vnode.c:1.147	Wed Oct 26 23:40:08 2022
+++ src/sys/kern/vfs_vnode.c	Wed Feb 22 21:44:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.147 2022/10/26 23:40:08 riastradh Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.148 2023/02/22 21:44:21 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.147 2022/10/26 23:40:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.148 2023/02/22 21:44:21 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -269,17 +269,12 @@ _vstate_assert(vnode_t *vp, enum vnode_s
 	int refcnt = vrefcnt(vp);
 
 	if (!has_lock) {
-		/*
-		 * Prevent predictive loads from the CPU, but check the state
-		 * without loooking first.
-		 *
-		 * XXX what does this pair with?
-		 */
-		membar_enter();
+		enum vnode_state vstate = atomic_load_relaxed(&vip->vi_state);
+
 		if (state == VS_ACTIVE && refcnt > 0 &&
-		(vip->vi_state == VS_LOADED || vip->vi_state == VS_BLOCKED))
+		(vstate == VS_LOADED || vstate == VS_BLOCKED))
 			return;
-		if (vip->vi_state == state)
+		if (vstate == state)
 			return;
 		mutex_enter((vp)->v_interlock);
 	}
@@ -363,7 +358,7 @@ vstate_assert_change(vnode_t *vp, enum v
 		atomic_and_uint(&vp->v_usecount, ~VUSECOUNT_GATE);
 	}
 
-	vip->vi_state = to;
+	atomic_store_relaxed(&vip->vi_state, to);
 	if (from == VS_LOADING)
 		cv_broadcast(&vcache_cv);
 	if (to == VS_LOADED || to == VS_RECLAIMED)
@@ -409,7 +404,7 @@ vstate_change(vnode_t *vp, enum vnode_st
 		atomic_and_uint(&vp->v_usecount, ~VUSECOUNT_GATE);
 	}
 
-	vip->vi_state = to;
+	atomic_store_relaxed(&vip->vi_state, to);
 	if (from == VS_LOADING)
 		cv_broadcast(&vcache_cv);
 	if (to == VS_LOADED || to == VS_RECLAIMED)



CVS commit: src/sys/rump/librump/rumpkern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:44:34 UTC 2023

Modified Files:
src/sys/rump/librump/rumpkern: lwproc.c

Log Message:
rumpkern/lwproc.c: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/rump/librump/rumpkern/lwproc.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

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 21:44:21 UTC 2023

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

Log Message:
_vstate_assert: Use atomic_load/store_relaxed.  Omit membar_enter.

Can't find anything this is supposed to pair with.  Pretty sure this
is just an optimistic unlocked test, not actually reliant on memory
ordering.  But as it is unlocked, it needs to be coordinated with
atomic_load/store_relaxed, not ordinary loads or stores, if for no
other reason than to pacify sanitizers.

No need in vnalloc_marker or vcache_alloc because these still have
exclusive access to the vnode at that point.

XXX Should deduplicate the logic in vstate_assert_change and
vstate_change.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/kern/vfs_vnode.c

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



CVS commit: [netbsd-8] src/doc

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:57:50 UTC 2023

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

Log Message:
Tickets #1798 - #1802


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

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



CVS commit: [netbsd-8] src/doc

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:57:50 UTC 2023

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

Log Message:
Tickets #1798 - #1802


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

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

Modified files:

Index: src/doc/CHANGES-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.165 src/doc/CHANGES-8.3:1.1.2.166
--- src/doc/CHANGES-8.3:1.1.2.165	Tue Feb 14 16:05:01 2023
+++ src/doc/CHANGES-8.3	Wed Feb 22 19:57:50 2023
@@ -1,4 +1,4 @@
- $NetBSD: CHANGES-8.3,v 1.1.2.165 2023/02/14 16:05:01 martin Exp $
+ $NetBSD: CHANGES-8.3,v 1.1.2.166 2023/02/22 19:57:50 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -3161,3 +3161,36 @@ xsrc/external/mit/xorg-server/dist/Xi/ex
 	CVE-2023-0494, ZDI-CAN-19596
 	[mrg, ticket #1797]
 
+lib/libc/string/swab.c1.20
+tests/lib/libc/string/t_swab.c			1.3
+
+	swab(3): PR 57141: fix swab(3) and ensure it is properly tested.
+	[riastradh, ticket #1798]
+
+sys/net/route.c	1.236
+
+	route(4): PR 56844: work around deadlock in rt_free wait path.
+	[riastradh, ticket #1801]
+
+sys/arch/x86/x86/efi_machdep.c			1.3
+	(applied to sys/arch/x86/x86/efi.c)
+
+	x86/efi: Print uuids in slightly more standard notation.
+	[riastradh, ticket #1799]
+
+crypto/external/bsd/openssh/bin/Makefile	1.5
+etc/bluetooth/Makefile1.6
+etc/iscsi/Makefile1.4
+etc/root/Makefile1.5
+etc/ssh/Makefile1.4
+external/ibm-public/postfix/etc/Makefile	1.2
+usr.bin/mail/Makefile1.41
+
+	Fix modes of editable config files.
+	[riastradh, ticket #1800]
+
+sys/net/bpf.c	1.247 (merged)
+
+	bpf(4): Reject bogus timeout values before arithmetic overflows.
+	[riastradh, ticket #1802]
+



CVS commit: [netbsd-9] src/doc

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:57:12 UTC 2023

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

Log Message:
Tickets #1600 - #1605


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.52 -r1.1.2.53 src/doc/CHANGES-9.4

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

Modified files:

Index: src/doc/CHANGES-9.4
diff -u src/doc/CHANGES-9.4:1.1.2.52 src/doc/CHANGES-9.4:1.1.2.53
--- src/doc/CHANGES-9.4:1.1.2.52	Fri Feb 17 17:42:21 2023
+++ src/doc/CHANGES-9.4	Wed Feb 22 19:57:11 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.4,v 1.1.2.52 2023/02/17 17:42:21 martin Exp $
+# $NetBSD: CHANGES-9.4,v 1.1.2.53 2023/02/22 19:57:11 martin Exp $
 
 A complete list of changes from the NetBSD 9.3 release to the NetBSD 9.4
 release:
@@ -852,3 +852,51 @@ sys/dev/usb/usbdevs_data.h			(regen)
 	urndis(4): Add OnePlus 5T to the quirky devices list.
 	[nia, ticket #1599]
 
+sys/arch/next68k/stand/boot/boot.c		1.14,1.15
+sys/arch/next68k/stand/boot/conf.c		1.8
+sys/arch/next68k/stand/boot/devopen.c		1.8
+sys/arch/next68k/stand/boot/en.c		1.20
+sys/arch/next68k/stand/boot/machdep.c		1.9
+sys/arch/next68k/stand/boot/rtc.c		1.8
+sys/arch/next68k/stand/boot/samachdep.h		1.1,1.2
+sys/arch/next68k/stand/boot/scsi.c		1.13,1.14
+sys/arch/next68k/stand/boot/scsivar.h		1.2
+sys/arch/next68k/stand/boot/sd.c		1.17
+sys/arch/next68k/stand/boot/version		1.7
+
+	next68k: various fixes for sdboot.
+	[tsutsui, ticket #1600]
+
+lib/libc/string/swab.c1.20
+tests/lib/libc/string/t_swab.c			1.3
+
+	swab(3): PR 57141: fix swab(3) and ensure it is properly tested.
+	[riastradh, ticket #1601]
+
+sys/net/route.c	1.236
+
+	route(4): PR 56844: work around deadlock in rt_free wait path.
+	[riastradh, ticket #1602]
+
+sys/arch/x86/x86/efi_machdep.c			1.3
+	(applied to sys/arch/x86/x86/efi.c)
+
+	x86/efi: Print uuids in slightly more standard notation.
+	[riastradh, ticket #1603]
+
+crypto/external/bsd/openssh/bin/Makefile	1.5
+etc/bluetooth/Makefile1.6
+etc/iscsi/Makefile1.4
+etc/root/Makefile1.5
+etc/ssh/Makefile1.4
+external/ibm-public/postfix/etc/Makefile	1.2
+usr.bin/mail/Makefile1.41
+
+	Fix modes of editable config files.
+	[riastradh, ticket #1604]
+
+sys/net/bpf.c	1.247 (merged)
+
+	bpf(4): Reject bogus timeout values before arithmetic overflows.
+	[riastradh, ticket #1605]
+



CVS commit: [netbsd-9] src/doc

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:57:12 UTC 2023

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

Log Message:
Tickets #1600 - #1605


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.52 -r1.1.2.53 src/doc/CHANGES-9.4

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



CVS commit: [netbsd-10] src/doc

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:56:28 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets #90 - #101


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 src/doc/CHANGES-10.0

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

Modified files:

Index: src/doc/CHANGES-10.0
diff -u src/doc/CHANGES-10.0:1.1.2.35 src/doc/CHANGES-10.0:1.1.2.36
--- src/doc/CHANGES-10.0:1.1.2.35	Fri Feb 17 17:37:39 2023
+++ src/doc/CHANGES-10.0	Wed Feb 22 19:56:27 2023
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-10.0,v 1.1.2.35 2023/02/17 17:37:39 martin Exp $
+# $NetBSD: CHANGES-10.0,v 1.1.2.36 2023/02/22 19:56:27 martin Exp $
 
 A complete list of changes from the initial NetBSD 10.0 branch on 2022-12-16
 until the 10.0 release:
@@ -1108,3 +1108,87 @@ sys/dev/usb/usbdevs_data.h			(regen)
 	urndis(4): Add OnePlus 5T to the quirky devices list.
 	[nia, ticket #89]
 
+sys/arch/next68k/stand/boot/boot.c		1.14,1.15
+sys/arch/next68k/stand/boot/conf.c		1.8
+sys/arch/next68k/stand/boot/devopen.c		1.8
+sys/arch/next68k/stand/boot/en.c		1.20
+sys/arch/next68k/stand/boot/machdep.c		1.9
+sys/arch/next68k/stand/boot/rtc.c		1.8
+sys/arch/next68k/stand/boot/samachdep.h		1.1,1.2
+sys/arch/next68k/stand/boot/scsi.c		1.13,1.14
+sys/arch/next68k/stand/boot/scsivar.h		1.2
+sys/arch/next68k/stand/boot/sd.c		1.17
+sys/arch/next68k/stand/boot/version		1.7
+
+	next68k: various fixes for sdboot.
+	[tsutsui, ticket #90]
+
+distrib/next68k/Makefile			1.2
+distrib/next68k/instkernel/Makefile		1.1
+distrib/next68k/ramdisk/Makefile		1.1
+distrib/next68k/ramdisk/dot.profile		1.1
+distrib/next68k/ramdisk/list			1.1
+etc/etc.next68k/MAKEDEV.conf			1.7
+etc/etc.next68k/Makefile.inc			1.8
+sys/arch/next68k/conf/GENERIC			1.156-1.161
+sys/arch/next68k/conf/RAMDISK			1.5
+sys/arch/next68k/conf/SLAB			1.62,1.63
+sys/arch/next68k/conf/majors.next68k		1.26
+
+	next68k: add a RAMDISK kernel.
+	[tsutsui, ticket #91]
+
+sys/dev/usb/ucom.c1.135,1.136
+
+	ucom(4): fix hang.
+	[riastradh, ticket #92]
+
+sbin/fsck/fsck.c1.53
+
+	fsck(8): fix detection of filesystem type.
+	[mlelstv, ticket #93]
+
+sbin/scan_ffs/Makefile1.11
+sbin/scan_ffs/scan_ffs.c			1.37
+
+	scan_ffs(8): support swapped-endian FFS.
+	[mlelstv, ticket #94]
+
+external/bsd/fetch/dist/libfetch/common.c	1.3,1.4
+
+	libfetch: enable SNI (server name indication) for TLS connections.
+	[mlelstv, ticket #95]
+
+
+sys/kern/kern_subr.c1.231
+
+	Delay root device detection for hot-plug devices like USB.
+	[mlelstv, ticket #96]
+
+sys/modules/drmkms/Makefile			1.19
+sys/modules/drmkms_pci/Makefile			1.11
+
+	Fix drmkms module builds.
+	[riastradh, ticket #97]
+
+lib/libc/string/swab.c1.20
+tests/lib/libc/string/t_swab.c			1.3
+
+	swab(3): PR 57141: fix swab(3) and ensure it is properly tested.
+	[riastradh, ticket #98]
+
+sys/net/route.c	1.236
+
+	route(4): PR 56844: work around deadlock in rt_free wait path.
+	[riastradh, ticket #99]
+
+sys/kern/kern_module.c1.161
+
+	module(9): Make error message for multiple MODULE decls more obvious.
+	[riastradh, ticket #100]
+
+sys/kern/kern_time.c1.219
+
+	In itimer_arm_real(), KASSERT that it->it_dying is false.
+	[thorpej, ticket #101]
+



CVS commit: [netbsd-10] src/doc

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:56:28 UTC 2023

Modified Files:
src/doc [netbsd-10]: CHANGES-10.0

Log Message:
Tickets #90 - #101


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 src/doc/CHANGES-10.0

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



CVS commit: [netbsd-10] src/sys/kern

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:54:30 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: kern_time.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #101):

sys/kern/kern_time.c: revision 1.219

In itimer_arm_real(), KASSERT that it->it_dying is false.  This was
already implicitly assumed, but make it explicit in hopes of tracking
down kern/57226.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.218.2.1 src/sys/kern/kern_time.c

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



CVS commit: [netbsd-10] src/sys/kern

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:54:30 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: kern_time.c

Log Message:
Pull up following revision(s) (requested by thorpej in ticket #101):

sys/kern/kern_time.c: revision 1.219

In itimer_arm_real(), KASSERT that it->it_dying is false.  This was
already implicitly assumed, but make it explicit in hopes of tracking
down kern/57226.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.218.2.1 src/sys/kern/kern_time.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_time.c
diff -u src/sys/kern/kern_time.c:1.218 src/sys/kern/kern_time.c:1.218.2.1
--- src/sys/kern/kern_time.c:1.218	Wed Oct 26 23:23:52 2022
+++ src/sys/kern/kern_time.c	Wed Feb 22 19:54:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_time.c,v 1.218 2022/10/26 23:23:52 riastradh Exp $	*/
+/*	$NetBSD: kern_time.c,v 1.218.2.1 2023/02/22 19:54:30 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009, 2020
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.218 2022/10/26 23:23:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.218.2.1 2023/02/22 19:54:30 martin Exp $");
 
 #include 
 #include 
@@ -809,6 +809,8 @@ static void itimer_callout(void *);
 static void
 itimer_arm_real(struct itimer * const it)
 {
+	KASSERT(!it->it_dying);
+
 	/*
 	 * Don't need to check tshzto() return value, here.
 	 * callout_reset() does it for us.



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:50:33 UTC 2023

Modified Files:
src/sys/net [netbsd-9]: bpf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1605):

sys/net/bpf.c: revision 1.247 (manually merged)

bpf(4): Reject bogus timeout values before arithmetic overflows.


To generate a diff of this commit:
cvs rdiff -u -r1.229.2.1 -r1.229.2.2 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.229.2.1 src/sys/net/bpf.c:1.229.2.2
--- src/sys/net/bpf.c:1.229.2.1	Wed Oct 16 09:46:55 2019
+++ src/sys/net/bpf.c	Wed Feb 22 19:50:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.229.2.1 2019/10/16 09:46:55 martin Exp $	*/
+/*	$NetBSD: bpf.c,v 1.229.2.2 2023/02/22 19:50:33 martin Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.229.2.1 2019/10/16 09:46:55 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.229.2.2 2023/02/22 19:50:33 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -1092,7 +1092,16 @@ bpf_ioctl(struct file *fp, u_long cmd, v
 			struct timeval *tv = addr;
 
 			/* Compute number of ticks. */
-			d->bd_rtout = tv->tv_sec * hz + tv->tv_usec / tick;
+			if (tv->tv_sec < 0 ||
+			tv->tv_usec < 0 || tv->tv_usec >= 100) {
+error = EINVAL;
+break;
+			} else if (tv->tv_sec > INT_MAX/hz - 1) {
+ d->bd_rtout = INT_MAX;
+ 			} else {
+d->bd_rtout = tv->tv_sec * hz
++ tv->tv_usec / tick;
+			}
 			if ((d->bd_rtout == 0) && (tv->tv_usec != 0))
 d->bd_rtout = 1;
 			break;
@@ -1121,7 +1130,16 @@ bpf_ioctl(struct file *fp, u_long cmd, v
 			struct timeval50 *tv = addr;
 
 			/* Compute number of ticks. */
-			d->bd_rtout = tv->tv_sec * hz + tv->tv_usec / tick;
+			if (tv->tv_sec < 0 ||
+			tv->tv_usec < 0 || tv->tv_usec >= 100) {
+error = EINVAL;
+break;
+			} else if (tv->tv_sec > INT_MAX/hz - 1) {
+ d->bd_rtout = INT_MAX;
+ 			} else {
+ d->bd_rtout = tv->tv_sec * hz
++ tv->tv_usec / tick;
+			}
 			if ((d->bd_rtout == 0) && (tv->tv_usec != 0))
 d->bd_rtout = 1;
 			break;



CVS commit: [netbsd-8] src/sys/net

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:51:47 UTC 2023

Modified Files:
src/sys/net [netbsd-8]: bpf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1802):

sys/net/bpf.c: revision 1.247 (manually merged)

bpf(4): Reject bogus timeout values before arithmetic overflows.


To generate a diff of this commit:
cvs rdiff -u -r1.216.6.7 -r1.216.6.8 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: [netbsd-8] src/sys/net

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:51:47 UTC 2023

Modified Files:
src/sys/net [netbsd-8]: bpf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1802):

sys/net/bpf.c: revision 1.247 (manually merged)

bpf(4): Reject bogus timeout values before arithmetic overflows.


To generate a diff of this commit:
cvs rdiff -u -r1.216.6.7 -r1.216.6.8 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.216.6.7 src/sys/net/bpf.c:1.216.6.8
--- src/sys/net/bpf.c:1.216.6.7	Sun Aug  4 11:19:03 2019
+++ src/sys/net/bpf.c	Wed Feb 22 19:51:47 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.216.6.7 2019/08/04 11:19:03 martin Exp $	*/
+/*	$NetBSD: bpf.c,v 1.216.6.8 2023/02/22 19:51:47 martin Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.216.6.7 2019/08/04 11:19:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.216.6.8 2023/02/22 19:51:47 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -1091,7 +1091,16 @@ bpf_ioctl(struct file *fp, u_long cmd, v
 			struct timeval *tv = addr;
 
 			/* Compute number of ticks. */
-			d->bd_rtout = tv->tv_sec * hz + tv->tv_usec / tick;
+			if (tv->tv_sec < 0 ||
+			tv->tv_usec < 0 || tv->tv_usec >= 100) {
+error = EINVAL;
+break;
+			} else if (tv->tv_sec > INT_MAX/hz - 1) {
+ d->bd_rtout = INT_MAX;
+ 			} else {
+d->bd_rtout = tv->tv_sec * hz
++ tv->tv_usec / tick;
+			}
 			if ((d->bd_rtout == 0) && (tv->tv_usec != 0))
 d->bd_rtout = 1;
 			break;
@@ -1120,7 +1129,16 @@ bpf_ioctl(struct file *fp, u_long cmd, v
 			struct timeval50 *tv = addr;
 
 			/* Compute number of ticks. */
-			d->bd_rtout = tv->tv_sec * hz + tv->tv_usec / tick;
+			if (tv->tv_sec < 0 ||
+			tv->tv_usec < 0 || tv->tv_usec >= 100) {
+error = EINVAL;
+break;
+			} else if (tv->tv_sec > INT_MAX/hz - 1) {
+ d->bd_rtout = INT_MAX;
+ 			} else {
+ d->bd_rtout = tv->tv_sec * hz
++ tv->tv_usec / tick;
+			}
 			if ((d->bd_rtout == 0) && (tv->tv_usec != 0))
 d->bd_rtout = 1;
 			break;



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:50:33 UTC 2023

Modified Files:
src/sys/net [netbsd-9]: bpf.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1605):

sys/net/bpf.c: revision 1.247 (manually merged)

bpf(4): Reject bogus timeout values before arithmetic overflows.


To generate a diff of this commit:
cvs rdiff -u -r1.229.2.1 -r1.229.2.2 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: [netbsd-8] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:32:23 UTC 2023

Modified Files:
src/crypto/external/bsd/openssh/bin [netbsd-8]: Makefile
src/etc/bluetooth [netbsd-8]: Makefile
src/etc/iscsi [netbsd-8]: Makefile
src/etc/root [netbsd-8]: Makefile
src/etc/ssh [netbsd-8]: Makefile
src/external/ibm-public/postfix/etc [netbsd-8]: Makefile
src/usr.bin/mail [netbsd-8]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1800):

etc/ssh/Makefile: revision 1.4
usr.bin/mail/Makefile: revision 1.41
external/ibm-public/postfix/etc/Makefile: revision 1.2
etc/bluetooth/Makefile: revision 1.6
crypto/external/bsd/openssh/bin/Makefile: revision 1.5
etc/root/Makefile: revision 1.5
etc/iscsi/Makefile: revision 1.4

/root: Install .cshrc and .profile links with the same mode.

Previously we would:

1. Install /root/.cshrc and /root/.profile with mode FILESMODE=644 as
   requested in src/etc/root/Makefile and as echoed in
   /etc/mtree/special.
2. Create hard links at /.cshrc and /.profile through CONFIGLINKS.
3. Because LINKSMODE was unset and defaults to NOBINMODE=444, change
   the mode to 444.

This scenario is confusing, and mtree objects to it, which is bad for
warning fatigue in a security-relevant mechanism.  (There are also
several other files mtree objects to out of the box -- we should fix
those too.)

With this change we install the links with the same mode as the
original files, in agreement with the mtree.  The files, .cshrc and
.profile, are intended to be editable configuration files, so 644
makes sense while 444 makes no sense and gets in the way of editors
like vi.

Discussed on tech-userlevel:
https://mail-index.netbsd.org/tech-userlevel/2022/08/29/msg013498.html

etc: Fix permissions of various editable configuration files.

This way they match the mtree and make sense and don't cause editors
to ask to override read-only files when editing them.

Exception: Not sure /etc/bluetooth/protocols makes as much sense to
edit, but the mtree says 644, so if you want to change it, make sure
to change it in both places -- Makefile and mtree.

/etc/ssh: Install ssh_known_hosts with mode 644.
Makes it agree with the mtree and more convenient for admin to edit.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.40.1 src/crypto/external/bsd/openssh/bin/Makefile
cvs rdiff -u -r1.5 -r1.5.58.1 src/etc/bluetooth/Makefile
cvs rdiff -u -r1.3 -r1.3.80.1 src/etc/iscsi/Makefile
cvs rdiff -u -r1.4 -r1.4.24.1 src/etc/root/Makefile
cvs rdiff -u -r1.3 -r1.3.2.1 src/etc/ssh/Makefile
cvs rdiff -u -r1.1 -r1.1.42.1 src/external/ibm-public/postfix/etc/Makefile
cvs rdiff -u -r1.36 -r1.36.16.1 src/usr.bin/mail/Makefile

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

Modified files:

Index: src/crypto/external/bsd/openssh/bin/Makefile
diff -u src/crypto/external/bsd/openssh/bin/Makefile:1.3 src/crypto/external/bsd/openssh/bin/Makefile:1.3.40.1
--- src/crypto/external/bsd/openssh/bin/Makefile:1.3	Sun Nov 21 19:19:21 2010
+++ src/crypto/external/bsd/openssh/bin/Makefile	Wed Feb 22 19:32:23 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2010/11/21 19:19:21 adam Exp $
+#	$NetBSD: Makefile,v 1.3.40.1 2023/02/22 19:32:23 martin Exp $
 
 .include 
 
@@ -11,7 +11,9 @@ SUBDIR=	ssh sshd ssh-add ssh-keygen ssh-
 .MADE: moduli
 CONFIGFILES=	ssh_config sshd_config moduli
 FILESDIR=	/etc/ssh
+FILESMODE=	644
 FILESDIR_moduli=/etc
+FILESMODE_moduli=444
 
 .include 
 .include 

Index: src/etc/bluetooth/Makefile
diff -u src/etc/bluetooth/Makefile:1.5 src/etc/bluetooth/Makefile:1.5.58.1
--- src/etc/bluetooth/Makefile:1.5	Tue Apr 15 11:17:47 2008
+++ src/etc/bluetooth/Makefile	Wed Feb 22 19:32:23 2023
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2008/04/15 11:17:47 plunky Exp $
+# $NetBSD: Makefile,v 1.5.58.1 2023/02/22 19:32:23 martin Exp $
 
 CONFIGFILES=	btattach.conf btdevctl.conf hosts protocols
 FILESDIR=	/etc/bluetooth
+FILESMODE=	644
 
 .include 

Index: src/etc/iscsi/Makefile
diff -u src/etc/iscsi/Makefile:1.3 src/etc/iscsi/Makefile:1.3.80.1
--- src/etc/iscsi/Makefile:1.3	Sat Jun 24 05:14:01 2006
+++ src/etc/iscsi/Makefile	Wed Feb 22 19:32:23 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2006/06/24 05:14:01 mrg Exp $
+#	$NetBSD: Makefile,v 1.3.80.1 2023/02/22 19:32:23 martin Exp $
 
 .include 
 
@@ -7,6 +7,7 @@
 CONFIGFILES=	auths targets
 FILESDIR=   	/etc/iscsi
 FILESMODE_auths=	0600
+FILESMODE_targets=	0644
 
 .endif
 

Index: src/etc/root/Makefile
diff -u src/etc/root/Makefile:1.4 src/etc/root/Makefile:1.4.24.1
--- src/etc/root/Makefile:1.4	Sat Nov 17 23:08:38 2012
+++ src/etc/root/Makefile	Wed Feb 22 19:32:23 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2012/11/17 23:08:38 uwe Exp $
+#	$NetBSD: Makefile,v 1.4.24.1 2023/02/22 19:32:23 martin Exp $
 
 CONFIGFILES=		dot.cshrc dot.klogin dot.login

CVS commit: [netbsd-8] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:32:23 UTC 2023

Modified Files:
src/crypto/external/bsd/openssh/bin [netbsd-8]: Makefile
src/etc/bluetooth [netbsd-8]: Makefile
src/etc/iscsi [netbsd-8]: Makefile
src/etc/root [netbsd-8]: Makefile
src/etc/ssh [netbsd-8]: Makefile
src/external/ibm-public/postfix/etc [netbsd-8]: Makefile
src/usr.bin/mail [netbsd-8]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1800):

etc/ssh/Makefile: revision 1.4
usr.bin/mail/Makefile: revision 1.41
external/ibm-public/postfix/etc/Makefile: revision 1.2
etc/bluetooth/Makefile: revision 1.6
crypto/external/bsd/openssh/bin/Makefile: revision 1.5
etc/root/Makefile: revision 1.5
etc/iscsi/Makefile: revision 1.4

/root: Install .cshrc and .profile links with the same mode.

Previously we would:

1. Install /root/.cshrc and /root/.profile with mode FILESMODE=644 as
   requested in src/etc/root/Makefile and as echoed in
   /etc/mtree/special.
2. Create hard links at /.cshrc and /.profile through CONFIGLINKS.
3. Because LINKSMODE was unset and defaults to NOBINMODE=444, change
   the mode to 444.

This scenario is confusing, and mtree objects to it, which is bad for
warning fatigue in a security-relevant mechanism.  (There are also
several other files mtree objects to out of the box -- we should fix
those too.)

With this change we install the links with the same mode as the
original files, in agreement with the mtree.  The files, .cshrc and
.profile, are intended to be editable configuration files, so 644
makes sense while 444 makes no sense and gets in the way of editors
like vi.

Discussed on tech-userlevel:
https://mail-index.netbsd.org/tech-userlevel/2022/08/29/msg013498.html

etc: Fix permissions of various editable configuration files.

This way they match the mtree and make sense and don't cause editors
to ask to override read-only files when editing them.

Exception: Not sure /etc/bluetooth/protocols makes as much sense to
edit, but the mtree says 644, so if you want to change it, make sure
to change it in both places -- Makefile and mtree.

/etc/ssh: Install ssh_known_hosts with mode 644.
Makes it agree with the mtree and more convenient for admin to edit.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.40.1 src/crypto/external/bsd/openssh/bin/Makefile
cvs rdiff -u -r1.5 -r1.5.58.1 src/etc/bluetooth/Makefile
cvs rdiff -u -r1.3 -r1.3.80.1 src/etc/iscsi/Makefile
cvs rdiff -u -r1.4 -r1.4.24.1 src/etc/root/Makefile
cvs rdiff -u -r1.3 -r1.3.2.1 src/etc/ssh/Makefile
cvs rdiff -u -r1.1 -r1.1.42.1 src/external/ibm-public/postfix/etc/Makefile
cvs rdiff -u -r1.36 -r1.36.16.1 src/usr.bin/mail/Makefile

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



CVS commit: [netbsd-9] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:30:51 UTC 2023

Modified Files:
src/crypto/external/bsd/openssh/bin [netbsd-9]: Makefile
src/etc/bluetooth [netbsd-9]: Makefile
src/etc/iscsi [netbsd-9]: Makefile
src/etc/root [netbsd-9]: Makefile
src/etc/ssh [netbsd-9]: Makefile
src/external/ibm-public/postfix/etc [netbsd-9]: Makefile
src/usr.bin/mail [netbsd-9]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1604):

etc/ssh/Makefile: revision 1.4
usr.bin/mail/Makefile: revision 1.41
external/ibm-public/postfix/etc/Makefile: revision 1.2
etc/bluetooth/Makefile: revision 1.6
crypto/external/bsd/openssh/bin/Makefile: revision 1.5
etc/root/Makefile: revision 1.5
etc/iscsi/Makefile: revision 1.4

/root: Install .cshrc and .profile links with the same mode.

Previously we would:

1. Install /root/.cshrc and /root/.profile with mode FILESMODE=644 as
   requested in src/etc/root/Makefile and as echoed in
   /etc/mtree/special.
2. Create hard links at /.cshrc and /.profile through CONFIGLINKS.
3. Because LINKSMODE was unset and defaults to NOBINMODE=444, change
   the mode to 444.

This scenario is confusing, and mtree objects to it, which is bad for
warning fatigue in a security-relevant mechanism.  (There are also
several other files mtree objects to out of the box -- we should fix
those too.)

With this change we install the links with the same mode as the
original files, in agreement with the mtree.  The files, .cshrc and
.profile, are intended to be editable configuration files, so 644
makes sense while 444 makes no sense and gets in the way of editors
like vi.

Discussed on tech-userlevel:
https://mail-index.netbsd.org/tech-userlevel/2022/08/29/msg013498.html

etc: Fix permissions of various editable configuration files.

This way they match the mtree and make sense and don't cause editors
to ask to override read-only files when editing them.

Exception: Not sure /etc/bluetooth/protocols makes as much sense to
edit, but the mtree says 644, so if you want to change it, make sure
to change it in both places -- Makefile and mtree.

/etc/ssh: Install ssh_known_hosts with mode 644.
Makes it agree with the mtree and more convenient for admin to edit.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.2.1 src/crypto/external/bsd/openssh/bin/Makefile
cvs rdiff -u -r1.5 -r1.5.68.1 src/etc/bluetooth/Makefile
cvs rdiff -u -r1.3 -r1.3.90.1 src/etc/iscsi/Makefile
cvs rdiff -u -r1.4 -r1.4.34.1 src/etc/root/Makefile
cvs rdiff -u -r1.3 -r1.3.12.1 src/etc/ssh/Makefile
cvs rdiff -u -r1.1 -r1.1.52.1 src/external/ibm-public/postfix/etc/Makefile
cvs rdiff -u -r1.38 -r1.38.4.1 src/usr.bin/mail/Makefile

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

Modified files:

Index: src/crypto/external/bsd/openssh/bin/Makefile
diff -u src/crypto/external/bsd/openssh/bin/Makefile:1.4 src/crypto/external/bsd/openssh/bin/Makefile:1.4.2.1
--- src/crypto/external/bsd/openssh/bin/Makefile:1.4	Sat Jun  1 13:21:27 2019
+++ src/crypto/external/bsd/openssh/bin/Makefile	Wed Feb 22 19:30:50 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2019/06/01 13:21:27 jmcneill Exp $
+#	$NetBSD: Makefile,v 1.4.2.1 2023/02/22 19:30:50 martin Exp $
 
 .include 
 
@@ -11,7 +11,9 @@ SUBDIR=	ssh sshd ssh-add ssh-copy-id ssh
 .MADE: moduli
 CONFIGFILES=	ssh_config sshd_config moduli
 FILESDIR=	/etc/ssh
+FILESMODE=	644
 FILESDIR_moduli=/etc
+FILESMODE_moduli=444
 
 .include 
 .include 

Index: src/etc/bluetooth/Makefile
diff -u src/etc/bluetooth/Makefile:1.5 src/etc/bluetooth/Makefile:1.5.68.1
--- src/etc/bluetooth/Makefile:1.5	Tue Apr 15 11:17:47 2008
+++ src/etc/bluetooth/Makefile	Wed Feb 22 19:30:50 2023
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2008/04/15 11:17:47 plunky Exp $
+# $NetBSD: Makefile,v 1.5.68.1 2023/02/22 19:30:50 martin Exp $
 
 CONFIGFILES=	btattach.conf btdevctl.conf hosts protocols
 FILESDIR=	/etc/bluetooth
+FILESMODE=	644
 
 .include 

Index: src/etc/iscsi/Makefile
diff -u src/etc/iscsi/Makefile:1.3 src/etc/iscsi/Makefile:1.3.90.1
--- src/etc/iscsi/Makefile:1.3	Sat Jun 24 05:14:01 2006
+++ src/etc/iscsi/Makefile	Wed Feb 22 19:30:51 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2006/06/24 05:14:01 mrg Exp $
+#	$NetBSD: Makefile,v 1.3.90.1 2023/02/22 19:30:51 martin Exp $
 
 .include 
 
@@ -7,6 +7,7 @@
 CONFIGFILES=	auths targets
 FILESDIR=   	/etc/iscsi
 FILESMODE_auths=	0600
+FILESMODE_targets=	0644
 
 .endif
 

Index: src/etc/root/Makefile
diff -u src/etc/root/Makefile:1.4 src/etc/root/Makefile:1.4.34.1
--- src/etc/root/Makefile:1.4	Sat Nov 17 23:08:38 2012
+++ src/etc/root/Makefile	Wed Feb 22 19:30:50 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2012/11/17 23:08:38 uwe Exp $
+#	$NetBSD: Makefile,v 1.4.34.1 2023/02/22 19:30:50 martin Exp $
 
 CONFIGFILES=		dot.cshrc dot.klogin dot.logi

CVS commit: [netbsd-9] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:30:51 UTC 2023

Modified Files:
src/crypto/external/bsd/openssh/bin [netbsd-9]: Makefile
src/etc/bluetooth [netbsd-9]: Makefile
src/etc/iscsi [netbsd-9]: Makefile
src/etc/root [netbsd-9]: Makefile
src/etc/ssh [netbsd-9]: Makefile
src/external/ibm-public/postfix/etc [netbsd-9]: Makefile
src/usr.bin/mail [netbsd-9]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1604):

etc/ssh/Makefile: revision 1.4
usr.bin/mail/Makefile: revision 1.41
external/ibm-public/postfix/etc/Makefile: revision 1.2
etc/bluetooth/Makefile: revision 1.6
crypto/external/bsd/openssh/bin/Makefile: revision 1.5
etc/root/Makefile: revision 1.5
etc/iscsi/Makefile: revision 1.4

/root: Install .cshrc and .profile links with the same mode.

Previously we would:

1. Install /root/.cshrc and /root/.profile with mode FILESMODE=644 as
   requested in src/etc/root/Makefile and as echoed in
   /etc/mtree/special.
2. Create hard links at /.cshrc and /.profile through CONFIGLINKS.
3. Because LINKSMODE was unset and defaults to NOBINMODE=444, change
   the mode to 444.

This scenario is confusing, and mtree objects to it, which is bad for
warning fatigue in a security-relevant mechanism.  (There are also
several other files mtree objects to out of the box -- we should fix
those too.)

With this change we install the links with the same mode as the
original files, in agreement with the mtree.  The files, .cshrc and
.profile, are intended to be editable configuration files, so 644
makes sense while 444 makes no sense and gets in the way of editors
like vi.

Discussed on tech-userlevel:
https://mail-index.netbsd.org/tech-userlevel/2022/08/29/msg013498.html

etc: Fix permissions of various editable configuration files.

This way they match the mtree and make sense and don't cause editors
to ask to override read-only files when editing them.

Exception: Not sure /etc/bluetooth/protocols makes as much sense to
edit, but the mtree says 644, so if you want to change it, make sure
to change it in both places -- Makefile and mtree.

/etc/ssh: Install ssh_known_hosts with mode 644.
Makes it agree with the mtree and more convenient for admin to edit.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.2.1 src/crypto/external/bsd/openssh/bin/Makefile
cvs rdiff -u -r1.5 -r1.5.68.1 src/etc/bluetooth/Makefile
cvs rdiff -u -r1.3 -r1.3.90.1 src/etc/iscsi/Makefile
cvs rdiff -u -r1.4 -r1.4.34.1 src/etc/root/Makefile
cvs rdiff -u -r1.3 -r1.3.12.1 src/etc/ssh/Makefile
cvs rdiff -u -r1.1 -r1.1.52.1 src/external/ibm-public/postfix/etc/Makefile
cvs rdiff -u -r1.38 -r1.38.4.1 src/usr.bin/mail/Makefile

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



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:24:59 UTC 2023

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

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1799):

sys/arch/x86/x86/efi_machdep.c: revision 1.3
(applied to sys/arch/x86/x86/efi.c)

x86/efi: Print uuids in slightly more standard notation.

Anyone need a spare hyphen?  We had a few extras, apparently.


To generate a diff of this commit:
cvs rdiff -u -r1.11.6.1 -r1.11.6.2 src/sys/arch/x86/x86/efi.c

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

Modified files:

Index: src/sys/arch/x86/x86/efi.c
diff -u src/sys/arch/x86/x86/efi.c:1.11.6.1 src/sys/arch/x86/x86/efi.c:1.11.6.2
--- src/sys/arch/x86/x86/efi.c:1.11.6.1	Thu Jun  7 15:52:54 2018
+++ src/sys/arch/x86/x86/efi.c	Wed Feb 22 19:24:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efi.c,v 1.11.6.1 2018/06/07 15:52:54 martin Exp $	*/
+/*	$NetBSD: efi.c,v 1.11.6.2 2023/02/22 19:24:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.11.6.1 2018/06/07 15:52:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.11.6.2 2023/02/22 19:24:59 martin Exp $");
 
 #include 
 #include 
@@ -122,7 +122,7 @@ efi_aprintuuid(const struct uuid * uuid)
 	aprint_debug("-%04" PRIx16 "", uuid->time_mid);
 	aprint_debug("-%04" PRIx16 "", uuid->time_hi_and_version);
 	aprint_debug("-%02" PRIx8 "", uuid->clock_seq_hi_and_reserved);
-	aprint_debug("-%02" PRIx8 "", uuid->clock_seq_low);
+	aprint_debug("%02" PRIx8 "", uuid->clock_seq_low);
 	aprint_debug("-");
 	for (i = 0; i < _UUID_NODE_LEN; i++) {
 		aprint_debug("%02" PRIx8 "", uuid->node[i]);



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:24:59 UTC 2023

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

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1799):

sys/arch/x86/x86/efi_machdep.c: revision 1.3
(applied to sys/arch/x86/x86/efi.c)

x86/efi: Print uuids in slightly more standard notation.

Anyone need a spare hyphen?  We had a few extras, apparently.


To generate a diff of this commit:
cvs rdiff -u -r1.11.6.1 -r1.11.6.2 src/sys/arch/x86/x86/efi.c

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



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:20:45 UTC 2023

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: efi.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1603):

sys/arch/x86/x86/efi_machdep.c: revision 1.3
(applied to sys/arch/x86/x86/efi.c)

x86/efi: Print uuids in slightly more standard notation.

Anyone need a spare hyphen?  We had a few extras, apparently.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/arch/x86/x86/efi.c

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

Modified files:

Index: src/sys/arch/x86/x86/efi.c
diff -u src/sys/arch/x86/x86/efi.c:1.19 src/sys/arch/x86/x86/efi.c:1.19.4.1
--- src/sys/arch/x86/x86/efi.c:1.19	Mon Dec  3 19:46:43 2018
+++ src/sys/arch/x86/x86/efi.c	Wed Feb 22 19:20:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $	*/
+/*	$NetBSD: efi.c,v 1.19.4.1 2023/02/22 19:20:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.19 2018/12/03 19:46:43 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.19.4.1 2023/02/22 19:20:45 martin Exp $");
 
 #include 
 #include 
@@ -134,7 +134,7 @@ efi_aprintuuid(const struct uuid * uuid)
 	aprint_debug("-%04" PRIx16 "", uuid->time_mid);
 	aprint_debug("-%04" PRIx16 "", uuid->time_hi_and_version);
 	aprint_debug("-%02" PRIx8 "", uuid->clock_seq_hi_and_reserved);
-	aprint_debug("-%02" PRIx8 "", uuid->clock_seq_low);
+	aprint_debug("%02" PRIx8 "", uuid->clock_seq_low);
 	aprint_debug("-");
 	for (i = 0; i < _UUID_NODE_LEN; i++) {
 		aprint_debug("%02" PRIx8 "", uuid->node[i]);



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:20:45 UTC 2023

Modified Files:
src/sys/arch/x86/x86 [netbsd-9]: efi.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1603):

sys/arch/x86/x86/efi_machdep.c: revision 1.3
(applied to sys/arch/x86/x86/efi.c)

x86/efi: Print uuids in slightly more standard notation.

Anyone need a spare hyphen?  We had a few extras, apparently.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.4.1 src/sys/arch/x86/x86/efi.c

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



CVS commit: [netbsd-10] src/sys/kern

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:07:09 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: kern_module.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #100):

sys/kern/kern_module.c: revision 1.161

module(9): Make error message for multiple MODULE decls more obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.160.2.1 src/sys/kern/kern_module.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_module.c
diff -u src/sys/kern/kern_module.c:1.160 src/sys/kern/kern_module.c:1.160.2.1
--- src/sys/kern/kern_module.c:1.160	Wed Oct 26 23:22:07 2022
+++ src/sys/kern/kern_module.c	Wed Feb 22 19:07:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_module.c,v 1.160 2022/10/26 23:22:07 riastradh Exp $	*/
+/*	$NetBSD: kern_module.c,v 1.160.2.1 2023/02/22 19:07:09 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.160 2022/10/26 23:22:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.160.2.1 2023/02/22 19:07:09 martin Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1632,8 +1632,16 @@ module_fetch_info(module_t *mod)
 		return error;
 	}
 	if (size != sizeof(modinfo_t **)) {
-		module_error("`link_set_modules' section wrong size "
-		"(got %zu, wanted %zu)", size, sizeof(modinfo_t **));
+		if (size > sizeof(modinfo_t **) &&
+		(size % sizeof(modinfo_t **)) == 0) {
+			module_error("`link_set_modules' section wrong size "
+			"(%zu different MODULE declarations?)",
+			size / sizeof(modinfo_t **));
+		} else {
+			module_error("`link_set_modules' section wrong size "
+			"(got %zu, wanted %zu)",
+			size, sizeof(modinfo_t **));
+		}
 		return ENOEXEC;
 	}
 	mod->mod_info = *(modinfo_t **)addr;



CVS commit: [netbsd-10] src/sys/kern

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 19:07:09 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: kern_module.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #100):

sys/kern/kern_module.c: revision 1.161

module(9): Make error message for multiple MODULE decls more obvious.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.160.2.1 src/sys/kern/kern_module.c

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



CVS commit: [netbsd-8] src/sys/net

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:55:07 UTC 2023

Modified Files:
src/sys/net [netbsd-8]: route.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1801):

sys/net/route.c: revision 1.236

route(4): Work around deadlock in rt_free wait path.
PR kern/56844


To generate a diff of this commit:
cvs rdiff -u -r1.194.6.15 -r1.194.6.16 src/sys/net/route.c

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



CVS commit: [netbsd-8] src/sys/net

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:55:07 UTC 2023

Modified Files:
src/sys/net [netbsd-8]: route.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1801):

sys/net/route.c: revision 1.236

route(4): Work around deadlock in rt_free wait path.
PR kern/56844


To generate a diff of this commit:
cvs rdiff -u -r1.194.6.15 -r1.194.6.16 src/sys/net/route.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/route.c
diff -u src/sys/net/route.c:1.194.6.15 src/sys/net/route.c:1.194.6.16
--- src/sys/net/route.c:1.194.6.15	Fri Oct  4 11:26:35 2019
+++ src/sys/net/route.c	Wed Feb 22 18:55:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.194.6.15 2019/10/04 11:26:35 martin Exp $	*/
+/*	$NetBSD: route.c,v 1.194.6.16 2023/02/22 18:55:06 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.194.6.15 2019/10/04 11:26:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.194.6.16 2023/02/22 18:55:06 martin Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -644,8 +644,17 @@ static bool
 rt_wait_ok(void)
 {
 
+	/*
+	 * This originally returned !cpu_softintr_p(), but that doesn't
+	 * work: the caller may hold a lock (probably softnet lock)
+	 * that a softint is waiting for, in which case waiting here
+	 * would cause a deadlock.  See https://gnats.netbsd.org/56844
+	 * for details.  For now, until the locking paths are sorted
+	 * out, we just disable the waiting option altogether and
+	 * always defer to workqueue.
+	 */
 	KASSERT(!cpu_intr_p());
-	return !cpu_softintr_p();
+	return false;
 }
 
 void



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:53:56 UTC 2023

Modified Files:
src/sys/net [netbsd-9]: route.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1602):

sys/net/route.c: revision 1.236

route(4): Work around deadlock in rt_free wait path.
PR kern/56844


To generate a diff of this commit:
cvs rdiff -u -r1.219.2.2 -r1.219.2.3 src/sys/net/route.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/route.c
diff -u src/sys/net/route.c:1.219.2.2 src/sys/net/route.c:1.219.2.3
--- src/sys/net/route.c:1.219.2.2	Thu Oct  3 17:12:53 2019
+++ src/sys/net/route.c	Wed Feb 22 18:53:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.219.2.2 2019/10/03 17:12:53 martin Exp $	*/
+/*	$NetBSD: route.c,v 1.219.2.3 2023/02/22 18:53:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.219.2.2 2019/10/03 17:12:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.219.2.3 2023/02/22 18:53:56 martin Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -644,8 +644,17 @@ static bool
 rt_wait_ok(void)
 {
 
+	/*
+	 * This originally returned !cpu_softintr_p(), but that doesn't
+	 * work: the caller may hold a lock (probably softnet lock)
+	 * that a softint is waiting for, in which case waiting here
+	 * would cause a deadlock.  See https://gnats.netbsd.org/56844
+	 * for details.  For now, until the locking paths are sorted
+	 * out, we just disable the waiting option altogether and
+	 * always defer to workqueue.
+	 */
 	KASSERT(!cpu_intr_p());
-	return !cpu_softintr_p();
+	return false;
 }
 
 void



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

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:53:56 UTC 2023

Modified Files:
src/sys/net [netbsd-9]: route.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1602):

sys/net/route.c: revision 1.236

route(4): Work around deadlock in rt_free wait path.
PR kern/56844


To generate a diff of this commit:
cvs rdiff -u -r1.219.2.2 -r1.219.2.3 src/sys/net/route.c

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



CVS commit: [netbsd-10] src/sys/net

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:52:46 UTC 2023

Modified Files:
src/sys/net [netbsd-10]: route.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #99):

sys/net/route.c: revision 1.236

route(4): Work around deadlock in rt_free wait path.
PR kern/56844


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.235.2.1 src/sys/net/route.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/route.c
diff -u src/sys/net/route.c:1.235 src/sys/net/route.c:1.235.2.1
--- src/sys/net/route.c:1.235	Fri Nov 25 08:39:32 2022
+++ src/sys/net/route.c	Wed Feb 22 18:52:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.235 2022/11/25 08:39:32 knakahara Exp $	*/
+/*	$NetBSD: route.c,v 1.235.2.1 2023/02/22 18:52:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.235 2022/11/25 08:39:32 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.235.2.1 2023/02/22 18:52:45 martin Exp $");
 
 #include 
 #ifdef RTFLUSH_DEBUG
@@ -642,8 +642,17 @@ static bool
 rt_wait_ok(void)
 {
 
+	/*
+	 * This originally returned !cpu_softintr_p(), but that doesn't
+	 * work: the caller may hold a lock (probably softnet lock)
+	 * that a softint is waiting for, in which case waiting here
+	 * would cause a deadlock.  See https://gnats.netbsd.org/56844
+	 * for details.  For now, until the locking paths are sorted
+	 * out, we just disable the waiting option altogether and
+	 * always defer to workqueue.
+	 */
 	KASSERT(!cpu_intr_p());
-	return !cpu_softintr_p();
+	return false;
 }
 
 void



CVS commit: [netbsd-10] src/sys/net

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:52:46 UTC 2023

Modified Files:
src/sys/net [netbsd-10]: route.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #99):

sys/net/route.c: revision 1.236

route(4): Work around deadlock in rt_free wait path.
PR kern/56844


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.235.2.1 src/sys/net/route.c

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



CVS commit: [netbsd-8] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:50:42 UTC 2023

Modified Files:
src/lib/libc/string [netbsd-8]: swab.c
src/tests/lib/libc/string [netbsd-8]: t_swab.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1798):

tests/lib/libc/string/t_swab.c: revision 1.3
lib/libc/string/swab.c: revision 1.20

swab(3): Rewrite this to be understandable.

And make the tests work, and exercise all lengths up to 100.
Evidently the previous definition, presumably tightly optimized for
1980s-era compilers and CPUs, was too hard to understand, because it
was incorrectly tested for two decades and broken for years.

PR lib/57141


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.38.1 src/lib/libc/string/swab.c
cvs rdiff -u -r1.2 -r1.2.34.1 src/tests/lib/libc/string/t_swab.c

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



CVS commit: [netbsd-8] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:50:42 UTC 2023

Modified Files:
src/lib/libc/string [netbsd-8]: swab.c
src/tests/lib/libc/string [netbsd-8]: t_swab.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1798):

tests/lib/libc/string/t_swab.c: revision 1.3
lib/libc/string/swab.c: revision 1.20

swab(3): Rewrite this to be understandable.

And make the tests work, and exercise all lengths up to 100.
Evidently the previous definition, presumably tightly optimized for
1980s-era compilers and CPUs, was too hard to understand, because it
was incorrectly tested for two decades and broken for years.

PR lib/57141


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.38.1 src/lib/libc/string/swab.c
cvs rdiff -u -r1.2 -r1.2.34.1 src/tests/lib/libc/string/t_swab.c

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

Modified files:

Index: src/lib/libc/string/swab.c
diff -u src/lib/libc/string/swab.c:1.18 src/lib/libc/string/swab.c:1.18.38.1
--- src/lib/libc/string/swab.c:1.18	Tue Jan  4 17:14:07 2011
+++ src/lib/libc/string/swab.c	Wed Feb 22 18:50:42 2023
@@ -1,11 +1,9 @@
-/*	$NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $	*/
+/*	$NetBSD: swab.c,v 1.18.38.1 2023/02/22 18:50:42 martin Exp $	*/
 
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jeffrey Mogul.
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -15,66 +13,58 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)swab.c	8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $");
+__RCSID("$NetBSD: swab.c,v 1.18.38.1 2023/02/22 18:50:42 martin Exp $");
 #endif
-#endif /* LIBC_SCCS and not lint */
 
 #include 
 #include 
 
 void
-swab(const void * __restrict from, void * __restrict to, ssize_t len)
+swab(const void *__restrict src, void *__restrict dst, ssize_t nbytes)
 {
-	char temp;
-	const char *fp;
-	char *tp;
-
-	if (len <= 1)
-		return;
+	const char *p = src;
+	char *q = dst;
+	size_t n;
 
-	_DIAGASSERT(from != NULL);
-	_DIAGASSERT(to != NULL);
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
 
-	len /= 2;
-	fp = (const char *)from;
-	tp = (char *)to;
-#define	STEP	temp = *fp++,*tp++ = *fp++,*tp++ = temp
-
-	if (__predict_false(len == 1)) {
-		STEP;
+	if (nbytes <= 1)
 		return;
-	}
 
-	/* round to multiple of 8 */
-	while ((--len % 8) != 0)
-		STEP;
-	len /= 8;
-	if (len == 0)
-		return;
-	while (len-- != 0) {
-		STEP; STEP; STEP; STEP;
-		STEP; STEP; STEP; STEP;
+	/*
+	 * Round nbytes/2 down; we ignore 

CVS commit: [netbsd-9] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:49:17 UTC 2023

Modified Files:
src/lib/libc/string [netbsd-9]: swab.c
src/tests/lib/libc/string [netbsd-9]: t_swab.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1601):

tests/lib/libc/string/t_swab.c: revision 1.3
lib/libc/string/swab.c: revision 1.20

swab(3): Rewrite this to be understandable.

And make the tests work, and exercise all lengths up to 100.
Evidently the previous definition, presumably tightly optimized for
1980s-era compilers and CPUs, was too hard to understand, because it
was incorrectly tested for two decades and broken for years.

PR lib/57141


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.48.1 src/lib/libc/string/swab.c
cvs rdiff -u -r1.2 -r1.2.44.1 src/tests/lib/libc/string/t_swab.c

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

Modified files:

Index: src/lib/libc/string/swab.c
diff -u src/lib/libc/string/swab.c:1.18 src/lib/libc/string/swab.c:1.18.48.1
--- src/lib/libc/string/swab.c:1.18	Tue Jan  4 17:14:07 2011
+++ src/lib/libc/string/swab.c	Wed Feb 22 18:49:17 2023
@@ -1,11 +1,9 @@
-/*	$NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $	*/
+/*	$NetBSD: swab.c,v 1.18.48.1 2023/02/22 18:49:17 martin Exp $	*/
 
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jeffrey Mogul.
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -15,66 +13,58 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)swab.c	8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $");
+__RCSID("$NetBSD: swab.c,v 1.18.48.1 2023/02/22 18:49:17 martin Exp $");
 #endif
-#endif /* LIBC_SCCS and not lint */
 
 #include 
 #include 
 
 void
-swab(const void * __restrict from, void * __restrict to, ssize_t len)
+swab(const void *__restrict src, void *__restrict dst, ssize_t nbytes)
 {
-	char temp;
-	const char *fp;
-	char *tp;
-
-	if (len <= 1)
-		return;
+	const char *p = src;
+	char *q = dst;
+	size_t n;
 
-	_DIAGASSERT(from != NULL);
-	_DIAGASSERT(to != NULL);
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
 
-	len /= 2;
-	fp = (const char *)from;
-	tp = (char *)to;
-#define	STEP	temp = *fp++,*tp++ = *fp++,*tp++ = temp
-
-	if (__predict_false(len == 1)) {
-		STEP;
+	if (nbytes <= 1)
 		return;
-	}
 
-	/* round to multiple of 8 */
-	while ((--len % 8) != 0)
-		STEP;
-	len /= 8;
-	if (len == 0)
-		return;
-	while (len-- != 0) {
-		STEP; STEP; STEP; STEP;
-		STEP; STEP; STEP; STEP;
+	/*
+	 * Round nbytes/2 down; we ignore 

CVS commit: [netbsd-9] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:49:17 UTC 2023

Modified Files:
src/lib/libc/string [netbsd-9]: swab.c
src/tests/lib/libc/string [netbsd-9]: t_swab.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1601):

tests/lib/libc/string/t_swab.c: revision 1.3
lib/libc/string/swab.c: revision 1.20

swab(3): Rewrite this to be understandable.

And make the tests work, and exercise all lengths up to 100.
Evidently the previous definition, presumably tightly optimized for
1980s-era compilers and CPUs, was too hard to understand, because it
was incorrectly tested for two decades and broken for years.

PR lib/57141


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.48.1 src/lib/libc/string/swab.c
cvs rdiff -u -r1.2 -r1.2.44.1 src/tests/lib/libc/string/t_swab.c

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



CVS commit: [netbsd-10] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:47:00 UTC 2023

Modified Files:
src/lib/libc/string [netbsd-10]: swab.c
src/tests/lib/libc/string [netbsd-10]: t_swab.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #98):

tests/lib/libc/string/t_swab.c: revision 1.3
lib/libc/string/swab.c: revision 1.20

swab(3): Rewrite this to be understandable.

And make the tests work, and exercise all lengths up to 100.
Evidently the previous definition, presumably tightly optimized for
1980s-era compilers and CPUs, was too hard to understand, because it
was incorrectly tested for two decades and broken for years.

PR lib/57141


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.56.1 src/lib/libc/string/swab.c
cvs rdiff -u -r1.2 -r1.2.52.1 src/tests/lib/libc/string/t_swab.c

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

Modified files:

Index: src/lib/libc/string/swab.c
diff -u src/lib/libc/string/swab.c:1.18 src/lib/libc/string/swab.c:1.18.56.1
--- src/lib/libc/string/swab.c:1.18	Tue Jan  4 17:14:07 2011
+++ src/lib/libc/string/swab.c	Wed Feb 22 18:47:00 2023
@@ -1,11 +1,9 @@
-/*	$NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $	*/
+/*	$NetBSD: swab.c,v 1.18.56.1 2023/02/22 18:47:00 martin Exp $	*/
 
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jeffrey Mogul.
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -15,66 +13,58 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)swab.c	8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp $");
+__RCSID("$NetBSD: swab.c,v 1.18.56.1 2023/02/22 18:47:00 martin Exp $");
 #endif
-#endif /* LIBC_SCCS and not lint */
 
 #include 
 #include 
 
 void
-swab(const void * __restrict from, void * __restrict to, ssize_t len)
+swab(const void *__restrict src, void *__restrict dst, ssize_t nbytes)
 {
-	char temp;
-	const char *fp;
-	char *tp;
-
-	if (len <= 1)
-		return;
+	const char *p = src;
+	char *q = dst;
+	size_t n;
 
-	_DIAGASSERT(from != NULL);
-	_DIAGASSERT(to != NULL);
+	_DIAGASSERT(src != NULL);
+	_DIAGASSERT(dst != NULL);
 
-	len /= 2;
-	fp = (const char *)from;
-	tp = (char *)to;
-#define	STEP	temp = *fp++,*tp++ = *fp++,*tp++ = temp
-
-	if (__predict_false(len == 1)) {
-		STEP;
+	if (nbytes <= 1)
 		return;
-	}
 
-	/* round to multiple of 8 */
-	while ((--len % 8) != 0)
-		STEP;
-	len /= 8;
-	if (len == 0)
-		return;
-	while (len-- != 0) {
-		STEP; STEP; STEP; STEP;
-		STEP; STEP; STEP; STEP;
+	/*
+	 * Round nbytes/2 down; we ignore 

CVS commit: [netbsd-10] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:47:00 UTC 2023

Modified Files:
src/lib/libc/string [netbsd-10]: swab.c
src/tests/lib/libc/string [netbsd-10]: t_swab.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #98):

tests/lib/libc/string/t_swab.c: revision 1.3
lib/libc/string/swab.c: revision 1.20

swab(3): Rewrite this to be understandable.

And make the tests work, and exercise all lengths up to 100.
Evidently the previous definition, presumably tightly optimized for
1980s-era compilers and CPUs, was too hard to understand, because it
was incorrectly tested for two decades and broken for years.

PR lib/57141


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.56.1 src/lib/libc/string/swab.c
cvs rdiff -u -r1.2 -r1.2.52.1 src/tests/lib/libc/string/t_swab.c

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



CVS commit: [netbsd-10] src/sys/modules

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:34:30 UTC 2023

Modified Files:
src/sys/modules/drmkms [netbsd-10]: Makefile
src/sys/modules/drmkms_pci [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #97):

sys/modules/drmkms/Makefile: revision 1.19
sys/modules/drmkms_pci/Makefile: revision 1.11

sys/modules/drmkms: Remove GPU scheduler files.
These have been moved out to drmkms_sched.kmod.

sys/modules/drmkms_pci: Remove drm_agpsupport.c.
This was moved to a separate drmkms_agp module.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.4.1 src/sys/modules/drmkms/Makefile
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/modules/drmkms_pci/Makefile

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



CVS commit: [netbsd-10] src/sys/modules

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 18:34:30 UTC 2023

Modified Files:
src/sys/modules/drmkms [netbsd-10]: Makefile
src/sys/modules/drmkms_pci [netbsd-10]: Makefile

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #97):

sys/modules/drmkms/Makefile: revision 1.19
sys/modules/drmkms_pci/Makefile: revision 1.11

sys/modules/drmkms: Remove GPU scheduler files.
These have been moved out to drmkms_sched.kmod.

sys/modules/drmkms_pci: Remove drm_agpsupport.c.
This was moved to a separate drmkms_agp module.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.4.1 src/sys/modules/drmkms/Makefile
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/modules/drmkms_pci/Makefile

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

Modified files:

Index: src/sys/modules/drmkms/Makefile
diff -u src/sys/modules/drmkms/Makefile:1.18 src/sys/modules/drmkms/Makefile:1.18.4.1
--- src/sys/modules/drmkms/Makefile:1.18	Sun Jul 17 15:35:42 2022
+++ src/sys/modules/drmkms/Makefile	Wed Feb 22 18:34:30 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.18 2022/07/17 15:35:42 riastradh Exp $
+# $NetBSD: Makefile,v 1.18.4.1 2023/02/22 18:34:30 martin Exp $
 
 .include "../Makefile.inc"
 .include "Makefile.inc"
@@ -52,10 +52,7 @@ SRCS+=	drm_legacy_misc.c
 SRCS+=	drm_lock.c
 SRCS+=	drm_scatter.c
 
-# GPU scheduler
-SRCS+=	sched_entity.c
-SRCS+=	sched_fence.c
-SRCS+=	sched_main.c
+# GPU scheduler is separatd out into drmkms_sched.kmod
 
 # Upstream source files.
 #SRCS+=	drm_agpsupport.c

Index: src/sys/modules/drmkms_pci/Makefile
diff -u src/sys/modules/drmkms_pci/Makefile:1.10 src/sys/modules/drmkms_pci/Makefile:1.10.4.1
--- src/sys/modules/drmkms_pci/Makefile:1.10	Sun Dec 19 11:54:25 2021
+++ src/sys/modules/drmkms_pci/Makefile	Wed Feb 22 18:34:30 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2021/12/19 11:54:25 riastradh Exp $
+# $NetBSD: Makefile,v 1.10.4.1 2023/02/22 18:34:30 martin Exp $
 
 .include "../Makefile.inc"
 .include "../drmkms/Makefile.inc"
@@ -13,7 +13,6 @@ KMOD=	drmkms_pci
 SRCS+=	drmfb_pci.c
 SRCS+=	linux_pci.c
 
-SRCS+=	drm_agpsupport.c
 SRCS+=	drm_pci.c
 SRCS+=	drm_pci_module.c
 



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 17:00:16 UTC 2023

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

Log Message:
autoconf(9): Clarify assertions about iattr in config_search.


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/sys/kern/subr_autoconf.c

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

Modified files:

Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.306 src/sys/kern/subr_autoconf.c:1.307
--- src/sys/kern/subr_autoconf.c:1.306	Tue Sep 13 09:43:33 2022
+++ src/sys/kern/subr_autoconf.c	Wed Feb 22 17:00:16 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.306 2022/09/13 09:43:33 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.307 2023/02/22 17:00:16 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.306 2022/09/13 09:43:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.307 2023/02/22 17:00:16 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1143,10 +1143,20 @@ config_search_internal(device_t parent, 
 	struct matchinfo m;
 
 	KASSERT(config_initialized);
-	KASSERT(!args->iattr ||
-		cfdriver_get_iattr(parent->dv_cfdriver, args->iattr));
-	KASSERT(args->iattr ||
-		cfdriver_iattr_count(parent->dv_cfdriver) < 2);
+	KASSERTMSG((!args->iattr ||
+		cfdriver_get_iattr(parent->dv_cfdriver, args->iattr)),
+	"%s searched for child at interface attribute %s,"
+	" but device %s(4) has no such interface attribute in config(5)",
+	device_xname(parent), args->iattr,
+	parent->dv_cfdriver->cd_name);
+	KASSERTMSG((args->iattr ||
+		cfdriver_iattr_count(parent->dv_cfdriver) < 2),
+	"%s searched for child without interface attribute,"
+	" needed to disambiguate among the %d declared for in %s(4)"
+	" in config(5)",
+	device_xname(parent),
+	cfdriver_iattr_count(parent->dv_cfdriver),
+	parent->dv_cfdriver->cd_name);
 
 	m.fn = args->submatch;		/* N.B. union */
 	m.parent = parent;



CVS commit: src/sys/kern

2023-02-22 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 22 17:00:16 UTC 2023

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

Log Message:
autoconf(9): Clarify assertions about iattr in config_search.


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/sys/kern/subr_autoconf.c

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



CVS commit: [netbsd-10] src/sys/kern

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:28:02 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: kern_subr.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #96):

sys/kern/kern_subr.c: revision 1.231

If a specified root device does not exist when the kernel tries to
mount the root filesystem, retry for up to ROOT_WAITTIME (20) seconds.

This helps for root on hot-plug devices like USB disks.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.230.4.1 src/sys/kern/kern_subr.c

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

Modified files:

Index: src/sys/kern/kern_subr.c
diff -u src/sys/kern/kern_subr.c:1.230 src/sys/kern/kern_subr.c:1.230.4.1
--- src/sys/kern/kern_subr.c:1.230	Sat Mar 19 13:51:35 2022
+++ src/sys/kern/kern_subr.c	Wed Feb 22 13:28:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_subr.c,v 1.230 2022/03/19 13:51:35 hannken Exp $	*/
+/*	$NetBSD: kern_subr.c,v 1.230.4.1 2023/02/22 13:28:01 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.230 2022/03/19 13:51:35 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.230.4.1 2023/02/22 13:28:01 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -174,6 +174,13 @@ uint64_t booted_nblks;
 char *bootspec;
 
 /*
+ * Time to wait for a specified boot device to appear.
+ */
+#ifndef ROOT_WAITTIME
+#define ROOT_WAITTIME 20
+#endif
+
+/*
  * Use partition letters if it's a disk class but not a wedge or flash.
  * XXX Check for wedge/flash is kinda gross.
  */
@@ -185,6 +192,7 @@ char *bootspec;
 void
 setroot(device_t bootdv, int bootpartition)
 {
+	time_t waitend;
 
 	/*
 	 * Let bootcode augment "rootspec", ensure that
@@ -241,14 +249,19 @@ setroot(device_t bootdv, int bootpartiti
 	/*
 	 * loop until a root device is specified
 	 */
+	waitend = time_uptime + ROOT_WAITTIME;
 	do {
 		if (boothowto & RB_ASKNAME)
 			setroot_ask(bootdv, bootpartition);
-		else
+		else {
 			setroot_root(bootdv, bootpartition);
-
-		if (root_device == NULL)
-			boothowto |= RB_ASKNAME;
+			if (root_device == NULL) {
+if (time_uptime < waitend) {
+	kpause("root", false, hz, NULL);
+} else
+	boothowto |= RB_ASKNAME;
+			}
+		}
 	} while (root_device == NULL);
 }
 



CVS commit: [netbsd-10] src/sys/kern

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:28:02 UTC 2023

Modified Files:
src/sys/kern [netbsd-10]: kern_subr.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #96):

sys/kern/kern_subr.c: revision 1.231

If a specified root device does not exist when the kernel tries to
mount the root filesystem, retry for up to ROOT_WAITTIME (20) seconds.

This helps for root on hot-plug devices like USB disks.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.230.4.1 src/sys/kern/kern_subr.c

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



CVS commit: [netbsd-10] src/external/bsd/fetch/dist/libfetch

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:24:05 UTC 2023

Modified Files:
src/external/bsd/fetch/dist/libfetch [netbsd-10]: common.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #95):

external/bsd/fetch/dist/libfetch/common.c: revision 1.3
external/bsd/fetch/dist/libfetch/common.c: revision 1.4

Use SNI.
Shut down SSL when closing connection.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.54.1 src/external/bsd/fetch/dist/libfetch/common.c

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

Modified files:

Index: src/external/bsd/fetch/dist/libfetch/common.c
diff -u src/external/bsd/fetch/dist/libfetch/common.c:1.2 src/external/bsd/fetch/dist/libfetch/common.c:1.2.54.1
--- src/external/bsd/fetch/dist/libfetch/common.c:1.2	Sat Jun 25 20:27:01 2011
+++ src/external/bsd/fetch/dist/libfetch/common.c	Wed Feb 22 13:24:05 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: common.c,v 1.2 2011/06/25 20:27:01 christos Exp $	*/
+/*	$NetBSD: common.c,v 1.2.54.1 2023/02/22 13:24:05 martin Exp $	*/
 /*-
  * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
  * Copyright (c) 2008, 2010 Joerg Sonnenberger 
@@ -452,6 +452,10 @@ fetch_ssl(conn_t *conn, int verbose)
 		return (-1);
 	}
 	SSL_set_fd(conn->ssl, conn->sd);
+	if (!SSL_set_tlsext_host_name(conn->ssl, conn->cache_url->host)) {
+		fprintf(stderr, "SSL hostname setting failed\n"); 
+		return (-1);
+	}
 	if (SSL_connect(conn->ssl) == -1){
 		ERR_print_errors_fp(stderr);
 		return (-1);
@@ -709,6 +713,22 @@ fetch_close(conn_t *conn)
 {
 	int ret;
 
+#ifdef WITH_SSL
+	if (conn->ssl) {
+		SSL_shutdown(conn->ssl);
+		SSL_set_connect_state(conn->ssl);
+		SSL_free(conn->ssl);
+		conn->ssl = NULL;
+	}
+	if (conn->ssl_ctx) {
+		SSL_CTX_free(conn->ssl_ctx);
+		conn->ssl_ctx = NULL;
+	}
+	if (conn->ssl_cert) {
+		X509_free(conn->ssl_cert);
+		conn->ssl_cert = NULL;
+	}
+#endif
 	ret = close(conn->sd);
 	if (conn->cache_url)
 		fetchFreeURL(conn->cache_url);



CVS commit: [netbsd-10] src/external/bsd/fetch/dist/libfetch

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:24:05 UTC 2023

Modified Files:
src/external/bsd/fetch/dist/libfetch [netbsd-10]: common.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #95):

external/bsd/fetch/dist/libfetch/common.c: revision 1.3
external/bsd/fetch/dist/libfetch/common.c: revision 1.4

Use SNI.
Shut down SSL when closing connection.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.54.1 src/external/bsd/fetch/dist/libfetch/common.c

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



CVS commit: [netbsd-10] src/sbin/scan_ffs

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:11:38 UTC 2023

Modified Files:
src/sbin/scan_ffs [netbsd-10]: Makefile scan_ffs.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #94):

sbin/scan_ffs/Makefile: revision 1.11
sbin/scan_ffs/scan_ffs.c: revision 1.37

Work on swapped-endian FFS.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.6.1 src/sbin/scan_ffs/Makefile
cvs rdiff -u -r1.36 -r1.36.2.1 src/sbin/scan_ffs/scan_ffs.c

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

Modified files:

Index: src/sbin/scan_ffs/Makefile
diff -u src/sbin/scan_ffs/Makefile:1.10 src/sbin/scan_ffs/Makefile:1.10.6.1
--- src/sbin/scan_ffs/Makefile:1.10	Mon Sep  7 03:09:53 2020
+++ src/sbin/scan_ffs/Makefile	Wed Feb 22 13:11:37 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2020/09/07 03:09:53 mrg Exp $
+# $NetBSD: Makefile,v 1.10.6.1 2023/02/22 13:11:37 martin Exp $
 
 .include 
 
@@ -10,9 +10,9 @@ MLINKS=	scan_ffs.8 scan_lfs.8
 LDADD=	-lutil
 DPADD=	${LIBUTIL}
 
-SRCS=	scan_ffs.c lfs_cksum.c
+SRCS=	scan_ffs.c ffs_bswap.c lfs_cksum.c
 SCAN_FFS=${NETBSDSRCDIR}/sbin/scan_ffs
-.PATH:  ${NETBSDSRCDIR}/sys/ufs/lfs ${SCAN_FFS}
+.PATH:  ${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/sys/ufs/lfs ${SCAN_FFS}
 
 MAN=	scan_ffs.8
 

Index: src/sbin/scan_ffs/scan_ffs.c
diff -u src/sbin/scan_ffs/scan_ffs.c:1.36 src/sbin/scan_ffs/scan_ffs.c:1.36.2.1
--- src/sbin/scan_ffs/scan_ffs.c:1.36	Thu Nov 17 06:40:39 2022
+++ src/sbin/scan_ffs/scan_ffs.c	Wed Feb 22 13:11:37 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: scan_ffs.c,v 1.36 2022/11/17 06:40:39 chs Exp $ */
+/* $NetBSD: scan_ffs.c,v 1.36.2.1 2023/02/22 13:11:37 martin Exp $ */
 
 /*
  * Copyright (c) 2005-2007 Juan Romero Pardines
@@ -33,7 +33,7 @@
  
 #include 
 #ifndef lint
-__RCSID("$NetBSD: scan_ffs.c,v 1.36 2022/11/17 06:40:39 chs Exp $");
+__RCSID("$NetBSD: scan_ffs.c,v 1.36.2.1 2023/02/22 13:11:37 martin Exp $");
 #endif /* not lint */
 
 #include 
@@ -50,6 +50,7 @@ __RCSID("$NetBSD: scan_ffs.c,v 1.36 2022
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -123,6 +124,14 @@ static int
 ffs_checkver(struct sblockinfo *sbi)
 {
 	switch (sbi->ffs->fs_magic) {
+		case FS_UFS1_MAGIC_SWAPPED:
+		case FS_UFS2_MAGIC_SWAPPED:
+		case FS_UFS2EA_MAGIC_SWAPPED:
+			ffs_sb_swap(sbi->ffs, sbi->ffs);
+			break;
+	}
+
+	switch (sbi->ffs->fs_magic) {
 		case FS_UFS1_MAGIC:
 		case FS_UFS1_MAGIC_SWAPPED:
 			sbi->ffs->fs_size = sbi->ffs->fs_old_size;



CVS commit: [netbsd-10] src/sbin/scan_ffs

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:11:38 UTC 2023

Modified Files:
src/sbin/scan_ffs [netbsd-10]: Makefile scan_ffs.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #94):

sbin/scan_ffs/Makefile: revision 1.11
sbin/scan_ffs/scan_ffs.c: revision 1.37

Work on swapped-endian FFS.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.6.1 src/sbin/scan_ffs/Makefile
cvs rdiff -u -r1.36 -r1.36.2.1 src/sbin/scan_ffs/scan_ffs.c

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



CVS commit: [netbsd-10] src/sbin/fsck

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:09:34 UTC 2023

Modified Files:
src/sbin/fsck [netbsd-10]: fsck.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #93):

sbin/fsck/fsck.c: revision 1.53

Use opendisk when looking for filesystem type, otherwise the detection
only works if the correct device path is given as an argument.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.52.26.1 src/sbin/fsck/fsck.c

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



CVS commit: [netbsd-10] src/sbin/fsck

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:09:34 UTC 2023

Modified Files:
src/sbin/fsck [netbsd-10]: fsck.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #93):

sbin/fsck/fsck.c: revision 1.53

Use opendisk when looking for filesystem type, otherwise the detection
only works if the correct device path is given as an argument.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.52.26.1 src/sbin/fsck/fsck.c

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

Modified files:

Index: src/sbin/fsck/fsck.c
diff -u src/sbin/fsck/fsck.c:1.52 src/sbin/fsck/fsck.c:1.52.26.1
--- src/sbin/fsck/fsck.c:1.52	Sat Oct 25 22:00:19 2014
+++ src/sbin/fsck/fsck.c	Wed Feb 22 13:09:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fsck.c,v 1.52 2014/10/25 22:00:19 mlelstv Exp $	*/
+/*	$NetBSD: fsck.c,v 1.52.26.1 2023/02/22 13:09:33 martin Exp $	*/
 
 /*
  * Copyright (c) 1996 Christos Zoulas. All rights reserved.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: fsck.c,v 1.52 2014/10/25 22:00:19 mlelstv Exp $");
+__RCSID("$NetBSD: fsck.c,v 1.52.26.1 2023/02/22 13:09:33 martin Exp $");
 #endif /* not lint */
 
 #include 
@@ -557,10 +557,11 @@ getfslab(const char *str)
 	char p;
 	const char *vfstype;
 	u_char t;
+	char buf[MAXPATHLEN];
 
 	/* deduce the file system type from the disk label */
-	if ((fd = open(str, O_RDONLY)) == -1)
-		err(1, "cannot open `%s'", str);
+if ((fd = opendisk(str, O_RDONLY, buf, sizeof(buf), 0)) == -1)
+		err(1, "cannot open `%s'", buf);
 
 	/* First check to see if it's a wedge. */
 	if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == 0) {
@@ -570,22 +571,22 @@ getfslab(const char *str)
 	}
 
 	if (ioctl(fd, DIOCGDINFO, &dl) == -1)
-		err(1, "cannot get disklabel for `%s'", str);
+		err(1, "cannot get disklabel for `%s'", buf);
 
 	(void) close(fd);
 
-	p = str[strlen(str) - 1];
+	p = buf[strlen(buf) - 1];
 
 	if ((p - 'a') >= dl.d_npartitions)
-		errx(1, "partition `%s' is not defined on disk", str);
+		errx(1, "partition `%s' is not defined on disk", buf);
 
 	if ((t = dl.d_partitions[p - 'a'].p_fstype) >= FSMAXTYPES) 
 		errx(1, "partition `%s' is not of a legal vfstype",
-		str);
+		buf);
 
 	if ((vfstype = fscknames[t]) == NULL)
 		errx(1, "vfstype `%s' on partition `%s' is not supported",
-		fstypenames[t], str);
+		fstypenames[t], buf);
 
 	return vfstype;
 }



CVS commit: [netbsd-10] src/sys/dev/usb

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:06:42 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-10]: ucom.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #92):

sys/dev/usb/ucom.c: revision 1.136
sys/dev/usb/ucom.c: revision 1.135

ucom(4): Nix broken error branch.

This error branch was introduced to make the system act, when a USB
serial adapter is yanked, as if the other end had spat out a line
feed in an attempt to wake any sleeping readers so they will stop
using the USB serial port.

This is no longer necessary, because ttycancel will wake them anyway,
and it is actually harmful because it puts stuff in the output queue
(CR LF) that will never be processed, causing subsequent users to
hang trying to open the device.

Problem found and patch tested by tih@.

ucom(4): Missed a spot in previous -- nix now-unused local.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.134.2.1 src/sys/dev/usb/ucom.c

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



CVS commit: [netbsd-10] src/sys/dev/usb

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 13:06:42 UTC 2023

Modified Files:
src/sys/dev/usb [netbsd-10]: ucom.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #92):

sys/dev/usb/ucom.c: revision 1.136
sys/dev/usb/ucom.c: revision 1.135

ucom(4): Nix broken error branch.

This error branch was introduced to make the system act, when a USB
serial adapter is yanked, as if the other end had spat out a line
feed in an attempt to wake any sleeping readers so they will stop
using the USB serial port.

This is no longer necessary, because ttycancel will wake them anyway,
and it is actually harmful because it puts stuff in the output queue
(CR LF) that will never be processed, causing subsequent users to
hang trying to open the device.

Problem found and patch tested by tih@.

ucom(4): Missed a spot in previous -- nix now-unused local.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.134.2.1 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.134 src/sys/dev/usb/ucom.c:1.134.2.1
--- src/sys/dev/usb/ucom.c:1.134	Wed Oct 26 23:48:43 2022
+++ src/sys/dev/usb/ucom.c	Wed Feb 22 13:06:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.134 2022/10/26 23:48:43 riastradh Exp $	*/
+/*	$NetBSD: ucom.c,v 1.134.2.1 2023/02/22 13:06:42 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.134 2022/10/26 23:48:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.134.2.1 2023/02/22 13:06:42 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1435,7 +1435,6 @@ static void
 ucomreadcb(struct usbd_xfer *xfer, void *p, usbd_status status)
 {
 	struct ucom_softc *sc = (struct ucom_softc *)p;
-	struct tty *tp = sc->sc_tty;
 	struct ucom_buffer *ub;
 	uint32_t cc;
 	u_char *cp;
@@ -1446,18 +1445,8 @@ ucomreadcb(struct usbd_xfer *xfer, void 
 
 	if (status == USBD_CANCELLED || status == USBD_IOERROR ||
 	sc->sc_closing) {
-
 		DPRINTF("... done (status %jd closing %jd)",
 		status, sc->sc_closing, 0, 0);
-
-		if (status == USBD_IOERROR || sc->sc_closing) {
-			/* Send something to wake upper layer */
-			(tp->t_linesw->l_rint)('\n', tp);
-			ttylock(tp);	/* XXX */
-			ttwakeup(tp);
-			ttyunlock(tp);	/* XXX */
-		}
-
 		mutex_exit(&sc->sc_lock);
 		return;
 	}



CVS commit: [netbsd-10] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 12:59:17 UTC 2023

Modified Files:
src/distrib/next68k [netbsd-10]: Makefile
src/etc/etc.next68k [netbsd-10]: MAKEDEV.conf Makefile.inc
src/sys/arch/next68k/conf [netbsd-10]: GENERIC RAMDISK SLAB
majors.next68k
Added Files:
src/distrib/next68k/instkernel [netbsd-10]: Makefile
src/distrib/next68k/ramdisk [netbsd-10]: Makefile dot.profile list

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #91):

etc/etc.next68k/MAKEDEV.conf: revision 1.7
sys/arch/next68k/conf/GENERIC: revision 1.156
sys/arch/next68k/conf/GENERIC: revision 1.157
sys/arch/next68k/conf/GENERIC: revision 1.158
distrib/next68k/instkernel/Makefile: revision 1.1
sys/arch/next68k/conf/GENERIC: revision 1.159
distrib/next68k/ramdisk/list: revision 1.1
etc/etc.next68k/Makefile.inc: revision 1.8
sys/arch/next68k/conf/RAMDISK: revision 1.5
distrib/next68k/ramdisk/dot.profile: revision 1.1
sys/arch/next68k/conf/SLAB: revision 1.62
sys/arch/next68k/conf/GENERIC: revision 1.160
sys/arch/next68k/conf/SLAB: revision 1.63
sys/arch/next68k/conf/GENERIC: revision 1.161
distrib/next68k/ramdisk/Makefile: revision 1.1
sys/arch/next68k/conf/majors.next68k: revision 1.26
distrib/next68k/Makefile: revision 1.2

Remove trailing TABs.

Remove trailing spaces and TABs.

Enable file-system CD9660.
It's useful for installation especially on emulators.

Remove nonexistent options SWAPDEBUG.

Remove unnecessary commented out lines.

Disable rarely used options and devices, and add options MODULAR instead.

Also enable files-system MSDOS for file exchange via removable media.

Build a RAMDISK root kernel on NetBSD/next68k release build.
No sysinst(8) yet, but useful on bootstrap and rescue ops.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/distrib/next68k/Makefile
cvs rdiff -u -r0 -r1.1.2.2 src/distrib/next68k/instkernel/Makefile
cvs rdiff -u -r0 -r1.1.2.2 src/distrib/next68k/ramdisk/Makefile \
src/distrib/next68k/ramdisk/dot.profile src/distrib/next68k/ramdisk/list
cvs rdiff -u -r1.5.16.1 -r1.5.16.2 src/etc/etc.next68k/MAKEDEV.conf
cvs rdiff -u -r1.7 -r1.7.76.1 src/etc/etc.next68k/Makefile.inc
cvs rdiff -u -r1.153.4.1 -r1.153.4.2 src/sys/arch/next68k/conf/GENERIC
cvs rdiff -u -r1.4 -r1.4.96.1 src/sys/arch/next68k/conf/RAMDISK
cvs rdiff -u -r1.60 -r1.60.18.1 src/sys/arch/next68k/conf/SLAB
cvs rdiff -u -r1.25 -r1.25.22.1 src/sys/arch/next68k/conf/majors.next68k

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

Modified files:

Index: src/distrib/next68k/Makefile
diff -u src/distrib/next68k/Makefile:1.2.2.2 src/distrib/next68k/Makefile:1.2.2.3
--- src/distrib/next68k/Makefile:1.2.2.2	Sun Feb 12 12:32:35 2023
+++ src/distrib/next68k/Makefile	Wed Feb 22 12:59:17 2023
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.2.2.2 2023/02/12 12:32:35 martin Exp $
+#	$NetBSD: Makefile,v 1.2.2.3 2023/02/22 12:59:17 martin Exp $
 
-SUBDIR=		cdroms
+SUBDIR=		ramdisk .WAIT instkernel .WAIT cdroms
 TARGETS+=	release
 
 iso_image:

Index: src/etc/etc.next68k/MAKEDEV.conf
diff -u src/etc/etc.next68k/MAKEDEV.conf:1.5.16.1 src/etc/etc.next68k/MAKEDEV.conf:1.5.16.2
--- src/etc/etc.next68k/MAKEDEV.conf:1.5.16.1	Mon Feb  6 16:53:34 2023
+++ src/etc/etc.next68k/MAKEDEV.conf	Wed Feb 22 12:59:17 2023
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.5.16.1 2023/02/06 16:53:34 martin Exp $
+# $NetBSD: MAKEDEV.conf,v 1.5.16.2 2023/02/22 12:59:17 martin Exp $
 
 all_md)
 	makedev wscons sd0 sd1 sd2 sd3 tty0 tty1
@@ -9,7 +9,7 @@ all_md)
 	;;
 
 raminst)
-	makedev std
+	makedev std bpf md0
 	makedev sd0 sd1 sd2 sd3 st0 st1 cd0 cd1
 	makedev tty0 tty1 opty
 	;;

Index: src/etc/etc.next68k/Makefile.inc
diff -u src/etc/etc.next68k/Makefile.inc:1.7 src/etc/etc.next68k/Makefile.inc:1.7.76.1
--- src/etc/etc.next68k/Makefile.inc:1.7	Tue Mar 18 04:20:37 2008
+++ src/etc/etc.next68k/Makefile.inc	Wed Feb 22 12:59:17 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.7 2008/03/18 04:20:37 lukem Exp $
+#	$NetBSD: Makefile.inc,v 1.7.76.1 2023/02/22 12:59:17 martin Exp $
 #
 #	etc.next68k/Makefile.inc -- next68k-specific etc Makefile targets
 #
@@ -7,6 +7,7 @@
 # to update the release documentation in distrib/notes/common/contents
 
 KERNEL_SETS=		GENERIC
+BUILD_KERNELS=		RAMDISK
 
 snap_md_post:
 	# install boot image in installation directory

Index: src/sys/arch/next68k/conf/GENERIC
diff -u src/sys/arch/next68k/conf/GENERIC:1.153.4.1 src/sys/arch/next68k/conf/GENERIC:1.153.4.2
--- src/sys/arch/next68k/conf/GENERIC:1.153.4.1	Wed Feb 15 19:16:43 2023
+++ src/sys/arch/next68k/conf/GENERIC	Wed Feb 22 12:59:17 2023
@@ -1,7 +1,7 @@
-# $NetBSD: GENERIC,v 1.153.4.1 2023/02/15 19:16:43 martin Exp $
+# $NetBSD: GENERIC,v 1.153.4.2 2023/02/22 12:59:17 martin Exp $
 #
 

CVS commit: [netbsd-10] src

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 12:59:17 UTC 2023

Modified Files:
src/distrib/next68k [netbsd-10]: Makefile
src/etc/etc.next68k [netbsd-10]: MAKEDEV.conf Makefile.inc
src/sys/arch/next68k/conf [netbsd-10]: GENERIC RAMDISK SLAB
majors.next68k
Added Files:
src/distrib/next68k/instkernel [netbsd-10]: Makefile
src/distrib/next68k/ramdisk [netbsd-10]: Makefile dot.profile list

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #91):

etc/etc.next68k/MAKEDEV.conf: revision 1.7
sys/arch/next68k/conf/GENERIC: revision 1.156
sys/arch/next68k/conf/GENERIC: revision 1.157
sys/arch/next68k/conf/GENERIC: revision 1.158
distrib/next68k/instkernel/Makefile: revision 1.1
sys/arch/next68k/conf/GENERIC: revision 1.159
distrib/next68k/ramdisk/list: revision 1.1
etc/etc.next68k/Makefile.inc: revision 1.8
sys/arch/next68k/conf/RAMDISK: revision 1.5
distrib/next68k/ramdisk/dot.profile: revision 1.1
sys/arch/next68k/conf/SLAB: revision 1.62
sys/arch/next68k/conf/GENERIC: revision 1.160
sys/arch/next68k/conf/SLAB: revision 1.63
sys/arch/next68k/conf/GENERIC: revision 1.161
distrib/next68k/ramdisk/Makefile: revision 1.1
sys/arch/next68k/conf/majors.next68k: revision 1.26
distrib/next68k/Makefile: revision 1.2

Remove trailing TABs.

Remove trailing spaces and TABs.

Enable file-system CD9660.
It's useful for installation especially on emulators.

Remove nonexistent options SWAPDEBUG.

Remove unnecessary commented out lines.

Disable rarely used options and devices, and add options MODULAR instead.

Also enable files-system MSDOS for file exchange via removable media.

Build a RAMDISK root kernel on NetBSD/next68k release build.
No sysinst(8) yet, but useful on bootstrap and rescue ops.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 src/distrib/next68k/Makefile
cvs rdiff -u -r0 -r1.1.2.2 src/distrib/next68k/instkernel/Makefile
cvs rdiff -u -r0 -r1.1.2.2 src/distrib/next68k/ramdisk/Makefile \
src/distrib/next68k/ramdisk/dot.profile src/distrib/next68k/ramdisk/list
cvs rdiff -u -r1.5.16.1 -r1.5.16.2 src/etc/etc.next68k/MAKEDEV.conf
cvs rdiff -u -r1.7 -r1.7.76.1 src/etc/etc.next68k/Makefile.inc
cvs rdiff -u -r1.153.4.1 -r1.153.4.2 src/sys/arch/next68k/conf/GENERIC
cvs rdiff -u -r1.4 -r1.4.96.1 src/sys/arch/next68k/conf/RAMDISK
cvs rdiff -u -r1.60 -r1.60.18.1 src/sys/arch/next68k/conf/SLAB
cvs rdiff -u -r1.25 -r1.25.22.1 src/sys/arch/next68k/conf/majors.next68k

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



CVS commit: [netbsd-9] src/sys/arch/next68k/stand/boot

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 12:09:16 UTC 2023

Modified Files:
src/sys/arch/next68k/stand/boot [netbsd-9]: boot.c conf.c devopen.c
en.c machdep.c rtc.c scsi.c scsivar.h sd.c version
Added Files:
src/sys/arch/next68k/stand/boot [netbsd-9]: samachdep.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1600):

sys/arch/next68k/stand/boot/en.c: revision 1.20
sys/arch/next68k/stand/boot/scsi.c: revision 1.13
sys/arch/next68k/stand/boot/scsi.c: revision 1.14
sys/arch/next68k/stand/boot/conf.c: revision 1.8
sys/arch/next68k/stand/boot/sd.c: revision 1.17
sys/arch/next68k/stand/boot/samachdep.h: revision 1.1
sys/arch/next68k/stand/boot/samachdep.h: revision 1.2
sys/arch/next68k/stand/boot/rtc.c: revision 1.8
sys/arch/next68k/stand/boot/machdep.c: revision 1.9
sys/arch/next68k/stand/boot/boot.c: revision 1.14
sys/arch/next68k/stand/boot/boot.c: revision 1.15
sys/arch/next68k/stand/boot/scsivar.h: revision 1.2
sys/arch/next68k/stand/boot/devopen.c: revision 1.8
sys/arch/next68k/stand/boot/version: revision 1.7

Use common declarations and macros in proper headers.

Also fix inconsistent sdopen() and sdstrategy() args and
remove useless #if 0'ed out code.
No functional change.

Replace DELAY() with one in hp300 bootloader and adjust cpuspeed counts.

Fix boot failure on my ancient Seagate ST52160N drive.
It looks some of such old drives can't respond to SCSI
test-unit-ready command without proper wait after SCSI bus reset.

Bump version again to denote a fix.

XXX we should re-evaluate cpuspeed counts for DELAY() in bootloaders
(where cache is disabled) on other m68k ports, hp300 and luna68k etc.

Actually bump version (missed in the previous commit).


To generate a diff of this commit:
cvs rdiff -u -r1.12.22.1 -r1.12.22.2 src/sys/arch/next68k/stand/boot/boot.c
cvs rdiff -u -r1.7 -r1.7.170.1 src/sys/arch/next68k/stand/boot/conf.c
cvs rdiff -u -r1.6.32.1 -r1.6.32.2 src/sys/arch/next68k/stand/boot/devopen.c
cvs rdiff -u -r1.19 -r1.19.6.1 src/sys/arch/next68k/stand/boot/en.c
cvs rdiff -u -r1.7.102.1 -r1.7.102.2 \
src/sys/arch/next68k/stand/boot/machdep.c
cvs rdiff -u -r1.6.70.1 -r1.6.70.2 src/sys/arch/next68k/stand/boot/rtc.c
cvs rdiff -u -r0 -r1.2.4.2 src/sys/arch/next68k/stand/boot/samachdep.h
cvs rdiff -u -r1.10.96.1 -r1.10.96.2 src/sys/arch/next68k/stand/boot/scsi.c
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.242.1 \
src/sys/arch/next68k/stand/boot/scsivar.h
cvs rdiff -u -r1.12.34.1 -r1.12.34.2 src/sys/arch/next68k/stand/boot/sd.c
cvs rdiff -u -r1.4.212.2 -r1.4.212.3 src/sys/arch/next68k/stand/boot/version

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/next68k/stand/boot/boot.c
diff -u src/sys/arch/next68k/stand/boot/boot.c:1.12.22.1 src/sys/arch/next68k/stand/boot/boot.c:1.12.22.2
--- src/sys/arch/next68k/stand/boot/boot.c:1.12.22.1	Wed Feb 15 19:28:29 2023
+++ src/sys/arch/next68k/stand/boot/boot.c	Wed Feb 22 12:09:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.12.22.1 2023/02/15 19:28:29 martin Exp $	*/
+/*	$NetBSD: boot.c,v 1.12.22.2 2023/02/22 12:09:16 martin Exp $	*/
 /*
  * Copyright (c) 1994 Rolf Grossmann
  * All rights reserved.
@@ -34,17 +34,17 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include /* for NEXT_RAMBASE */
 
 #include 
 
-#define KERN_LOADADDR NEXT_RAMBASE
+#include "samachdep.h"
 
-extern int errno;
+#define KERN_LOADADDR NEXT_RAMBASE
 
-extern char *mg;
 #define	MON(type, off) (*(type *)((u_int) (mg) + off))
 
 int devparse(const char *, int *, char *, char *, char *, char **);
@@ -56,18 +56,12 @@ int devparse(const char *, int *, char *
  * Boot device is derived from PROM provided information.
  */
 
-extern char bootprog_rev[];
-extern char bootprog_name[];
-extern int build;
 #define KNAMEN 100
 char kernel[KNAMEN];
 int entry_point;		/* return value filled in by machdep_start */
+int cpuspeed = MHZ_33;		/* assume fastest 33 MHz for sanity */
 int turbo;
 
-extern void rtc_init(void);
-
-extern int try_bootp;
-
 volatile int qq;
 
 int
@@ -86,10 +80,13 @@ main(char *boot_arg)
 	machine = MON(char, MG_machine_type);
 	if (machine == NeXT_TURBO_MONO ||
 	machine == NeXT_TURBO_COLOR ||
-	machine == NeXT_CUBE_TURBO)
+	machine == NeXT_CUBE_TURBO) {
 		turbo = 1;
-	else
+		cpuspeed = MHZ_33;
+	} else {
 		turbo = 0;
+		cpuspeed = MHZ_25;
+	}
 
 	memset(marks, 0, sizeof(marks));
 	printf(">> %s BOOT [%s #%d]\n", bootprog_name, bootprog_rev, build);

Index: src/sys/arch/next68k/stand/boot/conf.c
diff -u src/sys/arch/next68k/stand/boot/conf.c:1.7 src/sys/arch/next68k/stand/boot/conf.c:1.7.170.1
--- src/sys/arch/next68k/stand/boot/conf.c:1.7	Sun Dec 11 12:18:29 2005
+++ src/sys/arch/next68k/stand/boot/conf.c	Wed Feb 22 12:09:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD

CVS commit: [netbsd-9] src/sys/arch/next68k/stand/boot

2023-02-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 22 12:09:16 UTC 2023

Modified Files:
src/sys/arch/next68k/stand/boot [netbsd-9]: boot.c conf.c devopen.c
en.c machdep.c rtc.c scsi.c scsivar.h sd.c version
Added Files:
src/sys/arch/next68k/stand/boot [netbsd-9]: samachdep.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1600):

sys/arch/next68k/stand/boot/en.c: revision 1.20
sys/arch/next68k/stand/boot/scsi.c: revision 1.13
sys/arch/next68k/stand/boot/scsi.c: revision 1.14
sys/arch/next68k/stand/boot/conf.c: revision 1.8
sys/arch/next68k/stand/boot/sd.c: revision 1.17
sys/arch/next68k/stand/boot/samachdep.h: revision 1.1
sys/arch/next68k/stand/boot/samachdep.h: revision 1.2
sys/arch/next68k/stand/boot/rtc.c: revision 1.8
sys/arch/next68k/stand/boot/machdep.c: revision 1.9
sys/arch/next68k/stand/boot/boot.c: revision 1.14
sys/arch/next68k/stand/boot/boot.c: revision 1.15
sys/arch/next68k/stand/boot/scsivar.h: revision 1.2
sys/arch/next68k/stand/boot/devopen.c: revision 1.8
sys/arch/next68k/stand/boot/version: revision 1.7

Use common declarations and macros in proper headers.

Also fix inconsistent sdopen() and sdstrategy() args and
remove useless #if 0'ed out code.
No functional change.

Replace DELAY() with one in hp300 bootloader and adjust cpuspeed counts.

Fix boot failure on my ancient Seagate ST52160N drive.
It looks some of such old drives can't respond to SCSI
test-unit-ready command without proper wait after SCSI bus reset.

Bump version again to denote a fix.

XXX we should re-evaluate cpuspeed counts for DELAY() in bootloaders
(where cache is disabled) on other m68k ports, hp300 and luna68k etc.

Actually bump version (missed in the previous commit).


To generate a diff of this commit:
cvs rdiff -u -r1.12.22.1 -r1.12.22.2 src/sys/arch/next68k/stand/boot/boot.c
cvs rdiff -u -r1.7 -r1.7.170.1 src/sys/arch/next68k/stand/boot/conf.c
cvs rdiff -u -r1.6.32.1 -r1.6.32.2 src/sys/arch/next68k/stand/boot/devopen.c
cvs rdiff -u -r1.19 -r1.19.6.1 src/sys/arch/next68k/stand/boot/en.c
cvs rdiff -u -r1.7.102.1 -r1.7.102.2 \
src/sys/arch/next68k/stand/boot/machdep.c
cvs rdiff -u -r1.6.70.1 -r1.6.70.2 src/sys/arch/next68k/stand/boot/rtc.c
cvs rdiff -u -r0 -r1.2.4.2 src/sys/arch/next68k/stand/boot/samachdep.h
cvs rdiff -u -r1.10.96.1 -r1.10.96.2 src/sys/arch/next68k/stand/boot/scsi.c
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.242.1 \
src/sys/arch/next68k/stand/boot/scsivar.h
cvs rdiff -u -r1.12.34.1 -r1.12.34.2 src/sys/arch/next68k/stand/boot/sd.c
cvs rdiff -u -r1.4.212.2 -r1.4.212.3 src/sys/arch/next68k/stand/boot/version

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



  1   2   >