CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sun Mar 20 00:41:01 UTC 2022 Modified Files: src/sys/dev/usb: ualea.c Log Message: ualea(4): Fix detach and error paths. - Set sc_needed before aborting the pipe to prevent the xfer callback from rescheduling itself. - Make sure all paths out of the xfer callback clear sc_inflight. While here, use device_printf instead of aprint_* after attach. Now my system survives repeated insertion and yanking of ualea(4) during: sysctl -w kern.entropy.depletion=1 cat /dev/null To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/ualea.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ualea.c diff -u src/sys/dev/usb/ualea.c:1.16 src/sys/dev/usb/ualea.c:1.17 --- src/sys/dev/usb/ualea.c:1.16 Sat Mar 19 11:37:06 2022 +++ src/sys/dev/usb/ualea.c Sun Mar 20 00:41:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ualea.c,v 1.16 2022/03/19 11:37:06 riastradh Exp $ */ +/* $NetBSD: ualea.c,v 1.17 2022/03/20 00:41:01 riastradh Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.16 2022/03/19 11:37:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.17 2022/03/20 00:41:01 riastradh Exp $"); #include #include @@ -159,6 +159,11 @@ ualea_detach(device_t self, int flags) if (sc->sc_attached) rnd_detach_source(>sc_rnd); + /* Prevent xfer from rescheduling itself, if still pending. */ + mutex_enter(>sc_lock); + sc->sc_needed = 0; + mutex_exit(>sc_lock); + /* Cancel pending xfer. */ if (sc->sc_pipe) usbd_abort_pipe(sc->sc_pipe); @@ -196,8 +201,8 @@ ualea_xfer(struct ualea_softc *sc) status = usbd_transfer(sc->sc_xfer); KASSERT(status != USBD_NORMAL_COMPLETION); /* asynchronous xfer */ if (status != USBD_IN_PROGRESS) { - aprint_error_dev(sc->sc_dev, "failed to issue xfer: %d\n", - status); + device_printf(sc->sc_dev, "failed to issue xfer: %s\n", + usbd_errstr(status)); /* We failed -- let someone else have a go. */ return; } @@ -227,14 +232,16 @@ ualea_xfer_done(struct usbd_xfer *xfer, /* Check the transfer status. */ if (status) { - aprint_error_dev(sc->sc_dev, "xfer failed: %d\n", status); - return; + device_printf(sc->sc_dev, "xfer failed: %s\n", + usbd_errstr(status)); + pktsize = 0; + goto out; } /* Get and sanity-check the transferred size. */ usbd_get_xfer_status(xfer, NULL, , , NULL); if (pktsize > sc->sc_maxpktsize) { - aprint_error_dev(sc->sc_dev, + device_printf(sc->sc_dev, "bogus packet size: %"PRIu32" > %"PRIu16" (max), ignoring" "\n", pktsize, sc->sc_maxpktsize);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sun Mar 20 00:41:01 UTC 2022 Modified Files: src/sys/dev/usb: ualea.c Log Message: ualea(4): Fix detach and error paths. - Set sc_needed before aborting the pipe to prevent the xfer callback from rescheduling itself. - Make sure all paths out of the xfer callback clear sc_inflight. While here, use device_printf instead of aprint_* after attach. Now my system survives repeated insertion and yanking of ualea(4) during: sysctl -w kern.entropy.depletion=1 cat /dev/null To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/usb/ualea.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sun Mar 20 00:40:52 UTC 2022 Modified Files: src/sys/dev/usb: usbdi.c Log Message: usbdi(9): Make sure aborting a pipe waits for all callbacks. There may be a callback in flight from an xfer that has already been taken off the queue by the time usbd_ar_pipe gets to it. We must guarantee that even that callback has completed before returning control to the caller. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.239 src/sys/dev/usb/usbdi.c:1.240 --- src/sys/dev/usb/usbdi.c:1.239 Sat Mar 19 10:05:52 2022 +++ src/sys/dev/usb/usbdi.c Sun Mar 20 00:40:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.239 2022/03/19 10:05:52 riastradh Exp $ */ +/* $NetBSD: usbdi.c,v 1.240 2022/03/20 00:40:52 riastradh Exp $ */ /* * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.239 2022/03/19 10:05:52 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.240 2022/03/20 00:40:52 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -1071,6 +1071,19 @@ usbd_ar_pipe(struct usbd_pipe *pipe) } } + /* + * There may be an xfer callback already in progress which was + * taken off the queue before we got to it. We must wait for + * the callback to finish before returning control to the + * caller. + */ + while (pipe->up_callingxfer) { + USBHIST_LOG(usbdebug, "wait for callback" + "pipe = %#jx xfer = %#jx", + (uintptr_t)pipe, (uintptr_t)pipe->up_callingxfer, 0, 0); + cv_wait(>up_callingcv, pipe->up_dev->ud_bus->ub_lock); + } + KASSERT(mutex_owned(pipe->up_dev->ud_bus->ub_lock)); KASSERTMSG(pipe->up_abortlwp == curlwp, "pipe->up_abortlwp=%p", pipe->up_abortlwp);
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sun Mar 20 00:40:52 UTC 2022 Modified Files: src/sys/dev/usb: usbdi.c Log Message: usbdi(9): Make sure aborting a pipe waits for all callbacks. There may be a callback in flight from an xfer that has already been taken off the queue by the time usbd_ar_pipe gets to it. We must guarantee that even that callback has completed before returning control to the caller. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sun Mar 20 00:19:11 UTC 2022 Modified Files: src/sys/kern: kern_entropy.c Log Message: entropy(9): Avoid reentrance to per-CPU state from sleeping on lock. Changing the global entropy lock from IPL_VM to IPL_SOFTSERIAL meant it went from being a spin lock, which blocks preemption, to being an adaptive lock, which might sleep -- and allow other threads to run concurrently with the softint, even if those threads have softints blocked with splsoftserial. This manifested as KASSERT(!ec->ec_locked) triggering in entropy_consolidate_xc -- presumably entropy_softintr slept on the global entropy lock while holding the per-CPU state locked with ec->ec_locked, and then entropy_consolidate_xc ran. Instead, to protect access to the per-CPU state without taking a global lock, defer entropy_account_cpu until after ec->ec_locked is cleared. This way, we never sleep while holding ec->ec_locked, nor do we incur any contention on shared memory when entering entropy unless we're about to distribute it. To verify this, sprinkle in assertions that curlwp->l_ncsw hasn't changed by the time we release ec->ec_locked. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_entropy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_entropy.c diff -u src/sys/kern/kern_entropy.c:1.41 src/sys/kern/kern_entropy.c:1.42 --- src/sys/kern/kern_entropy.c:1.41 Sat Mar 19 14:35:08 2022 +++ src/sys/kern/kern_entropy.c Sun Mar 20 00:19:11 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_entropy.c,v 1.41 2022/03/19 14:35:08 riastradh Exp $ */ +/* $NetBSD: kern_entropy.c,v 1.42 2022/03/20 00:19:11 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.41 2022/03/19 14:35:08 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.42 2022/03/20 00:19:11 riastradh Exp $"); #include #include @@ -678,6 +678,7 @@ static void entropy_account_cpu(struct entropy_cpu *ec) { unsigned diff; + int s; KASSERT(E->stage >= ENTROPY_WARM); @@ -690,12 +691,9 @@ entropy_account_cpu(struct entropy_cpu * __predict_true((time_uptime - E->timestamp) <= 60)) return; - /* If there's nothing pending, stop here. */ - if (ec->ec_pending == 0) - return; - /* Consider consolidation, under the lock. */ mutex_enter(>lock); + s = splsoftserial(); if (E->needed != 0 && E->needed <= ec->ec_pending) { /* * If we have not yet attained full entropy but we can @@ -750,6 +748,7 @@ entropy_account_cpu(struct entropy_cpu * entropy_partial_evcnt.ev_count++; } } + splx(s); mutex_exit(>lock); } @@ -799,7 +798,8 @@ static void entropy_enter(const void *buf, size_t len, unsigned nbits) { struct entropy_cpu *ec; - uint32_t pending; + unsigned pending; + uint64_t ncsw; int s; KASSERTMSG(!cpu_intr_p(), @@ -821,6 +821,7 @@ entropy_enter(const void *buf, size_t le s = splsoftserial(); KASSERT(!ec->ec_locked); ec->ec_locked = true; + ncsw = curlwp->l_ncsw; __insn_barrier(); /* Enter into the per-CPU pool. */ @@ -831,15 +832,17 @@ entropy_enter(const void *buf, size_t le pending += MIN(ENTROPY_CAPACITY*NBBY - pending, nbits); atomic_store_relaxed(>ec_pending, pending); - /* Consolidate globally if appropriate based on what we added. */ - entropy_account_cpu(ec); - /* Release the per-CPU state. */ KASSERT(ec->ec_locked); __insn_barrier(); + KASSERT(ncsw == curlwp->l_ncsw); ec->ec_locked = false; splx(s); percpu_putref(entropy_percpu); + + /* Consolidate globally if appropriate based on what we added. */ + if (pending) + entropy_account_cpu(ec); } /* @@ -935,6 +938,8 @@ static void entropy_softintr(void *cookie) { struct entropy_cpu *ec; + unsigned pending; + uint64_t ncsw; /* * Acquire the per-CPU state. Other users can lock this only @@ -944,6 +949,7 @@ entropy_softintr(void *cookie) ec = percpu_getref(entropy_percpu); KASSERT(!ec->ec_locked); ec->ec_locked = true; + ncsw = curlwp->l_ncsw; __insn_barrier(); /* Count statistics. */ @@ -952,14 +958,19 @@ entropy_softintr(void *cookie) /* Stir the pool if necessary. */ entpool_stir(ec->ec_pool); - /* Consolidate globally if appropriate based on what we added. */ - entropy_account_cpu(ec); + /* Determine if there's anything pending on this CPU. */ + pending = ec->ec_pending; /* Release the per-CPU state. */ KASSERT(ec->ec_locked); __insn_barrier(); + KASSERT(ncsw == curlwp->l_ncsw); ec->ec_locked = false; percpu_putref(entropy_percpu); + + /* Consolidate globally if appropriate based on what we added. */ + if (pending) + entropy_account_cpu(ec); } /* @@ -1092,6 +1103,7 @@ entropy_consolidate_xc(void *vpool, void uint8_t buf[ENTPOOL_CAPACITY]; uint32_t extra[7]; unsigned i = 0; +
CVS commit: src/sys/kern
Module Name:src Committed By: riastradh Date: Sun Mar 20 00:19:11 UTC 2022 Modified Files: src/sys/kern: kern_entropy.c Log Message: entropy(9): Avoid reentrance to per-CPU state from sleeping on lock. Changing the global entropy lock from IPL_VM to IPL_SOFTSERIAL meant it went from being a spin lock, which blocks preemption, to being an adaptive lock, which might sleep -- and allow other threads to run concurrently with the softint, even if those threads have softints blocked with splsoftserial. This manifested as KASSERT(!ec->ec_locked) triggering in entropy_consolidate_xc -- presumably entropy_softintr slept on the global entropy lock while holding the per-CPU state locked with ec->ec_locked, and then entropy_consolidate_xc ran. Instead, to protect access to the per-CPU state without taking a global lock, defer entropy_account_cpu until after ec->ec_locked is cleared. This way, we never sleep while holding ec->ec_locked, nor do we incur any contention on shared memory when entering entropy unless we're about to distribute it. To verify this, sprinkle in assertions that curlwp->l_ncsw hasn't changed by the time we release ec->ec_locked. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/kern/kern_entropy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src
Am 19.03.2022 um 16:28 schrieb Paul Goyette: Does this impact PR/51084 at all? PR/51084 is about MAKEVERBOSE as well, but it's a different part of the build infrastructure. So no, that PR is not yet fixed.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sat Mar 19 20:50:32 UTC 2022 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: usb: Insert assertion to diagnose ud_cdesc/ud_ifaces inconsistency. Syzbot found a way to see ud_cdesc=NULL but ud_ifaces!=NULL: https://syzkaller.appspot.com/bug?id=e6d4449a128e73a9a88100a5cc833e5cae9fecae Maybe it's a race with two threads somehow doing usbd_free_device at the same time when only one should, but let's rule this case out early on to make it easier to prove it has to be a race. To generate a diff of this commit: cvs rdiff -u -r1.274 -r1.275 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.274 src/sys/dev/usb/usb_subr.c:1.275 --- src/sys/dev/usb/usb_subr.c:1.274 Sun Mar 13 20:44:06 2022 +++ src/sys/dev/usb/usb_subr.c Sat Mar 19 20:50:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.274 2022/03/13 20:44:06 riastradh Exp $ */ +/* $NetBSD: usb_subr.c,v 1.275 2022/03/19 20:50:32 riastradh Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.274 2022/03/13 20:44:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.275 2022/03/19 20:50:32 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -905,6 +905,7 @@ bad: /* XXX Use usbd_set_config() to reset the config? */ /* XXX Should we forbid USB_UNCONFIG_NO from bConfigurationValue? */ dev->ud_config = USB_UNCONFIG_NO; + KASSERT(dev->ud_ifaces == NULL); kmem_free(cdp, len); dev->ud_cdesc = NULL; if (bdp != NULL) {
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sat Mar 19 20:50:32 UTC 2022 Modified Files: src/sys/dev/usb: usb_subr.c Log Message: usb: Insert assertion to diagnose ud_cdesc/ud_ifaces inconsistency. Syzbot found a way to see ud_cdesc=NULL but ud_ifaces!=NULL: https://syzkaller.appspot.com/bug?id=e6d4449a128e73a9a88100a5cc833e5cae9fecae Maybe it's a race with two threads somehow doing usbd_free_device at the same time when only one should, but let's rule this case out early on to make it easier to prove it has to be a race. To generate a diff of this commit: cvs rdiff -u -r1.274 -r1.275 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sat Mar 19 20:44:07 UTC 2022 Modified Files: src/sys/dev/usb: umidi.c Log Message: umidi(4): Parse descriptors a little more robustly. Reported-by: syzbot+fd58d1d4dd12f8931...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/umidi.c diff -u src/sys/dev/usb/umidi.c:1.85 src/sys/dev/usb/umidi.c:1.86 --- src/sys/dev/usb/umidi.c:1.85 Mon Mar 14 16:14:11 2022 +++ src/sys/dev/usb/umidi.c Sat Mar 19 20:44:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: umidi.c,v 1.85 2022/03/14 16:14:11 riastradh Exp $ */ +/* $NetBSD: umidi.c,v 1.86 2022/03/19 20:44:07 riastradh Exp $ */ /* * Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.85 2022/03/14 16:14:11 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.86 2022/03/19 20:44:07 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -70,13 +70,6 @@ __KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1. #define UMIDI_EMBEDDED 0x01 #define UMIDI_EXTERNAL 0x02 -/* generic, for iteration */ -typedef struct { - uByte bLength; - uByte bDescriptorType; - uByte bDescriptorSubtype; -} UPACKED umidi_cs_descriptor_t; - typedef struct { uByte bLength; uByte bDescriptorType; @@ -870,58 +863,75 @@ static usbd_status alloc_all_endpoints_yamaha(struct umidi_softc *sc) { /* This driver currently supports max 1in/1out bulk endpoints */ + char *end; + usb_config_descriptor_t *cdesc; usb_descriptor_t *desc; - umidi_cs_descriptor_t *udesc; + usb_interface_descriptor_t *idesc; + umidi_cs_interface_descriptor_t *udesc; usb_endpoint_descriptor_t *epd; int out_addr, in_addr, i; int dir; - size_t remain, descsize; sc->sc_out_num_jacks = sc->sc_in_num_jacks = 0; out_addr = in_addr = 0; /* detect endpoints */ - desc = TO_D(usbd_get_interface_descriptor(sc->sc_iface)); - for (i=(int)TO_IFD(desc)->bNumEndpoints-1; i>=0; i--) { + cdesc = usbd_get_config_descriptor(sc->sc_udev); + end = (char *)cdesc + UGETW(cdesc->wTotalLength); + idesc = usbd_get_interface_descriptor(sc->sc_iface); + KASSERT((char *)cdesc <= (char *)idesc); + KASSERT((char *)idesc < end); + KASSERT(end - (char *)idesc >= sizeof(*idesc)); + KASSERT(idesc->bLength >= sizeof(*idesc)); + KASSERT(idesc->bLength <= end - (char *)idesc); + for (i = idesc->bNumEndpoints; i --> 0;) { epd = usbd_interface2endpoint_descriptor(sc->sc_iface, i); KASSERT(epd != NULL); if (UE_GET_XFERTYPE(epd->bmAttributes) == UE_BULK) { dir = UE_GET_DIR(epd->bEndpointAddress); - if (dir==UE_DIR_OUT && !out_addr) + if (dir == UE_DIR_OUT && !out_addr) out_addr = epd->bEndpointAddress; - else if (dir==UE_DIR_IN && !in_addr) + else if (dir == UE_DIR_IN && !in_addr) in_addr = epd->bEndpointAddress; } } - udesc = (umidi_cs_descriptor_t *)NEXT_D(desc); + desc = NEXT_D(idesc); + if ((char *)desc > end || end - (char *)desc < sizeof(*desc) || + desc->bLength < sizeof(*desc) || + desc->bLength > end - (char *)desc) + return USBD_INVAL; /* count jacks */ - if (!(udesc->bDescriptorType==UDESC_CS_INTERFACE && - udesc->bDescriptorSubtype==UMIDI_MS_HEADER)) + if (!(desc->bDescriptorType == UDESC_CS_INTERFACE && + desc->bDescriptorSubtype == UMIDI_MS_HEADER)) + return USBD_INVAL; + if (desc->bLength < sizeof(*udesc)) + return USBD_INVAL; + udesc = TO_CSIFD(desc); + if (UGETW(udesc->wTotalLength) > end - (char *)udesc) return USBD_INVAL; - remain = (size_t)UGETW(TO_CSIFD(udesc)->wTotalLength) - - (size_t)udesc->bLength; - udesc = (umidi_cs_descriptor_t *)NEXT_D(udesc); - - while (remain >= sizeof(usb_descriptor_t)) { - descsize = udesc->bLength; - if (descsize>remain || descsize==0) + if (UGETW(udesc->wTotalLength) < udesc->bLength) + return USBD_INVAL; + end = (char *)udesc + UGETW(udesc->wTotalLength); + desc = NEXT_D(udesc); + + for (; end - (char *)desc >= sizeof(*desc); desc = NEXT_D(desc)) { + if (desc->bLength < sizeof(*desc) || + desc->bLength > end - (char *)desc) break; - if (udesc->bDescriptorType == UDESC_CS_INTERFACE && - remain >= UMIDI_JACK_DESCRIPTOR_SIZE) { - if (udesc->bDescriptorSubtype == UMIDI_OUT_JACK) + if (desc->bDescriptorType == UDESC_CS_INTERFACE && + desc->bLength >= UMIDI_JACK_DESCRIPTOR_SIZE) { + if (desc->bDescriptorSubtype == UMIDI_OUT_JACK) sc->sc_out_num_jacks++; - else if (udesc->bDescriptorSubtype == UMIDI_IN_JACK) + else if (desc->bDescriptorSubtype == UMIDI_IN_JACK) sc->sc_in_num_jacks++; } - udesc = (umidi_cs_descriptor_t *)NEXT_D(udesc); - remain -= descsize; } /* validate some parameters */ - if (sc->sc_out_num_jacks>UMIDI_MAX_EPJACKS) + if (sc->sc_out_num_jacks > UMIDI_MAX_EPJACKS) sc->sc_out_num_jacks =
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sat Mar 19 20:44:07 UTC 2022 Modified Files: src/sys/dev/usb: umidi.c Log Message: umidi(4): Parse descriptors a little more robustly. Reported-by: syzbot+fd58d1d4dd12f8931...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/dev/usb/umidi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: riastradh Date: Sat Mar 19 16:20:45 UTC 2022 Modified Files: src/sys/dev/pci: viornd.c Log Message: viornd(4): Revert IPL change for lock. This lock is taken in hard interrupt context, so it needs to remain at IPL_VM. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/viornd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/viornd.c diff -u src/sys/dev/pci/viornd.c:1.15 src/sys/dev/pci/viornd.c:1.16 --- src/sys/dev/pci/viornd.c:1.15 Sat Mar 19 11:37:06 2022 +++ src/sys/dev/pci/viornd.c Sat Mar 19 16:20:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: viornd.c,v 1.15 2022/03/19 11:37:06 riastradh Exp $ */ +/* $NetBSD: viornd.c,v 1.16 2022/03/19 16:20:45 riastradh Exp $ */ /* $OpenBSD: viornd.c,v 1.1 2014/01/21 21:14:58 sf Exp $ */ /* @@ -139,7 +139,7 @@ viornd_attach(device_t parent, device_t sc->sc_dev = self; sc->sc_virtio = vsc; - mutex_init(>sc_mutex, MUTEX_DEFAULT, IPL_SOFTSERIAL); + mutex_init(>sc_mutex, MUTEX_DEFAULT, IPL_VM); error = bus_dmamem_alloc(virtio_dmat(vsc), VIRTIO_PAGE_SIZE, 0, 0, segs, 1, ,
CVS commit: src/sys/dev/pci
Module Name:src Committed By: riastradh Date: Sat Mar 19 16:20:45 UTC 2022 Modified Files: src/sys/dev/pci: viornd.c Log Message: viornd(4): Revert IPL change for lock. This lock is taken in hard interrupt context, so it needs to remain at IPL_VM. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/viornd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src
Does this impact PR/51084 at all? On Sat, 19 Mar 2022, Roland Illig wrote: Module Name:src Committed By: rillig Date: Sat Mar 19 14:35:13 UTC 2022 Modified Files: src: Makefile Log Message: Makefile: fix location of postinstall program for MAKEVERBOSE > 2 If MAKEVERBOSE > 2, each shell command from a make target is echoed. This resulted in two additional words ending up in the variable _POSTINSTALL. Noticed by Brad Harder. Before: $ make -v _POSTINSTALL MAKEVERBOSE=3 echo .../usr.sbin/postinstall .../usr.sbin/postinstall/postinstall ... After: $ make -v _POSTINSTALL MAKEVERBOSE=3 .../usr.sbin/postinstall/postinstall ... To generate a diff of this commit: cvs rdiff -u -r1.333 -r1.334 src/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. !DSPAM:6235ea25249971057441505! ++--+--+ | Paul Goyette | PGP Key fingerprint: | E-mail addresses:| | (Retired) | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com| | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org | | & Network Engineer | | pgoyett...@gmail.com | ++--+--+
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Mar 19 14:48:31 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: ckctype.c Log Message: lint: be more specific in comment about check No binary change. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/lint1/ckctype.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Mar 19 14:48:31 UTC 2022 Modified Files: src/usr.bin/xlint/lint1: ckctype.c Log Message: lint: be more specific in comment about check No binary change. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/xlint/lint1/ckctype.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/xlint/lint1/ckctype.c diff -u src/usr.bin/xlint/lint1/ckctype.c:1.3 src/usr.bin/xlint/lint1/ckctype.c:1.4 --- src/usr.bin/xlint/lint1/ckctype.c:1.3 Sun Jul 25 22:43:08 2021 +++ src/usr.bin/xlint/lint1/ckctype.c Sat Mar 19 14:48:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ckctype.c,v 1.3 2021/07/25 22:43:08 rillig Exp $ */ +/* $NetBSD: ckctype.c,v 1.4 2022/03/19 14:48:31 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: ckctype.c,v 1.3 2021/07/25 22:43:08 rillig Exp $"); +__RCSID("$NetBSD: ckctype.c,v 1.4 2022/03/19 14:48:31 rillig Exp $"); #endif #include @@ -44,12 +44,15 @@ __RCSID("$NetBSD: ckctype.c,v 1.3 2021/0 #include "lint1.h" /* - * Check that the functions from are used properly. They are - * difficult to use when their argument comes from an expression of type - * 'char'. In such a case, the argument must be converted to 'unsigned char', - * not directly to 'int'. + * Check that the functions from are used properly. They must not + * be called with an argument of type 'char'. In such a case, the argument + * must be converted to 'unsigned char'. The tricky thing is that even though + * the expected argument type is 'int', a 'char' argument must not be directly + * cast to 'int', as that would preserve negative argument values. * - * https://stackoverflow.com/a/60696378 + * See also: + * ctype(3) + * https://stackoverflow.com/a/60696378 */ static bool
CVS commit: src
Module Name:src Committed By: rillig Date: Sat Mar 19 14:35:13 UTC 2022 Modified Files: src: Makefile Log Message: Makefile: fix location of postinstall program for MAKEVERBOSE > 2 If MAKEVERBOSE > 2, each shell command from a make target is echoed. This resulted in two additional words ending up in the variable _POSTINSTALL. Noticed by Brad Harder. Before: $ make -v _POSTINSTALL MAKEVERBOSE=3 echo .../usr.sbin/postinstall .../usr.sbin/postinstall/postinstall ... After: $ make -v _POSTINSTALL MAKEVERBOSE=3 .../usr.sbin/postinstall/postinstall ... To generate a diff of this commit: cvs rdiff -u -r1.333 -r1.334 src/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/Makefile diff -u src/Makefile:1.333 src/Makefile:1.334 --- src/Makefile:1.333 Thu Oct 29 20:26:24 2020 +++ src/Makefile Sat Mar 19 14:35:13 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.333 2020/10/29 20:26:24 uwe Exp $ +# $NetBSD: Makefile,v 1.334 2022/03/19 14:35:13 rillig Exp $ # # This is the top-level makefile for building NetBSD. For an outline of @@ -174,7 +174,7 @@ afterinstall: .PHONY .MAKE .endif _POSTINSTALL= ${:!cd ${.CURDIR}/usr.sbin/postinstall && \ - ${MAKE} print-objdir!}/postinstall \ + ${MAKE} -v .OBJDIR!}/postinstall \ -m ${MACHINE} -a ${MACHINE_ARCH} _POSTINSTALL_ENV= \ AWK=${TOOL_AWK:Q} \
CVS commit: src
Module Name:src Committed By: rillig Date: Sat Mar 19 14:35:13 UTC 2022 Modified Files: src: Makefile Log Message: Makefile: fix location of postinstall program for MAKEVERBOSE > 2 If MAKEVERBOSE > 2, each shell command from a make target is echoed. This resulted in two additional words ending up in the variable _POSTINSTALL. Noticed by Brad Harder. Before: $ make -v _POSTINSTALL MAKEVERBOSE=3 echo .../usr.sbin/postinstall .../usr.sbin/postinstall/postinstall ... After: $ make -v _POSTINSTALL MAKEVERBOSE=3 .../usr.sbin/postinstall/postinstall ... To generate a diff of this commit: cvs rdiff -u -r1.333 -r1.334 src/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 14:35:08 UTC 2022 Modified Files: src/sys/kern: kern_entropy.c src/sys/sys: rnd.h Log Message: rnd(9): Delete legacy rnd_initial_entropy symbol. Use entropy_epoch() instead. XXX kernel ABI change deleting symbol requires bump To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/kern/kern_entropy.c cvs rdiff -u -r1.49 -r1.50 src/sys/sys/rnd.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_entropy.c diff -u src/sys/kern/kern_entropy.c:1.40 src/sys/kern/kern_entropy.c:1.41 --- src/sys/kern/kern_entropy.c:1.40 Fri Mar 18 23:35:28 2022 +++ src/sys/kern/kern_entropy.c Sat Mar 19 14:35:08 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_entropy.c,v 1.40 2022/03/18 23:35:28 riastradh Exp $ */ +/* $NetBSD: kern_entropy.c,v 1.41 2022/03/19 14:35:08 riastradh Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.40 2022/03/18 23:35:28 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.41 2022/03/19 14:35:08 riastradh Exp $"); #include #include @@ -193,8 +193,6 @@ static struct percpu *entropy_percpu __r static void *entropy_sih __read_mostly; /* softint handler */ static struct lwp *entropy_lwp __read_mostly; /* housekeeping thread */ -int rnd_initial_entropy __read_mostly; /* XXX legacy */ - static struct krndsource seed_rndsource __read_mostly; /* @@ -1165,10 +1163,8 @@ entropy_notify(void) * that we're ready so operators can compare it to the timing * of other events. */ - if (__predict_false(!rnd_initial_entropy) && E->needed == 0) { + if (__predict_false(E->epoch == (unsigned)-1) && E->needed == 0) printf("entropy: ready\n"); - rnd_initial_entropy = 1; - } /* Set the epoch; roll over from UINTMAX-1 to 1. */ if (__predict_true(!atomic_load_relaxed(_depletion)) || @@ -1178,6 +1174,7 @@ entropy_notify(void) epoch = 1; atomic_store_relaxed(>epoch, epoch); } + KASSERT(E->epoch != (unsigned)-1); /* Notify waiters. */ if (E->stage >= ENTROPY_WARM) { Index: src/sys/sys/rnd.h diff -u src/sys/sys/rnd.h:1.49 src/sys/sys/rnd.h:1.50 --- src/sys/sys/rnd.h:1.49 Tue Apr 14 12:51:30 2015 +++ src/sys/sys/rnd.h Sat Mar 19 14:35:08 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: rnd.h,v 1.49 2015/04/14 12:51:30 riastradh Exp $ */ +/* $NetBSD: rnd.h,v 1.50 2022/03/19 14:35:08 riastradh Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -47,8 +47,6 @@ void rnd_init_softint(void); void rnd_seed(void *, size_t); int rnd_system_ioctl(struct file *, u_long, void *); -extern int rnd_initial_entropy; - #endif /* _KERNEL */ #endif /* !_SYS_RND_H_ */
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 14:35:08 UTC 2022 Modified Files: src/sys/kern: kern_entropy.c src/sys/sys: rnd.h Log Message: rnd(9): Delete legacy rnd_initial_entropy symbol. Use entropy_epoch() instead. XXX kernel ABI change deleting symbol requires bump To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/kern/kern_entropy.c cvs rdiff -u -r1.49 -r1.50 src/sys/sys/rnd.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 14:34:48 UTC 2022 Modified Files: src/sys/kern: kern_clock.c src/sys/sys: kernel.h Log Message: kern: Delete kernel_ticks from kernel ABI. Use getticks() instead. To generate a diff of this commit: cvs rdiff -u -r1.147 -r1.148 src/sys/kern/kern_clock.c cvs rdiff -u -r1.33 -r1.34 src/sys/sys/kernel.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_clock.c diff -u src/sys/kern/kern_clock.c:1.147 src/sys/kern/kern_clock.c:1.148 --- src/sys/kern/kern_clock.c:1.147 Fri Mar 18 23:37:14 2022 +++ src/sys/kern/kern_clock.c Sat Mar 19 14:34:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_clock.c,v 1.147 2022/03/18 23:37:14 riastradh Exp $ */ +/* $NetBSD: kern_clock.c,v 1.148 2022/03/19 14:34:47 riastradh Exp $ */ /*- * Copyright (c) 2000, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -69,7 +69,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.147 2022/03/18 23:37:14 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.148 2022/03/19 14:34:47 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_dtrace.h" @@ -135,7 +135,7 @@ int profhz; int profsrc; int schedhz; int profprocs; -int hardclock_ticks; +static int hardclock_ticks; static int hardscheddiv; /* hard => sched divider (used if schedhz == 0) */ static int psdiv; /* prof => stat divider */ int psratio; /* ratio: prof / stat */ Index: src/sys/sys/kernel.h diff -u src/sys/sys/kernel.h:1.33 src/sys/sys/kernel.h:1.34 --- src/sys/sys/kernel.h:1.33 Thu Apr 2 16:29:30 2020 +++ src/sys/sys/kernel.h Sat Mar 19 14:34:48 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: kernel.h,v 1.33 2020/04/02 16:29:30 maxv Exp $ */ +/* $NetBSD: kernel.h,v 1.34 2022/03/19 14:34:48 riastradh Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -56,7 +56,6 @@ extern int cold; /* still working on st extern int shutting_down; /* system is shutting down */ extern int tick; /* usec per tick (100 / hz) */ extern int tickadj; /* "standard" clock skew, us./tick */ -extern int hardclock_ticks; /* # of hardclock ticks; XXX use getticks()! */ extern int hz; /* system clock's frequency */ extern int stathz; /* statistics clock's frequency */ extern int profhz; /* profiling clock's frequency */
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 14:34:48 UTC 2022 Modified Files: src/sys/kern: kern_clock.c src/sys/sys: kernel.h Log Message: kern: Delete kernel_ticks from kernel ABI. Use getticks() instead. To generate a diff of this commit: cvs rdiff -u -r1.147 -r1.148 src/sys/kern/kern_clock.c cvs rdiff -u -r1.33 -r1.34 src/sys/sys/kernel.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: hannken Date: Sat Mar 19 13:53:33 UTC 2022 Modified Files: src/share/man/man9: vnode.9 src/sys/fs/efs: efs_vfsops.c src/sys/fs/hfs: hfs_vfsops.c src/sys/fs/union: union_subr.c src/sys/kern: vfs_vnode.c vnode_if.sh src/sys/miscfs/deadfs: dead_vfsops.c src/sys/sys: param.h vnode.h src/sys/ufs/chfs: chfs_vfsops.c src/sys/ufs/ext2fs: ext2fs_vfsops.c src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/lfs: lfs_vfsops.c src/sys/ufs/mfs: mfs_vfsops.c Log Message: Remove now unused VV_LOCKSWORK, all file systems support locking. Remove unused predicates vn_locked() and vn_anylocked(). Welcome to 9.99.95 To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/share/man/man9/vnode.9 cvs rdiff -u -r1.29 -r1.30 src/sys/fs/efs/efs_vfsops.c cvs rdiff -u -r1.37 -r1.38 src/sys/fs/hfs/hfs_vfsops.c cvs rdiff -u -r1.80 -r1.81 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.138 -r1.139 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.72 -r1.73 src/sys/kern/vnode_if.sh cvs rdiff -u -r1.10 -r1.11 src/sys/miscfs/deadfs/dead_vfsops.c cvs rdiff -u -r1.707 -r1.708 src/sys/sys/param.h cvs rdiff -u -r1.299 -r1.300 src/sys/sys/vnode.h cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.219 -r1.220 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.374 -r1.375 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.381 -r1.382 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.115 -r1.116 src/sys/ufs/mfs/mfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.83 src/share/man/man9/vnode.9:1.84 --- src/share/man/man9/vnode.9:1.83 Mon Jan 17 19:08:06 2022 +++ src/share/man/man9/vnode.9 Sat Mar 19 13:53:32 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.83 2022/01/17 19:08:06 christos Exp $ +.\" $NetBSD: vnode.9,v 1.84 2022/03/19 13:53:32 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 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 January 17, 2022 +.Dd March 19, 2022 .Dt VNODE 9 .Os .Sh NAME @@ -216,8 +216,6 @@ This vnode represents a tty; used when r This vnode might have user mappings. .It Dv VV_MPSAFE This file system is MP safe. -.It Dv VV_LOCKSWORK -This vnode's file system supports locking. .It Dv VI_TEXT This vnode is a pure text prototype. .It Dv VI_EXECMAP Index: src/sys/fs/efs/efs_vfsops.c diff -u src/sys/fs/efs/efs_vfsops.c:1.29 src/sys/fs/efs/efs_vfsops.c:1.30 --- src/sys/fs/efs/efs_vfsops.c:1.29 Fri Jan 17 20:08:07 2020 +++ src/sys/fs/efs/efs_vfsops.c Sat Mar 19 13:53:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: efs_vfsops.c,v 1.29 2020/01/17 20:08:07 ad Exp $ */ +/* $NetBSD: efs_vfsops.c,v 1.30 2022/03/19 13:53:32 hannken Exp $ */ /* * Copyright (c) 2006 Stephen M. Rumble @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.29 2020/01/17 20:08:07 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.30 2022/03/19 13:53:32 hannken Exp $"); #include #include @@ -439,7 +439,6 @@ efs_loadvnode(struct mount *mp, struct v } vp->v_tag = VT_EFS; - vp->v_vflag |= VV_LOCKSWORK; vp->v_data = eip; genfs_node_init(vp, _genfsops); uvm_vnp_setsize(vp, eip->ei_size); Index: src/sys/fs/hfs/hfs_vfsops.c diff -u src/sys/fs/hfs/hfs_vfsops.c:1.37 src/sys/fs/hfs/hfs_vfsops.c:1.38 --- src/sys/fs/hfs/hfs_vfsops.c:1.37 Fri Feb 28 11:27:38 2020 +++ src/sys/fs/hfs/hfs_vfsops.c Sat Mar 19 13:53:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: hfs_vfsops.c,v 1.37 2020/02/28 11:27:38 kamil Exp $ */ +/* $NetBSD: hfs_vfsops.c,v 1.38 2022/03/19 13:53:32 hannken Exp $ */ /*- * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.37 2020/02/28 11:27:38 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.38 2022/03/19 13:53:32 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -583,7 +583,6 @@ hfs_loadvnode(struct mount *mp, struct v vp->v_tag = VT_HFS; vp->v_op = hfs_vnodeop_p; - vp->v_vflag |= VV_LOCKSWORK; vp->v_data = hnode; genfs_node_init(vp, _genfsops); Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.80 src/sys/fs/union/union_subr.c:1.81 --- src/sys/fs/union/union_subr.c:1.80 Sat Mar 19 13:48:04 2022 +++ src/sys/fs/union/union_subr.c Sat Mar 19 13:53:32 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.80 2022/03/19 13:48:04 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.81 2022/03/19 13:53:32 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.80 2022/03/19 13:48:04 hannken Exp $"); +__KERNEL_RCSID(0,
CVS commit: src
Module Name:src Committed By: hannken Date: Sat Mar 19 13:53:33 UTC 2022 Modified Files: src/share/man/man9: vnode.9 src/sys/fs/efs: efs_vfsops.c src/sys/fs/hfs: hfs_vfsops.c src/sys/fs/union: union_subr.c src/sys/kern: vfs_vnode.c vnode_if.sh src/sys/miscfs/deadfs: dead_vfsops.c src/sys/sys: param.h vnode.h src/sys/ufs/chfs: chfs_vfsops.c src/sys/ufs/ext2fs: ext2fs_vfsops.c src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/lfs: lfs_vfsops.c src/sys/ufs/mfs: mfs_vfsops.c Log Message: Remove now unused VV_LOCKSWORK, all file systems support locking. Remove unused predicates vn_locked() and vn_anylocked(). Welcome to 9.99.95 To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/share/man/man9/vnode.9 cvs rdiff -u -r1.29 -r1.30 src/sys/fs/efs/efs_vfsops.c cvs rdiff -u -r1.37 -r1.38 src/sys/fs/hfs/hfs_vfsops.c cvs rdiff -u -r1.80 -r1.81 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.138 -r1.139 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.72 -r1.73 src/sys/kern/vnode_if.sh cvs rdiff -u -r1.10 -r1.11 src/sys/miscfs/deadfs/dead_vfsops.c cvs rdiff -u -r1.707 -r1.708 src/sys/sys/param.h cvs rdiff -u -r1.299 -r1.300 src/sys/sys/vnode.h cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.219 -r1.220 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.374 -r1.375 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.381 -r1.382 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.115 -r1.116 src/sys/ufs/mfs/mfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Sat Mar 19 13:52:45 UTC 2022 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Remove now unused genfs_nolock(), genfs_nounlock() and genfs_noislocked(). To generate a diff of this commit: cvs rdiff -u -r1.216 -r1.217 src/sys/miscfs/genfs/genfs_vnops.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/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.216 src/sys/miscfs/genfs/genfs_vnops.c:1.217 --- src/sys/miscfs/genfs/genfs_vnops.c:1.216 Wed Oct 20 03:08:18 2021 +++ src/sys/miscfs/genfs/genfs_vnops.c Sat Mar 19 13:52:45 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.216 2021/10/20 03:08:18 thorpej Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.217 2022/03/19 13:52:45 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.216 2021/10/20 03:08:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.217 2022/03/19 13:52:45 hannken Exp $"); #include #include @@ -425,30 +425,6 @@ genfs_islocked(void *v) return 0; } -/* - * Stubs to use when there is no locking to be done on the underlying object. - */ -int -genfs_nolock(void *v) -{ - - return (0); -} - -int -genfs_nounlock(void *v) -{ - - return (0); -} - -int -genfs_noislocked(void *v) -{ - - return (0); -} - int genfs_mmap(void *v) {
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Sat Mar 19 13:52:45 UTC 2022 Modified Files: src/sys/miscfs/genfs: genfs_vnops.c Log Message: Remove now unused genfs_nolock(), genfs_nounlock() and genfs_noislocked(). To generate a diff of this commit: cvs rdiff -u -r1.216 -r1.217 src/sys/miscfs/genfs/genfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Sat Mar 19 13:52:11 UTC 2022 Modified Files: src/sys/kern: vfs_vnode.c src/sys/miscfs/deadfs: dead_vfsops.c src/sys/miscfs/specfs: spec_vnops.c Log Message: Switch spec_vnodeop vector to real vnode locking, VV_LOCKSWORK now. To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.9 -r1.10 src/sys/miscfs/deadfs/dead_vfsops.c cvs rdiff -u -r1.183 -r1.184 src/sys/miscfs/specfs/spec_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.137 src/sys/kern/vfs_vnode.c:1.138 --- src/sys/kern/vfs_vnode.c:1.137 Tue Mar 15 15:27:43 2022 +++ src/sys/kern/vfs_vnode.c Sat Mar 19 13:52:11 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.137 2022/03/15 15:27:43 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.138 2022/03/19 13:52:11 hannken Exp $ */ /*- * Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc. @@ -148,7 +148,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.137 2022/03/15 15:27:43 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.138 2022/03/19 13:52:11 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_pax.h" @@ -1993,8 +1993,7 @@ vcache_make_anon(vnode_t *vp) /* Done with purge, change operations vector. */ mutex_enter(vp->v_interlock); vp->v_op = spec_vnodeop_p; - vp->v_vflag |= VV_MPSAFE; - vp->v_vflag &= ~VV_LOCKSWORK; + vp->v_vflag |= VV_MPSAFE | VV_LOCKSWORK; mutex_exit(vp->v_interlock); /* Index: src/sys/miscfs/deadfs/dead_vfsops.c diff -u src/sys/miscfs/deadfs/dead_vfsops.c:1.9 src/sys/miscfs/deadfs/dead_vfsops.c:1.10 --- src/sys/miscfs/deadfs/dead_vfsops.c:1.9 Tue Jan 1 10:06:54 2019 +++ src/sys/miscfs/deadfs/dead_vfsops.c Sat Mar 19 13:52:11 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: dead_vfsops.c,v 1.9 2019/01/01 10:06:54 hannken Exp $ */ +/* $NetBSD: dead_vfsops.c,v 1.10 2022/03/19 13:52:11 hannken Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.9 2019/01/01 10:06:54 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.10 2022/03/19 13:52:11 hannken Exp $"); #include #include @@ -104,7 +104,7 @@ dead_newvnode(struct mount *mp, struct v vp->v_tag = VT_NON; vp->v_type = vap->va_type; vp->v_op = spec_vnodeop_p; - vp->v_vflag |= VV_MPSAFE; + vp->v_vflag |= VV_MPSAFE | VV_LOCKSWORK; uvm_vnp_setsize(vp, 0); spec_node_init(vp, vap->va_rdev); Index: src/sys/miscfs/specfs/spec_vnops.c diff -u src/sys/miscfs/specfs/spec_vnops.c:1.183 src/sys/miscfs/specfs/spec_vnops.c:1.184 --- src/sys/miscfs/specfs/spec_vnops.c:1.183 Sun Jul 18 23:57:14 2021 +++ src/sys/miscfs/specfs/spec_vnops.c Sat Mar 19 13:52:11 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: spec_vnops.c,v 1.183 2021/07/18 23:57:14 dholland Exp $ */ +/* $NetBSD: spec_vnops.c,v 1.184 2022/03/19 13:52:11 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.183 2021/07/18 23:57:14 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.184 2022/03/19 13:52:11 hannken Exp $"); #include #include @@ -148,12 +148,12 @@ const struct vnodeopv_entry_desc spec_vn { _abortop_desc, genfs_badop }, /* abortop */ { _inactive_desc, spec_inactive }, /* inactive */ { _reclaim_desc, spec_reclaim }, /* reclaim */ - { _lock_desc, genfs_nolock }, /* lock */ - { _unlock_desc, genfs_nounlock }, /* unlock */ + { _lock_desc, genfs_lock }, /* lock */ + { _unlock_desc, genfs_unlock }, /* unlock */ { _bmap_desc, spec_bmap }, /* bmap */ { _strategy_desc, spec_strategy }, /* strategy */ { _print_desc, spec_print }, /* print */ - { _islocked_desc, genfs_noislocked }, /* islocked */ + { _islocked_desc, genfs_islocked }, /* islocked */ { _pathconf_desc, spec_pathconf }, /* pathconf */ { _advlock_desc, spec_advlock }, /* advlock */ { _bwrite_desc, vn_bwrite }, /* bwrite */
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Sat Mar 19 13:52:11 UTC 2022 Modified Files: src/sys/kern: vfs_vnode.c src/sys/miscfs/deadfs: dead_vfsops.c src/sys/miscfs/specfs: spec_vnops.c Log Message: Switch spec_vnodeop vector to real vnode locking, VV_LOCKSWORK now. To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.9 -r1.10 src/sys/miscfs/deadfs/dead_vfsops.c cvs rdiff -u -r1.183 -r1.184 src/sys/miscfs/specfs/spec_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Sat Mar 19 13:51:35 UTC 2022 Modified Files: src/sys/arch/evbarm/fdt: fdt_machdep.c src/sys/arch/x86/x86: x86_autoconf.c src/sys/arch/zaurus/zaurus: autoconf.c src/sys/kern: init_main.c kern_subr.c Log Message: Fix locking after opendisk(), VOP_IOCTL() needs an unlocked vnode, vn_rdwr() needs flag IO_NODELOCKED. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/arch/evbarm/fdt/fdt_machdep.c cvs rdiff -u -r1.86 -r1.87 src/sys/arch/x86/x86/x86_autoconf.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/zaurus/zaurus/autoconf.c cvs rdiff -u -r1.537 -r1.538 src/sys/kern/init_main.c cvs rdiff -u -r1.229 -r1.230 src/sys/kern/kern_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/fdt/fdt_machdep.c diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.89 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.90 --- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.89 Sat Mar 19 09:55:30 2022 +++ src/sys/arch/evbarm/fdt/fdt_machdep.c Sat Mar 19 13:51:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_machdep.c,v 1.89 2022/03/19 09:55:30 skrll Exp $ */ +/* $NetBSD: fdt_machdep.c,v 1.90 2022/03/19 13:51:35 hannken Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.89 2022/03/19 09:55:30 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.90 2022/03/19 13:51:35 hannken Exp $"); #include "opt_arm_debug.h" #include "opt_bootconfig.h" @@ -774,7 +774,7 @@ fdt_detect_root_device(device_t dev) if (!vp) return; error = vn_rdwr(UIO_READ, vp, buf, sizeof(buf), 0, UIO_SYSSPACE, - 0, NOCRED, , NULL); + IO_NODELOCKED, NOCRED, , NULL); VOP_CLOSE(vp, FREAD, NOCRED); vput(vp); Index: src/sys/arch/x86/x86/x86_autoconf.c diff -u src/sys/arch/x86/x86/x86_autoconf.c:1.86 src/sys/arch/x86/x86/x86_autoconf.c:1.87 --- src/sys/arch/x86/x86/x86_autoconf.c:1.86 Sat Feb 12 03:24:35 2022 +++ src/sys/arch/x86/x86/x86_autoconf.c Sat Mar 19 13:51:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_autoconf.c,v 1.86 2022/02/12 03:24:35 riastradh Exp $ */ +/* $NetBSD: x86_autoconf.c,v 1.87 2022/03/19 13:51:35 hannken Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.86 2022/02/12 03:24:35 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.87 2022/03/19 13:51:35 hannken Exp $"); #include #include @@ -178,7 +178,7 @@ matchbiosdisks(void) } error = vn_rdwr(UIO_READ, tv, mbr, DEV_BSIZE, 0, UIO_SYSSPACE, - 0, NOCRED, NULL, NULL); + IO_NODELOCKED, NOCRED, NULL, NULL); VOP_CLOSE(tv, FREAD, NOCRED); vput(tv); if (error) { @@ -243,7 +243,7 @@ match_bootwedge(device_t dv, struct btin nblks != 0; nblks--, blk++) { error = vn_rdwr(UIO_READ, tmpvn, (void *) bf, sizeof(bf), blk * DEV_BSIZE, UIO_SYSSPACE, - 0, NOCRED, NULL, NULL); + IO_NODELOCKED, NOCRED, NULL, NULL); if (error) { if (error != EINVAL) { aprint_error("%s: unable to read block %" @@ -298,7 +298,9 @@ match_bootdisk(device_t dv, struct btinf return 0; } + VOP_UNLOCK(tmpvn); error = VOP_IOCTL(tmpvn, DIOCGDINFO, , FREAD, NOCRED); + vn_lock(tmpvn, LK_EXCLUSIVE | LK_RETRY); if (error) { /* * XXX Can't happen -- open() would have errored out Index: src/sys/arch/zaurus/zaurus/autoconf.c diff -u src/sys/arch/zaurus/zaurus/autoconf.c:1.15 src/sys/arch/zaurus/zaurus/autoconf.c:1.16 --- src/sys/arch/zaurus/zaurus/autoconf.c:1.15 Sat Feb 12 03:24:35 2022 +++ src/sys/arch/zaurus/zaurus/autoconf.c Sat Mar 19 13:51:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.15 2022/02/12 03:24:35 riastradh Exp $ */ +/* $NetBSD: autoconf.c,v 1.16 2022/03/19 13:51:35 hannken Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.15 2022/02/12 03:24:35 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.16 2022/03/19 13:51:35 hannken Exp $"); #include "opt_md.h" @@ -109,7 +109,9 @@ match_bootdisk(device_t dv, struct btinf if ((tmpvn = opendisk(dv)) == NULL) return 0; + VOP_UNLOCK(tmpvn); error = VOP_IOCTL(tmpvn, DIOCGDINFO, , FREAD, NOCRED); + vn_lock(tmpvn, LK_EXCLUSIVE | LK_RETRY); if (error) { /* * XXX Can't happen -- open() would have errored out Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.537 src/sys/kern/init_main.c:1.538 --- src/sys/kern/init_main.c:1.537 Fri Mar 18 23:37:06 2022 +++ src/sys/kern/init_main.c Sat Mar 19 13:51:35 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.537 2022/03/18 23:37:06 riastradh Exp $ */ +/* $NetBSD: init_main.c,v 1.538 2022/03/19 13:51:35 hannken Exp $ */ /*- * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation,
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Sat Mar 19 13:51:35 UTC 2022 Modified Files: src/sys/arch/evbarm/fdt: fdt_machdep.c src/sys/arch/x86/x86: x86_autoconf.c src/sys/arch/zaurus/zaurus: autoconf.c src/sys/kern: init_main.c kern_subr.c Log Message: Fix locking after opendisk(), VOP_IOCTL() needs an unlocked vnode, vn_rdwr() needs flag IO_NODELOCKED. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/arch/evbarm/fdt/fdt_machdep.c cvs rdiff -u -r1.86 -r1.87 src/sys/arch/x86/x86/x86_autoconf.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/zaurus/zaurus/autoconf.c cvs rdiff -u -r1.537 -r1.538 src/sys/kern/init_main.c cvs rdiff -u -r1.229 -r1.230 src/sys/kern/kern_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/ata
Module Name:src Committed By: hannken Date: Sat Mar 19 13:51:01 UTC 2022 Modified Files: src/sys/dev/ata: ata_raid_adaptec.c ata_raid_intel.c ata_raid_jmicron.c ata_raid_nvidia.c ata_raid_promise.c ata_raid_subr.c ata_raid_via.c Log Message: Lock vnode across VOP_OPEN. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ata/ata_raid_adaptec.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/ata_raid_intel.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ata/ata_raid_jmicron.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/ata_raid_nvidia.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ata/ata_raid_promise.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/ata_raid_subr.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/ata_raid_via.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/ata/ata_raid_adaptec.c diff -u src/sys/dev/ata/ata_raid_adaptec.c:1.11 src/sys/dev/ata/ata_raid_adaptec.c:1.12 --- src/sys/dev/ata/ata_raid_adaptec.c:1.11 Mon Oct 22 19:38:06 2018 +++ src/sys/dev/ata/ata_raid_adaptec.c Sat Mar 19 13:51:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $ */ +/* $NetBSD: ata_raid_adaptec.c,v 1.12 2022/03/19 13:51:01 hannken Exp $ */ /*- * Copyright (c) 2000,2001,2002 Søren Schmidt @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.12 2022/03/19 13:51:01 hannken Exp $"); #include #include @@ -86,6 +86,7 @@ ata_raid_read_config_adaptec(struct wd_s if (error) goto out; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(vp, FREAD, NOCRED); if (error) { vput(vp); Index: src/sys/dev/ata/ata_raid_intel.c diff -u src/sys/dev/ata/ata_raid_intel.c:1.10 src/sys/dev/ata/ata_raid_intel.c:1.11 --- src/sys/dev/ata/ata_raid_intel.c:1.10 Fri Oct 4 12:24:32 2019 +++ src/sys/dev/ata/ata_raid_intel.c Sat Mar 19 13:51:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $ */ +/* $NetBSD: ata_raid_intel.c,v 1.11 2022/03/19 13:51:01 hannken Exp $ */ /*- * Copyright (c) 2000-2008 Søren Schmidt @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.11 2022/03/19 13:51:01 hannken Exp $"); #include #include @@ -158,6 +158,7 @@ ata_raid_read_config_intel(struct wd_sof if (error) goto out; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(vp, FREAD, NOCRED); if (error) { vput(vp); Index: src/sys/dev/ata/ata_raid_jmicron.c diff -u src/sys/dev/ata/ata_raid_jmicron.c:1.7 src/sys/dev/ata/ata_raid_jmicron.c:1.8 --- src/sys/dev/ata/ata_raid_jmicron.c:1.7 Mon Oct 22 19:38:06 2018 +++ src/sys/dev/ata/ata_raid_jmicron.c Sat Mar 19 13:51:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_jmicron.c,v 1.7 2018/10/22 19:38:06 jdolecek Exp $ */ +/* $NetBSD: ata_raid_jmicron.c,v 1.8 2022/03/19 13:51:01 hannken Exp $ */ /*- * Copyright (c) 2000-2008 Søren Schmidt @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.7 2018/10/22 19:38:06 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.8 2022/03/19 13:51:01 hannken Exp $"); #include #include @@ -139,6 +139,7 @@ ata_raid_read_config_jmicron(struct wd_s if (error) goto out; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(vp, FREAD, NOCRED); if (error) { vput(vp); Index: src/sys/dev/ata/ata_raid_nvidia.c diff -u src/sys/dev/ata/ata_raid_nvidia.c:1.4 src/sys/dev/ata/ata_raid_nvidia.c:1.5 --- src/sys/dev/ata/ata_raid_nvidia.c:1.4 Mon Oct 22 19:38:06 2018 +++ src/sys/dev/ata/ata_raid_nvidia.c Sat Mar 19 13:51:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_nvidia.c,v 1.4 2018/10/22 19:38:06 jdolecek Exp $ */ +/* $NetBSD: ata_raid_nvidia.c,v 1.5 2022/03/19 13:51:01 hannken Exp $ */ /*- * Copyright (c) 2000 - 2008 Søren Schmidt @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.4 2018/10/22 19:38:06 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.5 2022/03/19 13:51:01 hannken Exp $"); #include #include @@ -145,6 +145,7 @@ ata_raid_read_config_nvidia(struct wd_so if (error) goto out; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(vp, FREAD, NOCRED); if (error) { vput(vp); Index: src/sys/dev/ata/ata_raid_promise.c diff -u src/sys/dev/ata/ata_raid_promise.c:1.13 src/sys/dev/ata/ata_raid_promise.c:1.14 --- src/sys/dev/ata/ata_raid_promise.c:1.13 Mon Oct 22 19:38:06 2018 +++ src/sys/dev/ata/ata_raid_promise.c Sat Mar 19 13:51:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid_promise.c,v 1.13 2018/10/22 19:38:06 jdolecek Exp $ */ +/* $NetBSD: ata_raid_promise.c,v 1.14 2022/03/19 13:51:01 hannken Exp $ */ /*- * Copyright (c)
CVS commit: src/sys/dev/ata
Module Name:src Committed By: hannken Date: Sat Mar 19 13:51:01 UTC 2022 Modified Files: src/sys/dev/ata: ata_raid_adaptec.c ata_raid_intel.c ata_raid_jmicron.c ata_raid_nvidia.c ata_raid_promise.c ata_raid_subr.c ata_raid_via.c Log Message: Lock vnode across VOP_OPEN. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ata/ata_raid_adaptec.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/ata_raid_intel.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ata/ata_raid_jmicron.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/ata_raid_nvidia.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ata/ata_raid_promise.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/ata_raid_subr.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/ata_raid_via.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sat Mar 19 13:50:28 UTC 2022 Modified Files: src/sys/kern: vfs_mount.c Log Message: Lock vnode across VOP_OPEN. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.89 src/sys/kern/vfs_mount.c:1.90 --- src/sys/kern/vfs_mount.c:1.89 Wed Mar 16 20:31:02 2022 +++ src/sys/kern/vfs_mount.c Sat Mar 19 13:50:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.89 2022/03/16 20:31:02 andvar Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $ */ /*- * Copyright (c) 1997-2020 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.89 2022/03/16 20:31:02 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.90 2022/03/19 13:50:28 hannken Exp $"); #include #include @@ -1178,7 +1178,9 @@ vfs_mountroot(void) panic("vfs_mountroot: rootdev not set for DV_DISK"); if (bdevvp(rootdev, )) panic("vfs_mountroot: can't get vnode for rootdev"); + vn_lock(rootvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(rootvp, FREAD, FSCRED); + VOP_UNLOCK(rootvp); if (error) { printf("vfs_mountroot: can't open root device\n"); return (error);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sat Mar 19 13:50:28 UTC 2022 Modified Files: src/sys/kern: vfs_mount.c Log Message: Lock vnode across VOP_OPEN. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sat Mar 19 13:50:02 UTC 2022 Modified Files: src/sys/kern: vfs_vnops.c Log Message: Lock vnode across VOP_OPEN. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/sys/kern/vfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnops.c diff -u src/sys/kern/vfs_vnops.c:1.225 src/sys/kern/vfs_vnops.c:1.226 --- src/sys/kern/vfs_vnops.c:1.225 Sun Mar 13 13:52:53 2022 +++ src/sys/kern/vfs_vnops.c Sat Mar 19 13:50:02 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnops.c,v 1.225 2022/03/13 13:52:53 riastradh Exp $ */ +/* $NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 hannken Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.225 2022/03/13 13:52:53 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.226 2022/03/19 13:50:02 hannken Exp $"); #include "veriexec.h" @@ -1344,13 +1344,15 @@ vn_bdev_open(dev_t dev, struct vnode **v if ((error = bdevvp(dev, vpp)) != 0) return error; + vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); if ((error = VOP_OPEN(*vpp, FREAD | FWRITE, l->l_cred)) != 0) { - vrele(*vpp); + vput(*vpp); return error; } mutex_enter((*vpp)->v_interlock); (*vpp)->v_writecount++; mutex_exit((*vpp)->v_interlock); + VOP_UNLOCK(*vpp); return 0; }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sat Mar 19 13:50:02 UTC 2022 Modified Files: src/sys/kern: vfs_vnops.c Log Message: Lock vnode across VOP_OPEN. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/sys/kern/vfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/landisk/landisk
Module Name:src Committed By: hannken Date: Sat Mar 19 13:49:21 UTC 2022 Modified Files: src/sys/arch/landisk/landisk: autoconf.c Log Message: Lock vnode across VOP_OPEN/VOP_IOCTL/VOP_CLOSE. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/landisk/landisk/autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/landisk/landisk/autoconf.c diff -u src/sys/arch/landisk/landisk/autoconf.c:1.8 src/sys/arch/landisk/landisk/autoconf.c:1.9 --- src/sys/arch/landisk/landisk/autoconf.c:1.8 Sat Apr 6 00:09:09 2019 +++ src/sys/arch/landisk/landisk/autoconf.c Sat Mar 19 13:49:21 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.8 2019/04/06 00:09:09 uwe Exp $ */ +/* $NetBSD: autoconf.c,v 1.9 2022/03/19 13:49:21 hannken Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.8 2019/04/06 00:09:09 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.9 2022/03/19 13:49:21 hannken Exp $"); #include #include @@ -107,6 +107,7 @@ match_bootdisk(device_t dv, struct btinf */ if (bdevvp(MAKEDISKDEV(bmajor, device_unit(dv), RAW_PART), )) panic("match_bootdisk: can't alloc vnode"); + vn_lock(tmpvn, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(tmpvn, FREAD, NOCRED); if (error) { #ifndef DEBUG
CVS commit: src/sys/arch/landisk/landisk
Module Name:src Committed By: hannken Date: Sat Mar 19 13:49:21 UTC 2022 Modified Files: src/sys/arch/landisk/landisk: autoconf.c Log Message: Lock vnode across VOP_OPEN/VOP_IOCTL/VOP_CLOSE. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/landisk/landisk/autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/ufs/mfs
Module Name:src Committed By: hannken Date: Sat Mar 19 13:48:42 UTC 2022 Modified Files: src/sys/ufs/mfs: mfs_vfsops.c mfs_vnops.c Log Message: Switch MFS device node to real vnode locking, VV_LOCKSWORK now. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/ufs/mfs/mfs_vfsops.c cvs rdiff -u -r1.63 -r1.64 src/sys/ufs/mfs/mfs_vnops.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/mfs/mfs_vfsops.c diff -u src/sys/ufs/mfs/mfs_vfsops.c:1.114 src/sys/ufs/mfs/mfs_vfsops.c:1.115 --- src/sys/ufs/mfs/mfs_vfsops.c:1.114 Mon Mar 16 21:20:13 2020 +++ src/sys/ufs/mfs/mfs_vfsops.c Sat Mar 19 13:48:42 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: mfs_vfsops.c,v 1.114 2020/03/16 21:20:13 pgoyette Exp $ */ +/* $NetBSD: mfs_vfsops.c,v 1.115 2022/03/19 13:48:42 hannken Exp $ */ /* * Copyright (c) 1989, 1990, 1993, 1994 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.114 2020/03/16 21:20:13 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mfs_vfsops.c,v 1.115 2022/03/19 13:48:42 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -208,6 +208,7 @@ mfs_mountroot(void) rootvp->v_data = mfsp; rootvp->v_op = mfs_vnodeop_p; rootvp->v_tag = VT_MFS; + rootvp->v_vflag |= VV_LOCKSWORK; mfsp->mfs_baseoff = mfs_rootbase; mfsp->mfs_size = mfs_rootsize; mfsp->mfs_vnode = rootvp; @@ -326,6 +327,7 @@ mfs_mount(struct mount *mp, const char * KASSERT(devvp->v_data == NULL); devvp->v_op = mfs_vnodeop_p; devvp->v_data = mfsp; + devvp->v_vflag |= VV_LOCKSWORK; mfsp->mfs_baseoff = args->base; mfsp->mfs_size = args->size; mfsp->mfs_vnode = devvp; Index: src/sys/ufs/mfs/mfs_vnops.c diff -u src/sys/ufs/mfs/mfs_vnops.c:1.63 src/sys/ufs/mfs/mfs_vnops.c:1.64 --- src/sys/ufs/mfs/mfs_vnops.c:1.63 Sun Jul 18 23:57:15 2021 +++ src/sys/ufs/mfs/mfs_vnops.c Sat Mar 19 13:48:42 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: mfs_vnops.c,v 1.63 2021/07/18 23:57:15 dholland Exp $ */ +/* $NetBSD: mfs_vnops.c,v 1.64 2022/03/19 13:48:42 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mfs_vnops.c,v 1.63 2021/07/18 23:57:15 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mfs_vnops.c,v 1.64 2022/03/19 13:48:42 hannken Exp $"); #include #include @@ -89,12 +89,12 @@ const struct vnodeopv_entry_desc mfs_vno { _abortop_desc, genfs_badop }, /* abortop */ { _inactive_desc, mfs_inactive }, /* inactive */ { _reclaim_desc, mfs_reclaim }, /* reclaim */ - { _lock_desc, genfs_nolock }, /* lock */ - { _unlock_desc, genfs_nounlock }, /* unlock */ + { _lock_desc, genfs_lock }, /* lock */ + { _unlock_desc, genfs_unlock }, /* unlock */ { _bmap_desc, mfs_bmap }, /* bmap */ { _strategy_desc, mfs_strategy }, /* strategy */ { _print_desc, mfs_print }, /* print */ - { _islocked_desc, genfs_noislocked }, /* islocked */ + { _islocked_desc, genfs_islocked }, /* islocked */ { _pathconf_desc, genfs_badop }, /* pathconf */ { _advlock_desc, genfs_badop }, /* advlock */ { _bwrite_desc, vn_bwrite }, /* bwrite */
CVS commit: src/sys/ufs/mfs
Module Name:src Committed By: hannken Date: Sat Mar 19 13:48:42 UTC 2022 Modified Files: src/sys/ufs/mfs: mfs_vfsops.c mfs_vnops.c Log Message: Switch MFS device node to real vnode locking, VV_LOCKSWORK now. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/ufs/mfs/mfs_vfsops.c cvs rdiff -u -r1.63 -r1.64 src/sys/ufs/mfs/mfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Sat Mar 19 13:48:04 UTC 2022 Modified Files: src/sys/fs/union: union_subr.c union_vnops.c Log Message: As FSTRANS is part of VOP_*LOCK() since June 4, 2017 the vdead_check() from union_lock() is no longer needed. Adapt union_lock() to the recent addition of upgrade or downgrade. VV_LOCKSWORK now. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.82 -r1.83 src/sys/fs/union/union_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Sat Mar 19 13:48:04 UTC 2022 Modified Files: src/sys/fs/union: union_subr.c union_vnops.c Log Message: As FSTRANS is part of VOP_*LOCK() since June 4, 2017 the vdead_check() from union_lock() is no longer needed. Adapt union_lock() to the recent addition of upgrade or downgrade. VV_LOCKSWORK now. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.82 -r1.83 src/sys/fs/union/union_vnops.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/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.79 src/sys/fs/union/union_subr.c:1.80 --- src/sys/fs/union/union_subr.c:1.79 Tue Aug 18 09:44:07 2020 +++ src/sys/fs/union/union_subr.c Sat Mar 19 13:48:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.79 2020/08/18 09:44:07 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.80 2022/03/19 13:48:04 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.79 2020/08/18 09:44:07 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.80 2022/03/19 13:48:04 hannken Exp $"); #include #include @@ -567,6 +567,7 @@ union_loadvnode(struct mount *mp, struct vp->v_tag = VT_UNION; vp->v_op = union_vnodeop_p; + vp->v_vflag |= VV_LOCKSWORK; vp->v_data = un; un->un_vnode = vp; Index: src/sys/fs/union/union_vnops.c diff -u src/sys/fs/union/union_vnops.c:1.82 src/sys/fs/union/union_vnops.c:1.83 --- src/sys/fs/union/union_vnops.c:1.82 Fri Dec 10 19:30:05 2021 +++ src/sys/fs/union/union_vnops.c Sat Mar 19 13:48:04 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vnops.c,v 1.82 2021/12/10 19:30:05 andvar Exp $ */ +/* $NetBSD: union_vnops.c,v 1.83 2022/03/19 13:48:04 hannken Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995 @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.82 2021/12/10 19:30:05 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.83 2022/03/19 13:48:04 hannken Exp $"); #include #include @@ -1709,15 +1709,6 @@ union_lock(void *v) lockvp = LOCKVP(vp); error = union_lock1(vp, lockvp, flags); mutex_exit(>un_lock); - if (error) - return error; - if (mutex_tryenter(vp->v_interlock)) { - error = vdead_check(vp, VDEAD_NOWAIT); - mutex_exit(vp->v_interlock); - } else - error = EBUSY; - if (error) - union_unlock1(vp, lockvp); return error; } @@ -1726,7 +1717,7 @@ union_lock(void *v) lockvp = LOCKVP(vp); mutex_exit(>un_lock); error = union_lock1(vp, lockvp, flags); - if (error != 0) + if (error != 0 || (flags & (LK_DOWNGRADE | LK_UPGRADE)) != 0) return error; mutex_enter(>un_lock); if (lockvp == LOCKVP(vp)) @@ -1735,14 +1726,6 @@ union_lock(void *v) } mutex_exit(>un_lock); - mutex_enter(vp->v_interlock); - error = vdead_check(vp, VDEAD_NOWAIT); - if (error) { - union_unlock1(vp, lockvp); - error = vdead_check(vp, 0); - KASSERT(error == ENOENT); - } - mutex_exit(vp->v_interlock); return error; }
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:55:03 UTC 2022 Modified Files: src/sys/arch/arm/broadcom: bcm2835_rng.c src/sys/arch/arm/omap: am335x_trng.c src/sys/arch/arm/ti: ti_rng.c src/sys/arch/mips/cavium/dev: octeon_rnm.c src/sys/arch/mips/ingenic: ingenic_rng.c src/sys/dev/ic: amdccp.c amdccpvar.h rng200.c rng200var.h Log Message: rnd(9): Omit needless locks in various HWRNG drivers. Now that the rnd(9) API guarantees serial callbacks, we can simplify everything a bit more. (Some drivers like hifn(4) and sun8icrypto(4) still use locks to coordinate with other parts of the driver to submit requests to and process responses from the device.) To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/broadcom/bcm2835_rng.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/omap/am335x_trng.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_rng.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/mips/cavium/dev/octeon_rnm.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/ingenic/ingenic_rng.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/amdccp.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/amdccpvar.h \ src/sys/dev/ic/rng200var.h cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/rng200.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/broadcom/bcm2835_rng.c diff -u src/sys/arch/arm/broadcom/bcm2835_rng.c:1.16 src/sys/arch/arm/broadcom/bcm2835_rng.c:1.17 --- src/sys/arch/arm/broadcom/bcm2835_rng.c:1.16 Sat Mar 19 11:37:05 2022 +++ src/sys/arch/arm/broadcom/bcm2835_rng.c Sat Mar 19 11:55:03 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bcm2835_rng.c,v 1.16 2022/03/19 11:37:05 riastradh Exp $ */ +/* $NetBSD: bcm2835_rng.c,v 1.17 2022/03/19 11:55:03 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.16 2022/03/19 11:37:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.17 2022/03/19 11:55:03 riastradh Exp $"); #include #include @@ -58,7 +58,6 @@ struct bcm2835rng_softc { bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; - kmutex_t sc_lock; krndsource_t sc_rndsource; }; @@ -121,7 +120,6 @@ bcmrng_attach(device_t parent, device_t bus_space_write_4(sc->sc_iot, sc->sc_ioh, RNG_CTRL, ctrl); /* set up an rndsource */ - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL); rndsource_setcb(>sc_rndsource, _get, sc); rnd_attach_source(>sc_rndsource, device_xname(self), RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB); @@ -134,7 +132,6 @@ bcmrng_get(size_t bytes_wanted, void *ar uint32_t status, cnt; uint32_t buf[RNG_DATA_MAX]; /* 1k on the stack */ - mutex_enter(>sc_lock); while (bytes_wanted) { status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, RNG_STATUS); cnt = __SHIFTOUT(status, RNG_STATUS_CNT); @@ -148,5 +145,4 @@ bcmrng_get(size_t bytes_wanted, void *ar bytes_wanted -= MIN(bytes_wanted, (cnt * 4)); } explicit_memset(buf, 0, sizeof(buf)); - mutex_exit(>sc_lock); } Index: src/sys/arch/arm/omap/am335x_trng.c diff -u src/sys/arch/arm/omap/am335x_trng.c:1.4 src/sys/arch/arm/omap/am335x_trng.c:1.5 --- src/sys/arch/arm/omap/am335x_trng.c:1.4 Sat Mar 19 11:37:05 2022 +++ src/sys/arch/arm/omap/am335x_trng.c Sat Mar 19 11:55:03 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: am335x_trng.c,v 1.4 2022/03/19 11:37:05 riastradh Exp $ */ +/* $NetBSD: am335x_trng.c,v 1.5 2022/03/19 11:55:03 riastradh Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.4 2022/03/19 11:37:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.5 2022/03/19 11:55:03 riastradh Exp $"); #include "opt_omap.h" @@ -56,7 +56,6 @@ struct trng_softc { bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; - kmutex_t sc_lock; krndsource_t sc_rndsource; }; @@ -99,8 +98,6 @@ trng_attach(device_t parent, device_t se return; } - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL); - prcm_module_enable(_module); if ((TRNG_READ(sc, TRNG_CONTROL_REG) & TRNG_CONTROL_ENABLE) == 0) { @@ -127,7 +124,6 @@ trng_callback(size_t bytes_wanted, void uint32_t buf[2]; u_int retry; - mutex_enter(>sc_lock); while (bytes_wanted) { for (retry = 10; retry > 0; retry--) { if (TRNG_READ(sc, TRNG_STATUS_REG) & TRNG_STATUS_READY) @@ -144,5 +140,4 @@ trng_callback(size_t bytes_wanted, void bytes_wanted -= MIN(bytes_wanted, sizeof(buf)); } explicit_memset(buf, 0, sizeof(buf)); - mutex_exit(>sc_lock); } Index: src/sys/arch/arm/ti/ti_rng.c diff -u src/sys/arch/arm/ti/ti_rng.c:1.6 src/sys/arch/arm/ti/ti_rng.c:1.7 --- src/sys/arch/arm/ti/ti_rng.c:1.6 Sat Mar 19 11:37:05 2022 +++ src/sys/arch/arm/ti/ti_rng.c Sat Mar 19 11:55:03 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ti_rng.c,v 1.6 2022/03/19 11:37:05 riastradh Exp $
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:55:03 UTC 2022 Modified Files: src/sys/arch/arm/broadcom: bcm2835_rng.c src/sys/arch/arm/omap: am335x_trng.c src/sys/arch/arm/ti: ti_rng.c src/sys/arch/mips/cavium/dev: octeon_rnm.c src/sys/arch/mips/ingenic: ingenic_rng.c src/sys/dev/ic: amdccp.c amdccpvar.h rng200.c rng200var.h Log Message: rnd(9): Omit needless locks in various HWRNG drivers. Now that the rnd(9) API guarantees serial callbacks, we can simplify everything a bit more. (Some drivers like hifn(4) and sun8icrypto(4) still use locks to coordinate with other parts of the driver to submit requests to and process responses from the device.) To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/broadcom/bcm2835_rng.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/omap/am335x_trng.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_rng.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/mips/cavium/dev/octeon_rnm.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/mips/ingenic/ingenic_rng.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/amdccp.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/amdccpvar.h \ src/sys/dev/ic/rng200var.h cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/rng200.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:54:53 UTC 2022 Modified Files: src/share/man/man9: rnd.9 Log Message: rnd(9): Document the serial use of rndsource callbacks. This simplifies the rndsource API -- no need to lock, unless you're also coordinating with other driver logic like concurrent opencrypto(4) requests that share device requests. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/share/man/man9/rnd.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/rnd.9 diff -u src/share/man/man9/rnd.9:1.29 src/share/man/man9/rnd.9:1.30 --- src/share/man/man9/rnd.9:1.29 Mon May 4 15:13:45 2020 +++ src/share/man/man9/rnd.9 Sat Mar 19 11:54:53 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: rnd.9,v 1.29 2020/05/04 15:13:45 wiz Exp $ +.\" $NetBSD: rnd.9,v 1.30 2022/03/19 11:54:53 riastradh Exp $ .\" .\" Copyright (c) 1997 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -165,6 +165,12 @@ not or .Fn rnd_add_uint32 . .El +.Pp +.Nm +issues calls to each source's +.Fa callback +in serial \(em it never issues two calls to the same source's callback +at the same time in two differen threads or on two different CPUs. .It Fn rnd_attach_source "rnd_source" "devname" "type" "flags" Makes .Fa rnd_source
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:54:53 UTC 2022 Modified Files: src/share/man/man9: rnd.9 Log Message: rnd(9): Document the serial use of rndsource callbacks. This simplifies the rndsource API -- no need to lock, unless you're also coordinating with other driver logic like concurrent opencrypto(4) requests that share device requests. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/share/man/man9/rnd.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/nvidia
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:37:17 UTC 2022 Modified Files: src/sys/arch/arm/nvidia: tegra124_car.c Log Message: tegra124_car(4): Attach rndsource synchronously. It looks like the original motivation for deferring to config_interrupts was to wait until softint_establish worked. But this no longer needs to use softints to deliver the entropy, so that's moot. Doing this synchronously gives us a better chance for more entropy earlier. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/nvidia/tegra124_car.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/nvidia/tegra124_car.c diff -u src/sys/arch/arm/nvidia/tegra124_car.c:1.23 src/sys/arch/arm/nvidia/tegra124_car.c:1.24 --- src/sys/arch/arm/nvidia/tegra124_car.c:1.23 Sat Mar 19 11:36:53 2022 +++ src/sys/arch/arm/nvidia/tegra124_car.c Sat Mar 19 11:37:17 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tegra124_car.c,v 1.23 2022/03/19 11:36:53 riastradh Exp $ */ +/* $NetBSD: tegra124_car.c,v 1.24 2022/03/19 11:37:17 riastradh Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tegra124_car.c,v 1.23 2022/03/19 11:36:53 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tegra124_car.c,v 1.24 2022/03/19 11:37:17 riastradh Exp $"); #include #include @@ -785,7 +785,7 @@ tegra124_car_attach(device_t parent, dev tegra124_car_init(sc); - config_interrupts(self, tegra124_car_rnd_attach); + tegra124_car_rnd_attach(self); } static void
CVS commit: src/sys/arch/arm/nvidia
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:37:17 UTC 2022 Modified Files: src/sys/arch/arm/nvidia: tegra124_car.c Log Message: tegra124_car(4): Attach rndsource synchronously. It looks like the original motivation for deferring to config_interrupts was to wait until softint_establish worked. But this no longer needs to use softints to deliver the entropy, so that's moot. Doing this synchronously gives us a better chance for more entropy earlier. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/nvidia/tegra124_car.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:37:06 UTC 2022 Modified Files: src/sys/arch/arm/broadcom: bcm2835_rng.c src/sys/arch/arm/omap: am335x_trng.c src/sys/arch/arm/rockchip: rk_v1crypto.c src/sys/arch/arm/sunxi: sun8i_crypto.c src/sys/arch/arm/ti: ti_rng.c src/sys/arch/mips/cavium/dev: octeon_rnm.c src/sys/arch/mips/ingenic: ingenic_rng.c src/sys/dev/ic: amdccp.c rng200.c src/sys/dev/pci: amdpm.c viornd.c src/sys/dev/usb: ualea.c Log Message: rnd(9): Adjust IPL of locks used by rndsource callbacks. These no longer ever run from hard interrupt context or with a spin lock held, so there is no longer any need to have them at IPL_VM to block hard interrupts. Instead, lower them to IPL_SOFTSERIAL. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/broadcom/bcm2835_rng.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/omap/am335x_trng.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/rockchip/rk_v1crypto.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/sunxi/sun8i_crypto.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/ti_rng.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mips/cavium/dev/octeon_rnm.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/mips/ingenic/ingenic_rng.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/amdccp.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/rng200.c cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/amdpm.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/viornd.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/usb/ualea.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/broadcom/bcm2835_rng.c diff -u src/sys/arch/arm/broadcom/bcm2835_rng.c:1.15 src/sys/arch/arm/broadcom/bcm2835_rng.c:1.16 --- src/sys/arch/arm/broadcom/bcm2835_rng.c:1.15 Wed Jan 27 03:10:19 2021 +++ src/sys/arch/arm/broadcom/bcm2835_rng.c Sat Mar 19 11:37:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bcm2835_rng.c,v 1.15 2021/01/27 03:10:19 thorpej Exp $ */ +/* $NetBSD: bcm2835_rng.c,v 1.16 2022/03/19 11:37:05 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.15 2021/01/27 03:10:19 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.16 2022/03/19 11:37:05 riastradh Exp $"); #include #include @@ -121,7 +121,7 @@ bcmrng_attach(device_t parent, device_t bus_space_write_4(sc->sc_iot, sc->sc_ioh, RNG_CTRL, ctrl); /* set up an rndsource */ - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM); + mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL); rndsource_setcb(>sc_rndsource, _get, sc); rnd_attach_source(>sc_rndsource, device_xname(self), RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB); @@ -134,7 +134,7 @@ bcmrng_get(size_t bytes_wanted, void *ar uint32_t status, cnt; uint32_t buf[RNG_DATA_MAX]; /* 1k on the stack */ - mutex_spin_enter(>sc_lock); + mutex_enter(>sc_lock); while (bytes_wanted) { status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, RNG_STATUS); cnt = __SHIFTOUT(status, RNG_STATUS_CNT); @@ -148,5 +148,5 @@ bcmrng_get(size_t bytes_wanted, void *ar bytes_wanted -= MIN(bytes_wanted, (cnt * 4)); } explicit_memset(buf, 0, sizeof(buf)); - mutex_spin_exit(>sc_lock); + mutex_exit(>sc_lock); } Index: src/sys/arch/arm/omap/am335x_trng.c diff -u src/sys/arch/arm/omap/am335x_trng.c:1.3 src/sys/arch/arm/omap/am335x_trng.c:1.4 --- src/sys/arch/arm/omap/am335x_trng.c:1.3 Thu Apr 30 03:40:52 2020 +++ src/sys/arch/arm/omap/am335x_trng.c Sat Mar 19 11:37:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: am335x_trng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $ */ +/* $NetBSD: am335x_trng.c,v 1.4 2022/03/19 11:37:05 riastradh Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.4 2022/03/19 11:37:05 riastradh Exp $"); #include "opt_omap.h" @@ -99,7 +99,7 @@ trng_attach(device_t parent, device_t se return; } - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM); + mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL); prcm_module_enable(_module); Index: src/sys/arch/arm/rockchip/rk_v1crypto.c diff -u src/sys/arch/arm/rockchip/rk_v1crypto.c:1.7 src/sys/arch/arm/rockchip/rk_v1crypto.c:1.8 --- src/sys/arch/arm/rockchip/rk_v1crypto.c:1.7 Wed Jan 27 03:10:19 2021 +++ src/sys/arch/arm/rockchip/rk_v1crypto.c Sat Mar 19 11:37:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: rk_v1crypto.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $ */ +/* $NetBSD: rk_v1crypto.c,v 1.8 2022/03/19 11:37:05 riastradh Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.7 2021/01/27 03:10:19 thorpej Exp $"); +__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.8 2022/03/19
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:37:06 UTC 2022 Modified Files: src/sys/arch/arm/broadcom: bcm2835_rng.c src/sys/arch/arm/omap: am335x_trng.c src/sys/arch/arm/rockchip: rk_v1crypto.c src/sys/arch/arm/sunxi: sun8i_crypto.c src/sys/arch/arm/ti: ti_rng.c src/sys/arch/mips/cavium/dev: octeon_rnm.c src/sys/arch/mips/ingenic: ingenic_rng.c src/sys/dev/ic: amdccp.c rng200.c src/sys/dev/pci: amdpm.c viornd.c src/sys/dev/usb: ualea.c Log Message: rnd(9): Adjust IPL of locks used by rndsource callbacks. These no longer ever run from hard interrupt context or with a spin lock held, so there is no longer any need to have them at IPL_VM to block hard interrupts. Instead, lower them to IPL_SOFTSERIAL. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/broadcom/bcm2835_rng.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/omap/am335x_trng.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/rockchip/rk_v1crypto.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/sunxi/sun8i_crypto.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/ti_rng.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mips/cavium/dev/octeon_rnm.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/mips/ingenic/ingenic_rng.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/amdccp.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/rng200.c cvs rdiff -u -r1.42 -r1.43 src/sys/dev/pci/amdpm.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/viornd.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/usb/ualea.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/nvidia
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:36:53 UTC 2022 Modified Files: src/sys/arch/arm/nvidia: tegra124_car.c Log Message: tegra124_car(4): No need for rnd lock -- delete it. This only ever reads from a single device register, so no need to serialize access. XXX This should really have a hardware-specific health test, but I can't find any documentation on the underlying physical entropy source. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/nvidia/tegra124_car.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/nvidia/tegra124_car.c diff -u src/sys/arch/arm/nvidia/tegra124_car.c:1.22 src/sys/arch/arm/nvidia/tegra124_car.c:1.23 --- src/sys/arch/arm/nvidia/tegra124_car.c:1.22 Wed Jan 27 03:10:19 2021 +++ src/sys/arch/arm/nvidia/tegra124_car.c Sat Mar 19 11:36:53 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tegra124_car.c,v 1.22 2021/01/27 03:10:19 thorpej Exp $ */ +/* $NetBSD: tegra124_car.c,v 1.23 2022/03/19 11:36:53 riastradh Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tegra124_car.c,v 1.22 2021/01/27 03:10:19 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tegra124_car.c,v 1.23 2022/03/19 11:36:53 riastradh Exp $"); #include #include @@ -708,7 +708,6 @@ struct tegra124_car_softc { u_int sc_clock_cells; u_int sc_reset_cells; - kmutex_t sc_rndlock; krndsource_t sc_rndsource; }; @@ -917,7 +916,6 @@ tegra124_car_rnd_attach(device_t self) { struct tegra124_car_softc * const sc = device_private(self); - mutex_init(>sc_rndlock, MUTEX_DEFAULT, IPL_VM); rndsource_setcb(>sc_rndsource, tegra124_car_rnd_callback, sc); rnd_attach_source(>sc_rndsource, device_xname(sc->sc_dev), RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB); @@ -930,7 +928,6 @@ tegra124_car_rnd_callback(size_t bytes_w uint16_t buf[512]; uint32_t cnt; - mutex_enter(>sc_rndlock); while (bytes_wanted) { const u_int nbytes = MIN(bytes_wanted, 1024); for (cnt = 0; cnt < bytes_wanted / 2; cnt++) { @@ -942,7 +939,6 @@ tegra124_car_rnd_callback(size_t bytes_w bytes_wanted -= MIN(bytes_wanted, nbytes); } explicit_memset(buf, 0, sizeof(buf)); - mutex_exit(>sc_rndlock); } static struct tegra_clk *
CVS commit: src/sys/arch/arm/nvidia
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:36:53 UTC 2022 Modified Files: src/sys/arch/arm/nvidia: tegra124_car.c Log Message: tegra124_car(4): No need for rnd lock -- delete it. This only ever reads from a single device register, so no need to serialize access. XXX This should really have a hardware-specific health test, but I can't find any documentation on the underlying physical entropy source. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/nvidia/tegra124_car.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:36:43 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: meson_rng.c Log Message: meson_rng(4): No need for lock -- delete it. We only ever read a single register at a time; no exclusive access or serialization needed. XXX This driver should have some kind of hardware-specific health test -- is there documentation anywhere for what this RNG actually is? To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_rng.c diff -u src/sys/arch/arm/amlogic/meson_rng.c:1.4 src/sys/arch/arm/amlogic/meson_rng.c:1.5 --- src/sys/arch/arm/amlogic/meson_rng.c:1.4 Wed Jan 27 03:10:18 2021 +++ src/sys/arch/arm/amlogic/meson_rng.c Sat Mar 19 11:36:43 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_rng.c,v 1.4 2021/01/27 03:10:18 thorpej Exp $ */ +/* $NetBSD: meson_rng.c,v 1.5 2022/03/19 11:36:43 riastradh Exp $ */ /*- * Copyright (c) 2015-2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.4 2021/01/27 03:10:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.5 2022/03/19 11:36:43 riastradh Exp $"); #include #include @@ -49,7 +49,6 @@ struct meson_rng_softc { bus_space_tag_t sc_bst; bus_space_handle_t sc_bsh; - kmutex_t sc_lock; krndsource_t sc_rndsource; }; @@ -91,8 +90,6 @@ meson_rng_attach(device_t parent, device return; } - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM); - /* Core clock is optional */ clk = fdtbus_clock_get(phandle, "core"); if (clk != NULL && clk_enable(clk) != 0) { @@ -114,7 +111,6 @@ meson_rng_get(size_t bytes_wanted, void struct meson_rng_softc * const sc = priv; uint32_t data; - mutex_spin_enter(>sc_lock); while (bytes_wanted) { data = bus_space_read_4(sc->sc_bst, sc->sc_bsh, 0); rnd_add_data_sync(>sc_rndsource, , sizeof(data), @@ -122,5 +118,4 @@ meson_rng_get(size_t bytes_wanted, void bytes_wanted -= MIN(bytes_wanted, sizeof(data)); } explicit_memset(, 0, sizeof(data)); - mutex_spin_exit(>sc_lock); }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:36:43 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: meson_rng.c Log Message: meson_rng(4): No need for lock -- delete it. We only ever read a single register at a time; no exclusive access or serialization needed. XXX This driver should have some kind of hardware-specific health test -- is there documentation anywhere for what this RNG actually is? To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sat Mar 19 10:05:52 UTC 2022 Modified Files: src/sys/dev/usb: usbdi.c Log Message: usbdi(9): Fix usbd_get_no_alts. This incorrectly rejected the configuration as invalid if any descriptor is not large enough to be interface descriptors. Instead, it should reject the configuration only if any descriptor is not large enough to be a _descriptor_, or if any interface-type descriptor is not large enough to be an interface descriptor, but skip over descriptors of other types even if they're smaller than interface descriptors. Candidate fix for PR kern/56762. To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.238 src/sys/dev/usb/usbdi.c:1.239 --- src/sys/dev/usb/usbdi.c:1.238 Sun Mar 13 13:07:39 2022 +++ src/sys/dev/usb/usbdi.c Sat Mar 19 10:05:52 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.238 2022/03/13 13:07:39 riastradh Exp $ */ +/* $NetBSD: usbdi.c,v 1.239 2022/03/19 10:05:52 riastradh Exp $ */ /* * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.238 2022/03/13 13:07:39 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.239 2022/03/19 10:05:52 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -973,16 +973,24 @@ usbd_get_no_alts(usb_config_descriptor_t { char *p = (char *)cdesc; char *end = p + UGETW(cdesc->wTotalLength); - usb_interface_descriptor_t *d; + usb_descriptor_t *desc; + usb_interface_descriptor_t *idesc; int n; - for (n = 0; end - p >= sizeof(*d); p += d->bLength) { - d = (usb_interface_descriptor_t *)p; - if (d->bLength < sizeof(*d) || d->bLength > end - p) + for (n = 0; end - p >= sizeof(*desc); p += desc->bLength) { + desc = (usb_descriptor_t *)p; + if (desc->bLength < sizeof(*desc) || desc->bLength > end - p) break; - if (d->bDescriptorType == UDESC_INTERFACE && - d->bInterfaceNumber == ifaceno) + if (desc->bDescriptorType != UDESC_INTERFACE) + continue; + if (desc->bLength < sizeof(*idesc)) + break; + idesc = (usb_interface_descriptor_t *)desc; + if (idesc->bInterfaceNumber == ifaceno) { n++; + if (n == INT_MAX) +break; + } } return n; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: riastradh Date: Sat Mar 19 10:05:52 UTC 2022 Modified Files: src/sys/dev/usb: usbdi.c Log Message: usbdi(9): Fix usbd_get_no_alts. This incorrectly rejected the configuration as invalid if any descriptor is not large enough to be interface descriptors. Instead, it should reject the configuration only if any descriptor is not large enough to be a _descriptor_, or if any interface-type descriptor is not large enough to be an interface descriptor, but skip over descriptors of other types even if they're smaller than interface descriptors. Candidate fix for PR kern/56762. To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/fdt
Module Name:src Committed By: skrll Date: Sat Mar 19 09:55:30 UTC 2022 Modified Files: src/sys/arch/evbarm/fdt: fdt_machdep.c Log Message: Improve a VPRINTF To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/arch/evbarm/fdt/fdt_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/evbarm/fdt/fdt_machdep.c diff -u src/sys/arch/evbarm/fdt/fdt_machdep.c:1.88 src/sys/arch/evbarm/fdt/fdt_machdep.c:1.89 --- src/sys/arch/evbarm/fdt/fdt_machdep.c:1.88 Wed Mar 9 10:06:36 2022 +++ src/sys/arch/evbarm/fdt/fdt_machdep.c Sat Mar 19 09:55:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_machdep.c,v 1.88 2022/03/09 10:06:36 mrg Exp $ */ +/* $NetBSD: fdt_machdep.c,v 1.89 2022/03/19 09:55:30 skrll Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.88 2022/03/09 10:06:36 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.89 2022/03/19 09:55:30 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_bootconfig.h" @@ -475,8 +475,8 @@ fdt_map_efi_runtime(const char *prop, en const paddr_t pa = be64toh(map[0]); const vaddr_t va = be64toh(map[1]); const size_t sz = be64toh(map[2]); - VPRINTF("%s: %s %" PRIxPADDR "-%" PRIxVADDR "(%" PRIxVADDR - "-%" PRIxVSIZE "\n", __func__, prop, pa, pa + sz - 1, + VPRINTF("%s: %s %#" PRIxPADDR "-%#" PRIxVADDR " (%#" PRIxVADDR + "-%#" PRIxVSIZE ")\n", __func__, prop, pa, pa + sz - 1, va, va + sz - 1); arm_efirt_md_map_range(va, pa, sz, type); map += 3;
CVS commit: src/sys/arch/evbarm/fdt
Module Name:src Committed By: skrll Date: Sat Mar 19 09:55:30 UTC 2022 Modified Files: src/sys/arch/evbarm/fdt: fdt_machdep.c Log Message: Improve a VPRINTF To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/arch/evbarm/fdt/fdt_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/arm32
Module Name:src Committed By: skrll Date: Sat Mar 19 09:54:25 UTC 2022 Modified Files: src/sys/arch/arm/arm32: pmap.c Log Message: Alight code re-organisation so it better matches the VPRINTF headings it is under. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.433 -r1.434 src/sys/arch/arm/arm32/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/arm/arm32/pmap.c diff -u src/sys/arch/arm/arm32/pmap.c:1.433 src/sys/arch/arm/arm32/pmap.c:1.434 --- src/sys/arch/arm/arm32/pmap.c:1.433 Sat Mar 12 15:32:31 2022 +++ src/sys/arch/arm/arm32/pmap.c Sat Mar 19 09:54:25 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.433 2022/03/12 15:32:31 riastradh Exp $ */ +/* $NetBSD: pmap.c,v 1.434 2022/03/19 09:54:25 skrll Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. @@ -192,7 +192,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.433 2022/03/12 15:32:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.434 2022/03/19 09:54:25 skrll Exp $"); #include #include @@ -6229,6 +6229,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v * Initialise the kernel pmap object */ curcpu()->ci_pmap_cur = pm; + pm->pm_refs = 1; #ifdef ARM_MMU_EXTENDED pm->pm_l1 = l1pt; pm->pm_l1_pa = kernel_l1pt.pv_pa; @@ -6242,6 +6243,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v #else pm->pm_l1 = l1; #endif + mutex_init(>pm_lock, MUTEX_DEFAULT, IPL_VM); VPRINTF("locks "); /* @@ -6250,8 +6252,6 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v */ mutex_init(_lock, MUTEX_DEFAULT, IPL_VM); mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); - mutex_init(>pm_lock, MUTEX_DEFAULT, IPL_VM); - pm->pm_refs = 1; VPRINTF("l1pt "); /*
CVS commit: src/sys/arch/arm/arm32
Module Name:src Committed By: skrll Date: Sat Mar 19 09:54:25 UTC 2022 Modified Files: src/sys/arch/arm/arm32: pmap.c Log Message: Alight code re-organisation so it better matches the VPRINTF headings it is under. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.433 -r1.434 src/sys/arch/arm/arm32/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: skrll Date: Sat Mar 19 09:53:19 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: pmap.c Log Message: Slight code re-organisation. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/arch/aarch64/aarch64/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/aarch64/aarch64/pmap.c diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.130 src/sys/arch/aarch64/aarch64/pmap.c:1.131 --- src/sys/arch/aarch64/aarch64/pmap.c:1.130 Sat Mar 12 15:32:30 2022 +++ src/sys/arch/aarch64/aarch64/pmap.c Sat Mar 19 09:53:18 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.130 2022/03/12 15:32:30 riastradh Exp $ */ +/* $NetBSD: pmap.c,v 1.131 2022/03/19 09:53:18 skrll Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.130 2022/03/12 15:32:30 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.131 2022/03/19 09:53:18 skrll Exp $"); #include "opt_arm_debug.h" #include "opt_cpuoptions.h" @@ -276,7 +276,7 @@ phys_to_pp(paddr_t pa) #endif /* __HAVE_PMAP_PV_TRACK */ } -#define IN_RANGE(va,sta,end) (((sta) <= (va)) && ((va) < (end))) +#define IN_RANGE(va, sta, end) (((sta) <= (va)) && ((va) < (end))) #define IN_DIRECTMAP_ADDR(va) \ IN_RANGE((va), AARCH64_DIRECTMAP_START, AARCH64_DIRECTMAP_END) @@ -288,31 +288,34 @@ phys_to_pp(paddr_t pa) #endif #ifdef DIAGNOSTIC -#define KASSERT_PM_ADDR(pm,va) \ - do {\ - int space = aarch64_addressspace(va); \ - if ((pm) == pmap_kernel()) {\ - KASSERTMSG(space == AARCH64_ADDRSPACE_UPPER, \ - "%s: kernel pm %p: va=%016lx" \ - " is out of upper address space", \ - __func__, (pm), (va)); \ - KASSERTMSG(IN_RANGE((va), VM_MIN_KERNEL_ADDRESS, \ - VM_MAX_KERNEL_ADDRESS), \ - "%s: kernel pm %p: va=%016lx" \ - " is not kernel address", \ - __func__, (pm), (va)); \ - } else { \ - KASSERTMSG(space == AARCH64_ADDRSPACE_LOWER, \ - "%s: user pm %p: va=%016lx" \ - " is out of lower address space", \ - __func__, (pm), (va)); \ - KASSERTMSG(IN_RANGE((va), \ - VM_MIN_ADDRESS, VM_MAX_ADDRESS), \ - "%s: user pm %p: va=%016lx" \ - " is not user address", \ - __func__, (pm), (va)); \ - } \ - } while (0 /* CONSTCOND */) + +#define KERNEL_ADDR_P(va) \ +IN_RANGE((va), VM_MIN_KERNEL_ADDRESS, VM_MAX_KERNEL_ADDRESS) + +#define KASSERT_PM_ADDR(pm, va) \ +do {\ + int space = aarch64_addressspace(va);\ + if ((pm) == pmap_kernel()) { \ + KASSERTMSG(space == AARCH64_ADDRSPACE_UPPER, \ + "%s: kernel pm %p: va=%016lx" \ + " is out of upper address space", \ + __func__, (pm), (va));\ + KASSERTMSG(KERNEL_ADDR_P(va),\ + "%s: kernel pm %p: va=%016lx" \ + " is not kernel address",\ + __func__, (pm), (va));\ + } else { \ + KASSERTMSG(space == AARCH64_ADDRSPACE_LOWER, \ + "%s: user pm %p: va=%016lx"\ + " is out of lower address space", \ + __func__, (pm), (va));\ + KASSERTMSG(IN_RANGE((va),\ + VM_MIN_ADDRESS, VM_MAX_ADDRESS), \ + "%s: user pm %p: va=%016lx"\ + " is not user address",\ + __func__, (pm), (va));\ + }\ +} while (0 /* CONSTCOND */) #else /* DIAGNOSTIC */ #define KASSERT_PM_ADDR(pm,va) #endif /* DIAGNOSTIC */
CVS commit: src/sys/arch/aarch64/aarch64
Module Name:src Committed By: skrll Date: Sat Mar 19 09:53:19 UTC 2022 Modified Files: src/sys/arch/aarch64/aarch64: pmap.c Log Message: Slight code re-organisation. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/arch/aarch64/aarch64/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.