Re: CVS commit: src/sys/fs/udf

2022-03-18 Thread Joerg Sonnenberger
Am Fri, Mar 18, 2022 at 04:06:18PM + schrieb Reinoud Zandijk:
> Module Name:  src
> Committed By: reinoud
> Date: Fri Mar 18 16:06:18 UTC 2022
> 
> Modified Files:
>   src/sys/fs/udf: ecma167-udf.h
> 
> Log Message:
> Replace the variable field data[0] to data[1] to avoid undefined behaviour.

Just use a flexible array member, data[]. That gives essentially the
same behavior as the ancient GNU extension of [0] but sanitizers knows
what it means. That said, it is somewhat pointless in a packed data
structure...

Joerg


re: CVS commit: src/sys/external/bsd/drm/dist/bsd-core

2022-03-18 Thread matthew green
> Log Message:
> old drm: Use getticks(), not hardclock_ticks.
>
> Should delete this code, no idea if it even still compiles.

it did last i tried, and it still worked on the r100/r200 systems
that new drm is still problematic with.

not objecting...


.mrg.


CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:37:14 UTC 2022

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

Log Message:
clockrnd(9): Use atomic_load_relaxed for struct clockrnd::needed.

This may be set concurrently by clockrnd_get, so let's match the
atomic_store_relaxed and avoid the appearance of data races.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/kern/kern_clock.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_clock.c
diff -u src/sys/kern/kern_clock.c:1.146 src/sys/kern/kern_clock.c:1.147
--- src/sys/kern/kern_clock.c:1.146	Sat Aug 14 21:17:11 2021
+++ src/sys/kern/kern_clock.c	Fri Mar 18 23:37:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_clock.c,v 1.146 2021/08/14 21:17:11 ryo Exp $	*/
+/*	$NetBSD: kern_clock.c,v 1.147 2022/03/18 23:37:14 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.146 2021/08/14 21:17:11 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.147 2022/03/18 23:37:14 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -163,7 +163,7 @@ clockrnd_sample(struct clockrnd *C)
 	struct cpu_info *ci = curcpu();
 
 	/* If there's nothing needed right now, stop here.  */
-	if (__predict_true(C->needed == 0))
+	if (__predict_true(atomic_load_relaxed(&C->needed) == 0))
 		return;
 
 	/*



CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:37:14 UTC 2022

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

Log Message:
clockrnd(9): Use atomic_load_relaxed for struct clockrnd::needed.

This may be set concurrently by clockrnd_get, so let's match the
atomic_store_relaxed and avoid the appearance of data races.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/kern/kern_clock.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-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:37:06 UTC 2022

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

Log Message:
entropy(9): Establish the softint a little earlier.

Just need to wait until softint_establish and high-priority xcalls
will work, no later than that.  Doing this earlier gives us slightly
more of a chance to ensure cprng_fast and ssp get entropy from
hardware RNG devices that rely on interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.536 -r1.537 src/sys/kern/init_main.c

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

Modified files:

Index: src/sys/kern/init_main.c
diff -u src/sys/kern/init_main.c:1.536 src/sys/kern/init_main.c:1.537
--- src/sys/kern/init_main.c:1.536	Wed Jan 26 11:48:54 2022
+++ src/sys/kern/init_main.c	Fri Mar 18 23:37:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.536 2022/01/26 11:48:54 andvar Exp $	*/
+/*	$NetBSD: init_main.c,v 1.537 2022/03/18 23:37:06 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.536 2022/01/26 11:48:54 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.537 2022/03/18 23:37:06 riastradh Exp $");
 
 #include "opt_cnmagic.h"
 #include "opt_ddb.h"
@@ -552,6 +552,9 @@ main(void)
 	evcnt_attach_legacy_intrcnt();
 #endif
 
+	/* Enable deferred processing of RNG samples */
+	rnd_init_softint();
+
 	/* Once all CPUs are detected, initialize the per-CPU cprng_fast.  */
 	cprng_fast_init();
 
@@ -574,9 +577,6 @@ main(void)
 	/* Get the threads going and into any sleeps before continuing. */
 	yield();
 
-	/* Enable deferred processing of RNG samples */
-	rnd_init_softint();
-
 	vmem_rehash_start();	/* must be before exec_init */
 
 	/* Initialize exec structures */



CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:37:06 UTC 2022

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

Log Message:
entropy(9): Establish the softint a little earlier.

Just need to wait until softint_establish and high-priority xcalls
will work, no later than that.  Doing this earlier gives us slightly
more of a chance to ensure cprng_fast and ssp get entropy from
hardware RNG devices that rely on interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.536 -r1.537 src/sys/kern/init_main.c

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



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:57 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c

Log Message:
sun8icrypto(4): Do self-test and first RNG draw synchronously.

If the self-test fails, disable everything else at boot -- don't just
leave it to the operator to notice and do something.

This way we get entropy earlier at boot, before threads start and
before the first things in the kernel that draw from it (cprng fast
init, ssp init).


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

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.28 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.29
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.28	Fri Mar 18 23:36:42 2022
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Fri Mar 18 23:36:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.29 2022/03/18 23:36:57 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.29 2022/03/18 23:36:57 riastradh Exp $");
 
 #include 
 #include 
