Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/kern Pull up following revision(s) (requested by pgoy...



details:   https://anonhg.NetBSD.org/src/rev/f85dd07112fe
branches:  netbsd-7
changeset: 799933:f85dd07112fe
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jul 10 09:38:38 2016 +0000

description:
Pull up following revision(s) (requested by pgoyette in ticket #1183):
        sys/kern/kern_module.c: revision 1.111
Check for duplicate module names before loading modules that were
"pushed" by the boot loader.  The boot loader pushes the module
name for the root file system (unless the root file system is ffs)
even if the file system module is built into the kernel.  When
this happens, we get a lot of "redefined symbol" error messages.
This fix does not alter the behavior of pushing the file system
name.  It simply avoids the redefined symbol errors by detecting
that the module is already built-in to the kernel and not trying
to load another copy.
While here, differentiate the error message text between "failed
to load" and "failed to fetch_info" conditions.
Addresses PR kern/50357

diffstat:

 sys/kern/kern_module.c |  22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diffs (57 lines):

diff -r 4abe7d27f86d -r f85dd07112fe sys/kern/kern_module.c
--- a/sys/kern/kern_module.c    Tue Jul 05 19:20:55 2016 +0000
+++ b/sys/kern/kern_module.c    Sun Jul 10 09:38:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_module.c,v 1.97.2.2 2016/03/03 14:47:08 martin Exp $      */
+/*     $NetBSD: kern_module.c,v 1.97.2.3 2016/07/10 09:38:38 martin Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.97.2.2 2016/03/03 14:47:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.97.2.3 2016/07/10 09:38:38 martin Exp $");
 
 #define _MODULE_INTERNAL
 
@@ -1235,6 +1235,8 @@
 int
 module_prime(const char *name, void *base, size_t size)
 {
+       __link_set_decl(modules, modinfo_t);
+       modinfo_t *const *mip;
        module_t *mod;
        int error;
 
@@ -1243,6 +1245,18 @@
                return ENOMEM;
        }
 
+       /* Check for duplicate modules */
+
+       __link_set_foreach(mip, modules) {
+               if (*mip == &module_dummy)
+                       continue;
+               if (strcmp((*mip)->mi_name, name) == 0) {
+                       module_error("module `%s' pushed by boot loader "
+                           "already exists", name);
+                       kmem_free(mod, sizeof(*mod));
+                       return EEXIST;
+               }
+       }
        error = kobj_load_mem(&mod->mod_kobj, name, base, size);
        if (error != 0) {
                kmem_free(mod, sizeof(*mod));
@@ -1254,8 +1268,8 @@
        if (error != 0) {
                kobj_unload(mod->mod_kobj);
                kmem_free(mod, sizeof(*mod));
-               module_error("unable to load `%s' pushed by boot loader, "
-                   "error %d", name, error);
+               module_error("unable to fetch_info for `%s' pushed by boot "
+                   "loader, error %d", name, error);
                return error;
        }
 



Home | Main Index | Thread Index | Old Index