Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern autoconf(9), drvctl(4): Sprinkle kernel lock assert...



details:   https://anonhg.NetBSD.org/src/rev/63a0f9f5b175
branches:  trunk
changeset: 1021642:63a0f9f5b175
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Jun 12 12:12:11 2021 +0000

description:
autoconf(9), drvctl(4): Sprinkle kernel lock assertions.

diffstat:

 sys/kern/kern_drvctl.c   |  12 ++++++++++--
 sys/kern/subr_autoconf.c |  28 ++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 4 deletions(-)

diffs (180 lines):

diff -r b2c0162f1b27 -r 63a0f9f5b175 sys/kern/kern_drvctl.c
--- a/sys/kern/kern_drvctl.c    Sat Jun 12 12:11:59 2021 +0000
+++ b/sys/kern/kern_drvctl.c    Sat Jun 12 12:12:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_drvctl.c,v 1.46 2021/06/12 12:11:59 riastradh Exp $ */
+/* $NetBSD: kern_drvctl.c,v 1.47 2021/06/12 12:12:11 riastradh Exp $ */
 
 /*
  * Copyright (c) 2004
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.46 2021/06/12 12:11:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.47 2021/06/12 12:12:11 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -195,6 +195,8 @@
 {
        device_t d;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        if ((d = device_find_by_xname(a->devname)) == NULL)
                return ENXIO;
 
@@ -221,6 +223,8 @@
        deviter_t di;
        int cnt = 0, idx, error = 0;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        if (*l->l_devname == '\0')
                d = NULL;
        else if (memchr(l->l_devname, 0, sizeof(l->l_devname)) == NULL)
@@ -251,6 +255,8 @@
 {
        device_t d;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        if ((d = device_find_by_xname(devname)) == NULL)
                return ENXIO;
 
@@ -275,6 +281,8 @@
        device_t d;
        const struct cfiattrdata * const *ap;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        /* XXX there should be a way to get limits and defaults (per device)
           from config generated data */
        int locs[MAXLOCATORS];
diff -r b2c0162f1b27 -r 63a0f9f5b175 sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Sat Jun 12 12:11:59 2021 +0000
+++ b/sys/kern/subr_autoconf.c  Sat Jun 12 12:12:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.281 2021/06/12 12:11:49 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.282 2021/06/12 12:12:11 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -79,7 +79,7 @@
 #define        __SUBR_AUTOCONF_PRIVATE /* see <sys/device.h> */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.281 2021/06/12 12:11:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.282 2021/06/12 12:12:11 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -377,6 +377,8 @@
 {
        int error;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        if ((error = frob_cfdrivervec(cfdriverv,
            config_cfdriver_attach, config_cfdriver_detach, "init", false))!= 0)
                return error;
@@ -404,6 +406,8 @@
 {
        int error;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        if ((error = config_cfdata_detach(cfdatav)) != 0)
                return error;
        if ((error = frob_cfattachvec(cfattachv,
@@ -439,6 +443,9 @@
 void
 config_deferred(device_t dev)
 {
+
+       KASSERT(KERNEL_LOCKED_P());
+
        config_process_deferred(&deferred_config_queue, dev);
        config_process_deferred(&interrupt_config_queue, dev);
        config_process_deferred(&mountroot_config_queue, dev);
@@ -906,6 +913,7 @@
        const struct cfdata *cf1;
        deviter_t di;
 
+       KASSERT(KERNEL_LOCKED_P());
 
        /*
         * "alldevs" is likely longer than a modules's cfdata, so make it
@@ -939,6 +947,8 @@
 {
        struct cftable *ct;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        ct = kmem_alloc(sizeof(*ct), KM_SLEEP);
        ct->ct_cfdata = cf;
        TAILQ_INSERT_TAIL(&allcftables, ct, ct_list);
@@ -1011,6 +1021,8 @@
 {
        struct cfattach *ca;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        ca = config_cfattach_lookup(cf->cf_name, cf->cf_atname);
        if (ca == NULL) {
                /* No attachment for this entry, oh well. */
@@ -1710,6 +1722,8 @@
        struct cftable *ct;
        const char *drvname;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        dev = config_vdevalloc(parent, cf, tag, ap);
        if (!dev)
                panic("config_attach: allocation of device softc failed");
@@ -1782,6 +1796,8 @@
        device_t dev;
        va_list ap;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        va_start(ap, tag);
        dev = config_vattach(parent, cf, aux, print, tag, ap);
        va_end(ap);
@@ -1803,6 +1819,8 @@
 {
        device_t dev;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        dev = config_devalloc(ROOT, cf, CFARG_EOL);
        if (!dev)
                return NULL;
@@ -1886,6 +1904,8 @@
        device_t d __diagused;
        int rv = 0;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        cf = dev->dv_cfdata;
        KASSERTMSG((cf == NULL || cf->cf_fstate == FSTATE_FOUND ||
                cf->cf_fstate == FSTATE_STAR),
@@ -2007,6 +2027,8 @@
        deviter_t di;
        int error = 0;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        for (dv = deviter_first(&di, DEVITER_F_RW); dv != NULL;
             dv = deviter_next(&di)) {
                if (device_parent(dv) != parent)
@@ -2228,6 +2250,8 @@
 {
        struct deferred_config *dc;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        mutex_enter(&config_misc_lock);
        dc = TAILQ_FIRST(queue);
        while (dc) {



Home | Main Index | Thread Index | Old Index