CVS commit: src/sys/dev/usb

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:13:10 UTC 2022

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

Log Message:
ualea(4): Simplify xfer error branches.

- Avoid going into a loop in case the transfer fails repeatedly --
  just give up immediately if it fails.

- Assert result size is reasonable; no need to assume usbdi(9) is
  malicious.  If it can return ux_actlen > ux_length, that's a bug in
  usbdi(9) that we should fix.


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

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



CVS commit: src/sys/dev/usb

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:13:10 UTC 2022

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

Log Message:
ualea(4): Simplify xfer error branches.

- Avoid going into a loop in case the transfer fails repeatedly --
  just give up immediately if it fails.

- Assert result size is reasonable; no need to assume usbdi(9) is
  malicious.  If it can return ux_actlen > ux_length, that's a bug in
  usbdi(9) that we should fix.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/usb/ualea.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/ualea.c
diff -u src/sys/dev/usb/ualea.c:1.17 src/sys/dev/usb/ualea.c:1.18
--- src/sys/dev/usb/ualea.c:1.17	Sun Mar 20 00:41:01 2022
+++ src/sys/dev/usb/ualea.c	Sun Mar 20 13:13:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ualea.c,v 1.17 2022/03/20 00:41:01 riastradh Exp $	*/
+/*	$NetBSD: ualea.c,v 1.18 2022/03/20 13:13:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.17 2022/03/20 00:41:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.18 2022/03/20 13:13:10 riastradh Exp $");
 
 #include 
 #include 
@@ -230,39 +230,37 @@ ualea_xfer_done(struct usbd_xfer *xfer, 
 	void *pkt;
 	uint32_t pktsize;
 
-	/* Check the transfer status.  */
+	/*
+	 * If the transfer failed, give up -- forget what we need and
+	 * don't reschedule ourselves.
+	 */
 	if (status) {
 		device_printf(sc->sc_dev, "xfer failed: %s\n",
 		usbd_errstr(status));
-		pktsize = 0;
-		goto out;
+		mutex_enter(>sc_lock);
+		sc->sc_needed = 0;
+		sc->sc_inflight = false;
+		mutex_exit(>sc_lock);
+		return;
 	}
 
-	/* Get and sanity-check the transferred size.  */
+	/* Get the transferred size.  */
 	usbd_get_xfer_status(xfer, NULL, , , NULL);
-	if (pktsize > sc->sc_maxpktsize) {
-		device_printf(sc->sc_dev,
-		"bogus packet size: %"PRIu32" > %"PRIu16" (max), ignoring"
-		"\n",
-		pktsize, sc->sc_maxpktsize);
-		goto out;
-	}
+	KASSERTMSG(pktsize <= sc->sc_maxpktsize,
+	"pktsize %"PRIu32" > %"PRIu16" (max)",
+	pktsize, sc->sc_maxpktsize);
 
 	/* Add the data to the pool.  */
 	rnd_add_data(>sc_rnd, pkt, pktsize, NBBY*pktsize);
 
-out:
+	/*
+	 * Debit what we contributed from what we need, mark the xfer
+	 * as done, and reschedule the xfer if we still need more.
+	 */
 	mutex_enter(>sc_lock);
-
-	/* Debit what we contributed from what we need.  */
 	sc->sc_needed -= MIN(sc->sc_needed, pktsize);
-
-	/* Mark xfer done.  */
 	sc->sc_inflight = false;
-
-	/* Reissue xfer if we still need more.  */
 	ualea_xfer(sc);
-
 	mutex_exit(>sc_lock);
 }
 



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 14:05:41 UTC 2022

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

Log Message:
Revert "entropy(9): Nix rnd_trylock_sources."

Not a premature optimization after all -- this is necessary because
entropy_request can run in softint context, where the cv_wait_sig in
rnd_lock_sources is forbidden.  Need to do this another way.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 14:05:41 UTC 2022

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

Log Message:
Revert "entropy(9): Nix rnd_trylock_sources."

Not a premature optimization after all -- this is necessary because
entropy_request can run in softint context, where the cv_wait_sig in
rnd_lock_sources is forbidden.  Need to do this another way.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.47 src/sys/kern/kern_entropy.c:1.48
--- src/sys/kern/kern_entropy.c:1.47	Sun Mar 20 13:44:18 2022
+++ src/sys/kern/kern_entropy.c	Sun Mar 20 14:05:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.47 2022/03/20 13:44:18 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.48 2022/03/20 14:05:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.47 2022/03/20 13:44:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.48 2022/03/20 14:05:41 riastradh Exp $");
 
 #include 
 #include 
@@ -1702,10 +1702,30 @@ rnd_lock_sources(void)
 }
 
 /*
+ * rnd_trylock_sources()
+ *
+ *	Try to lock the list of sources, but if it's already locked,
+ *	fail.  Caller must hold the global entropy lock.  If
+ *	successful, no rndsource will go away until rnd_unlock_sources
+ *	even while the caller releases the global entropy lock.
+ */
+static bool
+rnd_trylock_sources(void)
+{
+
+	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
+
+	if (E->sourcelock)
+		return false;
+	E->sourcelock = curlwp;
+	return true;
+}
+
+/*
  * rnd_unlock_sources()
  *
- *	Unlock the list of sources after rnd_lock_sources.  Caller must
- *	hold the global entropy lock.
+ *	Unlock the list of sources after rnd_lock_sources or
+ *	rnd_trylock_sources.  Caller must hold the global entropy lock.
  */
 static void
 rnd_unlock_sources(void)
@@ -1748,11 +1768,12 @@ entropy_request(size_t nbytes)
 	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
 
 	/*
-	 * Lock the list of entropy sources to block rnd_detach_source
-	 * until we're done, and to serialize calls to the entropy
-	 * callbacks as guaranteed to drivers.
+	 * If there is a request in progress, let it proceed.
+	 * Otherwise, note that a request is in progress to avoid
+	 * reentry and to block rnd_detach_source until we're done.
 	 */
-	rnd_lock_sources();
+	if (!rnd_trylock_sources())
+		return;
 	entropy_request_evcnt.ev_count++;
 
 	/* Clamp to the maximum reasonable request.  */



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:44:18 UTC 2022

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

Log Message:
entropy(9): Nix rnd_trylock_sources.

This was a premature optimization that turned out to be bogus.  It's
not harmful to request more than we need from drivers, so let's not
go out of our way to avoid that.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.46 src/sys/kern/kern_entropy.c:1.47
--- src/sys/kern/kern_entropy.c:1.46	Sun Mar 20 13:18:11 2022
+++ src/sys/kern/kern_entropy.c	Sun Mar 20 13:44:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.46 2022/03/20 13:18:11 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.47 2022/03/20 13:44:18 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.46 2022/03/20 13:18:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.47 2022/03/20 13:44:18 riastradh Exp $");
 
 #include 
 #include 
@@ -1702,30 +1702,10 @@ rnd_lock_sources(void)
 }
 
 /*
- * rnd_trylock_sources()
- *
- *	Try to lock the list of sources, but if it's already locked,
- *	fail.  Caller must hold the global entropy lock.  If
- *	successful, no rndsource will go away until rnd_unlock_sources
- *	even while the caller releases the global entropy lock.
- */
-static bool
-rnd_trylock_sources(void)
-{
-
-	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
-
-	if (E->sourcelock)
-		return false;
-	E->sourcelock = curlwp;
-	return true;
-}
-
-/*
  * rnd_unlock_sources()
  *
- *	Unlock the list of sources after rnd_lock_sources or
- *	rnd_trylock_sources.  Caller must hold the global entropy lock.
+ *	Unlock the list of sources after rnd_lock_sources.  Caller must
+ *	hold the global entropy lock.
  */
 static void
 rnd_unlock_sources(void)
@@ -1768,12 +1748,11 @@ entropy_request(size_t nbytes)
 	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
 
 	/*
-	 * If there is a request in progress, let it proceed.
-	 * Otherwise, note that a request is in progress to avoid
-	 * reentry and to block rnd_detach_source until we're done.
+	 * Lock the list of entropy sources to block rnd_detach_source
+	 * until we're done, and to serialize calls to the entropy
+	 * callbacks as guaranteed to drivers.
 	 */
-	if (!rnd_trylock_sources())
-		return;
+	rnd_lock_sources();
 	entropy_request_evcnt.ev_count++;
 
 	/* Clamp to the maximum reasonable request.  */



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:44:18 UTC 2022

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

Log Message:
entropy(9): Nix rnd_trylock_sources.

