lkml.org 
[lkml]   [1999]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subjectmodules patch
Date
If a module breaks during its init routine then it is left in limbo.
It appears in lsmod but not in ksyms, you cannot even get symbols to
debug the Oops. This patch adds MOD_INITIALIZING and allows debugging
of module init() failures. The sparc64 patch is untested.

Against 2.3.29.

Index: 29.2/include/linux/module.h
--- 29.2/include/linux/module.h Fri, 12 Nov 1999 18:53:00 +1100 keith (linux-2.3/B/b/39_module.h 1.3 644)
+++ 29.2(w)/include/linux/module.h Thu, 25 Nov 1999 23:19:22 +1100 keith (linux-2.3/B/b/39_module.h 1.3 644)
@@ -102,6 +102,7 @@
#define MOD_VISITED 8
#define MOD_USED_ONCE 16
#define MOD_JUST_FREED 32
+#define MOD_INITIALIZING 64

/* Values for query_module's which. */

@@ -110,6 +111,9 @@
#define QM_REFS 3
#define QM_SYMBOLS 4
#define QM_INFO 5
+
+/* Can the module be queried? */
+#define MOD_CAN_QUERY(mod) (((mod)->flags & (MOD_RUNNING | MOD_INITIALIZING)) && !((mod)->flags & MOD_DELETED))

/* When struct module is extended, we must test whether the new member
is present in the header received from insmod before we can use it.
Index: 29.2/kernel/module.c
--- 29.2/kernel/module.c Wed, 24 Nov 1999 20:32:39 +1100 keith (linux-2.3/F/b/39_module.c 1.4 644)
+++ 29.2(w)/kernel/module.c Thu, 25 Nov 1999 23:46:15 +1100 keith (linux-2.3/F/b/39_module.c 1.4 644)
@@ -13,6 +13,7 @@
* 0.99.14 version by Jon Tombs <jon@gtex02.us.es>,
* Heavily modified by Bjorn Ekwall <bj0rn@blox.se> May 1994 (C)
* Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996
+ * Add MOD_INITIALIZING Keith Owens <kaos@ocs.com.au> Nov 1999
*
* This source is covered by the GNU GPL, the same as all kernel sources.
*/
@@ -325,16 +326,18 @@
put_mod_name(name);

/* Initialize the module. */
+ mod->flags |= MOD_INITIALIZING;
atomic_set(&mod->uc.usecount,1);
if (mod->init && mod->init() != 0) {
atomic_set(&mod->uc.usecount,0);
+ mod->flags &= ~MOD_INITIALIZING;
error = -EBUSY;
goto err0;
}
atomic_dec(&mod->uc.usecount);

/* And set it running. */
- mod->flags |= MOD_RUNNING;
+ mod->flags = (mod->flags | MOD_RUNNING) & ~MOD_INITIALIZING;
error = 0;
goto err0;

@@ -458,7 +461,7 @@

if (mod == &kernel_module)
return -EINVAL;
- if ((mod->flags & (MOD_RUNNING | MOD_DELETED)) != MOD_RUNNING)
+ if (!MOD_CAN_QUERY(mod))
if (put_user(0, ret))
return -EFAULT;
else
@@ -502,7 +505,7 @@

if (mod == &kernel_module)
return -EINVAL;
- if ((mod->flags & (MOD_RUNNING | MOD_DELETED)) != MOD_RUNNING)
+ if (!MOD_CAN_QUERY(mod))
if (put_user(0, ret))
return -EFAULT;
else
@@ -546,7 +549,7 @@
char *strings;
unsigned long *vals;

- if ((mod->flags & (MOD_RUNNING | MOD_DELETED)) != MOD_RUNNING)
+ if (!MOD_CAN_QUERY(mod))
if (put_user(0, ret))
return -EFAULT;
else
@@ -712,7 +715,7 @@
struct module_symbol *msym;
unsigned int j;

- if ((mod->flags & (MOD_RUNNING|MOD_DELETED)) != MOD_RUNNING)
+ if (!MOD_CAN_QUERY(mod))
continue;

/* magic: write module info as a pseudo symbol */
@@ -861,7 +864,10 @@
safe_copy_cstr(" (autoclean)");
if (!(mod->flags & MOD_USED_ONCE))
safe_copy_cstr(" (unused)");
- } else
+ }
+ else if (mod->flags & MOD_INITIALIZING)
+ safe_copy_cstr(" (initializing)");
+ else
safe_copy_cstr(" (uninitialized)");

if ((ref = mod->refs) != NULL) {
@@ -905,7 +911,7 @@
unsigned i;
struct module_symbol *sym;

- if (!(mod->flags & MOD_RUNNING) || (mod->flags & MOD_DELETED))
+ if (!MOD_CAN_QUERY(mod))
continue;

for (i = mod->nsyms, sym = mod->syms; i > 0; --i, ++sym) {
@@ -953,7 +959,7 @@

for (mp = module_list; mp; mp = mp->next) {
if (((modname == NULL) || (strcmp(mp->name, modname) == 0)) &&
- (mp->flags & (MOD_RUNNING | MOD_DELETED)) == MOD_RUNNING &&
+ MOD_CAN_QUERY(mp) &&
(mp->nsyms > 0)) {
for (i = mp->nsyms, sym = mp->syms;
i > 0; --i, ++sym) {
Index: 29.2/arch/sparc64/kernel/sys_sparc32.c
--- 29.2/arch/sparc64/kernel/sys_sparc32.c Sat, 04 Sep 1999 13:10:55 +1000 keith (linux-2.3/j/10_sys_sparc3 1.7 644)
+++ 29.2(w)/arch/sparc64/kernel/sys_sparc32.c Thu, 25 Nov 1999 23:22:57 +1100 keith (linux-2.3/j/10_sys_sparc3 1.7 644)
@@ -2988,7 +2988,7 @@

if (mod->next == NULL)
return -EINVAL;
- if ((mod->flags & (MOD_RUNNING | MOD_DELETED)) != MOD_RUNNING)
+ if (!MOD_CAN_QUERY(mod))
if (put_user(0, ret))
return -EFAULT;
else
@@ -3032,7 +3032,7 @@

if (mod->next == NULL)
return -EINVAL;
- if ((mod->flags & (MOD_RUNNING | MOD_DELETED)) != MOD_RUNNING)
+ if (!MOD_CAN_QUERY(mod))
if (put_user(0, ret))
return -EFAULT;
else
@@ -3076,7 +3076,7 @@
char *strings;
unsigned *vals;

- if ((mod->flags & (MOD_RUNNING | MOD_DELETED)) != MOD_RUNNING)
+ if (!MOD_CAN_QUERY(mod))
if (put_user(0, ret))
return -EFAULT;
else

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.031 / U:1.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site