@@ -113,6 +113,7 @@ struct sun8i_crypto_softc {
 
 	struct workqueue		*sc_wq;
 	void*sc_ih;
+	boolsc_polling;
 
 	kmutex_t			sc_lock;
 	struct sun8i_crypto_chan {
@@ -138,6 +139,8 @@ struct sun8i_crypto_softc {
 		struct sun8i_crypto_buf		cs_key;
 		struct sun8i_crypto_buf		cs_out;
 		struct sun8i_crypto_task	*cs_task;
+		boolcs_pending;
+		boolcs_passed;
 	}sc_selftest;
 	struct sun8i_crypto_sysctl {
 		struct sysctllog		*cy_log;
@@ -215,6 +218,11 @@ static void	sun8i_crypto_timeout(void *)
 static int	sun8i_crypto_intr(void *);
 static void	sun8i_crypto_schedule_worker(struct sun8i_crypto_softc *);
 static void	sun8i_crypto_worker(struct work *, void *);
+
+static bool	sun8i_crypto_poll(struct sun8i_crypto_softc *, uint32_t *,
+		uint32_t *);
+static bool	sun8i_crypto_done(struct sun8i_crypto_softc *, uint32_t,
+		uint32_t, unsigned);
 static bool	sun8i_crypto_chan_done(struct sun8i_crypto_softc *, unsigned,
 		int);
 
@@ -228,7 +236,7 @@ static void	sun8i_crypto_rng_get(size_t,
 static void	sun8i_crypto_rng_done(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, void *, int);
 
-static void	sun8i_crypto_selftest(device_t);
+static bool	sun8i_crypto_selftest(struct sun8i_crypto_softc *);
 static void	sun8i_crypto_selftest_done(struct sun8i_crypto_softc *,
 		struct sun8i_crypto_task *, void *, int);
 
@@ -450,9 +458,13 @@ sun8i_crypto_attach(device_t parent, dev
 	aprint_normal(": Crypto Engine\n");
 	aprint_debug_dev(self, ": clock freq %d\n", clk_get_rate(clk));
 
-	/* Disable and clear interrupts.  */
+	/*
+	 * Disable and clear interrupts.  Start in polling mode for
+	 * synchronous self-tests and the first RNG draw.
+	 */
 	sun8i_crypto_write(sc, SUN8I_CRYPTO_ICR, 0);
 	sun8i_crypto_write(sc, SUN8I_CRYPTO_ISR, 0);
+	sc->sc_polling = true;
 
 	/* Establish an interrupt handler.  */
 	sc->sc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_VM,
@@ -464,15 +476,29 @@ sun8i_crypto_attach(device_t parent, dev
 	}
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
-	/* Set up the RNG.  */
+	/* Perform self-tests.  If they fail, stop here.  */
+	if (!sun8i_crypto_selftest(sc))
+		return;
+
+	/*
+	 * Set up the RNG.  This will try to synchronously draw the
+	 * first sample by polling, so do this before we establish
+	 * the interrupt handler.
+	 */
 	sun8i_crypto_rng_attach(sc);
 
+	/*
+	 * Self-test has passed and first RNG draw has finished.  Use
+	 * interrupts, not polling, for all subsequent tasks.  Set this
+	 * atomically in case the interrupt handler has fired -- can't
+	 * be from us because we've kept ICR set to 0 to mask all
+	 * interrupts, but in case the interrupt vector is shared.
+	 */
+	atomic_store_relaxed(&sc->sc_polling, true);
+
 	/* Attach the sysctl.  */
 	sun8i_crypto_sysctl_attach(sc);
 
-	/* Perform self-tests.  */
-	config_interrupts(self, sun8i_crypto_selftest);
-
 	/* Register opencrypto handlers.  */
 	sun8i_crypto_register(sc);
 }
@@ -896,11 +922,16 @@ sun8i_crypto_submit(struct sun8i_crypto_
 		goto out;
 	}
 
-	/* Enable interrupts for this channel.  */
-	icr = sun8i_crypto_read(sc, SUN8I_CRYPTO_ICR);
-	icr |= __SHIFTIN(SUN8I_CRYPTO_ICR_INTR_EN_CHAN(i),
-	SUN8I_CRYPTO_ICR_INTR_EN);
-	sun8i_crypto_write(sc, SUN8I_CRYPTO_ICR, icr);
+	/*
+	 * Enable interrupts for this channel, unless we're still
+	 * polling.
+	 */
+	if (!sc->sc_polling) {
+		icr = sun8i_crypto_read(sc, SUN8I_CRYPTO_ICR);
+		icr |= __SHIFTIN(SUN8I_CRYPTO_ICR_INTR_EN_CHAN(i),
+		SUN8I_CRYPTO_I

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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:57 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c

Log Message:
sun8icrypto(4): Do self-test and first RNG draw synchronously.

If the self-test fails, disable everything else at boot -- don't just
leave it to the operator to notice and do something.

This way we get entropy earlier at boot, before threads start and
before the first things in the kernel that draw from it (cprng fast
init, ssp init).


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

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



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:42 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c

Log Message:
sun8icrypto(4): Attach rndsource as RND_TYPE_RNG.

Previously this was attached as RND_TYPE_UNKNOWN, at a time when the
kernel assumed _any_ RNG-type rndsource produced independent uniform
random bits and subjected it to automatic tests that would fail with
high probability for many other distributions.  But sun8icrypto(4) is
very nonuniform (probably yields consecutive samples of a ring
oscillator, which are very much not independent).

Now the kernel no longer makes this assumption, so it is valid to
label this as what it is -- a hardware RNG.  We should ideally still
have better information from the vendor about what's going on under
the hood before enabling nonzero entropy for it.  But at least we can
label its type accurately.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/sunxi/sun8i_crypto.c

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.27 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.28
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.27	Fri Mar 18 23:35:48 2022
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Fri Mar 18 23:36:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.28 2022/03/18 23:36:42 riastradh Exp $");
 
 #include 
 #include 
@@ -1284,14 +1284,12 @@ sun8i_crypto_rng_attach(struct sun8i_cry
 	}
 
 	/*
-	 * Attach the rndsource.  This is _not_ marked as RND_TYPE_RNG
-	 * because the output is not uniformly distributed.  The bits
-	 * are heavily weighted toward 0 or 1, at different times, and
-	 * I haven't scienced a satisfactory story out of it yet.
+	 * Attach the rndsource.  This will trigger an initial call to
+	 * it since we have RND_FLAG_HASCB.
 	 */
 	rndsource_setcb(&rng->cr_rndsource, sun8i_crypto_rng_get, sc);
 	rnd_attach_source(&rng->cr_rndsource, device_xname(self),
-	RND_TYPE_UNKNOWN,
+	RND_TYPE_RNG,
 	RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_VALUE|RND_FLAG_HASCB);
 
 	/* Success!  */



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:36:42 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c

Log Message:
sun8icrypto(4): Attach rndsource as RND_TYPE_RNG.

Previously this was attached as RND_TYPE_UNKNOWN, at a time when the
kernel assumed _any_ RNG-type rndsource produced independent uniform
random bits and subjected it to automatic tests that would fail with
high probability for many other distributions.  But sun8icrypto(4) is
very nonuniform (probably yields consecutive samples of a ring
oscillator, which are very much not independent).

Now the kernel no longer makes this assumption, so it is valid to
label this as what it is -- a hardware RNG.  We should ideally still
have better information from the vendor about what's going on under
the hood before enabling nonzero entropy for it.  But at least we can
label its type accurately.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/sunxi/sun8i_crypto.c

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



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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:48 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c

Log Message:
sun8icrypto(4): Split out interrupt and thread locks.

No need to block interrupts while we're going through all the data
structures -- only need to block interrupts for the handoff from
interrupt handler to lower-priority logic.


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

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

Modified files:

Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.26 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.27
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.26	Sat Aug  7 15:41:00 2021
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Fri Mar 18 23:35:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.27 2022/03/18 23:35:48 riastradh Exp $");
 
 #include 
 #include 
@@ -111,18 +111,22 @@ struct sun8i_crypto_softc {
 
 	const struct sun8i_crypto_config *sc_cfg;
 
+	struct workqueue		*sc_wq;
+	void*sc_ih;
+
 	kmutex_t			sc_lock;
 	struct sun8i_crypto_chan {
 		struct sun8i_crypto_task	*cc_task;
 		unsigned			cc_starttime;
 	}sc_chan[SUN8I_CRYPTO_NCHAN];
 	struct callout			sc_timeout;
-	struct workqueue		*sc_wq;
-	struct work			sc_work;
-	void*sc_ih;
+
+	kmutex_t			sc_intr_lock;
 	uint32_t			sc_done;
 	uint32_t			sc_esr;
+	struct work			sc_work;
 	boolsc_work_pending;
+
 	struct sun8i_crypto_rng {
 		struct sun8i_crypto_buf		cr_buf;
 		struct sun8i_crypto_task	*cr_task;
@@ -381,7 +385,8 @@ sun8i_crypto_attach(device_t parent, dev
 	0, 0, 0, "sun8icry", NULL, IPL_VM,
 	&sun8i_crypto_task_ctor, &sun8i_crypto_task_dtor, sc);
 	sc->sc_cfg = of_compatible_lookup(phandle, compat_data)->data;
-	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
+	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
 	callout_init(&sc->sc_timeout, CALLOUT_MPSAFE);
 	callout_setfunc(&sc->sc_timeout, &sun8i_crypto_timeout, sc);
 	if (workqueue_create(&sc->sc_wq, device_xname(self),
@@ -948,34 +953,16 @@ out:	/* Done!  */
  *
  *	Timeout handler.  Schedules work in a thread to cancel all
  *	pending tasks that were started long enough ago we're bored of
- *	waiting for them, and reschedules another timeout unless the
- *	channels are all idle.
+ *	waiting for them.
  */
 static void
 sun8i_crypto_timeout(void *cookie)
 {
 	struct sun8i_crypto_softc *sc = cookie;
-	unsigned i;
-
-	mutex_enter(&sc->sc_lock);
 
-	/* Check whether there are any tasks pending.  */
-	for (i = 0; i < SUN8I_CRYPTO_NCHAN; i++) {
-		if (sc->sc_chan[i].cc_task)
-			break;
-	}
-	if (i == SUN8I_CRYPTO_NCHAN)
-		/* None pending, so nothing to do.  */
-		goto out;
-
-	/*
-	 * Schedule the worker to check for timeouts, and schedule
-	 * another timeout in case we need it.
-	 */
+	mutex_enter(&sc->sc_intr_lock);
 	sun8i_crypto_schedule_worker(sc);
-	callout_schedule(&sc->sc_timeout, SUN8I_CRYPTO_TIMEOUT);
-
-out:	mutex_exit(&sc->sc_lock);
+	mutex_exit(&sc->sc_intr_lock);
 }
 
 /*
@@ -991,7 +978,7 @@ sun8i_crypto_intr(void *cookie)
 	struct sun8i_crypto_softc *sc = cookie;
 	uint32_t isr, esr;
 
-	mutex_enter(&sc->sc_lock);
+	mutex_enter(&sc->sc_intr_lock);
 
 	/*
 	 * Get and acknowledge the interrupts and error status.
@@ -1014,7 +1001,7 @@ sun8i_crypto_intr(void *cookie)
 	sc->sc_done |= __SHIFTOUT(isr, SUN8I_CRYPTO_ISR_DONE);
 	sc->sc_esr |= esr;
 
-	mutex_exit(&sc->sc_lock);
+	mutex_exit(&sc->sc_intr_lock);
 
 	return __SHIFTOUT(isr, SUN8I_CRYPTO_ISR_DONE) != 0;
 }
@@ -1029,7 +1016,7 @@ static void
 sun8i_crypto_schedule_worker(struct sun8i_crypto_softc *sc)
 {
 
-	KASSERT(mutex_owned(&sc->sc_lock));
+	KASSERT(mutex_owned(&sc->sc_intr_lock));
 
 	/* Start the worker if necessary.  */
 	if (!sc->sc_work_pending) {
@@ -1052,41 +1039,40 @@ sun8i_crypto_worker(struct work *wk, voi
 	uint32_t done, esr, esr_chan;
 	unsigned i, now;
 	bool unblock = false;
+	bool schedtimeout = false;
 	int error;
 
 	/*
-	 * Acquire the lock.  Note: We will be releasing and
-	 * reacquiring it throughout the loop.
+	 * Under the interrupt lock, acknowledge our work and claim the
+	 * done mask and error status.
 	 */
-	mutex_enter(&sc->sc_lock);
-
-	/* Acknowledge the work.  */
+	mutex_enter(&sc->sc_intr_lock);
 	KASSERT(sc->sc_work_pending);
 	sc->sc_work_pending = false;
-
-	/*
-	 * Claim the done mask and error status once; we will be
-	 * releasing and reacquiring the lock for the callbacks, so
-	 * they may change.
-	 */
 	do

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

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:48 UTC 2022

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c

Log Message:
sun8icrypto(4): Split out interrupt and thread locks.

No need to block interrupts while we're going through all the data
structures -- only need to block interrupts for the handoff from
interrupt handler to lower-priority logic.


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

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



CVS commit: src/tests/lib/libc/sys

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:37 UTC 2022

Modified Files:
src/tests/lib/libc/sys: t_getrandom.c

Log Message:
getrandom(2): Fix return value checks in automatic tests.

The syscall only guarantees up to 256 bytes in a single go -- if
interrupted, it might return short, but if the caller requested at
least 256 bytes it will definitely return 256 bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_getrandom.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/lib/libc/sys/t_getrandom.c
diff -u src/tests/lib/libc/sys/t_getrandom.c:1.3 src/tests/lib/libc/sys/t_getrandom.c:1.4
--- src/tests/lib/libc/sys/t_getrandom.c:1.3	Tue Aug 25 01:37:38 2020
+++ src/tests/lib/libc/sys/t_getrandom.c	Fri Mar 18 23:35:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_getrandom.c,v 1.3 2020/08/25 01:37:38 riastradh Exp $	*/
+/*	$NetBSD: t_getrandom.c,v 1.4 2022/03/18 23:35:37 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,9 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_getrandom.c,v 1.3 2020/08/25 01:37:38 riastradh Exp $");
+__RCSID("$NetBSD: t_getrandom.c,v 1.4 2022/03/18 23:35:37 riastradh Exp $");
+
+#include 
 
 #include 
 
@@ -89,7 +91,8 @@ ATF_TC_BODY(getrandom_default, tc)
 	if (n == -1) {
 		ATF_CHECK_EQ(errno, EINTR);
 	} else {
-		ATF_CHECK_EQ((size_t)n, sizeof buf);
+		ATF_CHECK(n >= (ssize_t)MIN(256, sizeof buf));
+		ATF_CHECK((size_t)n <= sizeof buf);
 		ATF_CHECK(memcmp(buf, zero24, 24) != 0);
 		ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
 	}
@@ -111,7 +114,8 @@ ATF_TC_BODY(getrandom_nonblock, tc)
 	if (n == -1) {
 		ATF_CHECK_EQ(errno, EAGAIN);
 	} else {
-		ATF_CHECK_EQ((size_t)n, sizeof buf);
+		ATF_CHECK(n >= (ssize_t)MIN(256, sizeof buf));
+		ATF_CHECK((size_t)n <= sizeof buf);
 		ATF_CHECK(memcmp(buf, zero24, 24) != 0);
 		ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
 	}
@@ -130,7 +134,8 @@ ATF_TC_BODY(getrandom_insecure, tc)
 	memset(buf, 0, sizeof buf);
 	n = getrandom(buf, sizeof buf, GRND_INSECURE);
 	ATF_CHECK(n != -1);
-	ATF_CHECK_EQ((size_t)n, sizeof buf);
+	ATF_CHECK(n >= (ssize_t)MIN(256, sizeof buf));
+	ATF_CHECK((size_t)n <= sizeof buf);
 	ATF_CHECK(memcmp(buf, zero24, 24) != 0);
 	ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
 }
@@ -149,7 +154,8 @@ ATF_TC_BODY(getrandom_insecure_nonblock,
 	memset(buf, 0, sizeof buf);
 	n = getrandom(buf, sizeof buf, GRND_INSECURE|GRND_NONBLOCK);
 	ATF_CHECK(n != -1);
-	ATF_CHECK_EQ((size_t)n, sizeof buf);
+	ATF_CHECK(n >= (ssize_t)MIN(256, sizeof buf));
+	ATF_CHECK((size_t)n <= sizeof buf);
 	ATF_CHECK(memcmp(buf, zero24, 24) != 0);
 	ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
 }



CVS commit: src/tests/lib/libc/sys

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:37 UTC 2022

Modified Files:
src/tests/lib/libc/sys: t_getrandom.c

Log Message:
getrandom(2): Fix return value checks in automatic tests.

The syscall only guarantees up to 256 bytes in a single go -- if
interrupted, it might return short, but if the caller requested at
least 256 bytes it will definitely return 256 bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_getrandom.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-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:28 UTC 2022

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

Log Message:
entropy(9): Count dropped or truncated interrupt samples.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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.39 src/sys/kern/kern_entropy.c:1.40
--- src/sys/kern/kern_entropy.c:1.39	Fri Mar 18 23:35:19 2022
+++ src/sys/kern/kern_entropy.c	Fri Mar 18 23:35:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.39 2022/03/18 23:35:19 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.40 2022/03/18 23:35:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.39 2022/03/18 23:35:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.40 2022/03/18 23:35:28 riastradh Exp $");
 
 #include 
 #include 
@@ -130,7 +130,11 @@ __KERNEL_RCSID(0, "$NetBSD: kern_entropy
  *	evcnt(9) assumes it stays put in memory.
  */
 struct entropy_cpu {
-	struct evcnt		*ec_softint_evcnt;
+	struct entropy_cpu_evcnt {
+		struct evcnt		softint;
+		struct evcnt		intrdrop;
+		struct evcnt		intrtrunc;
+	}			*ec_evcnt;
 	struct entpool		*ec_pool;
 	unsigned		ec_pending;
 	bool			ec_locked;
@@ -466,17 +470,21 @@ static void
 entropy_init_cpu(void *ptr, void *cookie, struct cpu_info *ci)
 {
 	struct entropy_cpu *ec = ptr;
+	const char *cpuname;
 
-	ec->ec_softint_evcnt = kmem_alloc(sizeof(*ec->ec_softint_evcnt),
-	KM_SLEEP);
+	ec->ec_evcnt = kmem_alloc(sizeof(*ec->ec_evcnt), KM_SLEEP);
 	ec->ec_pool = kmem_zalloc(sizeof(*ec->ec_pool), KM_SLEEP);
 	ec->ec_pending = 0;
 	ec->ec_locked = false;
 
 	/* XXX ci_cpuname may not be initialized early enough.  */
-	evcnt_attach_dynamic(ec->ec_softint_evcnt, EVCNT_TYPE_MISC, NULL,
-	ci->ci_cpuname[0] == '\0' ? "cpu0" : ci->ci_cpuname,
-	"entropy softint");
+	cpuname = ci->ci_cpuname[0] == '\0' ? "cpu0" : ci->ci_cpuname;
+	evcnt_attach_dynamic(&ec->ec_evcnt->softint, EVCNT_TYPE_MISC, NULL,
+	cpuname, "entropy softint");
+	evcnt_attach_dynamic(&ec->ec_evcnt->intrdrop, EVCNT_TYPE_MISC, NULL,
+	cpuname, "entropy intrdrop");
+	evcnt_attach_dynamic(&ec->ec_evcnt->intrtrunc, EVCNT_TYPE_MISC, NULL,
+	cpuname, "entropy intrtrunc");
 }
 
 /*
@@ -497,10 +505,12 @@ entropy_fini_cpu(void *ptr, void *cookie
 	 */
 	explicit_memset(ec->ec_pool, 0, sizeof(*ec->ec_pool));
 
-	evcnt_detach(ec->ec_softint_evcnt);
+	evcnt_detach(&ec->ec_evcnt->intrtrunc);
+	evcnt_detach(&ec->ec_evcnt->intrdrop);
+	evcnt_detach(&ec->ec_evcnt->softint);
 
 	kmem_free(ec->ec_pool, sizeof(*ec->ec_pool));
-	kmem_free(ec->ec_softint_evcnt, sizeof(*ec->ec_softint_evcnt));
+	kmem_free(ec->ec_evcnt, sizeof(*ec->ec_evcnt));
 }
 
 /*
@@ -872,8 +882,10 @@ entropy_enter_intr(const void *buf, size
 	 * higher-priority interrupts will drop their samples.
 	 */
 	ec = percpu_getref(entropy_percpu);
-	if (ec->ec_locked)
+	if (ec->ec_locked) {
+		ec->ec_evcnt->intrdrop.ev_count++;
 		goto out0;
+	}
 	ec->ec_locked = true;
 	__insn_barrier();
 
@@ -885,6 +897,7 @@ entropy_enter_intr(const void *buf, size
 		sih = atomic_load_relaxed(&entropy_sih);
 		if (__predict_true(sih != NULL))
 			softint_schedule(sih);
+		ec->ec_evcnt->intrtrunc.ev_count++;
 		goto out1;
 	}
 	fullyused = true;
@@ -936,7 +949,7 @@ entropy_softintr(void *cookie)
 	__insn_barrier();
 
 	/* Count statistics.  */
-	ec->ec_softint_evcnt->ev_count++;
+	ec->ec_evcnt->softint.ev_count++;
 
 	/* Stir the pool if necessary.  */
 	entpool_stir(ec->ec_pool);



CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:28 UTC 2022

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

Log Message:
entropy(9): Count dropped or truncated interrupt samples.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 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-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:19 UTC 2022

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

Log Message:
entropy(9): Reduce global entropy lock from IPL_VM to IPL_SOFTSERIAL.

This is no longer ever taken in hard interrupt context, so there's no
longer any need to block interrupts while doing crypto operations on
the global entropy pool.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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.38 src/sys/kern/kern_entropy.c:1.39
--- src/sys/kern/kern_entropy.c:1.38	Fri Mar 18 23:35:07 2022
+++ src/sys/kern/kern_entropy.c	Fri Mar 18 23:35:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.38 2022/03/18 23:35:07 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.39 2022/03/18 23:35:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.38 2022/03/18 23:35:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.39 2022/03/18 23:35:19 riastradh Exp $");
 
 #include 
 #include 
@@ -366,7 +366,7 @@ entropy_init(void)
 	NULL, 0, &E->epoch, 0, CTL_CREATE, CTL_EOL);
 
 	/* Initialize the global state for multithreaded operation.  */
-	mutex_init(&E->lock, MUTEX_DEFAULT, IPL_VM);
+	mutex_init(&E->lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
 	cv_init(&E->cv, "entropy");
 	selinit(&E->selq);
 	cv_init(&E->sourcelock_cv, "entsrclock");



CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:19 UTC 2022

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

Log Message:
entropy(9): Reduce global entropy lock from IPL_VM to IPL_SOFTSERIAL.

This is no longer ever taken in hard interrupt context, so there's no
longer any need to block interrupts while doing crypto operations on
the global entropy pool.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:07 UTC 2022

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

Log Message:
entropy(9): Request entropy after the softint is enabled.

Otherwise, there is a window during which interrupts are running, but
the softint is not, so if many interrupts queue (low-entropy) samples
early at boot, they might get dropped on the floor.  This could
happen, for instance, with a PCI RNG like ubsec(4) or hifn(4) which
requests entropy and processes it in its own hard interrupt handler.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 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.37 src/sys/kern/kern_entropy.c:1.38
--- src/sys/kern/kern_entropy.c:1.37	Fri Mar 18 23:34:56 2022
+++ src/sys/kern/kern_entropy.c	Fri Mar 18 23:35:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.37 2022/03/18 23:34:56 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.38 2022/03/18 23:35:07 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.37 2022/03/18 23:34:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.38 2022/03/18 23:35:07 riastradh Exp $");
 
 #include 
 #include 
@@ -2431,6 +2431,7 @@ rnd_init_softint(void)
 {
 
 	entropy_init_late();
+	entropy_bootrequest();
 }
 
 int



CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:35:07 UTC 2022

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

Log Message:
entropy(9): Request entropy after the softint is enabled.

Otherwise, there is a window during which interrupts are running, but
the softint is not, so if many interrupts queue (low-entropy) samples
early at boot, they might get dropped on the floor.  This could
happen, for instance, with a PCI RNG like ubsec(4) or hifn(4) which
requests entropy and processes it in its own hard interrupt handler.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 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-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:34:56 UTC 2022

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

Log Message:
entropy(9): Use the early-entropy path only while cold.

This way, we never take the global entropy lock from interrupt
handlers (no interrupts while cold), so the global entropy lock need
not block interrupts.

There's an annoying ordering issue here: softint_establish doesn't
work until after CPUs have been detected, which happens inside
configure(), which is also what enables interrupts.  So we have no
opportunity to softint_establish the entropy softint _before_
interrupts are enabled.

To work around this, we have to put a conditional into the interrupt
path, and go out of our way to process any queued samples after
establishing the softint.  If we just made softint_establish work
early, like percpu_create does now, this problem would go away and we
could delete a bit of logic here.

Candidate fix for PR kern/56730.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/sys/kern/kern_entropy.c:1.37
--- src/sys/kern/kern_entropy.c:1.36	Fri Mar 18 23:34:44 2022
+++ src/sys/kern/kern_entropy.c	Fri Mar 18 23:34:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.36 2022/03/18 23:34:44 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.37 2022/03/18 23:34:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.36 2022/03/18 23:34:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.37 2022/03/18 23:34:56 riastradh Exp $");
 
 #include 
 #include 
@@ -396,6 +396,13 @@ entropy_init(void)
 	E->stage = ENTROPY_WARM;
 }
 
+static void
+entropy_init_late_cpu(void *a, void *b)
+{
+
+	entropy_softintr(NULL);
+}
+
 /*
  * entropy_init_late()
  *
@@ -406,6 +413,7 @@ entropy_init(void)
 static void
 entropy_init_late(void)
 {
+	void *sih;
 	int error;
 
 	KASSERT(E->stage == ENTROPY_WARM);
@@ -414,9 +422,9 @@ entropy_init_late(void)
 	 * Establish the softint at the highest softint priority level.
 	 * Must happen after CPU detection.
 	 */
-	entropy_sih = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE,
+	sih = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE,
 	&entropy_softintr, NULL);
-	if (entropy_sih == NULL)
+	if (sih == NULL)
 		panic("unable to establish entropy softint");
 
 	/*
@@ -431,10 +439,22 @@ entropy_init_late(void)
 
 	/*
 	 * Wait until the per-CPU initialization has hit all CPUs
-	 * before proceeding to mark the entropy system hot.
+	 * before proceeding to mark the entropy system hot and
+	 * enabling use of the softint.
 	 */
 	xc_barrier(XC_HIGHPRI);
 	E->stage = ENTROPY_HOT;
+	atomic_store_relaxed(&entropy_sih, sih);
+
+	/*
+	 * At this point, entering new samples from interrupt handlers
+	 * will trigger the softint to process them.  But there may be
+	 * some samples that were entered from interrupt handlers
+	 * before the softint was available.  Make sure we process
+	 * those samples on all CPUs by running the softint logic on
+	 * all CPUs.
+	 */
+	xc_wait(xc_broadcast(XC_HIGHPRI, entropy_init_late_cpu, NULL, NULL));
 }
 
 /*
@@ -651,7 +671,7 @@ entropy_account_cpu(struct entropy_cpu *
 {
 	unsigned diff;
 
-	KASSERT(E->stage == ENTROPY_HOT);
+	KASSERT(E->stage >= ENTROPY_WARM);
 
 	/*
 	 * If there's no entropy needed, and entropy has been
@@ -738,8 +758,7 @@ entropy_enter_early(const void *buf, siz
 {
 	bool notify = false;
 
-	if (E->stage >= ENTROPY_WARM)
-		mutex_enter(&E->lock);
+	KASSERT(E->stage == ENTROPY_COLD);
 
 	/* Enter it into the pool.  */
 	entpool_enter(&E->pool, buf, len);
@@ -758,9 +777,6 @@ entropy_enter_early(const void *buf, siz
 		entropy_notify();
 		entropy_immediate_evcnt.ev_count++;
 	}
-
-	if (E->stage >= ENTROPY_WARM)
-		mutex_exit(&E->lock);
 }
 
 /*
@@ -784,7 +800,7 @@ entropy_enter(const void *buf, size_t le
 	"impossible entropy rate: %u bits in %zu-byte string", nbits, len);
 
 	/* If it's too early after boot, just use entropy_enter_early.  */
-	if (__predict_false(E->stage < ENTROPY_HOT)) {
+	if (__predict_false(E->stage == ENTROPY_COLD)) {
 		entropy_enter_early(buf, len, nbits);
 		return;
 	}
@@ -839,12 +855,13 @@ entropy_enter_intr(const void *buf, size
 	struct entropy_cpu *ec;
 	bool fullyused = false;
 	uint32_t pending;
+	void *sih;
 
 	KASSERTMSG(howmany(nbits, NBBY) <= len,
 	"impossible entropy rate: %u bits in %zu-byte string", nbits, len);
 
 	/* If it's too early after boot, just use entropy_enter_early.  */
-	if (__predict_false(E->stage < ENTROPY_HOT)) {
+	if (__predict_false(E->stage == ENTROPY_COLD)) {
 		entropy_enter_early(buf, len, nbits);
 		return true;
 	}
@@ -865,7 +882,9 @@ entropy_enter_

CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:34:56 UTC 2022

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

Log Message:
entropy(9): Use the early-entropy path only while cold.

This way, we never take the global entropy lock from interrupt
handlers (no interrupts while cold), so the global entropy lock need
not block interrupts.

There's an annoying ordering issue here: softint_establish doesn't
work until after CPUs have been detected, which happens inside
configure(), which is also what enables interrupts.  So we have no
opportunity to softint_establish the entropy softint _before_
interrupts are enabled.

To work around this, we have to put a conditional into the interrupt
path, and go out of our way to process any queued samples after
establishing the softint.  If we just made softint_establish work
early, like percpu_create does now, this problem would go away and we
could delete a bit of logic here.

Candidate fix for PR kern/56730.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:34:44 UTC 2022

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

Log Message:
entropy(9): Create per-CPU state earlier.

This will make it possible to use it from interrupts as soon as they
start, which means the global entropy pool lock won't have to block
interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/sys/kern/kern_entropy.c:1.36
--- src/sys/kern/kern_entropy.c:1.35	Wed Mar 16 23:56:55 2022
+++ src/sys/kern/kern_entropy.c	Fri Mar 18 23:34:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_entropy.c,v 1.35 2022/03/16 23:56:55 riastradh Exp $	*/
+/*	$NetBSD: kern_entropy.c,v 1.36 2022/03/18 23:34:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.35 2022/03/16 23:56:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.36 2022/03/18 23:34:44 riastradh Exp $");
 
 #include 
 #include 
@@ -382,6 +382,10 @@ entropy_init(void)
 	LIST_FOREACH(rs, &E->sources, list)
 		rs->state = percpu_alloc(sizeof(struct rndsource_cpu));
 
+	/* Allocate and initialize the per-CPU state.  */
+	entropy_percpu = percpu_create(sizeof(struct entropy_cpu),
+	entropy_init_cpu, entropy_fini_cpu, NULL);
+
 	/* Enter the boot cycle count to get started.  */
 	extra[i++] = entropy_timer();
 	KASSERT(i == __arraycount(extra));
@@ -406,10 +410,6 @@ entropy_init_late(void)
 
 	KASSERT(E->stage == ENTROPY_WARM);
 
-	/* Allocate and initialize the per-CPU state.  */
-	entropy_percpu = percpu_create(sizeof(struct entropy_cpu),
-	entropy_init_cpu, entropy_fini_cpu, NULL);
-
 	/*
 	 * Establish the softint at the highest softint priority level.
 	 * Must happen after CPU detection.
@@ -453,8 +453,10 @@ entropy_init_cpu(void *ptr, void *cookie
 	ec->ec_pending = 0;
 	ec->ec_locked = false;
 
+	/* XXX ci_cpuname may not be initialized early enough.  */
 	evcnt_attach_dynamic(ec->ec_softint_evcnt, EVCNT_TYPE_MISC, NULL,
-	ci->ci_cpuname, "entropy softint");
+	ci->ci_cpuname[0] == '\0' ? "cpu0" : ci->ci_cpuname,
+	"entropy softint");
 }
 
 /*



CVS commit: src/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:34:44 UTC 2022

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

Log Message:
entropy(9): Create per-CPU state earlier.

This will make it possible to use it from interrupts as soon as they
start, which means the global entropy pool lock won't have to block
interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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/external/bsd/drm2/linux

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:33:41 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
drm: In ww_mutex_unlock, do lockdebug check first.

This way we get a full lockdebug dump when LOCKDEBUG is enabled,
instead of just the panic message (which includes the lock address
you could pass to `show lock' in ddb, but let's get the dump by
default even if you don't enter ddb).

Also in the KASSERT print the mutex.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c

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

Modified files:

Index: src/sys/external/bsd/drm2/linux/linux_ww_mutex.c
diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.13 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.14
--- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.13	Sun Dec 26 16:14:34 2021
+++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c	Fri Mar 18 23:33:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ww_mutex.c,v 1.13 2021/12/26 16:14:34 riastradh Exp $	*/
+/*	$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.13 2021/12/26 16:14:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $");
 
 #include 
 #include 
@@ -1041,7 +1041,8 @@ ww_mutex_unlock(struct ww_mutex *mutex)
 	struct ww_acquire_ctx *ctx;
 
 	mutex_enter(&mutex->wwm_lock);
-	KASSERT(mutex->wwm_state != WW_UNLOCKED);
+	WW_UNLOCKED(mutex);
+	KASSERTMSG(mutex->wwm_state != WW_UNLOCKED, "mutex %p", mutex);
 	switch (mutex->wwm_state) {
 	case WW_UNLOCKED:
 		panic("unlocking unlocked wait/wound mutex: %p", mutex);
@@ -1070,7 +1071,6 @@ ww_mutex_unlock(struct ww_mutex *mutex)
 		mutex->wwm_state = WW_UNLOCKED;
 		break;
 	}
-	WW_UNLOCKED(mutex);
 	cv_broadcast(&mutex->wwm_cv);
 	mutex_exit(&mutex->wwm_lock);
 }



CVS commit: src/sys/external/bsd/drm2/linux

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:33:41 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
drm: In ww_mutex_unlock, do lockdebug check first.

This way we get a full lockdebug dump when LOCKDEBUG is enabled,
instead of just the panic message (which includes the lock address
you could pass to `show lock' in ddb, but let's get the dump by
default even if you don't enter ddb).

Also in the KASSERT print the mutex.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c

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



CVS commit: src/sys/external/bsd/dwc2

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:59 UTC 2022

Modified Files:
src/sys/external/bsd/dwc2: dwc2.h

Log Message:
dwc2: Use getticks(), not hardclock_ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/dwc2/dwc2.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/external/bsd/dwc2/dwc2.h
diff -u src/sys/external/bsd/dwc2/dwc2.h:1.11 src/sys/external/bsd/dwc2/dwc2.h:1.12
--- src/sys/external/bsd/dwc2/dwc2.h:1.11	Sun Dec 19 11:00:47 2021
+++ src/sys/external/bsd/dwc2/dwc2.h	Fri Mar 18 23:32:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2.h,v 1.11 2021/12/19 11:00:47 riastradh Exp $	*/
+/*	$NetBSD: dwc2.h,v 1.12 2022/03/18 23:32:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -104,7 +104,7 @@ extern int dwc2debug;
 #define	dev_vdbg(...) do { } while (0)
 #endif
 
-#define jiffies			hardclock_ticks
+#define jiffies			getticks()
 #define msecs_to_jiffies	mstohz
 
 enum usb_otg_state {



CVS commit: src/sys/external/bsd/dwc2

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:59 UTC 2022

Modified Files:
src/sys/external/bsd/dwc2: dwc2.h

Log Message:
dwc2: Use getticks(), not hardclock_ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/external/bsd/dwc2/dwc2.h

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



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:50 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: jiffies.h

Log Message:
drm: Use getticks(), not hardclock_ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/jiffies.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/external/bsd/drm2/include/linux/jiffies.h
diff -u src/sys/external/bsd/drm2/include/linux/jiffies.h:1.13 src/sys/external/bsd/drm2/include/linux/jiffies.h:1.14
--- src/sys/external/bsd/drm2/include/linux/jiffies.h:1.13	Fri Feb 14 14:34:59 2020
+++ src/sys/external/bsd/drm2/include/linux/jiffies.h	Fri Mar 18 23:32:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: jiffies.h,v 1.13 2020/02/14 14:34:59 maya Exp $	*/
+/*	$NetBSD: jiffies.h,v 1.14 2022/03/18 23:32:49 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -39,8 +39,8 @@
 
 #include 
 
-#define	jiffies		hardclock_ticks
-#define	jiffies_64	hardclock_ticks /* XXX */
+#define	jiffies		getticks()
+#define	jiffies_64	getticks() /* XXX */
 
 /* XXX Er, what?  */
 #define	MAX_JIFFY_OFFSET	((INT_MAX >> 1) - 1)
@@ -49,7 +49,7 @@ static inline uint64_t
 get_jiffies_64(void)
 {
 
-	return (uint64_t)(unsigned)hardclock_ticks;
+	return (uint64_t)(unsigned)getticks();
 }
 
 static inline uint64_t



CVS commit: src/sys/external/bsd/drm2/include/linux

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:50 UTC 2022

Modified Files:
src/sys/external/bsd/drm2/include/linux: jiffies.h

Log Message:
drm: Use getticks(), not hardclock_ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/include/linux/jiffies.h

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



CVS commit: src/sys/external/bsd/drm/dist/bsd-core

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:41 UTC 2022

Modified Files:
src/sys/external/bsd/drm/dist/bsd-core: drmP.h

Log Message:
old drm: Use getticks(), not hardclock_ticks.

Should delete this code, no idea if it even still compiles.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/external/bsd/drm/dist/bsd-core/drmP.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/external/bsd/drm/dist/bsd-core/drmP.h
diff -u src/sys/external/bsd/drm/dist/bsd-core/drmP.h:1.25 src/sys/external/bsd/drm/dist/bsd-core/drmP.h:1.26
--- src/sys/external/bsd/drm/dist/bsd-core/drmP.h:1.25	Sat Apr  6 03:06:28 2019
+++ src/sys/external/bsd/drm/dist/bsd-core/drmP.h	Fri Mar 18 23:32:41 2022
@@ -303,7 +303,7 @@ enum {
 #else
 #define DRM_MTRR_WC		0
 #endif
-#define jiffies			hardclock_ticks
+#define jiffies			getticks()
 
 #define DRM_MAXUNITS128
 extern struct drm_device *drm_units[];



CVS commit: src/sys/external/bsd/drm/dist/bsd-core

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:41 UTC 2022

Modified Files:
src/sys/external/bsd/drm/dist/bsd-core: drmP.h

Log Message:
old drm: Use getticks(), not hardclock_ticks.

Should delete this code, no idea if it even still compiles.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/external/bsd/drm/dist/bsd-core/drmP.h

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



CVS commit: src/sys

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:25 UTC 2022

Modified Files:
src/sys/dev/ic: arn5008.c athn.c
src/sys/net80211: ieee80211_netbsd.h

Log Message:
net80211: Use getticks(), not hardclock_ticks.

Less extern in .c this way too.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/arn5008.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ic/athn.c
cvs rdiff -u -r1.23 -r1.24 src/sys/net80211/ieee80211_netbsd.h

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

Modified files:

Index: src/sys/dev/ic/arn5008.c
diff -u src/sys/dev/ic/arn5008.c:1.18 src/sys/dev/ic/arn5008.c:1.19
--- src/sys/dev/ic/arn5008.c:1.18	Mon Sep  7 10:45:23 2020
+++ src/sys/dev/ic/arn5008.c	Fri Mar 18 23:32:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: arn5008.c,v 1.18 2020/09/07 10:45:23 mrg Exp $	*/
+/*	$NetBSD: arn5008.c,v 1.19 2022/03/18 23:32:24 riastradh Exp $	*/
 /*	$OpenBSD: ar5008.c,v 1.21 2012/08/25 12:14:31 kettenis Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.18 2020/09/07 10:45:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.19 2022/03/18 23:32:24 riastradh Exp $");
 
 #include 
 #include 
@@ -2487,7 +2487,6 @@ ar5008_hw_init(struct athn_softc *sc, st
 	ar5008_init_chains(sc);
 
 	if (sc->sc_flags & ATHN_FLAG_OLPC) {
-		extern int ticks;
 		sc->sc_olpc_ticks = ticks;
 		ops->olpc_init(sc);
 	}

Index: src/sys/dev/ic/athn.c
diff -u src/sys/dev/ic/athn.c:1.25 src/sys/dev/ic/athn.c:1.26
--- src/sys/dev/ic/athn.c:1.25	Wed Jun 16 00:21:18 2021
+++ src/sys/dev/ic/athn.c	Fri Mar 18 23:32:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: athn.c,v 1.25 2021/06/16 00:21:18 riastradh Exp $	*/
+/*	$NetBSD: athn.c,v 1.26 2022/03/18 23:32:24 riastradh Exp $	*/
 /*	$OpenBSD: athn.c,v 1.83 2014/07/22 13:12:11 mpi Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.25 2021/06/16 00:21:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.26 2022/03/18 23:32:24 riastradh Exp $");
 
 #ifndef _MODULE
 #include "athn_usb.h"		/* for NATHN_USB */
@@ -1293,7 +1293,6 @@ athn_iter_func(void *arg, struct ieee802
 Static void
 athn_calib_to(void *arg)
 {
-	extern int ticks;
 	struct athn_softc *sc = arg;
 	struct athn_ops *ops = &sc->sc_ops;
 	struct ieee80211com *ic = &sc->sc_ic;
@@ -1354,7 +1353,6 @@ athn_init_calib(struct athn_softc *sc, s
 	if (!AR_SREV_9380_10_OR_LATER(sc)) {
 		/* Do PA calibration. */
 		if (AR_SREV_9285_11_OR_LATER(sc)) {
-			extern int ticks;
 			sc->sc_pa_calib_ticks = ticks;
 			if (AR_SREV_9271(sc))
 ar9271_pa_calib(sc);

Index: src/sys/net80211/ieee80211_netbsd.h
diff -u src/sys/net80211/ieee80211_netbsd.h:1.23 src/sys/net80211/ieee80211_netbsd.h:1.24
--- src/sys/net80211/ieee80211_netbsd.h:1.23	Sun Mar 15 23:04:51 2020
+++ src/sys/net80211/ieee80211_netbsd.h	Fri Mar 18 23:32:25 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ieee80211_netbsd.h,v 1.23 2020/03/15 23:04:51 thorpej Exp $ */
+/* $NetBSD: ieee80211_netbsd.h,v 1.24 2022/03/18 23:32:25 riastradh Exp $ */
 /*-
  * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
  * All rights reserved.
@@ -235,7 +235,7 @@ struct ieee80211_michael_event {
 #define	RTM_IEEE80211_REJOIN	108	/* station re-associate (ap mode) */
 
 #ifdef _KERNEL
-#define	ticks	hardclock_ticks
+#define	ticks	getticks()
 
 void	if_printf(struct ifnet *, const char *, ...);
 void	get_random_bytes(void *, size_t);



CVS commit: src/sys

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:25 UTC 2022

Modified Files:
src/sys/dev/ic: arn5008.c athn.c
src/sys/net80211: ieee80211_netbsd.h

Log Message:
net80211: Use getticks(), not hardclock_ticks.

Less extern in .c this way too.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/arn5008.c
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ic/athn.c
cvs rdiff -u -r1.23 -r1.24 src/sys/net80211/ieee80211_netbsd.h

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



CVS commit: src/external/cddl/osnet/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:14 UTC 2022

Modified Files:
src/external/cddl/osnet/sys/kern: ddi.c

Log Message:
osnet: Delete dead #if 0 code using hardclock_ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/sys/kern/ddi.c

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



CVS commit: src/external/cddl/osnet/sys/kern

2022-03-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Mar 18 23:32:14 UTC 2022

Modified Files:
src/external/cddl/osnet/sys/kern: ddi.c

Log Message:
osnet: Delete dead #if 0 code using hardclock_ticks.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/sys/kern/ddi.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/cddl/osnet/sys/kern/ddi.c
diff -u src/external/cddl/osnet/sys/kern/ddi.c:1.8 src/external/cddl/osnet/sys/kern/ddi.c:1.9
--- src/external/cddl/osnet/sys/kern/ddi.c:1.8	Tue Jun 18 22:34:26 2019
+++ src/external/cddl/osnet/sys/kern/ddi.c	Fri Mar 18 23:32:14 2022
@@ -675,19 +675,3 @@ ddi_remove_minor_node(dev_info_t *dip, c
 	do_rmdirp(pn);
 	PNBUF_PUT(pn);
 }
-
-#if 0
-clock_t
-ddi_get_lbolt()
-{
-
-	return hardclock_ticks;
-}
-
-int64_t
-ddi_get_lbolt64()
-{
-
-	return hardclock_ticks;
-}
-#endif



CVS commit: src/sys/fs/udf

2022-03-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Mar 18 16:06:18 UTC 2022

Modified Files:
src/sys/fs/udf: ecma167-udf.h

Log Message:
Replace the variable field data[0] to data[1] to avoid undefined behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/udf/ecma167-udf.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/fs/udf/ecma167-udf.h
diff -u src/sys/fs/udf/ecma167-udf.h:1.16 src/sys/fs/udf/ecma167-udf.h:1.17
--- src/sys/fs/udf/ecma167-udf.h:1.16	Thu Aug  9 13:49:30 2018
+++ src/sys/fs/udf/ecma167-udf.h	Fri Mar 18 16:06:18 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ecma167-udf.h,v 1.16 2018/08/09 13:49:30 reinoud Exp $ */
+/* $NetBSD: ecma167-udf.h,v 1.17 2022/03/18 16:06:18 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009, 2017, 2018
@@ -651,7 +651,7 @@ struct fileid_desc {
 	uint8_t			l_fi;	/* Length of file identifier area */
 	struct long_ad		icb;
 	uint16_t		l_iu;	/* Length of implementation use area */
-	uint8_t			data[0];
+	uint8_t			data[1];
 } __packed;
 #define	UDF_FID_SIZE	38
 #define	UDF_FILE_CHAR_VIS	(1 << 0) /* Invisible */



CVS commit: src/sys/fs/udf

2022-03-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Mar 18 16:06:18 UTC 2022

Modified Files:
src/sys/fs/udf: ecma167-udf.h

Log Message:
Replace the variable field data[0] to data[1] to avoid undefined behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/udf/ecma167-udf.h

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

2022-03-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 18 13:27:22 UTC 2022

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

Log Message:
Ammend ticket #1738


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.124 -r1.1.2.125 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

2022-03-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 18 13:27:22 UTC 2022

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

Log Message:
Ammend ticket #1738


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.124 -r1.1.2.125 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.124 src/doc/CHANGES-8.3:1.1.2.125
--- src/doc/CHANGES-8.3:1.1.2.124	Tue Mar 15 10:01:03 2022
+++ src/doc/CHANGES-8.3	Fri Mar 18 13:27:22 2022
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.124 2022/03/15 10:01:03 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.125 2022/03/18 13:27:22 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -2553,7 +2553,7 @@ usr.bin/man/man.c1.69,1.70,1.72
 	man(1): fix -m option so it works as documented.
 	[gutteridge, ticket #1737]
 
-usr.sbin/puffs/mount_9p/node.c			1.30,1.31
+usr.sbin/puffs/mount_9p/node.c			1.30,1.31 (adapted)
 
 	mount_9p(8): fix writing to a file opened with write-only mode,
 	check returned type from T_READ request.



CVS commit: [netbsd-8] src/usr.sbin/puffs/mount_9p

2022-03-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 18 13:26:39 UTC 2022

Modified Files:
src/usr.sbin/puffs/mount_9p [netbsd-8]: node.c

Log Message:
Minimal build fix for ticket #1738


To generate a diff of this commit:
cvs rdiff -u -r1.21.40.1 -r1.21.40.2 src/usr.sbin/puffs/mount_9p/node.c

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

Modified files:

Index: src/usr.sbin/puffs/mount_9p/node.c
diff -u src/usr.sbin/puffs/mount_9p/node.c:1.21.40.1 src/usr.sbin/puffs/mount_9p/node.c:1.21.40.2
--- src/usr.sbin/puffs/mount_9p/node.c:1.21.40.1	Tue Mar 15 10:00:14 2022
+++ src/usr.sbin/puffs/mount_9p/node.c	Fri Mar 18 13:26:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: node.c,v 1.21.40.1 2022/03/15 10:00:14 martin Exp $	*/
+/*	$NetBSD: node.c,v 1.21.40.2 2022/03/18 13:26:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2007  Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: node.c,v 1.21.40.1 2022/03/15 10:00:14 martin Exp $");
+__RCSID("$NetBSD: node.c,v 1.21.40.2 2022/03/18 13:26:38 martin Exp $");
 #endif /* !lint */
 
 #include 
@@ -182,7 +182,7 @@ puffs9p_node_readdir(struct puffs_usermo
 	GETRESPONSE(pb);
 
 	if (p9pbuf_get_type(pb) != P9PROTO_R_READ) {
-		rv = proto_handle_rerror(pu, pb);
+		rv = EPROTO;
 		goto out;
 	}
 



CVS commit: [netbsd-8] src/usr.sbin/puffs/mount_9p

2022-03-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 18 13:26:39 UTC 2022

Modified Files:
src/usr.sbin/puffs/mount_9p [netbsd-8]: node.c

Log Message:
Minimal build fix for ticket #1738


To generate a diff of this commit:
cvs rdiff -u -r1.21.40.1 -r1.21.40.2 src/usr.sbin/puffs/mount_9p/node.c

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