This was a premature optimization that turned out to be bogus.  It's
not harmful to request more than we need from drivers, so let's not
go out of our way to avoid that.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:17:44 UTC 2022

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

Log Message:
entropy(9): Shuffle some assertions around.

Tripped over (diff || E->pending == ENTROPY_CAPACITY*NBBY), not sure
why yet, printing values will help.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:17:44 UTC 2022

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

Log Message:
entropy(9): Shuffle some assertions around.

Tripped over (diff || E->pending == ENTROPY_CAPACITY*NBBY), not sure
why yet, printing values will help.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.44 src/sys/kern/kern_entropy.c:1.45
--- src/sys/kern/kern_entropy.c:1.44	Sun Mar 20 13:17:32 2022
+++ src/sys/kern/kern_entropy.c	Sun Mar 20 13:17:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.44 2022/03/20 13:17:32 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.45 2022/03/20 13:17:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.44 2022/03/20 13:17:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.45 2022/03/20 13:17:44 riastradh Exp $");
 
 #include 
 #include 
@@ -771,17 +771,26 @@ entropy_account_cpu(struct entropy_cpu *
 		entropy_notify();
 		entropy_immediate_evcnt.ev_count++;
 	} else {
-		/* Record how much we can add to the global pool.  */
+		/* Determine how much we can add to the global pool.  */
+		KASSERTMSG(E->pending <= ENTROPY_CAPACITY*NBBY,
+		"E->pending=%u", E->pending);
 		diff = MIN(ec->ec_pending, ENTROPY_CAPACITY*NBBY - E->pending);
-		E->pending += diff;
-		atomic_store_relaxed(>ec_pending, ec->ec_pending - diff);
 
 		/*
-		 * This should have made a difference unless we were
-		 * already saturated.
+		 * This should make a difference unless we are already
+		 * saturated.
 		 */
-		KASSERT(diff || E->pending == ENTROPY_CAPACITY*NBBY);
+		KASSERTMSG(diff || E->pending == ENTROPY_CAPACITY*NBBY,
+		"diff=%u E->pending=%u ec->ec_pending=%u cap=%u",
+		diff, E->pending, ec->ec_pending,
+		(unsigned)ENTROPY_CAPACITY*NBBY);
+
+		/* Add to the global, subtract from the local.  */
+		E->pending += diff;
 		KASSERT(E->pending);
+		KASSERTMSG(E->pending <= ENTROPY_CAPACITY*NBBY,
+		"E->pending=%u", E->pending);
+		atomic_store_relaxed(>ec_pending, ec->ec_pending - diff);
 
 		if (E->needed <= E->pending) {
 			/*
@@ -907,6 +916,7 @@ entropy_enter_intr(const void *buf, size
 	uint32_t pending;
 	void *sih;
 
+	KASSERT(cpu_intr_p());
 	KASSERTMSG(howmany(nbits, NBBY) <= len,
 	"impossible entropy rate: %u bits in %zu-byte string", nbits, len);
 



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:17:09 UTC 2022

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

Log Message:
entropy(9): Factor out logic to lock and unlock per-CPU state.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.42 src/sys/kern/kern_entropy.c:1.43
--- src/sys/kern/kern_entropy.c:1.42	Sun Mar 20 00:19:11 2022
+++ src/sys/kern/kern_entropy.c	Sun Mar 20 13:17:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.42 2022/03/20 00:19:11 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.43 2022/03/20 13:17:09 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.42 2022/03/20 00:19:11 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.43 2022/03/20 13:17:09 riastradh Exp $");
 
 #include 
 #include 
@@ -141,6 +141,16 @@ struct entropy_cpu {
 };
 
 /*
+ * struct entropy_cpu_lock
+ *
+ *	State for locking the per-CPU entropy state.
+ */
+struct entropy_cpu_lock {
+	int		ecl_s;
+	uint64_t	ecl_ncsw;
+};
+
+/*
  * struct rndsource_cpu
  *
  *	Per-CPU rndsource state.
@@ -512,6 +522,47 @@ entropy_fini_cpu(void *ptr, void *cookie
 }
 
 /*
+ * ec = entropy_cpu_get()
+ * entropy_cpu_put(, ec)
+ *
+ *	Lock and unlock the per-CPU entropy state.  This only prevents
+ *	access on the same CPU -- by hard interrupts, by soft
+ *	interrupts, or by other threads.
+ *
+ *	Blocks soft interrupts and preemption altogether; doesn't block
+ *	hard interrupts, but causes samples in hard interrupts to be
+ *	dropped.
+ */
+static struct entropy_cpu *
+entropy_cpu_get(struct entropy_cpu_lock *lock)
+{
+	struct entropy_cpu *ec;
+
+	ec = percpu_getref(entropy_percpu);
+	lock->ecl_s = splsoftserial();
+	KASSERT(!ec->ec_locked);
+	ec->ec_locked = true;
+	lock->ecl_ncsw = curlwp->l_ncsw;
+	__insn_barrier();
+
+	return ec;
+}
+
+static void
+entropy_cpu_put(struct entropy_cpu_lock *lock, struct entropy_cpu *ec)
+{
+
+	KASSERT(ec == percpu_getptr_remote(entropy_percpu, curcpu()));
+	KASSERT(ec->ec_locked);
+
+	__insn_barrier();
+	KASSERT(lock->ecl_ncsw == curlwp->l_ncsw);
+	ec->ec_locked = false;
+	splx(lock->ecl_s);
+	percpu_putref(entropy_percpu);
+}
+
+/*
  * entropy_seed(seed)
  *
  *	Seed the entropy pool with seed.  Meant to be called as early
@@ -797,10 +848,9 @@ entropy_enter_early(const void *buf, siz
 static void
 entropy_enter(const void *buf, size_t len, unsigned nbits)
 {
+	struct entropy_cpu_lock lock;
 	struct entropy_cpu *ec;
 	unsigned pending;
-	uint64_t ncsw;
-	int s;
 
 	KASSERTMSG(!cpu_intr_p(),
 	"use entropy_enter_intr from interrupt context");
@@ -814,31 +864,15 @@ entropy_enter(const void *buf, size_t le
 	}
 
 	/*
-	 * Acquire the per-CPU state, blocking soft interrupts and
-	 * causing hard interrupts to drop samples on the floor.
+	 * With the per-CPU state locked, enter into the per-CPU pool
+	 * and count up what we can add.
 	 */
-	ec = percpu_getref(entropy_percpu);
-	s = splsoftserial();
-	KASSERT(!ec->ec_locked);
-	ec->ec_locked = true;
-	ncsw = curlwp->l_ncsw;
-	__insn_barrier();
-
-	/* Enter into the per-CPU pool.  */
+	ec = entropy_cpu_get();
 	entpool_enter(ec->ec_pool, buf, len);
-
-	/* Count up what we can add.  */
 	pending = ec->ec_pending;
 	pending += MIN(ENTROPY_CAPACITY*NBBY - pending, nbits);
 	atomic_store_relaxed(>ec_pending, pending);
-
-	/* Release the per-CPU state.  */
-	KASSERT(ec->ec_locked);
-	__insn_barrier();
-	KASSERT(ncsw == curlwp->l_ncsw);
-	ec->ec_locked = false;
-	splx(s);
-	percpu_putref(entropy_percpu);
+	entropy_cpu_put(, ec);
 
 	/* Consolidate globally if appropriate based on what we added.  */
 	if (pending)
@@ -937,36 +971,20 @@ out0:	percpu_putref(entropy_percpu);
 static void
 entropy_softintr(void *cookie)
 {
+	struct entropy_cpu_lock lock;
 	struct entropy_cpu *ec;
 	unsigned pending;
-	uint64_t ncsw;
 
 	/*
-	 * Acquire the per-CPU state.  Other users can lock this only
-	 * while soft interrupts are blocked.  Cause hard interrupts to
-	 * drop samples on the floor.
+	 * With the per-CPU state locked, stir the pool if necessary
+	 * and determine if there's any pending entropy on this CPU to
+	 * account globally.
 	 */
-	ec = percpu_getref(entropy_percpu);
-	KASSERT(!ec->ec_locked);
-	ec->ec_locked = true;
-	ncsw = curlwp->l_ncsw;
-	__insn_barrier();
-
-	/* Count statistics.  */
+	ec = entropy_cpu_get();
 	ec->ec_evcnt->softint.ev_count++;
-
-	/* Stir the pool if necessary.  */
 	entpool_stir(ec->ec_pool);
-
-	/* Determine if there's anything pending on this CPU.  */
 	pending = ec->ec_pending;
-
-	/* Release the per-CPU state.  */
-	KASSERT(ec->ec_locked);
-	__insn_barrier();
-	KASSERT(ncsw == 

CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:17:09 UTC 2022

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

Log Message:
entropy(9): Factor out logic to lock and unlock per-CPU state.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:17:32 UTC 2022

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

Log Message:
entropy(9): Lock the per-CPU state in entropy_account_cpu.

This was previously called with the per-CPU state locked, which
worked fine as long as the global entropy lock was a spin lock so
acquiring it would never sleep.  Now it's an adaptive lock, so it's
not safe to take with the per-CPU state lock -- but we still need to
prevent reentrant access to the per-CPU entropy pool by interrupt
handlers while we're extracting from it.  So now the logic for
entering a sample is:

- lock per-CPU state
- entpool_enter
- unlock per-CPU state
- if anything pending on this CPU and it's time to consolidate:
  - lock global entropy state
  - lock per-CPU state
  - transfer
  - unlock per-CPU state
  - unlock global entropy state


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:17:32 UTC 2022

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

Log Message:
entropy(9): Lock the per-CPU state in entropy_account_cpu.

This was previously called with the per-CPU state locked, which
worked fine as long as the global entropy lock was a spin lock so
acquiring it would never sleep.  Now it's an adaptive lock, so it's
not safe to take with the per-CPU state lock -- but we still need to
prevent reentrant access to the per-CPU entropy pool by interrupt
handlers while we're extracting from it.  So now the logic for
entering a sample is:

- lock per-CPU state
- entpool_enter
- unlock per-CPU state
- if anything pending on this CPU and it's time to consolidate:
  - lock global entropy state
  - lock per-CPU state
  - transfer
  - unlock per-CPU state
  - unlock global entropy state


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.43 src/sys/kern/kern_entropy.c:1.44
--- src/sys/kern/kern_entropy.c:1.43	Sun Mar 20 13:17:09 2022
+++ src/sys/kern/kern_entropy.c	Sun Mar 20 13:17:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.43 2022/03/20 13:17:09 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.44 2022/03/20 13:17:32 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.43 2022/03/20 13:17:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.44 2022/03/20 13:17:32 riastradh Exp $");
 
 #include 
 #include 
@@ -728,8 +728,9 @@ entropy_ready(void)
 static void
 entropy_account_cpu(struct entropy_cpu *ec)
 {
+	struct entropy_cpu_lock lock;
+	struct entropy_cpu *ec0;
 	unsigned diff;
-	int s;
 
 	KASSERT(E->stage >= ENTROPY_WARM);
 
@@ -742,9 +743,13 @@ entropy_account_cpu(struct entropy_cpu *
 	__predict_true((time_uptime - E->timestamp) <= 60))
 		return;
 
-	/* Consider consolidation, under the lock.  */
+	/*
+	 * Consider consolidation, under the global lock and with the
+	 * per-CPU state locked.
+	 */
 	mutex_enter(>lock);
-	s = splsoftserial();
+	ec0 = entropy_cpu_get();
+	KASSERT(ec0 == ec);
 	if (E->needed != 0 && E->needed <= ec->ec_pending) {
 		/*
 		 * If we have not yet attained full entropy but we can
@@ -799,7 +804,7 @@ entropy_account_cpu(struct entropy_cpu *
 			entropy_partial_evcnt.ev_count++;
 		}
 	}
-	splx(s);
+	entropy_cpu_put(, ec);
 	mutex_exit(>lock);
 }
 



CVS commit: src/sys/dev/usb

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:18:30 UTC 2022

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

Log Message:
ualea(4): Enter the data under the softc lock.

This avoids a race with a concurrent ualea_get updating sc_needed,
which could lead to hang when requesting more entropy.

ualea(4) now survives

sysctl -w kern.entropy.depletion=1
cat /dev/null &
cat /dev/null &

without hanging for longer (even if yanked and reinserted in the
middle, although the detach path is not relevant to the bug this
change fixes).


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

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



CVS commit: src/sys/dev/usb

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:18:30 UTC 2022

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

Log Message:
ualea(4): Enter the data under the softc lock.

This avoids a race with a concurrent ualea_get updating sc_needed,
which could lead to hang when requesting more entropy.

ualea(4) now survives

sysctl -w kern.entropy.depletion=1
cat /dev/null &
cat /dev/null &

without hanging for longer (even if yanked and reinserted in the
middle, although the detach path is not relevant to the bug this
change fixes).


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/usb/ualea.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/ualea.c
diff -u src/sys/dev/usb/ualea.c:1.18 src/sys/dev/usb/ualea.c:1.19
--- src/sys/dev/usb/ualea.c:1.18	Sun Mar 20 13:13:10 2022
+++ src/sys/dev/usb/ualea.c	Sun Mar 20 13:18:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ualea.c,v 1.18 2022/03/20 13:13:10 riastradh Exp $	*/
+/*	$NetBSD: ualea.c,v 1.19 2022/03/20 13:18:30 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.18 2022/03/20 13:13:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.19 2022/03/20 13:18:30 riastradh Exp $");
 
 #include 
 #include 
@@ -250,14 +250,18 @@ ualea_xfer_done(struct usbd_xfer *xfer, 
 	"pktsize %"PRIu32" > %"PRIu16" (max)",
 	pktsize, sc->sc_maxpktsize);
 
-	/* Add the data to the pool.  */
-	rnd_add_data(>sc_rnd, pkt, pktsize, NBBY*pktsize);
-
 	/*
-	 * Debit what we contributed from what we need, mark the xfer
-	 * as done, and reschedule the xfer if we still need more.
+	 * Enter the data, debit what we contributed from what we need,
+	 * mark the xfer as done, and reschedule the xfer if we still
+	 * need more.
+	 *
+	 * Must enter the data under the lock so it happens atomically
+	 * with updating sc_needed -- otherwise we might hang needing
+	 * entropy and not scheduling xfer.  Must not touch pkt after
+	 * clearing sc_inflight and possibly rescheduling the xfer.
 	 */
 	mutex_enter(>sc_lock);
+	rnd_add_data(>sc_rnd, pkt, pktsize, NBBY*pktsize);
 	sc->sc_needed -= MIN(sc->sc_needed, pktsize);
 	sc->sc_inflight = false;
 	ualea_xfer(sc);



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:18:12 UTC 2022

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

Log Message:
entropy(9): Fix another new race in entropy_account_cpu.

The consolidation xcall can preempt entropy_enter, between when it
unlocks the per-CPU state and when it calls entropy_account_cpu, with
the effect of setting ec->ec_pending=0.

Previously this was impossible because we called entropy_account_cpu
with the per-CPU state still locked, but that doesn't work now that
the global entropy lock is an adaptive lock which might sleep which
is forbidden while the per-CPU state is locked.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 13:18:12 UTC 2022

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

Log Message:
entropy(9): Fix another new race in entropy_account_cpu.

The consolidation xcall can preempt entropy_enter, between when it
unlocks the per-CPU state and when it calls entropy_account_cpu, with
the effect of setting ec->ec_pending=0.

Previously this was impossible because we called entropy_account_cpu
with the per-CPU state still locked, but that doesn't work now that
the global entropy lock is an adaptive lock which might sleep which
is forbidden while the per-CPU state is locked.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.45 src/sys/kern/kern_entropy.c:1.46
--- src/sys/kern/kern_entropy.c:1.45	Sun Mar 20 13:17:44 2022
+++ src/sys/kern/kern_entropy.c	Sun Mar 20 13:18:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.45 2022/03/20 13:17:44 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.46 2022/03/20 13:18:11 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.45 2022/03/20 13:17:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.46 2022/03/20 13:18:11 riastradh Exp $");
 
 #include 
 #include 
@@ -750,7 +750,9 @@ entropy_account_cpu(struct entropy_cpu *
 	mutex_enter(>lock);
 	ec0 = entropy_cpu_get();
 	KASSERT(ec0 == ec);
-	if (E->needed != 0 && E->needed <= ec->ec_pending) {
+	if (ec->ec_pending == 0) {
+		/* Raced with consolidation xcall.  Nothing to do.  */
+	} else if (E->needed != 0 && E->needed <= ec->ec_pending) {
 		/*
 		 * If we have not yet attained full entropy but we can
 		 * now, do so.  This way we disseminate entropy



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 14:30:57 UTC 2022

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

Log Message:
entropy(9): Fix premature optimization deadlock in entropy_request.

- For synchronous queries from /dev/random, which are waiting for
  entropy to be ready, wait for concurrent access -- e.g., concurrent
  rnd_detach_source -- to finish, and make sure to request entropy
  from all sources (unless we're interrupted by a signal).

- When invoked through softint context (e.g., cprng_fast_intr ->
  cprng_strong -> entropy_extract), don't wait, because we're
  forbidden from waiting anyway.

- For entropy_bootrequest, wait but don't bother failing on signal
  because this only happens in kthread context, not in userland
  process context, so there can't be signals.

Nix rnd_trylock_sources; use the same entropy_extract flags
(ENTROPY_WAIT, ENTROPY_SIG) for rnd_lock_sources.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.48 src/sys/kern/kern_entropy.c:1.49
--- src/sys/kern/kern_entropy.c:1.48	Sun Mar 20 14:05:41 2022
+++ src/sys/kern/kern_entropy.c	Sun Mar 20 14:30:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.48 2022/03/20 14:05:41 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.49 2022/03/20 14:30:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.48 2022/03/20 14:05:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.49 2022/03/20 14:30:56 riastradh Exp $");
 
 #include 
 #include 
@@ -260,7 +260,7 @@ static int	sysctl_entropy_consolidate(SY
 static int	sysctl_entropy_gather(SYSCTLFN_ARGS);
 static void	filt_entropy_read_detach(struct knote *);
 static int	filt_entropy_read_event(struct knote *, long);
-static void	entropy_request(size_t);
+static int	entropy_request(size_t, int);
 static void	rnd_add_data_1(struct krndsource *, const void *, uint32_t,
 		uint32_t, uint32_t);
 static unsigned	rndsource_entropybits(struct krndsource *);
@@ -648,6 +648,7 @@ entropy_seed(rndsave_t *seed)
 void
 entropy_bootrequest(void)
 {
+	int error;
 
 	KASSERT(E->stage >= ENTROPY_WARM);
 
@@ -656,7 +657,8 @@ entropy_bootrequest(void)
 	 * This is harmless overkill if the bootloader provided a seed.
 	 */
 	mutex_enter(>lock);
-	entropy_request(ENTROPY_CAPACITY);
+	error = entropy_request(ENTROPY_CAPACITY, ENTROPY_WAIT);
+	KASSERT(error == 0);
 	mutex_exit(>lock);
 }
 
@@ -1300,7 +1302,8 @@ sysctl_entropy_gather(SYSCTLFN_ARGS)
 		return error;
 	if (arg) {
 		mutex_enter(>lock);
-		entropy_request(ENTROPY_CAPACITY);
+		error = entropy_request(ENTROPY_CAPACITY,
+		ENTROPY_WAIT|ENTROPY_SIG);
 		mutex_exit(>lock);
 	}
 
@@ -1353,7 +1356,9 @@ entropy_extract(void *buf, size_t len, i
 	error = 0;
 	while (E->needed) {
 		/* Ask for more, synchronously if possible.  */
-		entropy_request(len);
+		error = entropy_request(len, flags);
+		if (error)
+			break;
 
 		/* If we got enough, we're done.  */
 		if (E->needed == 0) {
@@ -1677,24 +1682,33 @@ rnd_detach_source(struct krndsource *rs)
 }
 
 /*
- * rnd_lock_sources()
+ * rnd_lock_sources(flags)
+ *
+ *	Lock the list of entropy sources.  Caller must hold the global
+ *	entropy lock.  If successful, no rndsource will go away until
+ *	rnd_unlock_sources even while the caller releases the global
+ *	entropy lock.
  *
- *	Prevent changes to the list of rndsources while we iterate it.
- *	Interruptible.  Caller must hold the global entropy lock.  If
- *	successful, no rndsource will go away until rnd_unlock_sources
- *	even while the caller releases the global entropy lock.
+ *	If flags & ENTROPY_WAIT, wait for concurrent access to finish.
+ *	If flags & ENTROPY_SIG, allow interruption by signal.
  */
-static int
-rnd_lock_sources(void)
+static int __attribute__((warn_unused_result))
+rnd_lock_sources(int flags)
 {
 	int error;
 
 	KASSERT(mutex_owned(>lock));
 
 	while (E->sourcelock) {
-		error = cv_wait_sig(>sourcelock_cv, >lock);
-		if (error)
-			return error;
+		if (!ISSET(flags, ENTROPY_WAIT))
+			return EWOULDBLOCK;
+		if (ISSET(flags, ENTROPY_SIG)) {
+			error = cv_wait_sig(>sourcelock_cv, >lock);
+			if (error)
+return error;
+		} else {
+			cv_wait(>sourcelock_cv, >lock);
+		}
 	}
 
 	E->sourcelock = curlwp;
@@ -1702,30 +1716,10 @@ rnd_lock_sources(void)
 }
 
 /*
- * rnd_trylock_sources()
- *
- *	Try to lock the list of sources, but if it's already locked,
- *	fail.  Caller must hold the global entropy lock.  If
- *	successful, no rndsource will go away until rnd_unlock_sources
- *	even while the caller releases the global entropy lock.
- */
-static bool
-rnd_trylock_sources(void)
-{
-
-	KASSERT(E->stage == ENTROPY_COLD 

CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 14:30:57 UTC 2022

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

Log Message:
entropy(9): Fix premature optimization deadlock in entropy_request.

- For synchronous queries from /dev/random, which are waiting for
  entropy to be ready, wait for concurrent access -- e.g., concurrent
  rnd_detach_source -- to finish, and make sure to request entropy
  from all sources (unless we're interrupted by a signal).

- When invoked through softint context (e.g., cprng_fast_intr ->
  cprng_strong -> entropy_extract), don't wait, because we're
  forbidden from waiting anyway.

- For entropy_bootrequest, wait but don't bother failing on signal
  because this only happens in kthread context, not in userland
  process context, so there can't be signals.

Nix rnd_trylock_sources; use the same entropy_extract flags
(ENTROPY_WAIT, ENTROPY_SIG) for rnd_lock_sources.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/kern/kern_entropy.c

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



CVS commit: src/external/public-domain/tz/dist

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:22:20 UTC 2022

Modified Files:
src/external/public-domain/tz/dist: TZDATA_VERSION

Log Message:
Updated to tzdata2022agtz which is a 2022a fork with backzone zones
moved back into the main data repo (restoring old data)


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/external/public-domain/tz/dist/TZDATA_VERSION

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

Modified files:

Index: src/external/public-domain/tz/dist/TZDATA_VERSION
diff -u src/external/public-domain/tz/dist/TZDATA_VERSION:1.26 src/external/public-domain/tz/dist/TZDATA_VERSION:1.27
--- src/external/public-domain/tz/dist/TZDATA_VERSION:1.26	Fri Oct 22 21:01:06 2021
+++ src/external/public-domain/tz/dist/TZDATA_VERSION	Sun Mar 20 18:22:20 2022
@@ -1 +1 @@
-tzdata-2021e-(part-2021b)
+tzdata-2022agtz



CVS commit: src/external/public-domain/tz/dist

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:22:20 UTC 2022

Modified Files:
src/external/public-domain/tz/dist: TZDATA_VERSION

Log Message:
Updated to tzdata2022agtz which is a 2022a fork with backzone zones
moved back into the main data repo (restoring old data)


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/external/public-domain/tz/dist/TZDATA_VERSION

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



CVS commit: src/sys/arch/usermode/usermode

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 18:56:29 UTC 2022

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

Log Message:
fix typos in debug/panic messages: isued->issued, initialiased->initialised.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/usermode/usermode/pmap.c

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

Modified files:

Index: src/sys/arch/usermode/usermode/pmap.c
diff -u src/sys/arch/usermode/usermode/pmap.c:1.116 src/sys/arch/usermode/usermode/pmap.c:1.117
--- src/sys/arch/usermode/usermode/pmap.c:1.116	Sat Jul 24 21:31:36 2021
+++ src/sys/arch/usermode/usermode/pmap.c	Sun Mar 20 18:56:29 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.116 2021/07/24 21:31:36 andvar Exp $ */
+/* $NetBSD: pmap.c,v 1.117 2022/03/20 18:56:29 andvar Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.116 2021/07/24 21:31:36 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.117 2022/03/20 18:56:29 andvar Exp $");
 
 #include "opt_memsize.h"
 #include "opt_kmempages.h"
@@ -328,7 +328,7 @@ pmap_bootstrap(void)
 
 	memset(pv_table, 0, pv_table_size);	/* test and clear */
 
-	thunk_printf_debug("pv_table initialiased correctly, mmap works\n");
+	thunk_printf_debug("pv_table initialised correctly, mmap works\n");
 
 	/* advance */
 	kmem_kvm_cur_start += pv_table_size;
@@ -369,7 +369,7 @@ pmap_bootstrap(void)
 
 	memset(pmap->pm_l1, 0, pm_l1_size);	/* test and clear */
 
-	thunk_printf_debug("kernel pmap l1 table initialiased correctly\n");
+	thunk_printf_debug("kernel pmap l1 table initialised correctly\n");
 
 	/* advance for l1 tables */
 	kmem_kvm_cur_start += round_page(pm_l1_size);
@@ -895,7 +895,7 @@ pmap_do_enter(pmap_t pmap, vaddr_t va, p
 	lpn = atop(va - VM_MIN_ADDRESS);	/* V->L */
 #ifdef DIAGNOSTIC
 	if ((va < VM_MIN_ADDRESS) || (va > VM_MAX_KERNEL_ADDRESS))
-		panic("pmap_do_enter: invalid va isued\n");
+		panic("pmap_do_enter: invalid va issued\n");
 #endif
 
 	/* raise interrupt level */
@@ -1121,7 +1121,7 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa
 	thunk_printf_debug("pmap_extract: extracting va %p\n", (void *) va);
 #ifdef DIAGNOSTIC
 	if ((va < VM_MIN_ADDRESS) || (va > VM_MAX_KERNEL_ADDRESS)) {
-		thunk_printf_debug("pmap_extract: invalid va isued\n");
+		thunk_printf_debug("pmap_extract: invalid va issued\n");
 		thunk_printf("%p not in [%p, %p]\n", (void *) va,
 		(void *) VM_MIN_ADDRESS, (void *) VM_MAX_KERNEL_ADDRESS);
 		return false;



CVS commit: src/sys/arch/usermode/usermode

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 18:56:29 UTC 2022

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

Log Message:
fix typos in debug/panic messages: isued->issued, initialiased->initialised.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/usermode/usermode/pmap.c

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



CVS commit: src/external/public-domain/tz/dist

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:20:19 UTC 2022

Modified Files:
src/external/public-domain/tz/dist: asia australasia backward
leap-seconds.list leapseconds version

Log Message:
Merge tzdata2022agtz


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/public-domain/tz/dist/asia \
src/external/public-domain/tz/dist/australasia \
src/external/public-domain/tz/dist/version
cvs rdiff -u -r1.2 -r1.3 src/external/public-domain/tz/dist/backward \
src/external/public-domain/tz/dist/leap-seconds.list \
src/external/public-domain/tz/dist/leapseconds

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

Modified files:

Index: src/external/public-domain/tz/dist/asia
diff -u src/external/public-domain/tz/dist/asia:1.3 src/external/public-domain/tz/dist/asia:1.4
--- src/external/public-domain/tz/dist/asia:1.3	Fri Oct 22 21:01:06 2021
+++ src/external/public-domain/tz/dist/asia	Sun Mar 20 18:20:19 2022
@@ -150,7 +150,11 @@ Zone	Asia/Baku	3:19:24 -	LMT	1924 May  2
 			4:00	Azer	+04/+05
 
 # Bahrain
-# See Asia/Qatar.
+# Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
+Zone	Asia/Bahrain	3:22:20 -	LMT	1941 Jul 20  # Manamah
+			3:30	-	+0330	1944 Jan  1
+			4:00	-	+04	1972 Jun
+			3:00	-	+03
 
 # Bangladesh
 # From Alexander Krivenyshev (2009-05-13):
@@ -278,7 +282,13 @@ Zone	Asia/Yangon	6:24:47 -	LMT	1880 
 			6:30	-	+0630
 
 # Cambodia
-# See Asia/Bangkok.
+# Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
+Zone	Asia/Phnom_Penh	6:59:40 -	LMT	1906 Jul  1
+			7:06:30	-	PLMT	1911 May  1
+			7:00	-	+07	1942 Dec 31 23:00
+			8:00	-	+08	1945 Mar 14 23:00
+			9:00	-	+09	1945 Sep  2
+			7:00	-	+07
 
 
 # China
@@ -2703,10 +2713,20 @@ Zone	Asia/Pyongyang	8:23:00 -	LMT	1908 A
 ###
 
 # Kuwait
-# See Asia/Riyadh.
+# Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
+Zone	Asia/Kuwait	3:11:56 -	LMT	1950
+			3:00	-	+03
 
 # Laos
-# See Asia/Bangkok.
+# Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
+Zone	Asia/Vientiane	6:50:24 -	LMT	1906 Jul  1
+			7:06:30	-	PLMT	1911 May  1
+			7:00	-	+07	1942 Dec 31 23:00
+			8:00	-	+08	1945 Mar 14 23:00
+			9:00	-	+09	1945 Sep  2
+			7:00	-	+07	1947 Apr  1
+			8:00	-	+08	1955 Apr 15
+			7:00	-	+07
 
 
 # Lebanon
@@ -2747,6 +2767,7 @@ Rule	NBorneo	1935	1941	-	Dec	14	0:00	0	-
 # peninsular Malaysia
 # taken from Mok Ly Yng (2003-10-30)
 # https://web.archive.org/web/20190822231045/http://www.math.nus.edu.sg/~mathelmr/teaching/timezone.html
+# This agrees with Singapore since 1905-06-01.
 # Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
 Zone Asia/Kuala_Lumpur	6:46:46 -	LMT	1901 Jan  1
 			6:55:25	-	SMT	1905 Jun  1 # Singapore M.T.
@@ -2936,7 +2957,9 @@ Zone	Asia/Kathmandu	5:41:16 -	LMT	1920
 			5:45	-	+0545
 
 # Oman
-# See Asia/Dubai.
+# Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
+Zone	Asia/Muscat	3:54:24 -	LMT	1920
+			4:00	-	+04
 
 # Pakistan
 
@@ -3405,8 +3428,12 @@ Zone	Asia/Karachi	4:28:12 -	LMT	1907
 # ... winter time will begin in Palestine from Friday 10-29, 01:00 AM
 # by 60 minutes backwards.
 #
-# From Paul Eggert (2021-10-20):
-# Guess future fall transitions on October's last Friday at 01:00.
+# From Tim Parenti (2021-10-25), per Paul Eggert (2021-10-24):
+# Guess future fall transitions at 01:00 on the Friday preceding October's
+# last Sunday (i.e., Fri>=23), as this is more consistent with recent practice.
+
+# From Heba Hamad (2022-03-10):
+# summer time will begin in Palestine from Sunday 03-27-2022, 00:00 AM.
 
 # Rule	NAME	FROM	TO	-	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
@@ -3442,9 +3469,10 @@ Rule Palestine	2016	2018	-	Mar	Sat>=24	1
 Rule Palestine	2016	2018	-	Oct	Sat>=24	1:00	0	-
 Rule Palestine	2019	only	-	Mar	29	0:00	1:00	S
 Rule Palestine	2019	only	-	Oct	Sat>=24	0:00	0	-
-Rule Palestine	2020	max	-	Mar	Sat>=24	0:00	1:00	S
+Rule Palestine	2020	2021	-	Mar	Sat>=24	0:00	1:00	S
 Rule Palestine	2020	only	-	Oct	24	1:00	0	-
-Rule Palestine	2021	max	-	Oct	lastFri	1:00	0	-
+Rule Palestine	2021	max	-	Oct	Fri>=23	1:00	0	-
+Rule Palestine	2022	max	-	Mar	Sun>=25	0:00	1:00	S
 
 # Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct
@@ -3538,7 +3566,6 @@ Zone	Asia/Manila	-15:56:00 -	LMT	1844 De
 Zone	Asia/Qatar	3:26:08 -	LMT	1920 # Al Dawhah / Doha
 			4:00	-	+04	1972 Jun
 			3:00	-	+03
-Link Asia/Qatar Asia/Bahrain
 
 # Saudi Arabia
 #
@@ -3585,8 +3612,6 @@ Link Asia/Qatar Asia/Bahrain
 # Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Riyadh	3:06:52 -	LMT	1947 Mar 14
 			3:00	-	+03
-Link Asia/Riyadh Asia/Aden	# Yemen
-Link Asia/Riyadh Asia/Kuwait
 
 # Singapore
 # taken from Mok Ly Yng (2003-10-30)
@@ -3843,8 +3868,6 @@ Zone	Asia/Dushanbe	4:35:12 -	LMT	1924 Ma
 Zone	Asia/Bangkok	6:42:04	-	LMT	1880
 			6:42:04	-	BMT	1920 Apr # Bangkok Mean Time
 			7:00	-	+07
-Link Asia/Bangkok Asia/Phnom_Penh	# Cambodia
-Link Asia/Bangkok Asia/Vientiane	# Laos
 
 

CVS commit: src/external/public-domain/tz/dist

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:20:19 UTC 2022

Modified Files:
src/external/public-domain/tz/dist: asia australasia backward
leap-seconds.list leapseconds version

Log Message:
Merge tzdata2022agtz


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/public-domain/tz/dist/asia \
src/external/public-domain/tz/dist/australasia \
src/external/public-domain/tz/dist/version
cvs rdiff -u -r1.2 -r1.3 src/external/public-domain/tz/dist/backward \
src/external/public-domain/tz/dist/leap-seconds.list \
src/external/public-domain/tz/dist/leapseconds

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



CVS commit: src/sys/dev

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 19:26:27 UTC 2022

Modified Files:
src/sys/dev/raidframe: rf_aselect.c
src/sys/dev/usb: umass.c

Log Message:
s/initialiase/initialise/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/raidframe/rf_aselect.c
cvs rdiff -u -r1.187 -r1.188 src/sys/dev/usb/umass.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/raidframe/rf_aselect.c
diff -u src/sys/dev/raidframe/rf_aselect.c:1.30 src/sys/dev/raidframe/rf_aselect.c:1.31
--- src/sys/dev/raidframe/rf_aselect.c:1.30	Fri Jul 23 00:54:45 2021
+++ src/sys/dev/raidframe/rf_aselect.c	Sun Mar 20 19:26:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_aselect.c,v 1.30 2021/07/23 00:54:45 oster Exp $	*/
+/*	$NetBSD: rf_aselect.c,v 1.31 2022/03/20 19:26:27 andvar Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.30 2021/07/23 00:54:45 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.31 2022/03/20 19:26:27 andvar Exp $");
 
 #include 
 
@@ -51,7 +51,7 @@ int rf_SelectAlgorithm(RF_RaidAccess
 
 /**
  *
- * Create and Initialiaze a dag header and termination node
+ * Create and Initialize a dag header and termination node
  *
  */
 static void

Index: src/sys/dev/usb/umass.c
diff -u src/sys/dev/usb/umass.c:1.187 src/sys/dev/usb/umass.c:1.188
--- src/sys/dev/usb/umass.c:1.187	Fri Dec 31 14:24:16 2021
+++ src/sys/dev/usb/umass.c	Sun Mar 20 19:26:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: umass.c,v 1.187 2021/12/31 14:24:16 riastradh Exp $	*/
+/*	$NetBSD: umass.c,v 1.188 2022/03/20 19:26:27 andvar Exp $	*/
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.187 2021/12/31 14:24:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.188 2022/03/20 19:26:27 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -982,7 +982,7 @@ umass_setup_transfer(struct umass_softc 
 	if (sc->sc_dying)
 		return USBD_IOERROR;
 
-	/* Initialiase a USB transfer and then schedule it */
+	/* Initialise a USB transfer and then schedule it */
 
 	usbd_setup_xfer(xfer, sc, buffer, buflen, flags, sc->timeout,
 	sc->sc_methods->wire_state);
@@ -1010,7 +1010,7 @@ umass_setup_ctrl_transfer(struct umass_s
 	if (sc->sc_dying)
 		return USBD_IOERROR;
 
-	/* Initialiase a USB control transfer and then schedule it */
+	/* Initialise a USB control transfer and then schedule it */
 
 	usbd_setup_default_xfer(xfer, sc->sc_udev, (void *) sc, sc->timeout,
 		req, buffer, buflen, flags, sc->sc_methods->wire_state);



CVS commit: src

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 20:19:35 UTC 2022

Modified Files:
src/share/misc: acronyms.comp
src/sys/arch/hppa/hppa: lock_stubs.S
src/sys/net: if_types.h

Log Message:
s/circut/circuit/ and s/circiut/circuit/ in comments and acronyms file.


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/share/misc/acronyms.comp
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/hppa/hppa/lock_stubs.S
cvs rdiff -u -r1.32 -r1.33 src/sys/net/if_types.h

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

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.326 src/share/misc/acronyms.comp:1.327
--- src/share/misc/acronyms.comp:1.326	Thu Feb 10 20:49:39 2022
+++ src/share/misc/acronyms.comp	Sun Mar 20 20:19:34 2022
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.326 2022/02/10 20:49:39 fcambus Exp $
+$NetBSD: acronyms.comp,v 1.327 2022/03/20 20:19:34 andvar Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -1233,7 +1233,7 @@ PME	power management event
 PMEG	page map entry group
 PMI	performance monitoring infrastructure
 PMI	platform management interrupt
-PMIC	power management integrated circut
+PMIC	power management integrated circuit
 PMIO	port-mapped input/output
 PMT	photo-multiplier tube
 PMU	performance monitoring units

Index: src/sys/arch/hppa/hppa/lock_stubs.S
diff -u src/sys/arch/hppa/hppa/lock_stubs.S:1.27 src/sys/arch/hppa/hppa/lock_stubs.S:1.28
--- src/sys/arch/hppa/hppa/lock_stubs.S:1.27	Mon Apr 15 20:45:08 2019
+++ src/sys/arch/hppa/hppa/lock_stubs.S	Sun Mar 20 20:19:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.S,v 1.27 2019/04/15 20:45:08 skrll Exp $	*/
+/*	$NetBSD: lock_stubs.S,v 1.28 2022/03/20 20:19:34 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
@@ -119,7 +119,7 @@ LEAF_ENTRY(mutex_enter)
 
 	/*
 	 * It might be a spin lock (c.f. MUTEX_SPIN_FLAG) or might be
-	 * already owned.  We short circut the request and go straight
+	 * already owned.  We short circuit the request and go straight
 	 * into mutex_vector_enter() if the owners field is not 'unowned'.
 	 */
 

Index: src/sys/net/if_types.h
diff -u src/sys/net/if_types.h:1.32 src/sys/net/if_types.h:1.33
--- src/sys/net/if_types.h:1.32	Mon Aug  9 19:57:58 2021
+++ src/sys/net/if_types.h	Sun Mar 20 20:19:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_types.h,v 1.32 2021/08/09 19:57:58 andvar Exp $	*/
+/*	$NetBSD: if_types.h,v 1.33 2022/03/20 20:19:34 andvar Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -174,7 +174,7 @@
 #define IFT_A12MPPSWITCH	   0x82	/* Avalon Parallel Processor */
 #define IFT_TUNNEL		   0x83	/* Encapsulation interface */
 #define IFT_COFFEE		   0x84	/* coffee pot */
-#define IFT_CES			   0x85	/* Circiut Emulation Service */
+#define IFT_CES			   0x85	/* Circuit Emulation Service */
 #define IFT_ATMSUBINTERFACE	   0x86	/* (x)  ATM Sub Interface */
 #define IFT_L2VLAN		   0x87	/* Layer 2 Virtual LAN using 802.1Q */
 #define IFT_L3IPVLAN		   0x88	/* Layer 3 Virtual LAN - IP Protocol */



CVS commit: src

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 20:19:35 UTC 2022

Modified Files:
src/share/misc: acronyms.comp
src/sys/arch/hppa/hppa: lock_stubs.S
src/sys/net: if_types.h

Log Message:
s/circut/circuit/ and s/circiut/circuit/ in comments and acronyms file.


To generate a diff of this commit:
cvs rdiff -u -r1.326 -r1.327 src/share/misc/acronyms.comp
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/hppa/hppa/lock_stubs.S
cvs rdiff -u -r1.32 -r1.33 src/sys/net/if_types.h

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



CVS commit: src

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 18:19:58 UTC 2022

Modified Files:
src/share/man/man4: rnd.4
src/share/man/man7: entropy.7
src/sys/kern: kern_entropy.c

Log Message:
entropy(9): Improve entropy warning messages and documentation.

- For the main warning message, use less jargon, say `security', and
  cite the entropy(7) man page for further reading.  Document this in
  rnd(4) and entropy(7).

- For the debug-only warning message, say `entropy' only once and omit
  it from the rnd(4) man page -- it's not very important unless you're
  debugging the kernel in which case you probably know what you're
  doing enough to not need the text explained in the man page.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/share/man/man4/rnd.4
cvs rdiff -u -r1.3 -r1.4 src/share/man/man7/entropy.7
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/kern_entropy.c

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



CVS commit: src

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 20 18:19:58 UTC 2022

Modified Files:
src/share/man/man4: rnd.4
src/share/man/man7: entropy.7
src/sys/kern: kern_entropy.c

Log Message:
entropy(9): Improve entropy warning messages and documentation.

- For the main warning message, use less jargon, say `security', and
  cite the entropy(7) man page for further reading.  Document this in
  rnd(4) and entropy(7).

- For the debug-only warning message, say `entropy' only once and omit
  it from the rnd(4) man page -- it's not very important unless you're
  debugging the kernel in which case you probably know what you're
  doing enough to not need the text explained in the man page.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/share/man/man4/rnd.4
cvs rdiff -u -r1.3 -r1.4 src/share/man/man7/entropy.7
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/share/man/man4/rnd.4
diff -u src/share/man/man4/rnd.4:1.39 src/share/man/man4/rnd.4:1.40
--- src/share/man/man4/rnd.4:1.39	Tue Apr  6 22:12:16 2021
+++ src/share/man/man4/rnd.4	Sun Mar 20 18:19:57 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: rnd.4,v 1.39 2021/04/06 22:12:16 riastradh Exp $
+.\"	$NetBSD: rnd.4,v 1.40 2022/03/20 18:19:57 riastradh Exp $
 .\"
 .\" Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -567,9 +567,9 @@ The
 subsystem may print the following warnings to the console likely
 indicating security issues:
 .Bl -diag -offset indent
-.It entropy: WARNING: extracting entropy too early
-Something requested extraction of entropy from the pool before it
-has ever reached full entropy in the system's estimation.
+.It WARNING: system needs entropy for security; see entropy(7)
+A process tried to draw from the entropy pool before enough inputs from
+reliable entropy sources have been entered.
 .Pp
 The entropy may be low enough that an adversary who sees the output
 could guess the state of the pool by brute force, so in this event the
@@ -579,18 +579,6 @@ This message is rate-limited to happen n
 minute, so if you want to make sure it is gone you should consult
 .Dv kern.entropy.needed
 to confirm it is zero.
-.It entropy: WARNING: consolidating less than full entropy
-The operator triggered consolidation of entropy pending in per-CPU
-pools into the global pool when the system's estimate of the amount of
-entropy was still below the 256-bit threshold.
-.Pp
-This message can be safely ignored if the operator knows something the
-system doesn't, e.g. if the operator has flipped a coin 256 times and
-written the outcomes to
-.Pa /dev/random .
-.Pp
-This message is rate-limited to happen no more often than once per
-minute.
 .El
 .Pp
 The

Index: src/share/man/man7/entropy.7
diff -u src/share/man/man7/entropy.7:1.3 src/share/man/man7/entropy.7:1.4
--- src/share/man/man7/entropy.7:1.3	Fri Jan 15 15:17:09 2021
+++ src/share/man/man7/entropy.7	Sun Mar 20 18:19:58 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: entropy.7,v 1.3 2021/01/15 15:17:09 riastradh Exp $
+.\"	$NetBSD: entropy.7,v 1.4 2022/03/20 18:19:58 riastradh Exp $
 .\"
 .\" Copyright (c) 2021 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -169,14 +169,15 @@ You can manually save and load seeds wit
 tool.
 For example, you might use
 .Dl rndctl -S seed
-to save a seed from one machine, transfer it over a medium where you
-are confident there are no eavesdroppers to another machine, and load
-it with
+to save a seed from one machine, transfer it \(em over a medium where
+you are confident there are no eavesdroppers \(em to another machine,
+and load it with
 .Dl rndctl -L seed
 on the target machine; then run
 .Dl /etc/rc.d/random_seed stop
 on the target machine to ensure that the entropy will be saved for next
-boot, even if the system crashes or otherwise shuts down uncleanly.
+boot, even if the system later crashes or otherwise shuts down
+uncleanly.
 .Ic rndctl -S
 records the number of bits of entropy in the seed so that
 .Ic rndctl -L
@@ -215,6 +216,28 @@ generated with too little entropy, then 
 create new ones before allowing anyone to log in via
 .Xr ssh 1 .
 .\"
+.Sh DIAGNOSTICS
+.Nx
+may print the following warnings to the console:
+.Bl -diag -offset indent
+.It WARNING: system needs entropy for security; see entropy(7)
+Some process tried to draw use entropy from
+.Nx ,
+e.g. to generate a key for cryptography, before enough inputs from
+reliable entropy sources have been obtained.
+The entropy may be low enough that an adversary could guess keys by
+brute force.
+.Pp
+This message is rate-limited, so if you have added entropy and want to
+verify that the problem is resolved, you should consult the
+.Dv kern.entropy.needed
+.Xr sysctl 7
+variable to confirm it is zero, rather than 

CVS commit: src/sys/dev

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 19:26:27 UTC 2022

Modified Files:
src/sys/dev/raidframe: rf_aselect.c
src/sys/dev/usb: umass.c

Log Message:
s/initialiase/initialise/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/raidframe/rf_aselect.c
cvs rdiff -u -r1.187 -r1.188 src/sys/dev/usb/umass.c

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



CVS import: src/external/public-domain/tz/dist

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:00:00 UTC 2022

Update of /cvsroot/src/external/public-domain/tz/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv21813

Log Message:
Import tzdata2022agtz
   not from ftp://ftp.iana.org/tz/releases/tzdata2022agtz.tar.gz
   (2022a comes from ftp://ftp.iana.org/tz/releases/tzdata2022a.tar.gz)

Note that 2022agtz is mechanically derived from 2022a by moving back
zone data from the "backzone" file that had been removed as "redundant"
(because differences to some other zone are all prior to 1970) so that
this pre 1970 data is restored.   It isn't necessarily correct in all
cases, but it is usually better than using some other zone's data which
is just as likely to be incorrect for where it applies, and more so elsewhere.

Summary of changes in tzdata2022a (2022-03-15 23:02:01 -0700):
  * Palestine will spring forward on 2022-03-27, not 2022-03-26.
  * From 1992 through spring 1996, Ukraine's DST transitions were at
02:00 standard time, not at 01:00 UTC.
  * Chile's Santiago Mean Time and its LMT precursor have been adjusted
eastward by 1 second to align with past and present law.
  * Changes to commentary.

Status:

Vendor Tag: TZDATA
Release Tags:   TZDATA2022AGTZ

C src/external/public-domain/tz/dist/leap-seconds.list
U src/external/public-domain/tz/dist/calendars
U src/external/public-domain/tz/dist/CONTRIBUTING
U src/external/public-domain/tz/dist/LICENSE
U src/external/public-domain/tz/dist/Makefile
U src/external/public-domain/tz/dist/NEWS
U src/external/public-domain/tz/dist/README
N src/external/public-domain/tz/dist/SECURITY
U src/external/public-domain/tz/dist/theory.html
C src/external/public-domain/tz/dist/version
U src/external/public-domain/tz/dist/africa
U src/external/public-domain/tz/dist/antarctica
C src/external/public-domain/tz/dist/asia
C src/external/public-domain/tz/dist/australasia
U src/external/public-domain/tz/dist/europe
U src/external/public-domain/tz/dist/northamerica
U src/external/public-domain/tz/dist/southamerica
U src/external/public-domain/tz/dist/etcetera
U src/external/public-domain/tz/dist/factory
C src/external/public-domain/tz/dist/backward
U src/external/public-domain/tz/dist/backzone
U src/external/public-domain/tz/dist/iso3166.tab
U src/external/public-domain/tz/dist/checklinks.awk
C src/external/public-domain/tz/dist/leapseconds
U src/external/public-domain/tz/dist/zone.tab
U src/external/public-domain/tz/dist/leapseconds.awk
U src/external/public-domain/tz/dist/checktab.awk
U src/external/public-domain/tz/dist/zoneinfo2tdf.pl
U src/external/public-domain/tz/dist/ziguard.awk
U src/external/public-domain/tz/dist/zishrink.awk

6 conflicts created by this import.
Use the following command to help the merge:

cvs checkout -jTZDATA:yesterday -jTZDATA 
src/external/public-domain/tz/dist



CVS import: src/external/public-domain/tz/dist

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:00:00 UTC 2022

Update of /cvsroot/src/external/public-domain/tz/dist
In directory ivanova.netbsd.org:/tmp/cvs-serv21813

Log Message:
Import tzdata2022agtz
   not from ftp://ftp.iana.org/tz/releases/tzdata2022agtz.tar.gz
   (2022a comes from ftp://ftp.iana.org/tz/releases/tzdata2022a.tar.gz)

Note that 2022agtz is mechanically derived from 2022a by moving back
zone data from the "backzone" file that had been removed as "redundant"
(because differences to some other zone are all prior to 1970) so that
this pre 1970 data is restored.   It isn't necessarily correct in all
cases, but it is usually better than using some other zone's data which
is just as likely to be incorrect for where it applies, and more so elsewhere.

Summary of changes in tzdata2022a (2022-03-15 23:02:01 -0700):
  * Palestine will spring forward on 2022-03-27, not 2022-03-26.
  * From 1992 through spring 1996, Ukraine's DST transitions were at
02:00 standard time, not at 01:00 UTC.
  * Chile's Santiago Mean Time and its LMT precursor have been adjusted
eastward by 1 second to align with past and present law.
  * Changes to commentary.

Status:

Vendor Tag: TZDATA
Release Tags:   TZDATA2022AGTZ

C src/external/public-domain/tz/dist/leap-seconds.list
U src/external/public-domain/tz/dist/calendars
U src/external/public-domain/tz/dist/CONTRIBUTING
U src/external/public-domain/tz/dist/LICENSE
U src/external/public-domain/tz/dist/Makefile
U src/external/public-domain/tz/dist/NEWS
U src/external/public-domain/tz/dist/README
N src/external/public-domain/tz/dist/SECURITY
U src/external/public-domain/tz/dist/theory.html
C src/external/public-domain/tz/dist/version
U src/external/public-domain/tz/dist/africa
U src/external/public-domain/tz/dist/antarctica
C src/external/public-domain/tz/dist/asia
C src/external/public-domain/tz/dist/australasia
U src/external/public-domain/tz/dist/europe
U src/external/public-domain/tz/dist/northamerica
U src/external/public-domain/tz/dist/southamerica
U src/external/public-domain/tz/dist/etcetera
U src/external/public-domain/tz/dist/factory
C src/external/public-domain/tz/dist/backward
U src/external/public-domain/tz/dist/backzone
U src/external/public-domain/tz/dist/iso3166.tab
U src/external/public-domain/tz/dist/checklinks.awk
C src/external/public-domain/tz/dist/leapseconds
U src/external/public-domain/tz/dist/zone.tab
U src/external/public-domain/tz/dist/leapseconds.awk
U src/external/public-domain/tz/dist/checktab.awk
U src/external/public-domain/tz/dist/zoneinfo2tdf.pl
U src/external/public-domain/tz/dist/ziguard.awk
U src/external/public-domain/tz/dist/zishrink.awk

6 conflicts created by this import.
Use the following command to help the merge:

cvs checkout -jTZDATA:yesterday -jTZDATA 
src/external/public-domain/tz/dist



CVS commit: src/doc

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:04:52 UTC 2022

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Note tzdata 2022a (using tzdata2022agtz upstream fork)


To generate a diff of this commit:
cvs rdiff -u -r1.1845 -r1.1846 src/doc/3RDPARTY
cvs rdiff -u -r1.2865 -r1.2866 src/doc/CHANGES

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



CVS commit: src/doc

2022-03-20 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sun Mar 20 18:04:52 UTC 2022

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
Note tzdata 2022a (using tzdata2022agtz upstream fork)


To generate a diff of this commit:
cvs rdiff -u -r1.1845 -r1.1846 src/doc/3RDPARTY
cvs rdiff -u -r1.2865 -r1.2866 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1845 src/doc/3RDPARTY:1.1846
--- src/doc/3RDPARTY:1.1845	Tue Mar 15 21:02:11 2022
+++ src/doc/3RDPARTY	Sun Mar 20 18:04:52 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1845 2022/03/15 21:02:11 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1846 2022/03/20 18:04:52 kre Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1410,8 +1410,8 @@ Notes:
 Added changes from a5 -> a12 manually.
 
 Package:	tz
-Version:	tzcode2021e / tzdata2021e
-Current Vers:	tzcode2021e / tzdata2021e
+Version:	tzcode2021e / tzdata2022agtz
+Current Vers:	tzcode2022a / tzdata2022a
 Maintainer:	Paul Eggert 
 Archive Site:	ftp://ftp.iana.org/tz/releases/
 Archive Site:	ftp://munnari.oz.au/pub/oldtz/

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2865 src/doc/CHANGES:1.2866
--- src/doc/CHANGES:1.2865	Tue Mar 15 21:02:11 2022
+++ src/doc/CHANGES	Sun Mar 20 18:04:52 2022
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2865 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2866 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -482,3 +482,6 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	udf: Fix locking up CD/DVD burner issue that would lockup the FS.
 		[reinoud 20220309]
 	OpenSSL: Imported 1.1.1n. [christos 20220315]
+	tzdata: updated to 2022a (using the 2022agtz fork to restore data
+		from previously merged zones) [kre 20220320] 
+



CVS commit: src/sys/net

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 20:37:59 UTC 2022

Modified Files:
src/sys/net: if_types.h

Log Message:
s/Multilik/Multilink/


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/net/if_types.h

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

Modified files:

Index: src/sys/net/if_types.h
diff -u src/sys/net/if_types.h:1.33 src/sys/net/if_types.h:1.34
--- src/sys/net/if_types.h:1.33	Sun Mar 20 20:19:34 2022
+++ src/sys/net/if_types.h	Sun Mar 20 20:37:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_types.h,v 1.33 2022/03/20 20:19:34 andvar Exp $	*/
+/*	$NetBSD: if_types.h,v 1.34 2022/03/20 20:37:59 andvar Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -204,7 +204,7 @@
 #define IFT_USB			   0xa0	/* USB Interface */
 #define IFT_IEEE8023ADLAG	   0xa1	/* IEEE 802.3ad Link Aggregate*/
 #define IFT_BGPPOLICYACCOUNTING	   0xa2	/* BGP Policy Accounting */
-#define IFT_FRF16MFRBUNDLE	   0xa3	/* FRF.16 Multilik Frame Relay*/
+#define IFT_FRF16MFRBUNDLE	   0xa3	/* FRF.16 Multilink Frame Relay*/
 #define IFT_H323GATEKEEPER	   0xa4	/* H323 Gatekeeper */
 #define IFT_H323PROXY		   0xa5	/* H323 Voice and Video Proxy */
 #define IFT_MPLS		   0xa6	/* MPLS */



CVS commit: src/sys/net

2022-03-20 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Mar 20 20:37:59 UTC 2022

Modified Files:
src/sys/net: if_types.h

Log Message:
s/Multilik/Multilink/


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/net/if_types.h

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 21 00:25:04 UTC 2022

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

Log Message:
entropy(9): Make rnd_lock_sources work while cold.

x86 uses entropy_extract verry early.  Fixes mistake in previous
that did not manifest in my testing on aarch64, which does not use it
so early.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/kern/kern_entropy.c

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



CVS commit: src/sys/kern

2022-03-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 21 00:25:04 UTC 2022

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

Log Message:
entropy(9): Make rnd_lock_sources work while cold.

x86 uses entropy_extract verry early.  Fixes mistake in previous
that did not manifest in my testing on aarch64, which does not use it
so early.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/kern/kern_entropy.c

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

Modified files:

Index: src/sys/kern/kern_entropy.c
diff -u src/sys/kern/kern_entropy.c:1.50 src/sys/kern/kern_entropy.c:1.51
--- src/sys/kern/kern_entropy.c:1.50	Sun Mar 20 18:19:58 2022
+++ src/sys/kern/kern_entropy.c	Mon Mar 21 00:25:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.50 2022/03/20 18:19:58 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.51 2022/03/21 00:25:04 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.50 2022/03/20 18:19:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.51 2022/03/21 00:25:04 riastradh Exp $");
 
 #include 
 #include 
@@ -1698,9 +1698,10 @@ rnd_lock_sources(int flags)
 {
 	int error;
 
-	KASSERT(mutex_owned(>lock));
+	KASSERT(E->stage == ENTROPY_COLD || mutex_owned(>lock));
 
 	while (E->sourcelock) {
+		KASSERT(E->stage >= ENTROPY_WARM);
 		if (!ISSET(flags, ENTROPY_WAIT))
 			return EWOULDBLOCK;
 		if (ISSET(flags, ENTROPY_SIG)) {