CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sun May 3 04:06:15 UTC 2020 Modified Files: src/share/man/man9: condvar.9 Log Message: Bump date. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/share/man/man9/condvar.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/condvar.9 diff -u src/share/man/man9/condvar.9:1.26 src/share/man/man9/condvar.9:1.27 --- src/share/man/man9/condvar.9:1.26 Sun May 3 04:05:50 2020 +++ src/share/man/man9/condvar.9 Sun May 3 04:06:15 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: condvar.9,v 1.26 2020/05/03 04:05:50 riastradh Exp $ +.\" $NetBSD: condvar.9,v 1.27 2020/05/03 04:06:15 riastradh Exp $ .\" .\" Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd April 9, 2020 +.Dd May 2, 2020 .Dt CONDVAR 9 .Os .Sh NAME
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sun May 3 04:05:29 UTC 2020 Modified Files: src/share/man/man9: condvar.9 Log Message: Add a note about setting the timeout to zero _and_ returning success. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/share/man/man9/condvar.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/condvar.9 diff -u src/share/man/man9/condvar.9:1.24 src/share/man/man9/condvar.9:1.25 --- src/share/man/man9/condvar.9:1.24 Sun May 3 04:05:00 2020 +++ src/share/man/man9/condvar.9 Sun May 3 04:05:28 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: condvar.9,v 1.24 2020/05/03 04:05:00 riastradh Exp $ +.\" $NetBSD: condvar.9,v 1.25 2020/05/03 04:05:28 riastradh Exp $ .\" .\" Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -230,6 +230,19 @@ subtract the time elapsed from .Fa bt in place, or set it to zero if there is no time remaining. .Pp +Note that +.Fn cv_timedwaitbt +and +.Fn cv_timedwaitbt_sig +may return zero indicating success, rather than +.Er EWOULDBLOCK , +even if they set the timeout to zero; this means that the caller must +re-check the condition in order to avoid potentially losing a +.Fn cv_signal , +but the +.Em next +wait will time out immediately. +.Pp The hint .Fa epsilon , which can be
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sun May 3 04:05:50 UTC 2020 Modified Files: src/share/man/man9: condvar.9 Log Message: Document cv_timedwaitclock. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/share/man/man9/condvar.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/condvar.9 diff -u src/share/man/man9/condvar.9:1.25 src/share/man/man9/condvar.9:1.26 --- src/share/man/man9/condvar.9:1.25 Sun May 3 04:05:28 2020 +++ src/share/man/man9/condvar.9 Sun May 3 04:05:50 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: condvar.9,v 1.25 2020/05/03 04:05:28 riastradh Exp $ +.\" $NetBSD: condvar.9,v 1.26 2020/05/03 04:05:50 riastradh Exp $ .\" .\" Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -65,6 +65,13 @@ .Ft int .Fn cv_timedwaitbt_sig "kcondvar_t *cv" "kmutex_t *mtx" "struct bintime *bt" \ "const struct bintime *epsilon" +.Ft int +.Fn cv_timedwaitclock "kcondvar_t *cv" "kmutex_t *mtx" \ +"struct timespec *timeout" "clockid_t clockid" "int flags" \ +"const struct bintime *epsilon" +.Fn cv_timedwaitclock_sig "kcondvar_t *cv" "kmutex_t *mtx" \ +"struct timespec *timeout" "clockid_t clockid" "int flags" \ +"const struct bintime *epsilon" .Ft void .Fn cv_signal "kcondvar_t *cv" .Ft void @@ -257,6 +264,47 @@ However, the system is still limited by resolution and by scheduling competition, which may delay the wakeup by more than .Fa bt Li "+" Fa epsilon . +.It Fn cv_timedwaitclock "cv" "lock" "timeout" "clockid" "flags" "epsilon" +.It Fn cv_timedwaitclock_sig "cv" "lock" "timeout" "clockid" "flags" "epsilon" +As per +.Fn cv_wait +and +.Fn cv_wait_sig , +but will return early in case of timeout. +The timeout is measured by the clock +.Fa clockid ; +see +.Xr clock_settime 2 +for the supported options. +The +.Fa flags +may be +.Dv TIMER_RELTIME +for a relative duration or +.Dv TIMER_ABSTIME +for an absolute time on the clock. +For relative timeouts, +.Fn cv_timedwaitclock +and +.Fn cv_timedwaitclock_sig +subtract the elapsed time from +.Fa timeout +in place, or set it to zero if there is no time remaining. +The hint +.Fa epsilon +requests a maximum delay after the timeout before wakeup. +.Pp +It is safe to pass in values of +.Fa clockid +and +.Fa flags +from userland, and timeouts copied in from userland; if anything is +wrong with them, +.Fn cv_timedwaitclock +or +.Fn cv_timedwaitclock_sig +will return +.Er EINVAL . .It Fn cv_signal "cv" .Pp Awaken one LWP waiting on the specified condition variable. @@ -332,6 +380,29 @@ Consuming a resource: consume(res); .Ed .Pp +Consuming a resource using a timeout specified in a syscall by +userland: +.Bd -literal + struct timespec timeout; + + error = copyin(SCARG(uap, timeout), , sizeof timeout); + if (error) + return error; + + mutex_enter(>mutex); + while (res->state == BUSY) { + error = cv_timedwaitclock_sig(>condvar, + >mutex, , SCARG(uap, clock_id), + SCARG(uap, flags), DEFAULT_TIMEOUT_EPSILON); + if (error) + break; + } + mutex_exit(>mutex); + if (error) + return error; + consume(res); +.Ed +.Pp Releasing a resource for the next consumer to use: .Bd -literal mutex_enter(>mutex); @@ -371,3 +442,9 @@ and .Fn cv_timedwaitbt_sig primitives first appeared in .Nx 9.0 . +The +.Fn cv_timedwaitclock +and +.Fn cv_timedwaitclock_sig +primitives first appeared in +.Nx 10.0 .
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sun May 3 04:04:32 UTC 2020 Modified Files: src/share/man/man9: condvar.9 Log Message: Update cv_timedwaitbt documentation to reflect useful reality. Previously, a negative timeout was forbidden (kassert), a zero or maybe even just a sufficiently small timeout would block forever, and we would subtract the time elapsed -- possibly longer than the timeout, leading to a negative updated timeout, which would trip the kassert the next time around if used as advertised. DERP. Now negative timeouts are still forbidden in order to detect usage mistakes, but a zero timeout fails immediately and we clamp the subtracted time to be at least zero so you can always safely call cv_timedwaitbt in a loop. (An alternative would be to fail immediately for all nonpositive timeouts, and to leave in the timespec the negative time we overshot, but it's not clear this would be useful.) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/share/man/man9/condvar.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/condvar.9 diff -u src/share/man/man9/condvar.9:1.22 src/share/man/man9/condvar.9:1.23 --- src/share/man/man9/condvar.9:1.22 Fri Apr 10 17:16:21 2020 +++ src/share/man/man9/condvar.9 Sun May 3 04:04:32 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: condvar.9,v 1.22 2020/04/10 17:16:21 ad Exp $ +.\" $NetBSD: condvar.9,v 1.23 2020/05/03 04:04:32 riastradh Exp $ .\" .\" Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -213,19 +213,28 @@ if the timeout expires. .It Fn cv_timedwaitbt "cv" "mtx" "bt" "epsilon" .It Fn cv_timedwaitbt_sig "cv" "mtx" "bt" "epsilon" .Pp -Similar to -.Fn cv_timedwait +As per +.Fn cv_wait and -.Fn cv_timedwait_sig , -but +.Fn cv_wait_sig , +but will return early if the duration +.Fa bt +has elapsed, immediately if +.Fa bt +is zero. +On return, +.Fn cv_timedwaitbt +and +.Fn cv_timedwaitbt_sig +subtract the time elapsed from .Fa bt -is decremented in place with the amount of time actually waited, and on -return contains the amount of time remaining, possibly negative if the -timeout expired. +in place, or set it to zero if there is no time remaining. .Pp The hint -.Fa epsilon -requests that the wakeup not be delayed more than +.Fa epsilon , +which can be +.Dv DEFAULT_TIMEOUT_EPSILON +if in doubt, requests that the wakeup not be delayed more than .Fa bt Li "+" Fa epsilon , so that the system can coalesce multiple wakeups within their respective epsilons into a single high-resolution clock interrupt or @@ -291,10 +300,9 @@ Consuming a resource: * alloted time, return an error. */ struct bintime timeout = { .sec = 5, .frac = 0 }; - const struct bintime epsilon = { .sec = 1, .frac = 0 }; while (res->state == BUSY) { - error = cv_timedwaitbt(>condvar, \\ - >mutex, , ); + error = cv_timedwaitbt(>condvar, + >mutex, , DEFAULT_TIMEOUT_EPSILON); if (error) { KASSERT(error == EWOULDBLOCK); if (res->state != BUSY)
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sun May 3 04:05:00 UTC 2020 Modified Files: src/share/man/man9: condvar.9 Log Message: Simplify example of cv_timedwaitbt. It is simpler if there is only one place we check the condition. That said, there are cases where the caller needs to re-check before choosing to fail (e.g., futex_wait in kern/sys_futex.c, which must verify the condition before taking destructive steps to abort the wait). But it's not clear that that's the norm. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/share/man/man9/condvar.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/condvar.9 diff -u src/share/man/man9/condvar.9:1.23 src/share/man/man9/condvar.9:1.24 --- src/share/man/man9/condvar.9:1.23 Sun May 3 04:04:32 2020 +++ src/share/man/man9/condvar.9 Sun May 3 04:05:00 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: condvar.9,v 1.23 2020/05/03 04:04:32 riastradh Exp $ +.\" $NetBSD: condvar.9,v 1.24 2020/05/03 04:05:00 riastradh Exp $ .\" .\" Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -305,8 +305,6 @@ Consuming a resource: >mutex, , DEFAULT_TIMEOUT_EPSILON); if (error) { KASSERT(error == EWOULDBLOCK); - if (res->state != BUSY) -break; mutex_exit(>mutex); return ETIMEDOUT; }
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sun May 3 01:26:39 UTC 2020 Modified Files: src/sys/kern: sys_futex.c Log Message: Make sure futex waits never return ERESTART. If the user had passed in a relative timeout, this would have the effect of waiting for the full relative time repeatedly, without regard for how much time had elapsed during the wait before a signal. In principle this may not be necessary for absolute timeouts or indefinite timeouts, but it's not clear there's an advantage; we do the same for various other syscalls like nanosleep. Perhaps in the future we can arrange to keep the state of how much time had elapsed when we restart like Linux does, but that's a much more ambitious change. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/kern/sys_futex.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/sys_futex.c diff -u src/sys/kern/sys_futex.c:1.8 src/sys/kern/sys_futex.c:1.9 --- src/sys/kern/sys_futex.c:1.8 Sun May 3 01:25:48 2020 +++ src/sys/kern/sys_futex.c Sun May 3 01:26:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_futex.c,v 1.8 2020/05/03 01:25:48 riastradh Exp $ */ +/* $NetBSD: sys_futex.c,v 1.9 2020/05/03 01:26:39 riastradh Exp $ */ /*- * Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.8 2020/05/03 01:25:48 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.9 2020/05/03 01:26:39 riastradh Exp $"); /* * Futexes @@ -954,12 +954,16 @@ futex_wait(struct futex_wait *fw, struct * If we were woken up, the waker will have removed fw from the * queue. But if anything went wrong, we must remove fw from * the queue ourselves. While here, convert EWOULDBLOCK to - * ETIMEDOUT. + * ETIMEDOUT in case cv_timedwait_sig returned EWOULDBLOCK, and + * convert ERESTART to EINTR so that we don't restart with the + * same relative timeout after time has elapsed. */ if (error) { futex_wait_abort(fw); if (error == EWOULDBLOCK) error = ETIMEDOUT; + else if (error == ERESTART) + error = EINTR; } mutex_exit(>fw_lock);
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sun May 3 01:25:48 UTC 2020 Modified Files: src/sys/kern: sys_futex.c src/sys/sys: futex.h Log Message: Use cv_timedwaitclock_sig in futex. Possible fix for hangs observed with Java under Linux emulation. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/kern/sys_futex.c cvs rdiff -u -r1.2 -r1.3 src/sys/sys/futex.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/sys_futex.c diff -u src/sys/kern/sys_futex.c:1.7 src/sys/kern/sys_futex.c:1.8 --- src/sys/kern/sys_futex.c:1.7 Tue Apr 28 17:27:03 2020 +++ src/sys/kern/sys_futex.c Sun May 3 01:25:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_futex.c,v 1.7 2020/04/28 17:27:03 riastradh Exp $ */ +/* $NetBSD: sys_futex.c,v 1.8 2020/05/03 01:25:48 riastradh Exp $ */ /*- * Copyright (c) 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.7 2020/04/28 17:27:03 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_futex.c,v 1.8 2020/05/03 01:25:48 riastradh Exp $"); /* * Futexes @@ -916,17 +916,18 @@ futex_wait_abort(struct futex_wait *fw) } /* - * futex_wait(fw, deadline, clkid) + * futex_wait(fw, timeout, clkid, clkflags) * - * fw must be a waiter on a futex's queue. Wait until deadline on - * the clock clkid, or forever if deadline is NULL, for a futex - * wakeup. Return 0 on explicit wakeup or destruction of futex, - * ETIMEDOUT on timeout, EINTR/ERESTART on signal. Either way, fw - * will no longer be on a futex queue on return. + * fw must be a waiter on a futex's queue. Wait for timeout on + * the clock clkid according to clkflags (TIMER_*), or forever if + * timeout is NULL, for a futex wakeup. Return 0 on explicit + * wakeup or destruction of futex, ETIMEDOUT on timeout, + * EINTR/ERESTART on signal. Either way, fw will no longer be on + * a futex queue on return. */ static int -futex_wait(struct futex_wait *fw, const struct timespec *deadline, -clockid_t clkid) +futex_wait(struct futex_wait *fw, struct timespec *timeout, clockid_t clkid, +int clkflags) { int error = 0; @@ -934,7 +935,7 @@ futex_wait(struct futex_wait *fw, const mutex_enter(>fw_lock); for (;;) { - /* If we're done yet, stop and report success. */ + /* If we're done already, stop and report success. */ if (fw->fw_bitset == 0 || fw->fw_futex == NULL) { error = 0; break; @@ -945,30 +946,8 @@ futex_wait(struct futex_wait *fw, const break; /* Not done yet. Wait. */ - if (deadline) { - struct timespec ts; - - /* Check our watch. */ - error = clock_gettime1(clkid, ); - if (error) -break; - - /* If we're past the deadline, ETIMEDOUT. */ - if (timespeccmp(deadline, , <=)) { -error = ETIMEDOUT; -break; - } - - /* Count how much time is left. */ - timespecsub(deadline, , ); - - /* Wait for that much time, allowing signals. */ - error = cv_timedwait_sig(>fw_cv, >fw_lock, - tstohz()); - } else { - /* Wait indefinitely, allowing signals. */ - error = cv_wait_sig(>fw_cv, >fw_lock); - } + error = cv_timedwaitclock_sig(>fw_cv, >fw_lock, + timeout, clkid, clkflags, DEFAULT_TIMEOUT_EPSILON); } /* @@ -1188,13 +1167,11 @@ futex_queue_unlock2(struct futex *f, str */ static int futex_func_wait(bool shared, int *uaddr, int val, int val3, -const struct timespec *timeout, clockid_t clkid, int clkflags, +struct timespec *timeout, clockid_t clkid, int clkflags, register_t *retval) { struct futex *f; struct futex_wait wait, *fw = - struct timespec ts; - const struct timespec *deadline; int error; /* @@ -1208,17 +1185,6 @@ futex_func_wait(bool shared, int *uaddr, if (!futex_test(uaddr, val)) return EAGAIN; - /* Determine a deadline on the specified clock. */ - if (timeout == NULL || (clkflags & TIMER_ABSTIME) == TIMER_ABSTIME) { - deadline = timeout; - } else { - error = clock_gettime1(clkid, ); - if (error) - return error; - timespecadd(, timeout, ); - deadline = - } - /* Get the futex, creating it if necessary. */ error = futex_lookup_create(uaddr, shared, ); if (error) @@ -1255,7 +1221,7 @@ futex_func_wait(bool shared, int *uaddr, f = NULL; /* Wait. */ - error = futex_wait(fw, deadline, clkid); + error = futex_wait(fw, timeout, clkid, clkflags); if (error) goto out; @@ -1580,8 +1546,8 @@ out: * parsed out. */ int -do_futex(int *uaddr, int op, int val, const struct timespec *timeout, -int *uaddr2, int val2, int val3, register_t *retval) +do_futex(int *uaddr, int op, int val, struct timespec *timeout, int *uaddr2, +int val2, int val3, register_t *retval) { const bool shared = (op & FUTEX_PRIVATE_FLAG) ? false : true; const clockid_t clkid = (op & FUTEX_CLOCK_REALTIME) ? CLOCK_REALTIME Index: src/sys/sys/futex.h diff -u
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sun May 3 01:24:38 UTC 2020 Modified Files: src/sys/kern: kern_condvar.c src/sys/sys: condvar.h Log Message: New cv_timedwaitclock, cv_timedwaitclock_sig. Usage: given a struct timespec timeout copied from userland, along with a clockid and TIMER_* flags, error = cv_timedwaitclock(cv, lock, timeout, clockid, flags, DEFAULT_TIMEOUT_EPSILON); if (error) /* fail */ If flags is relative (i.e., (flags & TIMER_ABSTIME) == 0), then this deducts the time spent waiting from timeout, so you can run it in a loop: struct timespec timeout; error = copyin(SCARG(uap, timeout), , sizeof timeout); if (error) return error; mutex_enter(lock); while (!ready()) { error = cv_timedwaitclock_sig(cv, lock, , SCARG(uap, clockid), SCARG(uap, flags), DEFAULT_TIMEOUT_EPSILON); if (error) break; } mutex_exit(lock); CAVEAT: If the system call is interrupted by a signal with SA_RESTART so cv_timedwaitclock_sig fails with ERESTART, then the system call will be restarted with the _original_ relative timeout, not counting the time that was already spent waiting. This is a problem but it's not a problem I want to deal with at the moment. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/kern/kern_condvar.c cvs rdiff -u -r1.15 -r1.16 src/sys/sys/condvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_condvar.c diff -u src/sys/kern/kern_condvar.c:1.48 src/sys/kern/kern_condvar.c:1.49 --- src/sys/kern/kern_condvar.c:1.48 Sun May 3 01:19:47 2020 +++ src/sys/kern/kern_condvar.c Sun May 3 01:24:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_condvar.c,v 1.48 2020/05/03 01:19:47 riastradh Exp $ */ +/* $NetBSD: kern_condvar.c,v 1.49 2020/05/03 01:24:37 riastradh Exp $ */ /*- * Copyright (c) 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.48 2020/05/03 01:19:47 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.49 2020/05/03 01:24:37 riastradh Exp $"); #include #include @@ -244,6 +244,189 @@ cv_timedwait_sig(kcondvar_t *cv, kmutex_ return error; } +struct timedwaitclock { + struct timespec *timeout; + clockid_t clockid; + int flags; + const struct bintime *epsilon; + struct timespec starttime; +}; + +static int +cv_timedwaitclock_begin(struct timedwaitclock *T, int *timo) +{ + struct timespec delta; + const struct timespec *deltap; + int error; + + /* Sanity-check timeout -- may have come from userland. */ + if (T->timeout->tv_nsec < 0 || T->timeout->tv_nsec >= 10L) + return EINVAL; + + /* + * Compute the time delta. + */ + if ((T->flags & TIMER_ABSTIME) == TIMER_ABSTIME) { + /* Check our watch. */ + error = clock_gettime1(T->clockid, >starttime); + if (error) + return error; + + /* If the deadline has passed, we're done. */ + if (timespeccmp(T->timeout, >starttime, <=)) + return ETIMEDOUT; + + /* Count how much time is left. */ + timespecsub(T->timeout, >starttime, ); + deltap = + } else { + /* The user specified how much time is left. */ + deltap = T->timeout; + + /* If there's none left, we've timed out. */ + if (deltap->tv_sec == 0 && deltap->tv_nsec == 0) + return ETIMEDOUT; + } + + /* + * Convert to ticks, but clamp to be >=1. + * + * XXX In the tickless future, use a high-resolution timer if + * timo would round to zero. + */ + *timo = tstohz(deltap); + KASSERTMSG(*timo >= 0, "negative ticks: %d", *timo); + if (*timo == 0) + *timo = 1; + + /* Success! */ + return 0; +} + +static void +cv_timedwaitclock_end(struct timedwaitclock *T) +{ + struct timespec endtime, delta; + + /* If the timeout is absolute, nothing to do. */ + if ((T->flags & TIMER_ABSTIME) == TIMER_ABSTIME) + return; + + /* + * Check our watch. If anything goes wrong with it, make sure + * that the next time we immediately time out rather than fail + * to deduct the time elapsed. + */ + if (clock_gettime1(T->clockid, )) { + T->timeout->tv_sec = 0; + T->timeout->tv_nsec = 0; + return; + } + + /* Find how much time elapsed while we waited. */ + timespecsub(, >starttime, ); + + /* + * Paranoia: If the clock went backwards, treat it as if no + * time elapsed at all rather than adding anything. + */ + if (delta.tv_sec < 0 || + (delta.tv_sec == 0 && delta.tv_nsec < 0)) { + delta.tv_sec = 0; + delta.tv_nsec = 0; + } + + /* + * Set it to the time left, or zero, whichever is larger. We + * do not fail with EWOULDBLOCK here because this may have been + * an explicit wakeup, so the caller needs to check before they + * give up or else cv_signal would be lost. + */ + if
CVS commit: src/sys/sys
Module Name:src Committed By: riastradh Date: Sun May 3 01:20:37 UTC 2020 Modified Files: src/sys/sys: timevar.h Log Message: Define DEFAULT_TIMEOUT_EPSILON for cv_timedwaitbt. For now, it is roughly one bintime's worth of ticks. This is about the smallest difference between wait periods we can rely on at the moment; in the glorious tickless future we can revisit this. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/sys/timevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/timevar.h diff -u src/sys/sys/timevar.h:1.40 src/sys/sys/timevar.h:1.41 --- src/sys/sys/timevar.h:1.40 Thu Jan 2 15:42:27 2020 +++ src/sys/sys/timevar.h Sun May 3 01:20:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: timevar.h,v 1.40 2020/01/02 15:42:27 thorpej Exp $ */ +/* $NetBSD: timevar.h,v 1.41 2020/05/03 01:20:37 riastradh Exp $ */ /* * Copyright (c) 2005, 2008 The NetBSD Foundation. @@ -195,6 +195,12 @@ bool time_wraps(struct timespec *, struc extern volatile time_t time_second; /* current second in the epoch */ extern volatile time_t time_uptime; /* system uptime in seconds */ +#define DEFAULT_TIMEOUT_EPSILON \ + (&(const struct bintime) { \ + .sec = 0, \ + .frac = ((uint64_t)1 << 32)/hz << 32, \ + }) + static __inline time_t time_mono_to_wall(time_t t) {
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sun May 3 01:19:47 UTC 2020 Modified Files: src/sys/kern: kern_condvar.c Log Message: Fix edge cases in cv_timedwaitbt, cv_timedwaitbt_sig. - If the timeout is exactly zero, fail immediately with EWOULDBLOCK. - If the timeout is just so small it would be rounded to zero ticks, make sure to wait at least one tick. - Make sure we never return with a negative timeout left. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/kern/kern_condvar.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_condvar.c diff -u src/sys/kern/kern_condvar.c:1.47 src/sys/kern/kern_condvar.c:1.48 --- src/sys/kern/kern_condvar.c:1.47 Sun Apr 19 20:35:29 2020 +++ src/sys/kern/kern_condvar.c Sun May 3 01:19:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_condvar.c,v 1.47 2020/04/19 20:35:29 ad Exp $ */ +/* $NetBSD: kern_condvar.c,v 1.48 2020/05/03 01:19:47 riastradh Exp $ */ /*- * Copyright (c) 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.47 2020/04/19 20:35:29 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.48 2020/05/03 01:19:47 riastradh Exp $"); #include #include @@ -334,23 +334,45 @@ cv_timedwaitbt(kcondvar_t *cv, kmutex_t { struct bintime slept; unsigned start, end; + int timo; int error; KASSERTMSG(bt->sec >= 0, "negative timeout"); KASSERTMSG(epsilon != NULL, "specify maximum requested delay"); + /* If there's nothing left to wait, time out. */ + if (bt->sec == 0 && bt->frac == 0) + return EWOULDBLOCK; + + /* Convert to ticks, but clamp to be >=1. */ + timo = bintime2timo(bt); + KASSERTMSG(timo >= 0, "negative ticks: %d", timo); + if (timo == 0) + timo = 1; + /* * getticks() is technically int, but nothing special * happens instead of overflow, so we assume two's-complement * wraparound and just treat it as unsigned. */ start = getticks(); - error = cv_timedwait(cv, mtx, bintime2timo(bt)); + error = cv_timedwait(cv, mtx, timo); end = getticks(); + /* + * Set it to the time left, or zero, whichever is larger. We + * do not fail with EWOULDBLOCK here because this may have been + * an explicit wakeup, so the caller needs to check before they + * give up or else cv_signal would be lost. + */ slept = timo2bintime(end - start); - /* bt := bt - slept */ - bintime_sub(bt, ); + if (bintimecmp(bt, , <=)) { + bt->sec = 0; + bt->frac = 0; + } else { + /* bt := bt - slept */ + bintime_sub(bt, ); + } return error; } @@ -377,23 +399,45 @@ cv_timedwaitbt_sig(kcondvar_t *cv, kmute { struct bintime slept; unsigned start, end; + int timo; int error; KASSERTMSG(bt->sec >= 0, "negative timeout"); KASSERTMSG(epsilon != NULL, "specify maximum requested delay"); + /* If there's nothing left to wait, time out. */ + if (bt->sec == 0 && bt->frac == 0) + return EWOULDBLOCK; + + /* Convert to ticks, but clamp to be >=1. */ + timo = bintime2timo(bt); + KASSERTMSG(timo >= 0, "negative ticks: %d", timo); + if (timo == 0) + timo = 1; + /* * getticks() is technically int, but nothing special * happens instead of overflow, so we assume two's-complement * wraparound and just treat it as unsigned. */ start = getticks(); - error = cv_timedwait_sig(cv, mtx, bintime2timo(bt)); + error = cv_timedwait_sig(cv, mtx, timo); end = getticks(); + /* + * Set it to the time left, or zero, whichever is larger. We + * do not fail with EWOULDBLOCK here because this may have been + * an explicit wakeup, so the caller needs to check before they + * give up or else cv_signal would be lost. + */ slept = timo2bintime(end - start); - /* bt := bt - slept */ - bintime_sub(bt, ); + if (bintimecmp(bt, , <=)) { + bt->sec = 0; + bt->frac = 0; + } else { + /* bt := bt - slept */ + bintime_sub(bt, ); + } return error; }
CVS commit: src/sys/compat
Module Name:src Committed By: thorpej Date: Sun May 3 01:06:56 UTC 2020 Modified Files: src/sys/compat/linux/arch/alpha: files.linux_alpha src/sys/compat/linux/arch/amd64: linux_commons.c src/sys/compat/linux/arch/arm: linux_commons.c src/sys/compat/linux/arch/i386: linux_commons.c src/sys/compat/linux/arch/m68k: files.linux_m68k src/sys/compat/linux/arch/mips: files.linux_mips src/sys/compat/linux/arch/powerpc: files.linux_powerpc src/sys/compat/linux/common: linux_exec.c linux_misc.c linux_misc.h src/sys/compat/linux32/common: linux32_misc.c Removed Files: src/sys/compat/linux/common: linux_futex.c Log Message: Always clear FUTEX_PRIVATE_FLAG for Linux processes. NetBSD-native futexes exist in different namespace depending on FUTEX_PRIVATE_FLAG. This appears not to be the case in Linux, and some futex users will mix private and non- private ops on the same futex object. Provide a convenience wrapper that puts this logic in one place witn a comment explaining why. While here, move the Linux futex wrapper out of its own file and plop it in linux_misc.c, which is where it lives in the linux32 module. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/compat/linux/arch/alpha/files.linux_alpha cvs rdiff -u -r1.11 -r1.12 src/sys/compat/linux/arch/amd64/linux_commons.c cvs rdiff -u -r1.12 -r1.13 src/sys/compat/linux/arch/arm/linux_commons.c cvs rdiff -u -r1.16 -r1.17 src/sys/compat/linux/arch/i386/linux_commons.c cvs rdiff -u -r1.7 -r1.8 src/sys/compat/linux/arch/m68k/files.linux_m68k cvs rdiff -u -r1.7 -r1.8 src/sys/compat/linux/arch/mips/files.linux_mips cvs rdiff -u -r1.11 -r1.12 \ src/sys/compat/linux/arch/powerpc/files.linux_powerpc cvs rdiff -u -r1.123 -r1.124 src/sys/compat/linux/common/linux_exec.c cvs rdiff -u -r1.40 -r0 src/sys/compat/linux/common/linux_futex.c cvs rdiff -u -r1.248 -r1.249 src/sys/compat/linux/common/linux_misc.c cvs rdiff -u -r1.25 -r1.26 src/sys/compat/linux/common/linux_misc.h cvs rdiff -u -r1.29 -r1.30 src/sys/compat/linux32/common/linux32_misc.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/compat/linux/arch/alpha/files.linux_alpha diff -u src/sys/compat/linux/arch/alpha/files.linux_alpha:1.10 src/sys/compat/linux/arch/alpha/files.linux_alpha:1.11 --- src/sys/compat/linux/arch/alpha/files.linux_alpha:1.10 Sun Mar 24 16:24:19 2019 +++ src/sys/compat/linux/arch/alpha/files.linux_alpha Sun May 3 01:06:55 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.linux_alpha,v 1.10 2019/03/24 16:24:19 maxv Exp $ +# $NetBSD: files.linux_alpha,v 1.11 2020/05/03 01:06:55 thorpej Exp $ # # Config file description for alpha-dependent Linux compat code. @@ -9,6 +9,5 @@ file compat/linux/arch/alpha/linux_sysca file compat/linux/arch/alpha/linux_sysent.c compat_linux file compat/linux/common/linux_fadvise64.c compat_linux file compat/linux/common/linux_file64.c compat_linux -file compat/linux/common/linux_futex.c compat_linux file compat/linux/common/linux_olduname.c compat_linux file compat/linux/common/linux_sigaction.c compat_linux Index: src/sys/compat/linux/arch/amd64/linux_commons.c diff -u src/sys/compat/linux/arch/amd64/linux_commons.c:1.11 src/sys/compat/linux/arch/amd64/linux_commons.c:1.12 --- src/sys/compat/linux/arch/amd64/linux_commons.c:1.11 Mon May 30 17:50:31 2011 +++ src/sys/compat/linux/arch/amd64/linux_commons.c Sun May 3 01:06:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_commons.c,v 1.11 2011/05/30 17:50:31 alnsn Exp $ */ +/* $NetBSD: linux_commons.c,v 1.12 2020/05/03 01:06:55 thorpej Exp $ */ /* * This file includes C files from the common @@ -13,7 +13,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.11 2011/05/30 17:50:31 alnsn Exp $"); +__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.12 2020/05/03 01:06:55 thorpej Exp $"); #if defined(_KERNEL_OPT) #include "opt_sysv.h" @@ -35,5 +35,4 @@ __KERNEL_RCSID(1, "$NetBSD: linux_common #include "../../common/linux_file64.c" #include "../../common/linux_misc_notalpha.c" #include "../../common/linux_sig_notalpha.c" -#include "../../common/linux_futex.c" #include "../../common/linux_fadvise64.c" Index: src/sys/compat/linux/arch/arm/linux_commons.c diff -u src/sys/compat/linux/arch/arm/linux_commons.c:1.12 src/sys/compat/linux/arch/arm/linux_commons.c:1.13 --- src/sys/compat/linux/arch/arm/linux_commons.c:1.12 Tue May 31 22:35:22 2011 +++ src/sys/compat/linux/arch/arm/linux_commons.c Sun May 3 01:06:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_commons.c,v 1.12 2011/05/31 22:35:22 njoly Exp $ */ +/* $NetBSD: linux_commons.c,v 1.13 2020/05/03 01:06:55 thorpej Exp $ */ /* * This file includes C files from the common @@ -13,7 +13,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: linux_commons.c,v 1.12 2011/05/31 22:35:22 njoly Exp $"); +__KERNEL_RCSID(1, "$NetBSD:
CVS commit: src/sys/modules/compat_netbsd32
Module Name:src Committed By: thorpej Date: Sat May 2 22:19:47 UTC 2020 Modified Files: src/sys/modules/compat_netbsd32: Makefile Log Message: Include netbsd32_futex.c in the module. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/modules/compat_netbsd32/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/modules/compat_netbsd32/Makefile diff -u src/sys/modules/compat_netbsd32/Makefile:1.33 src/sys/modules/compat_netbsd32/Makefile:1.34 --- src/sys/modules/compat_netbsd32/Makefile:1.33 Sun Apr 19 17:40:49 2020 +++ src/sys/modules/compat_netbsd32/Makefile Sat May 2 22:19:47 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.33 2020/04/19 17:40:49 maya Exp $ +# $NetBSD: Makefile,v 1.34 2020/05/02 22:19:47 thorpej Exp $ .include "../Makefile.inc" .include "../Makefile.assym" @@ -32,6 +32,7 @@ SRCS+= netbsd32_drm.c SRCS+= netbsd32_core.c netbsd32_event.c SRCS+= netbsd32_exec_elf32.c netbsd32_execve.c SRCS+= netbsd32_fd.c netbsd32_fs.c +SRCS+= netbsd32_futex.c SRCS+= netbsd32_ioctl.c netbsd32_kern_proc.c SRCS+= netbsd32_lwp.c netbsd32_mod.c SRCS+= netbsd32_module.c netbsd32_netbsd.c
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: christos Date: Sat May 2 22:11:16 UTC 2020 Modified Files: src/sys/ufs/ffs: ffs_extattr.c ffs_inode.c Log Message: Remove the unlock/relock hack by using IO_EXT to indicate that we are already holding the lock. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/ffs/ffs_extattr.c cvs rdiff -u -r1.128 -r1.129 src/sys/ufs/ffs/ffs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_extattr.c diff -u src/sys/ufs/ffs/ffs_extattr.c:1.3 src/sys/ufs/ffs/ffs_extattr.c:1.4 --- src/sys/ufs/ffs/ffs_extattr.c:1.3 Mon Apr 20 14:10:10 2020 +++ src/sys/ufs/ffs/ffs_extattr.c Sat May 2 18:11:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_extattr.c,v 1.3 2020/04/20 18:10:10 christos Exp $ */ +/* $NetBSD: ffs_extattr.c,v 1.4 2020/05/02 22:11:16 christos Exp $ */ /*- * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND BSD-3-Clause) @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.3 2020/04/20 18:10:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.4 2020/05/02 22:11:16 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -392,10 +392,8 @@ ffs_extwrite(struct vnode *vp, struct ui } if (error) { if (ioflag & IO_UNIT) { - genfs_node_unlock(vp); // XXX: need our own lock (void)ffs_truncate(vp, osize, IO_EXT | (ioflag_SYNC), ucred); - genfs_node_wrlock(vp); uio->uio_offset -= resid - uio->uio_resid; uio->uio_resid = resid; } @@ -561,9 +559,7 @@ ffs_close_ea(struct vnode *vp, int commi ffs_unlock_ea(vp); return error; } - genfs_node_unlock(vp); // XXX: need our own lock error = ffs_truncate(vp, 0, IO_EXT, cred); - genfs_node_wrlock(vp); UFS_WAPBL_END(vp->v_mount); } error = ffs_extwrite(vp, , IO_EXT | IO_SYNC, cred); Index: src/sys/ufs/ffs/ffs_inode.c diff -u src/sys/ufs/ffs/ffs_inode.c:1.128 src/sys/ufs/ffs/ffs_inode.c:1.129 --- src/sys/ufs/ffs/ffs_inode.c:1.128 Thu Apr 23 17:47:09 2020 +++ src/sys/ufs/ffs/ffs_inode.c Sat May 2 18:11:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_inode.c,v 1.128 2020/04/23 21:47:09 ad Exp $ */ +/* $NetBSD: ffs_inode.c,v 1.129 2020/05/02 22:11:16 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.128 2020/04/23 21:47:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.129 2020/05/02 22:11:16 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -376,7 +376,8 @@ ffs_truncate(struct vnode *ovp, off_t le } } - genfs_node_wrlock(ovp); + if (!(ioflag & IO_EXT)) + genfs_node_wrlock(ovp); oip->i_size = length; DIP_ASSIGN(oip, size, length); uvm_vnp_setsize(ovp, length); @@ -585,7 +586,8 @@ out: oip->i_size = length; DIP_ASSIGN(oip, size, length); DIP_ADD(oip, blocks, -blocksreleased); - genfs_node_unlock(ovp); + if (!(ioflag & IO_EXT)) + genfs_node_unlock(ovp); oip->i_flag |= IN_CHANGE; UFS_WAPBL_UPDATE(ovp, NULL, NULL, 0); #if defined(QUOTA) || defined(QUOTA2)
CVS commit: src/share/mk
Module Name:src Committed By: christos Date: Sat May 2 19:46:58 UTC 2020 Modified Files: src/share/mk: bsd.README Log Message: document MKCOMPATMODULES To generate a diff of this commit: cvs rdiff -u -r1.401 -r1.402 src/share/mk/bsd.README Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.README diff -u src/share/mk/bsd.README:1.401 src/share/mk/bsd.README:1.402 --- src/share/mk/bsd.README:1.401 Sat Apr 4 19:54:06 2020 +++ src/share/mk/bsd.README Sat May 2 15:46:58 2020 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.README,v 1.401 2020/04/04 23:54:06 christos Exp $ +# $NetBSD: bsd.README,v 1.402 2020/05/02 19:46:58 christos Exp $ # @(#)bsd.README 8.2 (Berkeley) 4/2/94 This is the README file for the make "include" files for the NetBSD @@ -144,6 +144,9 @@ MKCOMPATX11 If "yes", build and instal building and installing src/compat. Default: no +MKCOMPATMODULES If "no", don't build compat modules (xen, etc.) + Default: yes + MKCOMPLEX If "no", don't build libm support for Default: yes
CVS commit: src/distrib/sets
Module Name:src Committed By: christos Date: Sat May 2 19:44:59 UTC 2020 Modified Files: src/distrib/sets: sets.subr Log Message: Add support for debugging modules for multi-arch (xen etc.) To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.190 src/distrib/sets/sets.subr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/sets.subr diff -u src/distrib/sets/sets.subr:1.189 src/distrib/sets/sets.subr:1.190 --- src/distrib/sets/sets.subr:1.189 Fri May 1 18:21:49 2020 +++ src/distrib/sets/sets.subr Sat May 2 15:44:59 2020 @@ -1,4 +1,4 @@ -# $NetBSD: sets.subr,v 1.189 2020/05/01 22:21:49 christos Exp $ +# $NetBSD: sets.subr,v 1.190 2020/05/02 19:44:59 christos Exp $ # # @@ -184,7 +184,7 @@ SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g # In each file, a record consists of a path and a System Package name, # separated by whitespace. E.g., # -# # $NetBSD: sets.subr,v 1.189 2020/05/01 22:21:49 christos Exp $ +# # $NetBSD: sets.subr,v 1.190 2020/05/02 19:44:59 christos Exp $ # . base-sys-root [keyword[,...]] # ./altroot base-sys-root # ./bin base-sys-root @@ -254,6 +254,17 @@ list_set_files() fi print_set_lists "$@" | \ ${AWK} -v obsolete=${obsolete} ' + function addkmod(line, fname, prefix, pat, patlen) { + if (substr(line, 1, patlen) != pat) { +return; + } + for (d in kmodarchdirs) { +xd = prefix kmodarchdirs[d] +xfile = xd substr(line, patlen + 1) +tmp = xd substr(fname, patlen + 1) +list[xfile] = tmp; + } + } BEGIN { if (obsolete) wanted["obsolete"] = 1 @@ -298,8 +309,12 @@ list_set_files() if (("kmod" in wanted) && ("compatmodules" in wanted)) { split("'"${KMODARCHDIRS}"'", kmodarchdirs, ","); -kmodpat = "./stand/" ENVIRON["MACHINE"] +kmodprefix = "./stand/" +kmodpat = kmodprefix ENVIRON["MACHINE"] l_kmodpat = length(kmodpat) +kmoddbprefix = "./usr/libdata/debug/stand/" +kmoddbpat = kmoddbprefix ENVIRON["MACHINE"] +l_kmoddbpat = length(kmoddbpat) } if ("'"${TOOLCHAIN_MISSING}"'" != "yes") { @@ -391,13 +406,9 @@ list_set_files() next list[$1] = $0 - if (havekmod > 0 && substr($1,1,l_kmodpat) == kmodpat) { -for (d in kmodarchdirs) { - xd = "./stand/" kmodarchdirs[d] - xfile = xd substr($1, l_kmodpat+1) - tmp = xd substr($0, l_kmodpat+1) - list[xfile] = tmp; -} + if (havekmod > 0) { +addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat) +addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat) next }
CVS commit: src/external/bsd/dhcpcd/sbin/dhcpcd
Module Name:src Committed By: fox Date: Sat May 2 19:35:03 UTC 2020 Modified Files: src/external/bsd/dhcpcd/sbin/dhcpcd: Makefile Log Message: external/bsd/dhcpcd: Suppress -Werror=sign-conversion error. Add -Wno-error=sign-conversion to prevent build failure, when run with MKLIBCSANITIZER=yes. Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag. Reviewed by: kamil@ To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile diff -u src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.51 src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.52 --- src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile:1.51 Thu Apr 2 12:56:01 2020 +++ src/external/bsd/dhcpcd/sbin/dhcpcd/Makefile Sat May 2 19:35:03 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.51 2020/04/02 12:56:01 roy Exp $ +# $NetBSD: Makefile,v 1.52 2020/05/02 19:35:03 fox Exp $ # WARNS?= 6 @@ -32,6 +32,13 @@ SRCS+= auth.c CPPFLAGS+= -DINET SRCS+= bpf.c dhcp.c ipv4.c SRCS+= privsep-bpf.c + +.if (${MKLIBCSANITIZER:Uno} == "yes") +.if (${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8) +COPTS.dhcp.c+= -Wno-error=sign-conversion +.endif +.endif + .if !defined(SMALLPROG) CPPFLAGS+= -DARP SRCS+= arp.c
CVS commit: src/sys/dev/ata
Module Name:src Committed By: thorpej Date: Sat May 2 19:09:56 UTC 2020 Modified Files: src/sys/dev/ata: ata.c ata_subr.c atavar.h Log Message: Back out changes to use a threadpool for now; it's causing trouble for some folks on Thinkpads. To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/sys/dev/ata/ata.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.106 -r1.107 src/sys/dev/ata/atavar.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/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.156 src/sys/dev/ata/ata.c:1.157 --- src/sys/dev/ata/ata.c:1.156 Sat Apr 25 00:07:27 2020 +++ src/sys/dev/ata/ata.c Sat May 2 19:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.156 2020/04/25 00:07:27 thorpej Exp $ */ +/* $NetBSD: ata.c,v 1.157 2020/05/02 19:09:56 thorpej Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.156 2020/04/25 00:07:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.157 2020/05/02 19:09:56 thorpej Exp $"); #include "opt_ata.h" @@ -425,60 +425,47 @@ atabusconfig_thread(void *arg) } /* - * atabus_tp_job: + * atabus_thread: * * Worker thread for the ATA bus. */ static void -atabus_tp_job(struct threadpool_job *j) +atabus_thread(void *arg) { - struct ata_channel *chp = - container_of(j, struct ata_channel, ch_tp_job); - struct atabus_softc *sc = device_private(chp->atabus); + struct atabus_softc *sc = arg; + struct ata_channel *chp = sc->sc_chan; struct ata_queue *chq = chp->ch_queue; struct ata_xfer *xfer; int i, rv; - /* XXX MPSAFE?? */ - KERNEL_LOCK(1, NULL); - ata_channel_lock(chp); - chp->ch_job_thread = curlwp; /* XXX gross */ + KASSERT(ata_is_thread_run(chp)); - /* XXX gross */ - if (__predict_false(!chp->ch_initial_config_done)) { - /* - * Probe the drives. Reset type to indicate to controllers - * that can re-probe that all drives must be probed.. - * - * Note: ch_ndrives may be changed during the probe. - */ - KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); - for (i = 0; i < chp->ch_ndrives; i++) { - chp->ch_drive[i].drive_flags = 0; - chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; - } - chp->ch_initial_config_done = true; - ata_channel_unlock(chp); - atabusconfig(sc); - ata_channel_lock(chp); + /* + * Probe the drives. Reset type to indicate to controllers + * that can re-probe that all drives must be probed.. + * + * Note: ch_ndrives may be changed during the probe. + */ + KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL); + for (i = 0; i < chp->ch_ndrives; i++) { + chp->ch_drive[i].drive_flags = 0; + chp->ch_drive[i].drive_type = ATA_DRIVET_NONE; } + ata_channel_unlock(chp); -#define WORK_TO_DO \ - (ATACH_TH_RESCAN | ATACH_TH_RESET | ATACH_TH_DRIVE_RESET | \ - ATACH_TH_RECOVERY) + atabusconfig(sc); + ata_channel_lock(chp); for (;;) { - if (chp->ch_flags & ATACH_SHUTDOWN) { - break; - } - if ((chp->ch_flags & WORK_TO_DO) == 0 && + if ((chp->ch_flags & (ATACH_TH_RESET | ATACH_TH_DRIVE_RESET + | ATACH_TH_RECOVERY | ATACH_SHUTDOWN)) == 0 && (chq->queue_active == 0 || chq->queue_freeze == 0)) { + cv_wait(>ch_thr_idle, >ch_lock); + } + if (chp->ch_flags & ATACH_SHUTDOWN) { break; } - -#undef WORK_TO_DO - if (chp->ch_flags & ATACH_TH_RESCAN) { chp->ch_flags &= ~ATACH_TH_RESCAN; ata_channel_unlock(chp); @@ -547,11 +534,10 @@ atabus_tp_job(struct threadpool_job *j) ata_channel_lock(chp); } } - chp->ch_job_thread = NULL; /* XXX gross */ - threadpool_job_done(>ch_tp_job); + chp->ch_thread = NULL; + cv_signal(>ch_thr_idle); ata_channel_unlock(chp); - - KERNEL_UNLOCK_ONE(NULL); + kthread_exit(0); } bool @@ -559,7 +545,7 @@ ata_is_thread_run(struct ata_channel *ch { KASSERT(mutex_owned(>ch_lock)); - return (chp->ch_job_thread == curlwp && !cpu_intr_p()); + return (chp->ch_thread == curlwp && !cpu_intr_p()); } static void @@ -567,7 +553,7 @@ ata_thread_wake_locked(struct ata_channe { KASSERT(mutex_owned(>ch_lock)); ata_channel_freeze_locked(chp); - threadpool_schedule_job(chp->ch_tp, >ch_tp_job); + cv_signal(>ch_thr_idle); } /* @@ -601,6 +587,7 @@ atabus_attach(device_t parent, device_t struct atabus_softc *sc = device_private(self); struct ata_channel *chp = aux; struct atabus_initq *initq; + int error; sc->sc_chan = chp; @@ -621,15 +608,11 @@ atabus_attach(device_t parent, device_t mutex_exit(_qlock); config_pending_incr(sc->sc_dev); - /* Initialize our threadpool job. */ - threadpool_job_init(>ch_tp_job, atabus_tp_job, - >ch_lock, "%s", device_xname(self)); - - /* ...and run it now to scan the bus. */ - KASSERT(chp->ch_tp != NULL); - ata_channel_lock(chp); - threadpool_schedule_job(chp->ch_tp, >ch_tp_job); - ata_channel_unlock(chp); + /*
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: christos Date: Sat May 2 19:01:08 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix build without XEN To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.206 src/sys/arch/amd64/amd64/locore.S:1.207 --- src/sys/arch/amd64/amd64/locore.S:1.206 Sat May 2 12:44:34 2020 +++ src/sys/arch/amd64/amd64/locore.S Sat May 2 15:01:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.206 2020/05/02 16:44:34 bouyer Exp $ */ +/* $NetBSD: locore.S,v 1.207 2020/05/02 19:01:08 christos Exp $ */ /* * Copyright-o-rama! @@ -1005,7 +1005,8 @@ longmode_hi: call _C_LABEL(main) END(start) -#ifndef XENPV +#if defined(XEN) +# if !defined(XENPV) /* entry point for Xen PVH */ .code32 ENTRY(start_xen32) @@ -1062,8 +1063,7 @@ ENTRY(start_xen32) jmp .Lbiosbasemem_finished END(start_xen32) .code64 -#endif /* XENPV */ -#if defined(XEN) +# endif /* !XENPV */ /* space for the hypercall call page */ #define HYPERCALL_PAGE_OFFSET 0x1000 .align HYPERCALL_PAGE_OFFSET
CVS commit: src/sys/arch/i386/i386
Module Name:src Committed By: bouyer Date: Sat May 2 18:49:57 UTC 2020 Modified Files: src/sys/arch/i386/i386: i386_trap.S locore.S Log Message: HANDLE_DEFERRED_FPU has to be donne with interrupt disabled; move it before STIC. Fix fpudna panic on i386 PV To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/i386/i386_trap.S cvs rdiff -u -r1.182 -r1.183 src/sys/arch/i386/i386/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/i386/i386_trap.S diff -u src/sys/arch/i386/i386/i386_trap.S:1.21 src/sys/arch/i386/i386/i386_trap.S:1.22 --- src/sys/arch/i386/i386/i386_trap.S:1.21 Sat Apr 25 15:26:17 2020 +++ src/sys/arch/i386/i386/i386_trap.S Sat May 2 18:49:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: i386_trap.S,v 1.21 2020/04/25 15:26:17 bouyer Exp $ */ +/* $NetBSD: i386_trap.S,v 1.22 2020/05/02 18:49:57 bouyer Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -66,7 +66,7 @@ #if 0 #include -__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.21 2020/04/25 15:26:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.22 2020/05/02 18:49:57 bouyer Exp $"); #endif /* @@ -434,6 +434,8 @@ calltrap: 3: CHECK_DEFERRED_SWITCH jnz 9f + HANDLE_DEFERRED_FPU + #ifdef XENPV STIC(%eax) jz 22f @@ -458,8 +460,6 @@ calltrap: 22: #endif /* XEN */ - HANDLE_DEFERRED_FPU - 6: #ifdef DIAGNOSTIC cmpl CPUVAR(ILEVEL),%ebx Index: src/sys/arch/i386/i386/locore.S diff -u src/sys/arch/i386/i386/locore.S:1.182 src/sys/arch/i386/i386/locore.S:1.183 --- src/sys/arch/i386/i386/locore.S:1.182 Sat May 2 16:44:35 2020 +++ src/sys/arch/i386/i386/locore.S Sat May 2 18:49:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.182 2020/05/02 16:44:35 bouyer Exp $ */ +/* $NetBSD: locore.S,v 1.183 2020/05/02 18:49:57 bouyer Exp $ */ /* * Copyright-o-rama! @@ -128,7 +128,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.182 2020/05/02 16:44:35 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.183 2020/05/02 18:49:57 bouyer Exp $"); #include "opt_copy_symtab.h" #include "opt_ddb.h" @@ -1560,6 +1560,8 @@ IDTVEC(syscall) orl CPUVAR(WANT_PMAPLOAD), %eax jnz 9f + HANDLE_DEFERRED_FPU + #ifdef XENPV STIC(%eax) jz 14f @@ -1589,8 +1591,6 @@ IDTVEC(syscall) jne 3f #endif - HANDLE_DEFERRED_FPU - INTRFASTEXIT #ifdef DIAGNOSTIC
CVS commit: src/sys/sys
Module Name:src Committed By: christos Date: Sat May 2 18:43:02 UTC 2020 Modified Files: src/sys/sys: file.h Log Message: We don't have rnd_ctx anymore. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/sys/file.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/file.h diff -u src/sys/sys/file.h:1.85 src/sys/sys/file.h:1.86 --- src/sys/sys/file.h:1.85 Wed May 8 09:40:19 2019 +++ src/sys/sys/file.h Sat May 2 14:43:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: file.h,v 1.85 2019/05/08 13:40:19 isaki Exp $ */ +/* $NetBSD: file.h,v 1.86 2020/05/02 18:43:02 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -103,7 +103,6 @@ union file_data { struct pipe *fd_pipe; // DTYPE_PIPE struct kqueue *fd_kq; // DTYPE_KQUEUE void *fd_data; // DTYPE_MISC - struct rnd_ctx *fd_rndctx; // DTYPE_MISC (rnd) struct audio_file *fd_audioctx; // DTYPE_MISC (audio) struct pad_softc *fd_pad; // DTYPE_MISC (pad) int fd_devunit; // DTYPE_MISC (tap)
CVS commit: src/usr.bin/fstat
Module Name:src Committed By: christos Date: Sat May 2 18:42:30 UTC 2020 Modified Files: src/usr.bin/fstat: misc.c Log Message: nuke random stuff that does not exist anymore. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/fstat/misc.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.bin/fstat/misc.c diff -u src/usr.bin/fstat/misc.c:1.22 src/usr.bin/fstat/misc.c:1.23 --- src/usr.bin/fstat/misc.c:1.22 Fri Sep 6 13:08:22 2019 +++ src/usr.bin/fstat/misc.c Sat May 2 14:42:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.22 2019/09/06 17:08:22 christos Exp $ */ +/* $NetBSD: misc.c,v 1.23 2020/05/02 18:42:30 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: misc.c,v 1.22 2019/09/06 17:08:22 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.23 2020/05/02 18:42:30 christos Exp $"); #include #include @@ -207,35 +207,6 @@ p_mqueue(struct file *f) } static int -p_rnd(struct file *f) -{ - struct cprng_strong { - char cs_name[16]; - int cs_flags; - /*...*/ - } str; - struct rnd_ctx { - struct cprng_strong *rc_cprng; - bool rc_hard; - } ctx; - char buf[1024]; - - if (!KVM_READ(f->f_data, , sizeof(ctx))) { - dprintf("can't read rnd_ctx at %p for pid %d", f->f_data, Pid); - return 0; - } - if (!KVM_READ(ctx.rc_cprng, , sizeof(str))) { - dprintf("can't read cprng_strong at %p for pid %d", f->f_data,\ - Pid); - return 0; - } - snprintb(buf, sizeof(buf), CPRNG_FMT, str.cs_flags); - (void)printf("* rnd \"%s\" flags %s", str.cs_name, buf); - oprint(f, "\n"); - return 0; -} - -static int p_kqueue(struct file *f) { struct kqueue kq; @@ -281,7 +252,8 @@ pmisc(struct file *f, const char *name) case NL_KQUEUE: return p_kqueue(f); case NL_RND: - return p_rnd(f); + printf("* random %p", f->f_data); + break; case NL_SEM: return p_sem(f); case NL_TAP:
CVS commit: src/sys/arch
Module Name:src Committed By: bouyer Date: Sat May 2 17:14:02 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: cpufunc.S src/sys/arch/i386/i386: cpufunc.S Log Message: Move x86_hotpatch() in !XENPV section. Fixes XEN3* builds. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.39 -r1.40 src/sys/arch/i386/i386/cpufunc.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.50 src/sys/arch/amd64/amd64/cpufunc.S:1.51 --- src/sys/arch/amd64/amd64/cpufunc.S:1.50 Sat May 2 11:37:17 2020 +++ src/sys/arch/amd64/amd64/cpufunc.S Sat May 2 17:14:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.50 2020/05/02 11:37:17 maxv Exp $ */ +/* $NetBSD: cpufunc.S,v 1.51 2020/05/02 17:14:01 bouyer Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -180,6 +180,44 @@ ENTRY(tsc_get_timecount) 2: jmp 1b END(tsc_get_timecount) + +/* + * %rdi = name + * %rsi = sel + */ +ENTRY(x86_hotpatch) + /* save RFLAGS, and disable intrs */ + pushfq + cli + + /* save CR0, and disable WP */ + movq %cr0,%rcx + pushq %rcx + andq $~CR0_WP,%rcx + movq %rcx,%cr0 + + callq _C_LABEL(x86_hotpatch_apply) + + /* write back and invalidate cache */ + wbinvd + + /* restore CR0 */ + popq %rcx + movq %rcx,%cr0 + + /* flush instruction pipeline */ + pushq %rax + callq x86_flush + popq %rax + + /* clean up */ + movq %rax,%rdi + callq _C_LABEL(x86_hotpatch_cleanup) + + /* restore RFLAGS */ + popfq + ret +END(x86_hotpatch) #endif /* !XENPV */ ENTRY(rdmsr_safe) @@ -380,41 +418,3 @@ ENTRY(outl) outl %eax, %dx ret END(outl) - -/* - * %rdi = name - * %rsi = sel - */ -ENTRY(x86_hotpatch) - /* save RFLAGS, and disable intrs */ - pushfq - cli - - /* save CR0, and disable WP */ - movq %cr0,%rcx - pushq %rcx - andq $~CR0_WP,%rcx - movq %rcx,%cr0 - - callq _C_LABEL(x86_hotpatch_apply) - - /* write back and invalidate cache */ - wbinvd - - /* restore CR0 */ - popq %rcx - movq %rcx,%cr0 - - /* flush instruction pipeline */ - pushq %rax - callq x86_flush - popq %rax - - /* clean up */ - movq %rax,%rdi - callq _C_LABEL(x86_hotpatch_cleanup) - - /* restore RFLAGS */ - popfq - ret -END(x86_hotpatch) Index: src/sys/arch/i386/i386/cpufunc.S diff -u src/sys/arch/i386/i386/cpufunc.S:1.39 src/sys/arch/i386/i386/cpufunc.S:1.40 --- src/sys/arch/i386/i386/cpufunc.S:1.39 Sat May 2 11:37:17 2020 +++ src/sys/arch/i386/i386/cpufunc.S Sat May 2 17:14:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.39 2020/05/02 11:37:17 maxv Exp $ */ +/* $NetBSD: cpufunc.S,v 1.40 2020/05/02 17:14:01 bouyer Exp $ */ /*- * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #include -__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.39 2020/05/02 11:37:17 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.40 2020/05/02 17:14:01 bouyer Exp $"); #include "opt_xen.h" @@ -71,6 +71,44 @@ ENTRY(lidt) lidt (%eax) ret END(lidt) + +ENTRY(x86_hotpatch) + /* save EFLAGS, and disable intrs */ + pushfl + cli + + /* save CR0, and disable WP */ + movl %cr0,%ecx + pushl %ecx + andl $~CR0_WP,%ecx + movl %ecx,%cr0 + + pushl 4*4(%esp) /* arg2 */ + pushl 4*4(%esp) /* arg1 */ + call _C_LABEL(x86_hotpatch_apply) + addl $2*4,%esp + + /* write back and invalidate cache */ + wbinvd + + /* restore CR0 */ + popl %ecx + movl %ecx,%cr0 + + /* flush instruction pipeline */ + pushl %eax + call x86_flush + popl %eax + + /* clean up */ + pushl %eax + call _C_LABEL(x86_hotpatch_cleanup) + addl $4,%esp + + /* restore RFLAGS */ + popfl + ret +END(x86_hotpatch) #endif /* XENPV */ ENTRY(x86_read_flags) @@ -274,41 +312,3 @@ ENTRY(outl) outl %eax, %dx ret END(outl) - -ENTRY(x86_hotpatch) - /* save EFLAGS, and disable intrs */ - pushfl - cli - - /* save CR0, and disable WP */ - movl %cr0,%ecx - pushl %ecx - andl $~CR0_WP,%ecx - movl %ecx,%cr0 - - pushl 4*4(%esp) /* arg2 */ - pushl 4*4(%esp) /* arg1 */ - call _C_LABEL(x86_hotpatch_apply) - addl $2*4,%esp - - /* write back and invalidate cache */ - wbinvd - - /* restore CR0 */ - popl %ecx - movl %ecx,%cr0 - - /* flush instruction pipeline */ - pushl %eax - call x86_flush - popl %eax - - /* clean up */ - pushl %eax - call _C_LABEL(x86_hotpatch_cleanup) - addl $4,%esp - - /* restore RFLAGS */ - popfl - ret -END(x86_hotpatch)
CVS commit: src/doc
Module Name:src Committed By: bouyer Date: Sat May 2 17:11:25 UTC 2020 Modified Files: src/doc: CHANGES Log Message: Note Xen PVH support To generate a diff of this commit: cvs rdiff -u -r1.2682 -r1.2683 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/CHANGES diff -u src/doc/CHANGES:1.2682 src/doc/CHANGES:1.2683 --- src/doc/CHANGES:1.2682 Mon Apr 27 18:08:25 2020 +++ src/doc/CHANGES Sat May 2 17:11:25 2020 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2682 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2683 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -186,3 +186,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0: tzdata updated to 2020a [kre 20200425] amd64, i386: Added support for Xen PV drivers under HVM guests. [bouyer 20200425] + xen: Added support for Xen PVH. [bouyer 20200502]
CVS commit: src/sys/arch/xen/conf
Module Name:src Committed By: bouyer Date: Sat May 2 16:46:06 UTC 2020 Modified Files: src/sys/arch/xen/conf: files.xen Log Message: This is called pvh_consinit not hvm_consinit To generate a diff of this commit: cvs rdiff -u -r1.183 -r1.184 src/sys/arch/xen/conf/files.xen Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.183 src/sys/arch/xen/conf/files.xen:1.184 --- src/sys/arch/xen/conf/files.xen:1.183 Sat May 2 16:44:36 2020 +++ src/sys/arch/xen/conf/files.xen Sat May 2 16:46:06 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.183 2020/05/02 16:44:36 bouyer Exp $ +# $NetBSD: files.xen,v 1.184 2020/05/02 16:46:06 bouyer Exp $ defflag opt_xen.h XEN XENPVH XENPVHVM PAE @@ -11,7 +11,7 @@ file arch/xen/x86/xen_mainbus.c xen file arch/xen/xen/xen_clock.c xen file arch/xen/x86/xen_bus_dma.c xen -file arch/xen/x86/hvm_consinit.c xenpvhvm +file arch/xen/x86/pvh_consinit.c xenpvhvm define hypervisorbus {} define xendevbus {}
CVS commit: src/sys/arch
Module Name:src Committed By: bouyer Date: Sat May 2 16:44:36 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: autoconf.c genassym.cf locore.S machdep.c src/sys/arch/amd64/conf: GENERIC src/sys/arch/i386/i386: autoconf.c genassym.cf locore.S machdep.c src/sys/arch/x86/acpi: acpi_machdep.c src/sys/arch/x86/include: cpu.h src/sys/arch/x86/isa: clock.c isa_machdep.c src/sys/arch/x86/x86: consinit.c cpu.c lapic.c pmap.c x86_autoconf.c x86_machdep.c src/sys/arch/xen/conf: Makefile.xen files.xen src/sys/arch/xen/include: hypervisor.h xen.h src/sys/arch/xen/x86: autoconf.c hypervisor_machdep.c x86_xpmap.c xen_mainbus.c src/sys/arch/xen/xen: hypervisor.c xen_clock.c xen_machdep.c Added Files: src/sys/arch/xen/x86: pvh_consinit.c Log Message: Introduce Xen PVH support in GENERIC. This is compiled in with options XENPVHVM x86 changes: - add Xen section and xen pvh entry points to locore.S. Set vm_guest to VM_GUEST_XENPVH in this entry point. Most of the boot procedure (especially page table setup and switch to paged mode) is shared with native. - change some x86_delay() to delay_func(), which points to x86_delay() for native/HVM, and xen_delay() for PVH Xen changes: - remove Xen bits from init_x86_64_ksyms() and init386_ksyms() and move to xen_init_ksyms(), used for both PV and PVH - set ISA no-legacy-devices property for PVH - factor out code from Xen's cpu_bootconf() to xen_bootconf() in xen_machdep.c - set up a specific pvh_consinit() which starts with printk() (which uses a simple hypercall that is available early) and switch to xencons when we can use pmap_kenter_pa(). To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/arch/amd64/amd64/autoconf.c cvs rdiff -u -r1.83 -r1.84 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.205 -r1.206 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.351 -r1.352 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.566 -r1.567 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.106 -r1.107 src/sys/arch/i386/i386/autoconf.c cvs rdiff -u -r1.121 -r1.122 src/sys/arch/i386/i386/genassym.cf cvs rdiff -u -r1.181 -r1.182 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.828 -r1.829 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/x86/acpi/acpi_machdep.c cvs rdiff -u -r1.124 -r1.125 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.37 -r1.38 src/sys/arch/x86/isa/clock.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x86/isa/isa_machdep.c cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x86/x86/consinit.c cvs rdiff -u -r1.188 -r1.189 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.77 -r1.78 src/sys/arch/x86/x86/lapic.c cvs rdiff -u -r1.386 -r1.387 src/sys/arch/x86/x86/pmap.c cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/x86/x86_autoconf.c cvs rdiff -u -r1.140 -r1.141 src/sys/arch/x86/x86/x86_machdep.c cvs rdiff -u -r1.49 -r1.50 src/sys/arch/xen/conf/Makefile.xen cvs rdiff -u -r1.182 -r1.183 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.51 -r1.52 src/sys/arch/xen/include/hypervisor.h cvs rdiff -u -r1.46 -r1.47 src/sys/arch/xen/include/xen.h cvs rdiff -u -r1.24 -r1.25 src/sys/arch/xen/x86/autoconf.c cvs rdiff -u -r1.38 -r1.39 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r0 -r1.1 src/sys/arch/xen/x86/pvh_consinit.c cvs rdiff -u -r1.85 -r1.86 src/sys/arch/xen/x86/x86_xpmap.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/xen/x86/xen_mainbus.c cvs rdiff -u -r1.78 -r1.79 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/xen/xen/xen_clock.c cvs rdiff -u -r1.23 -r1.24 src/sys/arch/xen/xen/xen_machdep.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/amd64/amd64/autoconf.c diff -u src/sys/arch/amd64/amd64/autoconf.c:1.29 src/sys/arch/amd64/amd64/autoconf.c:1.30 --- src/sys/arch/amd64/amd64/autoconf.c:1.29 Fri Dec 27 12:51:56 2019 +++ src/sys/arch/amd64/amd64/autoconf.c Sat May 2 16:44:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.29 2019/12/27 12:51:56 ad Exp $ */ +/* $NetBSD: autoconf.c,v 1.30 2020/05/02 16:44:34 bouyer Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29 2019/12/27 12:51:56 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.30 2020/05/02 16:44:34 bouyer Exp $"); #include "opt_multiprocessor.h" #include "opt_intrdebug.h" @@ -92,7 +92,14 @@ extern void platform_init(void); void cpu_configure(void) { +#ifdef XEN + if (vm_guest == VM_GUEST_XENPVH) + xen_startrtclock(); + else + startrtclock(); +#else startrtclock(); +#endif #if NBIOS32 > 0 efi_init(); Index: src/sys/arch/amd64/amd64/genassym.cf diff -u src/sys/arch/amd64/amd64/genassym.cf:1.83 src/sys/arch/amd64/amd64/genassym.cf:1.84 --- src/sys/arch/amd64/amd64/genassym.cf:1.83 Sat Apr
CVS commit: [netbsd-9] src/doc
Module Name:src Committed By: martin Date: Sat May 2 16:31:44 UTC 2020 Modified Files: src/doc [netbsd-9]: CHANGES-9.1 Log Message: Tickets #882 - #884 To generate a diff of this commit: cvs rdiff -u -r1.1.2.50 -r1.1.2.51 src/doc/CHANGES-9.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-9.1 diff -u src/doc/CHANGES-9.1:1.1.2.50 src/doc/CHANGES-9.1:1.1.2.51 --- src/doc/CHANGES-9.1:1.1.2.50 Fri May 1 11:55:45 2020 +++ src/doc/CHANGES-9.1 Sat May 2 16:31:44 2020 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-9.1,v 1.1.2.50 2020/05/01 11:55:45 martin Exp $ +# $NetBSD: CHANGES-9.1,v 1.1.2.51 2020/05/02 16:31:44 martin Exp $ A complete list of changes from the NetBSD 9.0 release to the NetBSD 9.1 release: @@ -2408,3 +2408,20 @@ sys/kern/vfs_mount.c1.82 Reopens PR kern/54969: Disk cache is no longer flushed on shutdown. [hannken, ticket #881] +etc/rc.d/random_seed1.9 + + Fix random_seed interruption window. + [riastradh, ticket #882] + +sys/arch/aarch64/aarch64/netbsd32_machdep.c 1.11 + + PR evbarm/55200: fix inverted logic in NETBSD32 user signal stack + handling. + [tnn, ticket #883] + +sys/arch/aarch64/aarch64/cpu_machdep.c 1.9 +sys/arch/aarch64/aarch64/sig_machdep.c 1.5 + + aarch64: fix sigaltstack(2) + [tnn, ticket #884] +
CVS commit: [netbsd-9] src/sys/arch/aarch64/aarch64
Module Name:src Committed By: martin Date: Sat May 2 16:30:08 UTC 2020 Modified Files: src/sys/arch/aarch64/aarch64 [netbsd-9]: cpu_machdep.c sig_machdep.c Log Message: Pull up following revision(s) (requested by tnn in ticket #884): sys/arch/aarch64/aarch64/sig_machdep.c: revision 1.5 sys/arch/aarch64/aarch64/cpu_machdep.c: revision 1.9 aarch64: handle _UC_SETSTACK and _UC_CLRSTACK like on arm32 ok ryo@ To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.6.4.1 src/sys/arch/aarch64/aarch64/cpu_machdep.c cvs rdiff -u -r1.3 -r1.3.4.1 src/sys/arch/aarch64/aarch64/sig_machdep.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/aarch64/aarch64/cpu_machdep.c diff -u src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.6 src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.6.4.1 --- src/sys/arch/aarch64/aarch64/cpu_machdep.c:1.6 Fri Aug 3 17:04:30 2018 +++ src/sys/arch/aarch64/aarch64/cpu_machdep.c Sat May 2 16:30:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_machdep.c,v 1.6 2018/08/03 17:04:30 ryo Exp $ */ +/* $NetBSD: cpu_machdep.c,v 1.6.4.1 2020/05/02 16:30:08 martin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: cpu_machdep.c,v 1.6 2018/08/03 17:04:30 ryo Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu_machdep.c,v 1.6.4.1 2020/05/02 16:30:08 martin Exp $"); #include "opt_multiprocessor.h" @@ -197,6 +197,8 @@ cpu_getmcontext(struct lwp *l, mcontext_ int cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) { + struct proc * const p = l->l_proc; + if (flags & _UC_CPU) { struct trapframe * const tf = l->l_md.md_utf; int error = cpu_mcontext_validate(l, mcp); @@ -215,6 +217,13 @@ cpu_setmcontext(struct lwp *l, const mco pcb->pcb_fpregs = *(const struct fpreg *)>__fregs; } + mutex_enter(p->p_lock); + if (flags & _UC_SETSTACK) + l->l_sigstk.ss_flags |= SS_ONSTACK; + if (flags & _UC_CLRSTACK) + l->l_sigstk.ss_flags &= ~SS_ONSTACK; + mutex_exit(p->p_lock); + return 0; } Index: src/sys/arch/aarch64/aarch64/sig_machdep.c diff -u src/sys/arch/aarch64/aarch64/sig_machdep.c:1.3 src/sys/arch/aarch64/aarch64/sig_machdep.c:1.3.4.1 --- src/sys/arch/aarch64/aarch64/sig_machdep.c:1.3 Tue Jul 17 00:36:30 2018 +++ src/sys/arch/aarch64/aarch64/sig_machdep.c Sat May 2 16:30:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sig_machdep.c,v 1.3 2018/07/17 00:36:30 christos Exp $ */ +/* $NetBSD: sig_machdep.c,v 1.3.4.1 2020/05/02 16:30:08 martin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: sig_machdep.c,v 1.3 2018/07/17 00:36:30 christos Exp $"); +__KERNEL_RCSID(1, "$NetBSD: sig_machdep.c,v 1.3.4.1 2020/05/02 16:30:08 martin Exp $"); #include #include @@ -71,6 +71,8 @@ sendsig_siginfo(const ksiginfo_t *ksi, c uc.uc_flags = _UC_SIGMASK; uc.uc_sigmask = *mask; uc.uc_link = l->l_ctxlink; + uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK) + ? _UC_SETSTACK : _UC_CLRSTACK; sendsig_reset(l, ksi->ksi_signo); mutex_exit(p->p_lock); cpu_getmcontext(l, _mcontext, _flags);
CVS commit: src/sys/arch
Module Name:src Committed By: maxv Date: Sat May 2 16:28:37 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S machdep.c src/sys/arch/amd64/include: asan.h src/sys/arch/x86/x86: pmap.c Log Message: Call kasan_early_init earlier, to unbreak KASAN after the recent RNG changes. Will also prevent further trouble. To generate a diff of this commit: cvs rdiff -u -r1.204 -r1.205 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.350 -r1.351 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/amd64/include/asan.h cvs rdiff -u -r1.385 -r1.386 src/sys/arch/x86/x86/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/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.204 src/sys/arch/amd64/amd64/locore.S:1.205 --- src/sys/arch/amd64/amd64/locore.S:1.204 Thu Apr 30 17:21:12 2020 +++ src/sys/arch/amd64/amd64/locore.S Sat May 2 16:28:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.204 2020/04/30 17:21:12 maxv Exp $ */ +/* $NetBSD: locore.S,v 1.205 2020/05/02 16:28:37 maxv Exp $ */ /* * Copyright-o-rama! @@ -150,6 +150,7 @@ #include +#include "opt_kasan.h" #include "opt_copy_symtab.h" #include "opt_ddb.h" #include "opt_ddbparam.h" @@ -973,6 +974,10 @@ longmode_hi: pushq %rdi call _C_LABEL(init_bootspace) +#ifdef KASAN + movq _C_LABEL(lwp0uarea)(%rip),%rdi + call _C_LABEL(kasan_early_init) +#endif call _C_LABEL(init_slotspace) popq %rdi call _C_LABEL(init_x86_64) Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.350 src/sys/arch/amd64/amd64/machdep.c:1.351 --- src/sys/arch/amd64/amd64/machdep.c:1.350 Thu Apr 30 03:29:19 2020 +++ src/sys/arch/amd64/amd64/machdep.c Sat May 2 16:28:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.350 2020/04/30 03:29:19 riastradh Exp $ */ +/* $NetBSD: machdep.c,v 1.351 2020/05/02 16:28:37 maxv Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.350 2020/04/30 03:29:19 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.351 2020/05/02 16:28:37 maxv Exp $"); #include "opt_modular.h" #include "opt_user_ldt.h" @@ -1570,7 +1570,7 @@ init_bootspace(void) bootspace.emodule = KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2; } -static void __noasan +static void init_pte(void) { #ifndef XENPV @@ -1586,7 +1586,7 @@ init_pte(void) normal_pdes[2] = L4_BASE; } -void __noasan +void init_slotspace(void) { vaddr_t va; @@ -1656,7 +1656,7 @@ init_slotspace(void) #endif } -void __noasan +void init_x86_64(paddr_t first_avail) { extern void consinit(void); @@ -1678,8 +1678,6 @@ init_x86_64(paddr_t first_avail) init_pte(); - kasan_early_init((void *)lwp0uarea); - uvm_lwp_setuarea(, lwp0uarea); cpu_probe(_info_primary); Index: src/sys/arch/amd64/include/asan.h diff -u src/sys/arch/amd64/include/asan.h:1.5 src/sys/arch/amd64/include/asan.h:1.6 --- src/sys/arch/amd64/include/asan.h:1.5 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/amd64/include/asan.h Sat May 2 16:28:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: asan.h,v 1.5 2020/04/25 15:26:16 bouyer Exp $ */ +/* $NetBSD: asan.h,v 1.6 2020/05/02 16:28:37 maxv Exp $ */ /* * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -48,25 +48,17 @@ #define KASAN_MD_SHADOW_START (VA_SIGN_NEG((L4_SLOT_KASAN * NBPD_L4))) #define KASAN_MD_SHADOW_END (KASAN_MD_SHADOW_START + __MD_SHADOW_SIZE) +/* -- */ + +/* + * Early mapping, used to map just the stack at boot time. We rely on the fact + * that VA = PA + KERNBASE. + */ + static bool __md_early __read_mostly = true; static uint8_t __md_earlypages[8 * PAGE_SIZE] __aligned(PAGE_SIZE); static size_t __md_earlytaken = 0; -static inline int8_t * -kasan_md_addr_to_shad(const void *addr) -{ - vaddr_t va = (vaddr_t)addr; - return (int8_t *)(KASAN_MD_SHADOW_START + - ((va - __MD_CANONICAL_BASE) >> KASAN_SHADOW_SCALE_SHIFT)); -} - -static inline bool -kasan_md_unsupported(vaddr_t addr) -{ - return (addr >= (vaddr_t)PTE_BASE && - addr < ((vaddr_t)PTE_BASE + NBPD_L4)); -} - static paddr_t __md_early_palloc(void) { @@ -82,18 +74,60 @@ __md_early_palloc(void) return ret; } -static paddr_t -__md_palloc(void) +static void +__md_early_shadow_map_page(vaddr_t va) { + extern struct bootspace bootspace; + const pt_entry_t pteflags = PTE_W | pmap_pg_nx | PTE_P; + pt_entry_t *pdir = (pt_entry_t *)bootspace.pdir; paddr_t pa; - if (__predict_false(__md_early)) + if (!pmap_valid_entry(pdir[pl4_pi(va)])) { + pa = __md_early_palloc(); + pdir[pl4_pi(va)] = pa | pteflags; + } + pdir = (pt_entry_t *)((pdir[pl4_pi(va)] & PTE_FRAME) + KERNBASE); + + if (!pmap_valid_entry(pdir[pl3_pi(va)])) { + pa = __md_early_palloc(); + pdir[pl3_pi(va)] = pa | pteflags; +
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: maxv Date: Sat May 2 16:25:47 UTC 2020 Modified Files: src/sys/arch/x86/x86: patch.c Log Message: Remove the D bit as part of the hotpatch cleanup procedure. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/arch/x86/x86/patch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/patch.c diff -u src/sys/arch/x86/x86/patch.c:1.47 src/sys/arch/x86/x86/patch.c:1.48 --- src/sys/arch/x86/x86/patch.c:1.47 Sat May 2 11:37:17 2020 +++ src/sys/arch/x86/x86/patch.c Sat May 2 16:25:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: patch.c,v 1.47 2020/05/02 11:37:17 maxv Exp $ */ +/* $NetBSD: patch.c,v 1.48 2020/05/02 16:25:47 maxv Exp $ */ /*- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.47 2020/05/02 11:37:17 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.48 2020/05/02 16:25:47 maxv Exp $"); #include "opt_lockdebug.h" #ifdef i386 @@ -49,6 +49,9 @@ __KERNEL_RCSID(0, "$NetBSD: patch.c,v 1. #include #include +#include +#include + #include #include @@ -256,6 +259,45 @@ x86_hotpatch_apply(uint8_t name, uint8_t return 0; } +#ifdef __x86_64__ +/* + * The CPU added the D bit on the text pages while we were writing to them. + * Remove that bit. Kinda annoying, but we can't avoid it. + */ +static void +remove_d_bit(void) +{ + extern struct bootspace bootspace; + pt_entry_t pte; + vaddr_t va; + size_t i, n; + + for (i = 0; i < BTSPACE_NSEGS; i++) { + if (bootspace.segs[i].type != BTSEG_TEXT) + continue; + va = bootspace.segs[i].va; + n = 0; + while (n < bootspace.segs[i].sz) { + if (L2_BASE[pl2_i(va)] & PTE_PS) { +pte = L2_BASE[pl2_i(va)] & ~PTE_D; +pmap_pte_set(_BASE[pl2_i(va)], pte); +n += NBPD_L2; +va += NBPD_L2; + } else { +pte = L1_BASE[pl1_i(va)] & ~PTE_D; +pmap_pte_set(_BASE[pl1_i(va)], pte); +n += NBPD_L1; +va += NBPD_L1; + } + } + } + + tlbflushg(); +} +#else +#define remove_d_bit() __nothing +#endif + /* * Interrupts disabled here. Called from ASM only, prototype not public. */ @@ -266,6 +308,8 @@ x86_hotpatch_cleanup(int retval) if (retval != 0) { panic("x86_hotpatch_apply failed"); } + + remove_d_bit(); } /* -- */
CVS commit: [netbsd-9] src/sys/arch/aarch64/aarch64
Module Name:src Committed By: martin Date: Sat May 2 16:26:04 UTC 2020 Modified Files: src/sys/arch/aarch64/aarch64 [netbsd-9]: netbsd32_machdep.c Log Message: Pull up following revision(s) (requested by tnn in ticket #883): sys/arch/aarch64/aarch64/netbsd32_machdep.c: revision 1.11 fix inverted logic in NETBSD32 user signal stack handling (PR evbarm/55200) To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.2.1 src/sys/arch/aarch64/aarch64/netbsd32_machdep.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/aarch64/aarch64/netbsd32_machdep.c diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7.2.1 --- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.7 Fri Jul 12 06:44:49 2019 +++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c Sat May 2 16:26:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.7 2019/07/12 06:44:49 skrll Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.7.2.1 2020/05/02 16:26:04 martin Exp $ */ /* * Copyright (c) 2018 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7 2019/07/12 06:44:49 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7.2.1 2020/05/02 16:26:04 martin Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -218,7 +218,7 @@ netbsd32_sendsig_siginfo(const ksiginfo_ int error; const bool onstack_p = - (ss->ss_flags & (SS_DISABLE | SS_ONSTACK)) && + (ss->ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 && (sa->sa_flags & SA_ONSTACK); vaddr_t sp = onstack_p ?
CVS commit: [netbsd-9] src/etc/rc.d
Module Name:src Committed By: martin Date: Sat May 2 16:24:11 UTC 2020 Modified Files: src/etc/rc.d [netbsd-9]: random_seed Log Message: Pull up following revision(s) (requested by riastradh in ticket #882): etc/rc.d/random_seed: revision 1.9 Don't delete the random seed before issuing `rndctl -S'. `rndctl -S' can replace the file just fine, and deleting it ahead of time adds a window during which we can lose the seed altogether if the system is interrupted by a crash or power outage. XXX pullup To generate a diff of this commit: cvs rdiff -u -r1.7.26.1 -r1.7.26.2 src/etc/rc.d/random_seed Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/rc.d/random_seed diff -u src/etc/rc.d/random_seed:1.7.26.1 src/etc/rc.d/random_seed:1.7.26.2 --- src/etc/rc.d/random_seed:1.7.26.1 Sun Mar 1 11:53:09 2020 +++ src/etc/rc.d/random_seed Sat May 2 16:24:11 2020 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: random_seed,v 1.7.26.1 2020/03/01 11:53:09 martin Exp $ +# $NetBSD: random_seed,v 1.7.26.2 2020/05/02 16:24:11 martin Exp $ # # PROVIDE: random_seed @@ -93,8 +93,6 @@ random_save() oum="$(umask)" umask 077 - rm -Pf "${random_file}" - if ! fs_safe "$(dirname "${random_file}")"; then umask "${oum}" return 1
CVS commit: src/lib/libkvm
Module Name:src Committed By: christos Date: Sat May 2 14:31:13 UTC 2020 Modified Files: src/lib/libkvm: kvm.c Log Message: Cast off_t to size_t to appease lint: warning: conversion from 'long long' to 'int' may lose accuracy To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/lib/libkvm/kvm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libkvm/kvm.c diff -u src/lib/libkvm/kvm.c:1.108 src/lib/libkvm/kvm.c:1.109 --- src/lib/libkvm/kvm.c:1.108 Tue Apr 28 10:27:41 2020 +++ src/lib/libkvm/kvm.c Sat May 2 10:31:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kvm.c,v 1.108 2020/04/28 14:27:41 christos Exp $ */ +/* $NetBSD: kvm.c,v 1.109 2020/05/02 14:31:13 christos Exp $ */ /*- * Copyright (c) 1989, 1992, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94"; #else -__RCSID("$NetBSD: kvm.c,v 1.108 2020/04/28 14:27:41 christos Exp $"); +__RCSID("$NetBSD: kvm.c,v 1.109 2020/05/02 14:31:13 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -182,7 +182,7 @@ _kvm_pread(kvm_t *kd, int fd, void *buf, errno = EINVAL; return -1; } - memcpy(buf, (char *)kd->dump_mem + off, size); + memcpy(buf, (char *)kd->dump_mem + (size_t)off, size); return size; } @@ -224,7 +224,7 @@ _kvm_pwrite(kvm_t *kd, const void *buf, errno = EINVAL; return -1; } - memcpy(mem + off, buf, size); + memcpy(mem + (size_t)off, buf, size); return size; }
CVS commit: src/sys/gdbscripts
Module Name:src Committed By: christos Date: Sat May 2 12:58:46 UTC 2020 Modified Files: src/sys/gdbscripts: modload Log Message: gdb has been fixed, so no need to reload the symbol file. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/gdbscripts/modload Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/gdbscripts/modload diff -u src/sys/gdbscripts/modload:1.2 src/sys/gdbscripts/modload:1.3 --- src/sys/gdbscripts/modload:1.2 Fri May 1 13:00:42 2020 +++ src/sys/gdbscripts/modload Sat May 2 08:58:46 2020 @@ -1,7 +1,5 @@ -# $NetBSD: modload,v 1.2 2020/05/01 17:00:42 christos Exp $ +# $NetBSD: modload,v 1.3 2020/05/02 12:58:46 christos Exp $ # Load the symbol files for all active modules -# Note that you need to re-run add-symbol-file netbsd.gdb after you -# load the modules. define modload set $h = module_list set $e = $h.tqh_first
CVS commit: src/external/gpl3/gdb/dist/gdb
Module Name:src Committed By: christos Date: Sat May 2 12:56:55 UTC 2020 Modified Files: src/external/gpl3/gdb/dist/gdb: bsd-kvm.c Log Message: Switch to the current thread, and reload the symbol file. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/external/gpl3/gdb/dist/gdb/bsd-kvm.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/gpl3/gdb/dist/gdb/bsd-kvm.c diff -u src/external/gpl3/gdb/dist/gdb/bsd-kvm.c:1.16 src/external/gpl3/gdb/dist/gdb/bsd-kvm.c:1.17 --- src/external/gpl3/gdb/dist/gdb/bsd-kvm.c:1.16 Thu May 30 17:43:23 2019 +++ src/external/gpl3/gdb/dist/gdb/bsd-kvm.c Sat May 2 08:56:55 2020 @@ -28,6 +28,7 @@ #include "value.h" #include "gdbcore.h" #include "inferior.h" /* for get_exec_file */ +#include "symfile.h" #include "gdbthread.h" #include "arch-utils.h" @@ -144,9 +145,12 @@ bsd_kvm_target_open (const char *arg, in inf->gdbarch = get_current_arch (); - add_thread_silent (bsd_kvm_ptid); + thread_info *tp = add_thread_silent (bsd_kvm_ptid); + switch_to_thread(tp); inferior_ptid = bsd_kvm_ptid; + symbol_file_add_main(execfile, 0); + target_fetch_registers (get_current_regcache (), -1); reinit_frame_cache ();
CVS commit: src
Module Name:src Committed By: maxv Date: Sat May 2 11:37:17 UTC 2020 Modified Files: src/external/cddl/osnet/dev/fbt/x86: fbt_isa.c src/sys/arch/amd64/amd64: cpufunc.S src/sys/arch/i386/i386: cpufunc.S src/sys/arch/x86/include: cpufunc.h src/sys/arch/x86/x86: patch.c spectre.c svs.c Log Message: Modify the hotpatch mechanism, in order to make it much less ROP-friendly. Currently x86_patch_window_open is a big problem, because it is a perfect function to inject/modify executable code with ROP. - Remove x86_patch_window_open(), along with its x86_patch_window_close() counterpart. - Introduce a read-only link-set of hotpatch descriptor structures, which reference a maximum of two read-only hotpatch sources. - Modify x86_hotpatch() to open a window and call the new x86_hotpatch_apply() function in a hard-coded manner. - Modify x86_hotpatch() to take a name and a selector, and have x86_hotpatch_apply() resolve the descriptor from the name and the source from the selector, before hotpatching. - Move the error handling in a separate x86_hotpatch_cleanup() function, that gets called after we closed the window. The resulting implementation is a bit complex and non-obvious. But it gains the following properties: the code executed in the hotpatch window is strictly hard-coded (no callback and no possibility to execute your own code in the window) and the pointers this code accesses are strictly read-only (no possibility to forge pointers to hotpatch an area that was not designated as hotpatchable at compile-time, and no possibility to choose what bytes to write other than the maximum of two read-only templates that were designated as valid for the given destination at compile-time). With current CPUs this slightly improves a situation that is already pretty bad by definition on x86. Assuming CET however, this change closes a big hole and is kinda great. The only ~problem there is, is that dtrace-fbt tries to hotpatch random places with random bytes, and there is just no way to make it safe. However dtrace is only in a module, that is rarely used and never compiled into the kernel, so it's not a big problem; add a shitty & vulnerable independent hotpatch window in it, and leave big XXXs. It looks like fbt is going to collapse soon anyway. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/amd64/cpufunc.S cvs rdiff -u -r1.38 -r1.39 src/sys/arch/i386/i386/cpufunc.S cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/include/cpufunc.h cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/x86/patch.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/x86/spectre.c \ src/sys/arch/x86/x86/svs.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/dev/fbt/x86/fbt_isa.c diff -u src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.2 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.3 --- src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.2 Wed Nov 13 10:13:41 2019 +++ src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c Sat May 2 11:37:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fbt_isa.c,v 1.2 2019/11/13 10:13:41 maxv Exp $ */ +/* $NetBSD: fbt_isa.c,v 1.3 2020/05/02 11:37:17 maxv Exp $ */ /* * CDDL HEADER START @@ -172,18 +172,40 @@ fbt_patch_tracepoint(fbt_probe_t *fbt, f #endif #ifdef __NetBSD__ +/* + * XXX XXX XXX This is absolutely unsafe, the mere existence of this code is a + * problem, because this function is too easily ROP-able. But this gets + * compiled as a module and never in the kernel, so we are fine "by default". + * XXX Add a #warning if it gets compiled in the kernel? + */ void fbt_patch_tracepoint(fbt_probe_t *fbt, fbt_patchval_t val) { u_long psl, cr0; - x86_patch_window_open(, ); + /* Disable interrupts. */ + psl = x86_read_psl(); + x86_disable_intr(); + + /* Disable write protection in supervisor mode. */ + cr0 = rcr0(); + lcr0(cr0 & ~CR0_WP); + /* XXX XXX XXX Shouldn't rely on caller-provided dst! */ + /* XXX XXX XXX Shouldn't rely on caller-provided val! */ for (; fbt != NULL; fbt = fbt->fbtp_next) { *fbt->fbtp_patchpoint = val; } - x86_patch_window_close(psl, cr0); + /* Write back and invalidate cache, flush pipelines. */ + wbinvd(); + x86_flush(); + + /* Re-enable write protection. */ + lcr0(cr0); + + /* Restore the PSL, potentially re-enabling interrupts. */ + x86_write_psl(psl); } #endif Index: src/sys/arch/amd64/amd64/cpufunc.S diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.49 src/sys/arch/amd64/amd64/cpufunc.S:1.50 --- src/sys/arch/amd64/amd64/cpufunc.S:1.49 Thu Nov 21 19:23:58 2019 +++ src/sys/arch/amd64/amd64/cpufunc.S Sat May 2 11:37:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufunc.S,v 1.49 2019/11/21 19:23:58 ad Exp $ */ +/* $NetBSD: cpufunc.S,v 1.50 2020/05/02 11:37:17 maxv Exp $ */ /* * Copyright (c) 1998,
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: jdolecek Date: Sat May 2 11:28:02 UTC 2020 Modified Files: src/sys/arch/xen/xen: xennetback_xenbus.c Log Message: fix gref offset when setting up copy of multi-fragment packet so data for second and further fragments gets copied into correct place To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/arch/xen/xen/xennetback_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xennetback_xenbus.c diff -u src/sys/arch/xen/xen/xennetback_xenbus.c:1.101 src/sys/arch/xen/xen/xennetback_xenbus.c:1.102 --- src/sys/arch/xen/xen/xennetback_xenbus.c:1.101 Fri May 1 19:59:47 2020 +++ src/sys/arch/xen/xen/xennetback_xenbus.c Sat May 2 11:28:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xennetback_xenbus.c,v 1.101 2020/05/01 19:59:47 jdolecek Exp $ */ +/* $NetBSD: xennetback_xenbus.c,v 1.102 2020/05/02 11:28:02 jdolecek Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.101 2020/05/01 19:59:47 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.102 2020/05/02 11:28:02 jdolecek Exp $"); #include "opt_xen.h" @@ -749,6 +749,7 @@ xennetback_tx_copy_process(struct ifnet } gsize = xst->xs_tx_size; + goff = 0; for (; seg < dm->dm_nsegs && gsize > 0; seg++) { bus_dma_segment_t *ds = >dm_segs[seg]; ma = ds->ds_addr; @@ -787,6 +788,7 @@ xennetback_tx_copy_process(struct ifnet segoff = 0; } KASSERT(gsize == 0); + KASSERT(goff == xst->xs_tx_size); } if (copycnt > 0) { if (xennetback_copy(ifp, xneti->xni_gop_copy, copycnt) != 0) @@ -931,6 +933,7 @@ mbuf_fail: * Flush queue if too full to fit this * new packet whole. */ +KASSERT(m0 == NULL); xennetback_tx_copy_process(ifp, xneti, queued); queued = 0; }
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: maxv Date: Sat May 2 11:12:50 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: spl.S Log Message: Remove unused. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/arch/amd64/amd64/spl.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/spl.S diff -u src/sys/arch/amd64/amd64/spl.S:1.44 src/sys/arch/amd64/amd64/spl.S:1.45 --- src/sys/arch/amd64/amd64/spl.S:1.44 Sat Apr 25 15:26:16 2020 +++ src/sys/arch/amd64/amd64/spl.S Sat May 2 11:12:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: spl.S,v 1.44 2020/04/25 15:26:16 bouyer Exp $ */ +/* $NetBSD: spl.S,v 1.45 2020/05/02 11:12:49 maxv Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -187,7 +187,6 @@ ENTRY(softint_trigger) ret END(softint_trigger) - /* * Xrecurse_preempt() * @@ -255,10 +254,7 @@ ENTRY(spllower) 2: movq %r8,%rbx jmp _C_LABEL(Xspllower) - - .align 16 END(spllower) -LABEL(spllower_end) /* * void Xspllower(int s); @@ -277,9 +273,6 @@ LABEL(spllower_end) * the sending CPU will never see the that CPU accept the IPI * (see pmap_tlb_shootnow). */ - nop - .align 4 /* Avoid confusion with cx8_spllower_end */ - IDTVEC(spllower) pushq %rbx pushq %r13
CVS commit: src/share/mk
Module Name:src Committed By: rin Date: Sat May 2 09:15:30 UTC 2020 Modified Files: src/share/mk: bsd.kmodule.mk Log Message: Fix previous; add missing .kmod.debug to realall. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/share/mk/bsd.kmodule.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.kmodule.mk diff -u src/share/mk/bsd.kmodule.mk:1.66 src/share/mk/bsd.kmodule.mk:1.67 --- src/share/mk/bsd.kmodule.mk:1.66 Fri May 1 22:23:00 2020 +++ src/share/mk/bsd.kmodule.mk Sat May 2 09:15:30 2020 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.kmodule.mk,v 1.66 2020/05/01 22:23:00 christos Exp $ +# $NetBSD: bsd.kmodule.mk,v 1.67 2020/05/02 09:15:30 rin Exp $ # We are not building this with PIE MKPIE=no @@ -114,7 +114,7 @@ PROGDEBUG:= ${PROG}.debug .endif # Build rules -realall: ${PROG} +realall: ${PROG} ${PROGDEBUG} OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
CVS commit: src/sys/kern
Module Name:src Committed By: martin Date: Sat May 2 09:13:40 UTC 2020 Modified Files: src/sys/kern: kern_lock.c Log Message: Fix inverted condition in r1.136 - we do want LOCKDEBUG spinouts of the kernel lock to assert as soon as we have userland running - not in the early boot phase (where firmware loading and device init could take a long time). To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/sys/kern/kern_lock.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_lock.c diff -u src/sys/kern/kern_lock.c:1.170 src/sys/kern/kern_lock.c:1.171 --- src/sys/kern/kern_lock.c:1.170 Sun Mar 8 15:05:18 2020 +++ src/sys/kern/kern_lock.c Sat May 2 09:13:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lock.c,v 1.170 2020/03/08 15:05:18 ad Exp $ */ +/* $NetBSD: kern_lock.c,v 1.171 2020/05/02 09:13:40 martin Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2020 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.170 2020/03/08 15:05:18 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.171 2020/05/02 09:13:40 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_lockdebug.h" @@ -240,7 +240,7 @@ _kernel_lock(int nlocks) #ifdef LOCKDEBUG if (SPINLOCK_SPINOUT(spins)) { extern int start_init_exec; -if (!start_init_exec) +if (start_init_exec) _KERNEL_LOCK_ABORT("spinout"); } SPINLOCK_BACKOFF_HOOK;
CVS commit: src/sys/dev/scsipi
Module Name:src Committed By: jdc Date: Sat May 2 06:45:53 UTC 2020 Modified Files: src/sys/dev/scsipi: scsiconf.c Log Message: Don't attempt to read opcodes and their timeouts at attach time for old devices. The MAINTENANCE IN command was introduced with SCSI-3 and sending it to older peripherals can cause timeouts or them not to respond to further requests. To generate a diff of this commit: cvs rdiff -u -r1.286 -r1.287 src/sys/dev/scsipi/scsiconf.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/scsipi/scsiconf.c diff -u src/sys/dev/scsipi/scsiconf.c:1.286 src/sys/dev/scsipi/scsiconf.c:1.287 --- src/sys/dev/scsipi/scsiconf.c:1.286 Wed Feb 19 16:04:39 2020 +++ src/sys/dev/scsipi/scsiconf.c Sat May 2 06:45:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: scsiconf.c,v 1.286 2020/02/19 16:04:39 riastradh Exp $ */ +/* $NetBSD: scsiconf.c,v 1.287 2020/05/02 06:45:53 jdc Exp $ */ /*- * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.286 2020/02/19 16:04:39 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.287 2020/05/02 06:45:53 jdc Exp $"); #include #include @@ -1018,10 +1018,14 @@ scsi_probe_device(struct scsibus_softc * scsipi_insert_periph(chan, periph); /* - * determine supported opcodes and - * timeouts if available + * Determine supported opcodes and timeouts if available. + * Only do this on peripherals reporting SCSI version 3 + * or greater - this command isn't in the SCSI-2 spec. and + * it causes either timeouts or peripherals disappearing + * when sent to some SCSI-1 or SCSI-2 peripherals. */ - scsipi_get_opcodeinfo(periph); + if (periph->periph_version >= 3) + scsipi_get_opcodeinfo(periph); /* * XXX Can't assign periph_dev here, because we'll