Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump Use improved kernel module interfaces: inst...



details:   https://anonhg.NetBSD.org/src/rev/c444488d2ef5
branches:  trunk
changeset: 752748:c444488d2ef5
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Mar 05 18:41:46 2010 +0000

description:
Use improved kernel module interfaces: instead of adding + loading
modules in bootstrap, just add them.  Load them later the same way
as the kernel does: module_init_class().

Change the signature of rump_module_init() to take a vector instead
of just one module.  All modules in a DSO should be init'd at the
same time because they might depend on each other, and code outside
the rump kernel cannot know which way.  (binary kernel modules are
still loaded with rump_sys_modctl() the usual way).

diffstat:

 sys/rump/librump/rumpkern/rump.c          |  65 +++++++++++++-----------------
 sys/rump/librump/rumpkern/rumpkern.ifspec |   6 +-
 sys/rump/librump/rumpvfs/rump_vfs.c       |   6 +-
 3 files changed, 36 insertions(+), 41 deletions(-)

diffs (163 lines):

diff -r 4664bd42e74a -r c444488d2ef5 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Fri Mar 05 18:41:29 2010 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Fri Mar 05 18:41:46 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.154 2010/03/01 13:12:20 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.155 2010/03/05 18:41:46 pooka Exp $ */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.154 2010/03/01 13:12:20 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.155 2010/03/05 18:41:46 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -145,6 +145,8 @@
 rump_proc_vfs_init_fn rump_proc_vfs_init;
 rump_proc_vfs_release_fn rump_proc_vfs_release;
 
+static void add_linkedin_modules(const struct modinfo *const *, size_t);
+
 static void __noinline
 messthestack(void)
 {
@@ -284,6 +286,8 @@
        devsw_init();
        pipe_init();
 
+       rumpuser_dl_bootstrap(add_linkedin_modules, rump_kernelfsym_load);
+
        /* these do nothing if not present */
        rump_vfs_init();
        rump_net_init();
@@ -299,7 +303,7 @@
 
        sysctl_finalize();
 
-       rumpuser_dl_bootstrap(rump_module_init, rump_kernelfsym_load);
+       module_init_class(MODULE_CLASS_ANY);
 
        rumpuser_gethostname(hostname, MAXHOSTNAMELEN, &error);
        hostnamelen = strlen(hostname);
@@ -612,48 +616,37 @@
        rumpuser_dl_component_init(type, rump_component_init_cb);
 }
 
-#define ERROUT(err) do { rv = err; goto out; } while (/*CONSTCOND*/0)
+/*
+ * Initialize a module which has already been loaded and linked
+ * with dlopen(). This is fundamentally the same as a builtin module.
+ */
 int
-rump_module_init(struct modinfo *mi, prop_dictionary_t props)
+rump_module_init(const struct modinfo * const *mip, size_t nmodinfo)
 {
-       struct module *mod;
-       int rv;
-
-       /* module_dummy */
-       if (mi->mi_name == NULL)
-               return EINVAL;
-
-       mutex_enter(&module_lock);
-       if (module_lookup(mi->mi_name))
-               ERROUT(EEXIST);
 
-       if (!module_compatible(mi->mi_version, __NetBSD_Version__))
-               ERROUT(EPROGMISMATCH);
-
-       rv = mi->mi_modcmd(MODULE_CMD_INIT, props);
-       if (rv == 0) {
-               mod = kmem_zalloc(sizeof(*mod), KM_SLEEP);
-               mod->mod_info = mi;
-               module_enqueue(mod);
-               if (mi->mi_class == MODULE_CLASS_SECMODEL)
-                       secmodel_register();
-       }
-
- out:
-       mutex_exit(&module_lock);
-       return rv;
+       return module_builtin_add(mip, nmodinfo, true);
 }
 
+/*
+ * Finish module (flawless victory, fatality!).
+ */
 int
-rump_module_fini(struct modinfo *mi)
+rump_module_fini(const struct modinfo *mi)
 {
-       int rv;
+
+       return module_builtin_remove(mi, true);
+}
 
-       rv = mi->mi_modcmd(MODULE_CMD_FINI, NULL);
-       if (rv == 0 && mi->mi_class == MODULE_CLASS_SECMODEL)
-               secmodel_deregister();
+/*
+ * Add loaded and linked module to the builtin list.  It will
+ * later be initialized with module_init_class().
+ */
 
-       return rv;
+static void
+add_linkedin_modules(const struct modinfo * const *mip, size_t nmodinfo)
+{
+
+       module_builtin_add(mip, nmodinfo, false);
 }
 
 int
diff -r 4664bd42e74a -r c444488d2ef5 sys/rump/librump/rumpkern/rumpkern.ifspec
--- a/sys/rump/librump/rumpkern/rumpkern.ifspec Fri Mar 05 18:41:29 2010 +0000
+++ b/sys/rump/librump/rumpkern/rumpkern.ifspec Fri Mar 05 18:41:46 2010 +0000
@@ -1,4 +1,4 @@
-;      $NetBSD: rumpkern.ifspec,v 1.3 2009/11/26 09:20:07 pooka Exp $
+;      $NetBSD: rumpkern.ifspec,v 1.4 2010/03/05 18:41:46 pooka Exp $
 
 NAME|kern
 PUBHDR|include/rump/rumpkern_if_pub.h
@@ -11,8 +11,8 @@
 void           |reboot         |int
 int            |getversion     |void
 
-int            |module_init    |struct modinfo *, prop_dictionary_t
-int            |module_fini    |struct modinfo *
+int            |module_init    |const struct modinfo * const *, size_t
+int            |module_fini    |const struct modinfo *
 int            |kernelfsym_load|void *, uint64_t, char *, uint64_t
 
 struct uio *   |uio_setup      |void *, size_t, off_t, enum rump_uiorw
diff -r 4664bd42e74a -r c444488d2ef5 sys/rump/librump/rumpvfs/rump_vfs.c
--- a/sys/rump/librump/rumpvfs/rump_vfs.c       Fri Mar 05 18:41:29 2010 +0000
+++ b/sys/rump/librump/rumpvfs/rump_vfs.c       Fri Mar 05 18:41:46 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_vfs.c,v 1.42 2009/12/17 00:29:46 pooka Exp $      */
+/*     $NetBSD: rump_vfs.c,v 1.43 2010/03/05 18:41:46 pooka Exp $      */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.42 2009/12/17 00:29:46 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.43 2010/03/05 18:41:46 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -133,6 +133,8 @@
        } else {
                syncdelay = 0;
        }
+
+       module_init_class(MODULE_CLASS_VFS);
 }
 
 void



Home | Main Index | Thread Index | Old Index