Skip to contentSkip to conversation

Module loader against 2.5.46: 1/9

PATCH In review Rusty Russell 9 participants 24 messages Nov 5, 2002 – Nov 11, 2002

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Module loader against 2.5.46: 1/9

Stands on its own: adds KBUILD_MODNAME to objects.

Linus, please apply.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: KBUILD_MODNAME define for build system
Author: Kai Germaschewski
Status: Tested on 2.5.45

D: This patch adds a -DKBUILD_MODNAME to the kernel compile, which
D: contains the base of the module name which is being built. D:

D: - Some sreorganization of the c_flags since they're needed for
D:   generating modversions (.ver) and compiling
D: - Use the right KBUILD_MODNAME also when the user just wants a .i/.s/.lst 
D:   file for debugging and also when generating modversions
D: - It looks like with your current approach you can't have a ',' or '-' in
D:   KBUILD_MODNAME - however, that means that KBUILD_MODNAME is not quite
D:   right for passing module parameters for built-in modules on the command
D:   line, it would be confusing to pass parameters for ide-cd as 
D:   ide_cd.foo=whatever. So that part could use a little more thought.
D: - If you think your module_names trick makes a noticable difference, feel
D:   free to re-add it.
D: - It's possible that objects are linked into more than one module - I 
D:   suppose this shouldn't be a problem, since these objects hopefully
D:   don't have a module_init() nor do they export symbols. Not sure if your
D:   patch did handle this.

D:
D: --Kai

net/unix/af_unix.c +2 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .31872-linux-2.5.45/net/unix/af_unix.c .31872-linux-2.5.45.updated/net/unix/af_unix.c
@@ -79,6 +79,8 @@
  *		  with BSD names.
  */
 
+#undef unix	/* KBUILD_MODNAME */
+
 #include <linux/module.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
scripts/Makefile.build +12 -4
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .31872-linux-2.5.45/scripts/Makefile.build .31872-linux-2.5.45.updated/scripts/Makefile.build
@@ -54,6 +54,7 @@ modkern_cflags := $(CFLAGS_KERNEL)
 
 $(real-objs-m)        : modkern_cflags := $(CFLAGS_MODULE)
 $(real-objs-m:.o=.i)  : modkern_cflags := $(CFLAGS_MODULE)
+$(real-objs-m:.o=.s)  : modkern_cflags := $(CFLAGS_MODULE)
 $(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE)
 
 $(export-objs)        : export_flags   := $(EXPORT_FLAGS)
@@ -61,10 +62,17 @@ $(export-objs:.o=.i)  : export_flags   :
 $(export-objs:.o=.s)  : export_flags   := $(EXPORT_FLAGS)
 $(export-objs:.o=.lst): export_flags   := $(EXPORT_FLAGS)
 
-c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
-	  $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
-	  -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \
-	  $(export_flags) 
+# Default for not multi-part modules
+modname = $(*F)
+
+$(multi-objs-m)         : modname = $(modname-multi)
+$(multi-objs-m:.o=.i)   : modname = $(modname-multi)
+$(multi-objs-m:.o=.s)   : modname = $(modname-multi)
+$(multi-objs-m:.o=.lst) : modname = $(modname-multi)
+$(multi-objs-y)         : modname = $(modname-multi)
+$(multi-objs-y:.o=.i)   : modname = $(modname-multi)
+$(multi-objs-y:.o=.s)   : modname = $(modname-multi)
+$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
 
 quiet_cmd_cc_s_c = CC      $@
 cmd_cc_s_c       = $(CC) $(c_flags) -S -o $@ $< 
scripts/Makefile.lib +21 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .31872-linux-2.5.45/scripts/Makefile.lib .31872-linux-2.5.45.updated/scripts/Makefile.lib
@@ -5,6 +5,8 @@
 # Standard vars
 
 comma   := ,
+empty   :=
+space   := $(empty) $(empty)
 
 # Figure out what we need to build from the various variables
 # ===========================================================================
@@ -40,11 +40,13 @@ __obj-m = $(filter-out export.o,$(obj-m)
 # if $(foo-objs) exists, foo.o is a composite object 
 multi-used-y := $(sort $(foreach m,$(__obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
 multi-used-m := $(sort $(foreach m,$(__obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
+multi-used   := $(multi-used-y) $(multi-used-m)
 
 # Build list of the parts of our composite objects, our composite
 # objects depend on those (obviously)
 multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
 multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
+multi-objs   := $(multi-objs-y) $(multi-objs-m)
 
 # $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
 # in the local directory
@@ -84,6 +86,23 @@ host-progs-multi-objs := $(addprefix $(o
 # contain a comma
 depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
 
+# These flags are needed for modversions and compiling, so we define them here
+# already
+# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will 
+# end up in (or would, if it gets compiled in)
+# Note: It's possible that one object gets potentially linked into more
+#       than one module. In that case KBUILD_MODNAME will be set to foo_bar,
+#       where foo and bar are the name of the modules.
+basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F)))
+modname_flags  = -DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname)))
+c_flags        = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
+	         $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
+	         $(basename_flags) $(modname_flags) $(export_flags) 
+
+# Finds the multi-part object the current object will be linked into
+modname-multi = $(subst $(space),_,$(strip $(foreach m,$(multi-used),\
+		$(if $(filter $(*F).o,$($(m:.o=-objs))),$(m:.o=)))))
+
 # Shipped files
 # ===========================================================================
 
scripts/Makefile.modver +3 -4
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .31872-linux-2.5.45/scripts/Makefile.modver .31872-linux-2.5.45.updated/scripts/Makefile.modver
@@ -48,11 +48,10 @@ CFLAGS_MODULE := $(filter-out -include i
 $(addprefix $(MODVERDIR)/,$(real-objs-y:.o=.ver)): modkern_cflags := $(CFLAGS_KERNEL)
 $(addprefix $(MODVERDIR)/,$(real-objs-m:.o=.ver)): modkern_cflags := $(CFLAGS_MODULE)
 $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)): export_flags   := -D__GENKSYMS__
+# Default for not multi-part modules
+modname = $(*F)
 
-c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
-	  $(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
-	  -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) \
-	  $(export_flags) 
+$(addprefix $(MODVERDIR)/,$(multi-objs:.o=.ver)) : modname = $(modname-multi)
 
 # Our objects only depend on modversions.h, not on the individual .ver
 # files (fix-dep filters them), so touch modversions.h if any of the .ver
#1 lore raw

PATCH 1/1 Module loader against 2.5.46: 7/9

Forced unload for modules "rmmod -f". Taints the kernel, but sometimes when you're developing or desperate, it's the best option.

Note that normal module unloading is still supported: this allows you to unload modules with non-zero refcounts, no unload routine, or which have been marked "unsafe" by detecting racy usages.

Linus, please apply,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: Forced Module Unload
Author: Rusty Russell
Status: Experimental
Depends: Module/module.patch.gz

D: Allows the (very dangerous!) "rmmod -f" for kernel developers and
D: desperate people.

include/linux/kernel.h +1 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9002-linux-2.5.45/include/linux/kernel.h .9002-linux-2.5.45.updated/include/linux/kernel.h
@@ -102,6 +102,7 @@ extern const char *print_tainted(void);
 #define TAINT_PROPRIETORY_MODULE	(1<<0)
 #define TAINT_FORCED_MODULE		(1<<1)
 #define TAINT_UNSAFE_SMP		(1<<2)
+#define TAINT_FORCED_RMMOD		(1<<3)
 
 extern void dump_stack(void);
 
init/Kconfig +10 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9002-linux-2.5.45/init/Kconfig .9002-linux-2.5.45.updated/init/Kconfig
@@ -125,6 +125,16 @@ config MODULE_UNLOAD
 	  anyway), which makes your kernel slightly smaller and
 	  simpler.  If unsure, say Y.
 
+config MODULE_FORCE_UNLOAD
+	bool "Forced module unloading"
+	depends on MODULES && EXPERIMENTAL
+	help
+	  This option allows you to force a module to unload, even if the
+	  kernel believes it is unsafe: the kernel will remove the module
+	  without waiting for anyone to stop using it (using the -f option to
+	  rmmod).  This is mainly for kernel developers and desparate users.
+	  If unsure, say N.
+
 config KMOD
 	bool "Kernel module loader"
 	depends on MODULES
kernel/module.c +38 -15

99 lines not on this page · raw message

#2 lore raw

PATCH 1/1 Module loader against 2.5.46: 8/9

In reply to Rusty Russell

Wedge to support old-style "MODULE_PARM" decls, by turning them into the equivalent PARAM table at load time.

With this, module parameters work again on all modules. Rusty.

Name: MODULE_PARM support for older modules
Author: Rusty Russell
Status: Experimental
Depends: Module/param-modules.patch.gz
Depends: Module/forceunload.patch.gz

D: This is the backwards compatibility code for MODULE_PARM.

include/linux/module.h +13 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .17025-linux-2.5.45/include/linux/module.h .17025-linux-2.5.45.updated/include/linux/module.h
@@ -15,6 +15,7 @@
 #include <linux/compiler.h>
 #include <linux/cache.h>
 #include <linux/kmod.h>
+#include <linux/stringify.h>
 #include <asm/module.h>
 #include <asm/uaccess.h> /* For struct exception_table_entry */
 
@@ -274,6 +275,17 @@ extern spinlock_t modlist_lock;
 #define __MOD_DEC_USE_COUNT(mod) module_put(mod)
 #define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE)
 
+struct obsolete_modparm { char name[64]; char type[64]; void *addr; };
+#ifdef MODULE
+/* DEPRECATED: Do not use. */
+#define MODULE_PARM(var,type)						    \
+struct obsolete_modparm __parm_##var __attribute__((section(".obsparm"))) = \
+{ __stringify(var), type };
+
+#else
+#define MODULE_PARM(var,type)
+#endif
+
 /* People do this inside their init routines, when the module isn't
    "live" yet.  They should no longer be doing that, but
    meanwhile... */
@@ -286,11 +298,11 @@ extern spinlock_t modlist_lock;
 #endif
 #define MOD_DEC_USE_COUNT module_put(THIS_MODULE)
 #define try_inc_mod_count(mod) try_module_get(mod)
-#define MODULE_PARM(parm,string)
 #define EXPORT_NO_SYMBOLS
 extern int module_dummy_usage;
 #define GET_USE_COUNT(module) (module_dummy_usage)
 #define MOD_IN_USE 0
+#define __MODULE_STRING(x) __stringify(x)
 #define __mod_between(a_start, a_len, b_start, b_len)		\
 (((a_start) >= (b_start) && (a_start) <= (b_start)+(b_len))	\
  || ((a_start)+(a_len) >= (b_start)				\
init/Kconfig +8 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .17025-linux-2.5.45/init/Kconfig .17025-linux-2.5.45.updated/init/Kconfig
@@ -135,6 +135,14 @@ config MODULE_FORCE_UNLOAD
 	  rmmod).  This is mainly for kernel developers and desparate users.
 	  If unsure, say N.
 
+config OBSOLETE_MODPARM
+	bool
+	default y
+	help
+	  Without this option you will not be able to use module parameters on
+	  modules which have not been converted to the new module parameter
+	  system yet.  If unsure, say Y.
+
 config KMOD
 	bool "Kernel module loader"
 	depends on MODULES
kernel/module.c +147 -9

186 lines not on this page · raw message

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#3 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

[ Cc: trimmed ]

init/Kconfig config MODULE_FORCE_UNLOAD · line 144

Quoted 7 lines · Rusty Russell
init/Kconfig +7 -0
+config OBSOLETE_MODPARM
+	bool
+	default y
+	help
+	  Without this option you will not be able to use module parameters on
+	  modules which have not been converted to the new module parameter
+	  system yet.  If unsure, say Y.

Triple negation, cool :-) How about something like

You need this option to use module parameters on modules which have not been converted to the new module parameter system yet. If unsure, say Y.

instead ?

- Werner

Signature · 3 lines
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         [email protected] /
/_http://www.almesberger.net/____________________________________________/
#4 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

In message <[email protected]> you write:

Quoted 13 lines

[ Cc: trimmed ]

Review

Quoted 7 lines · Rusty Russell
(quoted diff) +7 -0
+config OBSOLETE_MODPARM
+	bool
+	default y
+	help
+	  Without this option you will not be able to use module parameters on
+	  modules which have not been converted to the new module parameter
+	  system yet.  If unsure, say Y.

Triple negation, cool :-) How about something like

Quoted 4 lines

You need this option to use module parameters on modules which have not been converted to the new module parameter system yet. If unsure, say Y.

No. I don't think that my original version wasn't clear, nor do I have time to negate every suggestion, no matter how well meaning or not, even if I had no better things to do, which does not seem likely, does it not?

Point taken (although note that this option is never prompted for). Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: MODULE_PARM support for older modules
Author: Rusty Russell
Status: Experimental
Depends: Module/param-modules.patch.gz
Depends: Module/forceunload.patch.gz

D: This is the backwards compatibility code for MODULE_PARM.

include/linux/module.h +13 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .8562-linux-2.5.46/include/linux/module.h .8562-linux-2.5.46.updated/include/linux/module.h
@@ -15,6 +15,7 @@
 #include <linux/compiler.h>
 #include <linux/cache.h>
 #include <linux/kmod.h>
+#include <linux/stringify.h>
 #include <asm/module.h>
 #include <asm/uaccess.h> /* For struct exception_table_entry */
 
@@ -274,6 +275,17 @@ extern spinlock_t modlist_lock;
 #define __MOD_DEC_USE_COUNT(mod) module_put(mod)
 #define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE)
 
+struct obsolete_modparm { char name[64]; char type[64]; void *addr; };
+#ifdef MODULE
+/* DEPRECATED: Do not use. */
+#define MODULE_PARM(var,type)						    \
+struct obsolete_modparm __parm_##var __attribute__((section(".obsparm"))) = \
+{ __stringify(var), type };
+
+#else
+#define MODULE_PARM(var,type)
+#endif
+
 /* People do this inside their init routines, when the module isn't
    "live" yet.  They should no longer be doing that, but
    meanwhile... */
@@ -286,11 +298,11 @@ extern spinlock_t modlist_lock;
 #endif
 #define MOD_DEC_USE_COUNT module_put(THIS_MODULE)
 #define try_inc_mod_count(mod) try_module_get(mod)
-#define MODULE_PARM(parm,string)
 #define EXPORT_NO_SYMBOLS
 extern int module_dummy_usage;
 #define GET_USE_COUNT(module) (module_dummy_usage)
 #define MOD_IN_USE 0
+#define __MODULE_STRING(x) __stringify(x)
 #define __mod_between(a_start, a_len, b_start, b_len)		\
 (((a_start) >= (b_start) && (a_start) <= (b_start)+(b_len))	\
  || ((a_start)+(a_len) >= (b_start)				\
init/Kconfig +9 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .8562-linux-2.5.46/init/Kconfig .8562-linux-2.5.46.updated/init/Kconfig
@@ -135,6 +135,15 @@ config MODULE_FORCE_UNLOAD
 	  rmmod).  This is mainly for kernel developers and desparate users.
 	  If unsure, say N.
 
+config OBSOLETE_MODPARM
+	bool
+	default y
+	depends on MODULES
+	help
+	  You need this option to use module parameters on modules which
+	  have not been converted to the new module parameter system yet.
+	  If unsure, say Y.
+
 config KMOD
 	bool "Kernel module loader"
 	depends on MODULES
@@ -150,4 +159,3 @@ config KMOD
 	  in <file:Documentation/kmod.txt>.
 
 endmenu
-
kernel/module.c +147 -9

186 lines not on this page · raw message

#5 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

Quoted 1 line · Rusty Russell

Point taken

Thanks :-)

Quoted 1 line

(although note that this option is never prompted for).

Aha, learned something new about Kconfig. Subtle ! ;-) Well, I guess, some fine day, it will ...

- Werner

Signature · 3 lines
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         [email protected] /
/_http://www.almesberger.net/____________________________________________/
#6 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

In message <[email protected]> you write:

Quoted 5 lines
Quoted 1 line · Rusty Russell

(although note that this option is never prompted for).

Aha, learned something new about Kconfig. Subtle ! ;-) Well, I guess, some fine day, it will ...

Kconfig is way cool. The transition to a CONFIG_OBSOLETE version sometime soon (eg 2.7) is now trivial.

Rusty.
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#7 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

In reply to Rusty Russell
Quoted 19 lines · Rusty Russell

In message <[email protected]> you write:

Quoted 13 lines

[ Cc: trimmed ]

init/Kconfig config MODULE_FORCE_UNLOAD

Quoted 7 lines · Rusty Russell
init/Kconfig +7 -0
+config OBSOLETE_MODPARM
+	bool
+	default y
+	help
+	  Without this option you will not be able to use module parameters on
+	  modules which have not been converted to the new module parameter
+	  system yet.  If unsure, say Y.

Triple negation, cool :-) How about something like

Quoted 4 lines

You need this option to use module parameters on modules which have not been converted to the new module parameter system yet. If unsure, say Y.

Quoted 4 lines

No. I don't think that my original version wasn't clear, nor do I have time to negate every suggestion, no matter how well meaning or not, even if I had no better things to do, which does not seem likely, does it not?

Please don't take this personally, but you just used another double negative in your response. Now you may think that way, and talk that way, but a lot of people who use Linux are not native speakers of English, and from experience I suggest that the complex gramatical constructs in all the help stuff should be avoided. Eschew obfuscation.

Quoted 1 line

Point taken (although note that this option is never prompted for).

Then why have help at all? In fact why have the whole option if it can't be used? I assume you meant something else entirely, other than "can't be used."

Signature · 3 lines
bill davidsen <[email protected]>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
#8 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

In message <[email protected]> you w rite:

Quoted 8 lines · Rusty Russell
Quoted 4 lines

No. I don't think that my original version wasn't clear, nor do I have time to negate every suggestion, no matter how well meaning or not, even if I had no better things to do, which does not seem likely, does it not?

Please don't take this personally, but you just used another double negative in your response.

Did I? Not that I'm not sorry, but I just didn't realize my lack of clarity was causing confusion. I shall take your words to heart.

Quoted 4 lines

Now you may think that way, and talk that way, but a lot of people who use Linux are not native speakers of English, and from experience I suggest that the complex gramatical constructs in all the help stuff should be avoided.

I'd never have thought of that myself, but you're right. Even among our peers on this mailing list, for example, the nuances of English sometimes go astray.

I will try to ensure my writing is straigtforward and impossible to misunderstand.

Quoted 1 line

Eschew obfuscation.

Sorry, I don't understand?

But thankyou for your insight!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#9 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

On Thu, 7 Nov 2002, Rusty Russell wrote:

| In message <[email protected]> you w
| rite:
| > On Tue, 5 Nov 2002, Rusty Russell wrote:
| > > No.  I don't think that my original version wasn't clear, nor do I
| > > have time to negate every suggestion, no matter how well meaning or
| > > not, even if I had no better things to do, which does not seem likely,
| > > does it not?
| >
| > Please don't take this personally, but you just used another double
| > negative in your response.
|
| Did I?  Not that I'm not sorry, but I just didn't realize my lack of
| clarity was causing confusion.  I shall take your words to heart.

So you did it again, this time on purpose, right? ;) ("Not that I'm not sorry")

| > Now you may think that way, and talk that way, but a lot of people
| > who use Linux are not native speakers of English, and from
| > experience I suggest that the complex gramatical constructs in all
| > the help stuff should be avoided.
|
| I'd never have thought of that myself, but you're right.  Even among
| our peers on this mailing list, for example, the nuances of English
| sometimes go astray.
|
| I will try to ensure my writing is straigtforward and impossible to
| misunderstand.
|
| But thankyou for your insight!
| Rusty.
| --
Signature · 2 lines
~Randy
location: NPP-4E
#10 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

In reply to Rusty Russell
Quoted 14 lines · Rusty Russell

In message <[email protected]> you w rite:

Quoted 8 lines · Rusty Russell
Quoted 4 lines

No. I don't think that my original version wasn't clear, nor do I have time to negate every suggestion, no matter how well meaning or not, even if I had no better things to do, which does not seem likely, does it not?

Please don't take this personally, but you just used another double negative in your response.

Did I? Not that I'm not sorry, but I just didn't realize my lack of clarity was causing confusion. I shall take your words to heart.

Quoted 8 lines
Quoted 4 lines

Now you may think that way, and talk that way, but a lot of people who use Linux are not native speakers of English, and from experience I suggest that the complex gramatical constructs in all the help stuff should be avoided.

I'd never have thought of that myself, but you're right. Even among our peers on this mailing list, for example, the nuances of English sometimes go astray.

Sure, we have people mentally translating English into totally dissimilar languages like Finnish, German, Russian, Czech, and British.

Quoted 7 lines

I will try to ensure my writing is straigtforward and impossible to misunderstand.

Quoted 1 line

Eschew obfuscation.

Sorry, I don't understand?

eschew = roughly "avoid" or "stay away from" obfuscation = the process of making something obscure

Quoted 6 lines

But thankyou for your insight!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Signature · 3 lines
bill davidsen <[email protected]>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
#11 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

Quoted 3 lines · Bill Davidsen
Quoted 2 lines · Rusty Russell

In message <[email protected]> you w rite:

[snip]

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Eschew obfuscation.

Sorry, I don't understand?

eschew = roughly "avoid" or "stay away from"

Or "choose not to use". One does not say, "eschew that bear."

Quoted 1 line

obfuscation = the process of making something obscure

And the whole thing ("eschew obfuscation") is a stock expression in English, meaning "don't use unfamiliar words when familiar words will express what you mean." There's an implied self-reference: "eschew obfuscation" is a very obscure way of saying "keep it simple". It's mildly funny.

Signature · 2 lines
Mark H. Wood, amateur linguist   [email protected]
MS Windows *is* user-friendly, but only for certain values of "user".
#12 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

In message <[email protected]> you wri te:

Quoted 8 lines · Bill Davidsen
Quoted 1 line

eschew = roughly "avoid" or "stay away from"

Or "choose not to use". One does not say, "eschew that bear."

Quoted 1 line

obfuscation = the process of making something obscure

And the whole thing ("eschew obfuscation") is a stock expression in English, meaning "don't use unfamiliar words when familiar words will express what you mean."

Thankyou both for your explanations.

Back on topic, I think Bill brought up a good point: someone willing to criticize nontrivial uses of English in the kernel would fill a much-needed void in Linux.

Bill, would you be prepared for such a role? I think we'd be lucky to have either of you contribute patches.

Cheers!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#13 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

In reply to Bill Davidsen

Bill Davidsen <[email protected]> said:

[...]

Quoted 2 lines

Sure, we have people mentally translating English into totally dissimilar languages like Finnish, German, Russian, Czech, and British.

"Mentally translating" doesn't work, you have to learn to think in the "foreign" language(s).
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513

#14 lore raw

Re: [PATCH] Module loader against 2.5.46: 8/9

Quoted 6 lines · Horst von Brand

Bill Davidsen <[email protected]> said:

[...]

Quoted 2 lines

Sure, we have people mentally translating English into totally dissimilar languages like Finnish, German, Russian, Czech, and British.

                                                        ^^^^^^^^

English into British, I love it!

Quoted 8 lines

"Mentally translating" doesn't work, you have to learn to think in the "foreign" language(s).
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
-

--- and the first thing you learn, when learning a new language, is how to swear. It's important to align your thought processes!

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Bush : The Fourth Reich of America

#15 lore raw

PATCH 1/1 Module loader against 2.5.46: 3/9

In reply to Rusty Russell

Linus, please apply. Make x86 compile, and their modules work.

Rusty.

Name: New Module Loader Base: x86 support
Author: Rusty Russell
Status: Tested on 2.5.45
Depends: Module/module.patch.gz

D: This patch provides basic x86 support for modules.

arch/i386/kernel/Makefile +1 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9540-2.5.45-module-i386.pre/arch/i386/kernel/Makefile .9540-2.5.45-module-i386/arch/i386/kernel/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_SOFTWARE_SUSPEND)	+= suspen
 obj-$(CONFIG_X86_NUMAQ)		+= numaq.o
 obj-$(CONFIG_PROFILING)		+= profile.o
 obj-$(CONFIG_EDD)             	+= edd.o
+obj-$(CONFIG_MODULES)		+= module.o
 
 EXTRA_AFLAGS   := -traditional
 
arch/i386/kernel/entry.S +3 -3
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9540-2.5.45-module-i386.pre/arch/i386/kernel/entry.S .9540-2.5.45-module-i386/arch/i386/kernel/entry.S
@@ -610,10 +610,10 @@ ENTRY(sys_call_table)
 	.long sys_adjtimex
 	.long sys_mprotect	/* 125 */
 	.long sys_sigprocmask
-	.long sys_create_module
+	.long sys_ni_syscall	/* old "create_module" */ 
 	.long sys_init_module
 	.long sys_delete_module
-	.long sys_get_kernel_syms	/* 130 */
+	.long sys_ni_syscall	/* 130:	old "get_kernel_syms" */
 	.long sys_quotactl
 	.long sys_getpgid
 	.long sys_fchdir
@@ -650,7 +650,7 @@ ENTRY(sys_call_table)
 	.long sys_setresuid16
 	.long sys_getresuid16	/* 165 */
 	.long sys_vm86
-	.long sys_query_module
+	.long sys_ni_syscall	/* Old sys_query_module */
 	.long sys_poll
 	.long sys_nfsservctl
 	.long sys_setresgid16	/* 170 */
arch/i386/kernel/module.c +130 -0

130 lines not on this page · raw message

arch/i386/kernel/traps.c +4 -3
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9540-2.5.45-module-i386.pre/arch/i386/kernel/traps.c .9540-2.5.45-module-i386/arch/i386/kernel/traps.c
@@ -95,7 +95,8 @@ static int kstack_depth_to_print = 24;
 
 #ifdef CONFIG_MODULES
 
-extern struct module kernel_module;
+/* FIXME: Accessed without a lock --RR */
+extern struct list_head modules;
 
 static inline int kernel_text_address(unsigned long addr)
 {
@@ -106,11 +107,11 @@ static inline int kernel_text_address(un
 	    addr <= (unsigned long) &_etext)
 		return 1;
 
-	for (mod = module_list; mod != &kernel_module; mod = mod->next) {
+	list_for_each_entry(mod, &modules, list) {
 		/* mod_bound tests for addr being inside the vmalloc'ed
 		 * module area. Of course it'd be better to test only
 		 * for the .text subset... */
-		if (mod_bound(addr, 0, mod)) {
+		if (mod_bound((void *)addr, 0, mod)) {
 			retval = 1;
 			break;
 		}
arch/i386/mm/extable.c +8 -6
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9540-2.5.45-module-i386.pre/arch/i386/mm/extable.c .9540-2.5.45-module-i386/arch/i386/mm/extable.c
@@ -44,15 +44,17 @@ search_exception_table(unsigned long add
 	return ret;
 #else
 	unsigned long flags;
-	/* The kernel is the last "module" -- no need to treat it special.  */
-	struct module *mp;
+	struct list_head *i;
 
+	/* The kernel is the last "module" -- no need to treat it special.  */
 	spin_lock_irqsave(&modlist_lock, flags);
-	for (mp = module_list; mp != NULL; mp = mp->next) {
-		if (mp->ex_table_start == NULL || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING)))
+	list_for_each(i, &extables) {
+		struct exception_table *ex
+			= list_entry(i, struct exception_table, list);
+		if (ex->num_entries == 0)
 			continue;
-		ret = search_one_table(mp->ex_table_start,
-				       mp->ex_table_end - 1, addr);
+		ret = search_one_table(ex->entry,
+				       ex->entry + ex->num_entries - 1, addr);
 		if (ret)
 			break;
 	}
arch/i386/vmlinux.lds.S +1 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9540-2.5.45-module-i386.pre/arch/i386/vmlinux.lds.S .9540-2.5.45-module-i386/arch/i386/vmlinux.lds.S
@@ -26,6 +26,7 @@ SECTIONS
   __ex_table : { *(__ex_table) }
   __stop___ex_table = .;
 
+  . = ALIGN(64);
   __start___ksymtab = .;	/* Kernel symbol table */
   __ksymtab : { *(__ksymtab) }
   __stop___ksymtab = .;
include/asm-i386/module.h +7 -8
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .9540-2.5.45-module-i386.pre/include/asm-i386/module.h .9540-2.5.45-module-i386/include/asm-i386/module.h
@@ -1,12 +1,11 @@
 #ifndef _ASM_I386_MODULE_H
 #define _ASM_I386_MODULE_H
-/*
- * This file contains the i386 architecture specific module code.
- */
-
-#define module_map(x)		vmalloc(x)
-#define module_unmap(x)		vfree(x)
-#define module_arch_init(x)	(0)
-#define arch_init_modules(x)	do { } while (0)
+/* x86 is simple */
+struct mod_arch_specific
+{
+};
 
+#define Elf_Shdr Elf32_Shdr
+#define Elf_Sym Elf32_Sym
+#define Elf_Ehdr Elf32_Ehdr
 #endif /* _ASM_I386_MODULE_H */

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#16 lore raw

PATCH 1/1 Module loader against 2.5.46: 4/9

In reply to Rusty Russell

Now we reintroduce features: first a trivial patch to implement "strcspn" for module parameter parsing.

Linus, please apply,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: strcspn patch
Author: Rusty Russell
Status: Experimental

D: This patch implements a generic strcspn.

include/linux/string.h +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .17889-2.5.36-param.pre/include/linux/string.h .17889-2.5.36-param/include/linux/string.h
@@ -15,7 +15,7 @@ extern "C" {
 extern char * strpbrk(const char *,const char *);
 extern char * strsep(char **,const char *);
 extern __kernel_size_t strspn(const char *,const char *);
-
+extern __kernel_size_t strcspn(const char *,const char *);
 
 /*
  * Include machine specific inline routines
lib/string.c +23 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .17889-2.5.36-param.pre/lib/string.c .17889-2.5.36-param/lib/string.c
@@ -272,6 +272,29 @@ size_t strspn(const char *s, const char 
 }
 #endif
 
+/**
+ * strcspn - Calculate the length of the initial substring of @s which does
+ * 	not contain letters in @reject
+ * @s: The string to be searched
+ * @reject: The string to avoid
+ */
+size_t strcspn(const char *s, const char *reject)
+{
+	const char *p;
+	const char *r;
+	size_t count = 0;
+
+	for (p = s; *p != '\0'; ++p) {
+		for (r = reject; *r != '\0'; ++r) {
+			if (*p == *r)
+				return count;
+		}
+		++count;
+	}
+
+	return count;
+}	
+
 #ifndef __HAVE_ARCH_STRPBRK
 /**
  * strpbrk - Find the first occurrence of a set of characters
#17 lore raw

PATCH 1/1 Module loader against 2.5.46: 6/9

In reply to Rusty Russell

Trivially remove the #if 0 in module.c to enable the parameter parsing for modules.

Linus, please apply.
Rusty.

Name: Parameter Implementation for modules
Author: Rusty Russell
Status: Tested on 2.5.38
Depends: Module/param.patch.gz

D: This activates parameter parsing for PARAM() declarations in modules.

kernel/module.c +2 -3
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .31807-linux-2.5.43/kernel/module.c .31807-linux-2.5.43.updated/kernel/module.c
@@ -25,6 +25,7 @@
 #include <linux/fcntl.h>
 #include <linux/rcupdate.h>
 #include <linux/cpu.h>
+#include <linux/params.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 #include <asm/pgalloc.h>
@@ -951,8 +952,7 @@ static struct module *load_module(void *
 	if (err < 0)
 		goto cleanup;
 
-#if 0 /* Needs param support */
-	/* Size of section 0 is 0, so this works well */
+	/* Size of section 0 is 0, so this works well if no params */
 	err = parse_args(mod->args,
 			 (struct kernel_param *)
 			 sechdrs[setupindex].sh_offset,
@@ -961,7 +961,6 @@ static struct module *load_module(void *
 			 NULL);
 	if (err < 0)
 		goto cleanup;
-#endif
 
 	/* Get rid of temporary copy */
 	vfree(hdr);

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#18 lore raw

Re: [PATCH] Module loader against 2.5.46: 9/9

In reply to Rusty Russell

Since I believe kallsyms is important, this reimplements it sanely, using the current module infrastructure, and not using an external kallsyms script.

FYI, the previous interface was:

int kallsyms_symbol_to_address(
const char *name, /* Name to lookup */
unsigned long *token, /* Which module to start with */
const char **mod_name, /* Set to module name or "kernel" */
unsigned long *mod_start, /* Set to start address of module */
unsigned long *mod_end, /* Set to end address of module */
const char **sec_name, /* Set to section name */
unsigned long *sec_start, /* Set to start address of section */
unsigned long *sec_end, /* Set to end address of section */
const char **sym_name, /* Set to full symbol name */
unsigned long *sym_start, /* Set to start address of symbol */
unsigned long *sym_end /* Set to end address of symbol */
);

The new one is:
/* Lookup an address. modname is set to NULL if it's in the kernel. */ const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize, unsigned long *offset,
char **modname);

Rusty.

Name: kallsyms support
Author: Rusty Russell
Status: Documentation
Depends: Module/param-oldstyle.patch.gz

D: Reintroduces kallsyms support.

Makefile +2 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/Makefile .7287-linux-2.5.46.updated/Makefile
@@ -157,7 +157,7 @@ OBJCOPY		= $(CROSS_COMPILE)objcopy
 OBJDUMP		= $(CROSS_COMPILE)objdump
 AWK		= awk
 GENKSYMS	= /sbin/genksyms
-KALLSYMS	= /sbin/kallsyms
+KALLSYMS	= scripts/kallsyms
 PERL		= perl
 MODFLAGS	= -DMODULE
 CFLAGS_MODULE   = $(MODFLAGS)
@@ -335,7 +335,7 @@ ifdef CONFIG_KALLSYMS
 kallsyms.o := .tmp_kallsyms2.o
 
 quiet_cmd_kallsyms = KSYM    $@
-cmd_kallsyms = $(KALLSYMS) $< > $@
+cmd_kallsyms = sh $(KALLSYMS) $< $@
 
 .tmp_kallsyms1.o: .tmp_vmlinux1
 	$(call cmd,kallsyms)
arch/i386/Kconfig +7 -8
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/arch/i386/Kconfig .7287-linux-2.5.46.updated/arch/i386/Kconfig
@@ -1605,14 +1605,13 @@ config DEBUG_HIGHMEM
 	  This options enables addition error checking for high memory systems.
 	  Disable for production systems.
 
-# Reimplemented RSN.
-#config KALLSYMS
-#	bool "Load all symbols for debugging/kksymoops"
-#	depends on DEBUG_KERNEL
-#	help
-#	  Say Y here to let the kernel print out symbolic crash information and
-#	  symbolic stack backtraces. This increases the size of the kernel
-#	  somewhat, as all symbols have to be loaded into the kernel image.
+config KALLSYMS
+	bool "Load all symbols for debugging/kksymoops"
+	depends on DEBUG_KERNEL
+	help
+	  Say Y here to let the kernel print out symbolic crash information and
+	  symbolic stack backtraces. This increases the size of the kernel
+	  somewhat, as all symbols have to be loaded into the kernel image.
 
 config X86_EXTRA_IRQS
 	bool
arch/ia64/Kconfig +7 -7
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/arch/ia64/Kconfig .7287-linux-2.5.46.updated/arch/ia64/Kconfig
@@ -813,13 +813,13 @@ config DEBUG_KERNEL
 	  Say Y here if you are developing drivers or trying to debug and
 	  identify kernel problems.
 
-#  config KALLSYMS
-#  	bool "Load all symbols for debugging/kksymoops"
-#  	depends on DEBUG_KERNEL
-#  	help
-#  	  Say Y here to let the kernel print out symbolic crash information and
-#  	  symbolic stack backtraces. This increases the size of the kernel
-#  	  somewhat, as all symbols have to be loaded into the kernel image.
+config KALLSYMS
+	bool "Load all symbols for debugging/kksymoops"
+	depends on DEBUG_KERNEL
+	help
+	  Say Y here to let the kernel print out symbolic crash information and
+	  symbolic stack backtraces. This increases the size of the kernel
+	  somewhat, as all symbols have to be loaded into the kernel image.
 
 config IA64_PRINT_HAZARDS
 	bool "Print possible IA-64 dependency violations to console"
arch/ppc/Kconfig +3 -3
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/arch/ppc/Kconfig .7287-linux-2.5.46.updated/arch/ppc/Kconfig
@@ -1784,9 +1784,9 @@ config DEBUG_HIGHMEM
 	bool "Highmem debugging"
 	depends on DEBUG_KERNEL && HIGHMEM
 
-#  config KALLSYMS
-#  	bool "Load all symbols for debugging/kksymoops"
-#  	depends on DEBUG_KERNEL
+config KALLSYMS
+	bool "Load all symbols for debugging/kksymoops"
+	depends on DEBUG_KERNEL
 
 config KGDB
 	bool "Include kgdb kernel debugger"
arch/ppc/kernel/process.c +1 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/arch/ppc/kernel/process.c .7287-linux-2.5.46.updated/arch/ppc/kernel/process.c
@@ -34,6 +34,7 @@
 #include <linux/prctl.h>
 #include <linux/init_task.h>
 #include <linux/module.h>
+#include <linux/kallsyms.h>
 
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
arch/x86_64/Kconfig +7 -7
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/arch/x86_64/Kconfig .7287-linux-2.5.46.updated/arch/x86_64/Kconfig
@@ -739,13 +739,13 @@ config INIT_DEBUG
 	help
 	  Fill __init and __initdata at the end of boot. This is only for debugging.
 
-#  config KALLSYMS
-#  	bool "Load all symbols for debugging/kksymoops"
-#  	depends on DEBUG_KERNEL
-#  	help
-#  	  Say Y here to let the kernel print out symbolic crash information and
-#  	  symbolic stack backtraces. This increases the size of the kernel
-#  	  somewhat, as all symbols have to be loaded into the kernel image.
+config KALLSYMS
+	bool "Load all symbols for debugging/kksymoops"
+	depends on DEBUG_KERNEL
+	help
+	  Say Y here to let the kernel print out symbolic crash information and
+	  symbolic stack backtraces. This increases the size of the kernel
+	  somewhat, as all symbols have to be loaded into the kernel image.
 
 endmenu
 
fs/proc/base.c +8 -10
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/fs/proc/base.c .7287-linux-2.5.46.updated/fs/proc/base.c
@@ -257,20 +257,18 @@ out:
  */
 static int proc_pid_wchan(struct task_struct *task, char *buffer)
 {
-	const char *sym_name, *ignore;
-	unsigned long wchan, dummy;
+	char *modname;
+	const char *sym_name;
+	unsigned long wchan, size, offset;
 
 	wchan = get_wchan(task);
 
-	if (!kallsyms_address_to_symbol(wchan, &ignore, &dummy, &dummy,
-			&ignore, &dummy, &dummy, &sym_name,
-			&dummy, &dummy)) {
-		return sprintf(buffer, "%lu", wchan);
-	}
-
-	return sprintf(buffer, "%s", sym_name);
+	sym_name = kallsyms_lookup(wchan, &size, &offset, &modname);
+	if (sym_name)
+		return sprintf(buffer, "%s", sym_name);
+	return sprintf(buffer, "%lu", wchan);
 }
-#endif
+#endif /* CONFIG_KALLSYMS */
 
 /************************************************************************/
 /*                       Here the fs part begins                        */
include/linux/kallsyms.h +34 -150

197 lines not on this page · raw message

include/linux/module.h +22 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/include/linux/module.h .7287-linux-2.5.46.updated/include/linux/module.h
@@ -27,8 +27,6 @@
 #define MODULE_GENERIC_TABLE(gtype,name)
 #define MODULE_DEVICE_TABLE(type,name)
 #define MODULE_PARM_DESC(var,desc)
-#define print_symbol(format, addr)
-#define print_modules()
 
 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
 struct kernel_symbol
@@ -136,6 +134,13 @@ struct module
 	void (*exit)(void);
 #endif
 
+#ifdef CONFIG_KALLSYMS
+	/* We keep the symbol and string tables for kallsyms. */
+	Elf_Sym *symtab;
+	unsigned long num_syms;
+	char *strtab;
+#endif
+
 	/* The command line arguments (may be mangled).  People like
 	   keeping pointers to this stuff */
 	char args[0];
@@ -248,6 +253,12 @@ do {									     \
 	}								     \
 } while(0)
 
+/* For kallsyms to ask for address resolution.  NULL means not found. */
+const char *module_address_lookup(unsigned long addr,
+				  unsigned long *symbolsize,
+				  unsigned long *offset,
+				  char **modname);
+
 #else /* !CONFIG_MODULES... */
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
@@ -261,6 +272,15 @@ do {									     \
 #define module_put(module) do { } while(0)
 
 #define __unsafe(mod)
+
+/* For kallsyms to ask for address resolution.  NULL means not found. */
+static inline const char *module_address_lookup(unsigned long addr,
+						unsigned long *symbolsize,
+						unsigned long *offset,
+						char **modname)
+{
+	return NULL;
+}
 #endif /* CONFIG_MODULES */
 
 /* For archs to search exception tables */
kernel/Makefile +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/kernel/Makefile .7287-linux-2.5.46.updated/kernel/Makefile
@@ -4,7 +4,7 @@
 
 export-objs = signal.o sys.o kmod.o workqueue.o ksyms.o pm.o exec_domain.o \
 		printk.o platform.o suspend.o dma.o module.o cpufreq.o \
-		profile.o rcupdate.o intermodule.o params.o
+		profile.o rcupdate.o intermodule.o params.o kallsyms.o
 
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
 	    exit.o itimer.o time.o softirq.o resource.o \
kernel/kallsyms.c +79 -207

312 lines not on this page · raw message

kernel/module.c +86 -3

107 lines not on this page · raw message

scripts/kallsyms +40 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .7287-linux-2.5.46/scripts/kallsyms .7287-linux-2.5.46.updated/scripts/kallsyms
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Written by Rusty Russell <[email protected]> 2002.
+
+if [ $# -ne 2 ]; then
+    echo Usage: kallsyms vmlinux objfile >&2
+
+    echo Adds a .kallsyms section containing symbol info.
+    exit 1
+fi
+
+set -e
+
+# Clean up on exit.
+trap "rm -f kallsyms.map kallsyms.c $2" 0
+
+# Takes nm output from $1, produces a .c file on standard output.
+encode_symbols()
+{
+    # First take addresses.
+    echo "unsigned long kallsyms_addresses[] = {"
+    sed 's/^[	]*\([A-Fa-f0-9]*\).*/0x\1UL,/' < $1
+    echo "};"
+
+    # Now output size.
+    echo "unsigned long kallsyms_num_syms = `wc -l < $1`;"
+
+    # Now output names.
+    echo "char kallsyms_names[] = ";
+    sed 's/^[         ]*[A-Fa-f0-9]*[         ]*.[    ]\(.*\)/"\1\\0"/' < $1
+    echo ";"
+}
+
+# FIXME: Use System.map as input, and regenerate each time in Makefile.
+$NM $1 | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > kallsyms.map
+
+encode_symbols kallsyms.map > kallsyms.c
+$CC $CFLAGS -c -o $2 kallsyms.c
+
+trap "rm -f kallsyms.map kallsyms.c" 0
+exit 0

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#19 lore raw

Re: [PATCH] Module loader against 2.5.46: 9/9

Quoted 20 lines · Rusty Russell

Since I believe kallsyms is important, this reimplements it sanely, using the current module infrastructure, and not using an external kallsyms script.

FYI, the previous interface was:

int kallsyms_symbol_to_address(
const char *name, /* Name to lookup */
unsigned long *token, /* Which module to start with */
const char **mod_name, /* Set to module name or "kernel" */
unsigned long *mod_start, /* Set to start address of module */
unsigned long *mod_end, /* Set to end address of module */
const char **sec_name, /* Set to section name */
unsigned long *sec_start, /* Set to start address of section */
unsigned long *sec_end, /* Set to end address of section */
const char **sym_name, /* Set to full symbol name */
unsigned long *sym_start, /* Set to start address of symbol */
unsigned long *sym_end /* Set to end address of symbol */
);

Quoted 6 lines

The new one is:
/* Lookup an address. modname is set to NULL if it's in the kernel. */ const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize, unsigned long *offset,
char **modname);

If you are going to change the interface then don't call it kallsyms. kallsyms and that interface were designed to kernel debugging in general and kdb in particular. I need all the fields for decent debugging and I refuse to allow my kallsyms code to be appropiated for somebody else's usage if it stops kdb from working!

#20 lore raw

Re: [PATCH] Module loader against 2.5.46: 9/9

In message <[email protected]> you write:

Quoted 9 lines
Quoted 6 lines · Rusty Russell

The new one is:
/* Lookup an address. modname is set to NULL if it's in the kernel. */ const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize, unsigned long *offset,
char **modname);

Quoted 3 lines

If you are going to change the interface then don't call it kallsyms. kallsyms and that interface were designed to kernel debugging in general and kdb in particular.

That explains it: I didn't think you were insane 8). Thanks, I'll move it to some other name which just does the "add symbols to oops" minimum.

Thanks!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#21 lore raw

Re: [PATCH] Module loader against 2.5.46: 9/9

Quoted 3 lines · Rusty Russell

That explains it: I didn't think you were insane 8). Thanks, I'll move it to some other name which just does the "add symbols to oops" minimum.

I doubt that we need all of the kallsyms data in the kernel as well (unless you're using kdb.)

One of the things on my todo list is to look into a kallsyms replacement that allows cross-compilation (and actually allows kallsyms to work at all on ARM.)

ARM requires the ELF architecture private flags to be set correctly to link two objects together. So there's two problems with the current setup:

1. can't cross-compile with kallsyms
2. can't natively compile with kallsyms on architectures that require the private flags to be set correctly.

Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html
#22 lore raw

Re: [PATCH] Module loader against 2.5.46: 9/9

In message <[email protected]> you write:

Quoted 7 lines · Rusty Russell
Quoted 3 lines

That explains it: I didn't think you were insane 8). Thanks, I'll move it to some other name which just does the "add symbols to oops" minimum.

I doubt that we need all of the kallsyms data in the kernel as well (unless you're using kdb.)

Yes. From my IDE oops dumper experience, you can get the required kernel symbols down to 70k w/o kdb (it's about 380k as stands). I haven't made this optimization yet though.

Quoted 6 lines

One of the things on my todo list is to look into a kallsyms replacement that allows cross-compilation (and actually allows kallsyms to work at all on ARM.)

ARM requires the ELF architecture private flags to be set correctly to link two objects together. So there's two problems with the current setup:

Hmm, depends on state of module loader code. If it goes in, you'll
be getting a new one anyway which doesn't have this problem (I use $CC to create kallsyms.o which gets linked in). Otherwise, yes.

Cheers,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#23 lore raw

PATCH 1/1 Module loader against 2.5.46: 5/9

In reply to Rusty Russell

Now, we add support for the PARAM(foo, type, perms) macro:

o Module parameters appear as "foo", kernel parameters appear as "<modulename>.foo"
o Parameters are typechecked.
o Standard types are implemented, you can implement your own.
o Name "PARAM" clashes with include/asm-i386/setup.h, so we rename that to "PARAMS".
o Final permissions arg can be used for exposing parameters through sysfs (000 means no exposure).

Linus, please apply,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: Parameter Core Patch
Author: Rusty Russell
Status: Tested on 2.5.38
Depends: Misc/strcspn.patch.gz
Depends: Module/module-i386.patch.gz

D: This patch is a rewrite of the insmod and boot parameter handling,
D: to unify them.
D:
D: The new format is fairly simple: built on top of __PARAM_CALL there
D: are several helpers, eg "PARAM(foo, int, 000)". The final argument
D: is the permissions bits, for exposing parameters in driverfs (if
D: non-zero) at a later stage.

arch/i386/vmlinux.lds.S +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/arch/i386/vmlinux.lds.S .2447-linux-2.5-bk.updated/arch/i386/vmlinux.lds.S
@@ -67,6 +67,9 @@ SECTIONS
   __setup_start = .;
   .init.setup : { *(.init.setup) }
   __setup_end = .;
+  __param_start = .;
+  .param.init : { *(.param.init) }
+  __param_end = .;
   __initcall_start = .;
   .initcall.init : {
 	*(.initcall1.init) 
arch/ia64/vmlinux.lds.S +4 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/arch/ia64/vmlinux.lds.S .2447-linux-2.5-bk.updated/arch/ia64/vmlinux.lds.S
@@ -102,6 +102,10 @@ SECTIONS
   .init.setup : AT(ADDR(.init.setup) - PAGE_OFFSET)
         { *(.init.setup) }
   __setup_end = .;
+  __param_start = .;
+  .param.init : AT(ADDR(.param.init) - PAGE_OFFSET)
+        { *(.param.init) }
+  __param_end = .;
   __initcall_start = .;
   .initcall.init : AT(ADDR(.initcall.init) - PAGE_OFFSET)
 	{
arch/ppc/vmlinux.lds.S +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/arch/ppc/vmlinux.lds.S .2447-linux-2.5-bk.updated/arch/ppc/vmlinux.lds.S
@@ -101,6 +101,9 @@ SECTIONS
   __setup_start = .;
   .init.setup : { *(.init.setup) }
   __setup_end = .;
+  __param_start = .;
+  .param.init : { *(.param.init) }
+  __param_end = .;
   __initcall_start = .;
   .initcall.init : {
 	*(.initcall1.init) 
arch/ppc64/vmlinux.lds.S +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/arch/ppc64/vmlinux.lds.S .2447-linux-2.5-bk.updated/arch/ppc64/vmlinux.lds.S
@@ -99,6 +99,9 @@ SECTIONS
   __setup_start = .;
   .setup.init : { *(.setup.init) }
   __setup_end = .;
+  __param_start = .;
+  .param.init : { *(.param.init) }
+  __param_end = .;
   __initcall_start = .;
   .initcall.init : {
 	*(.initcall1.init) 
arch/sparc64/vmlinux.lds.S +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/arch/sparc64/vmlinux.lds.S .2447-linux-2.5-bk.updated/arch/sparc64/vmlinux.lds.S
@@ -46,6 +46,9 @@ SECTIONS
   __setup_start = .;
   .init.setup : { *(.init.setup) }
   __setup_end = .;
+  __param_start = .;
+  .param.init : { *(.param.init) }
+  __param_end = .;
   __initcall_start = .;
   .initcall.init : {
 	*(.initcall1.init) 
include/asm-i386/setup.h +21 -21

48 lines not on this page · raw message

include/linux/init.h +13 -7
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/include/linux/init.h .2447-linux-2.5-bk.updated/include/linux/init.h
@@ -86,19 +86,15 @@ typedef void (*exitcall_t)(void);
 #define __exitcall(fn)							\
 	static exitcall_t __exitcall_##fn __exit_call = fn
 
-/*
- * Used for kernel command line parameter setup
- */
-struct kernel_param {
+struct obs_kernel_param {
 	const char *str;
 	int (*setup_func)(char *);
 };
 
-extern struct kernel_param __setup_start, __setup_end;
-
+/* OBSOLETE: see params.h for the right way. */
 #define __setup(str, fn)						\
 	static char __setup_str_##fn[] __initdata = str;		\
-	static struct kernel_param __setup_##fn				\
+	static struct obs_kernel_param __setup_##fn			\
 		 __attribute__((unused,__section__ (".init.setup")))	\
 		= { __setup_str_##fn, fn }
 
@@ -177,6 +173,16 @@ extern struct kernel_param __setup_start
 /* Data marked not to be saved by software_suspend() */
 #define __nosavedata __attribute__ ((__section__ (".data.nosave")))
 
+/* This means "can be init if no module support, otherwise module load
+   may call it." */
+#ifdef CONFIG_MODULES
+#define __init_or_module
+#define __initdata_or_module
+#else
+#define __init_or_module __init
+#define __initdata_or_module __initdata
+#endif /*CONFIG_MODULES*/
+
 #ifdef CONFIG_HOTPLUG
 #define __devinit
 #define __devinitdata
include/linux/kernel.h +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/include/linux/kernel.h .2447-linux-2.5-bk.updated/include/linux/kernel.h
@@ -71,7 +71,7 @@ extern int sscanf(const char *, const ch
 extern int vsscanf(const char *, const char *, va_list);
 
 extern int get_option(char **str, int *pint);
-extern char *get_options(char *str, int nints, int *ints);
+extern char *get_options(const char *str, int nints, int *ints);
 extern unsigned long long memparse(char *ptr, char **retptr);
 extern void dev_probe_lock(void);
 extern void dev_probe_unlock(void);
include/linux/params.h +123 -0

123 lines not on this page · raw message

init/main.c +40 -64

142 lines not on this page · raw message

kernel/Makefile +2 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/kernel/Makefile .2447-linux-2.5-bk.updated/kernel/Makefile
@@ -4,13 +4,13 @@
 
 export-objs = signal.o sys.o kmod.o workqueue.o ksyms.o pm.o exec_domain.o \
 		printk.o platform.o suspend.o dma.o module.o cpufreq.o \
-		profile.o rcupdate.o intermodule.o
+		profile.o rcupdate.o intermodule.o params.o
 
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
 	    exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o futex.o platform.o pid.o \
-	    rcupdate.o intermodule.o
+	    rcupdate.o intermodule.o params.o
 
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o
kernel/params.c +338 -0

338 lines not on this page · raw message

lib/cmdline.c +5 -5
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2447-linux-2.5-bk/lib/cmdline.c .2447-linux-2.5-bk.updated/lib/cmdline.c
@@ -33,11 +33,11 @@
 
 int get_option (char **str, int *pint)
 {
-	char *cur = *str;
+	const char *cur = *str;
 
 	if (!cur || !(*cur))
 		return 0;
-	*pint = simple_strtol (cur, str, 0);
+	*pint = simple_strtol (cur, (char **)str, 0);
 	if (cur == *str)
 		return 0;
 	if (**str == ',') {
@@ -64,12 +64,12 @@ int get_option (char **str, int *pint)
  *	completely parseable).
  */
  
-char *get_options (char *str, int nints, int *ints)
+char *get_options (const char *str, int nints, int *ints)
 {
 	int res, i = 1;
 
 	while (i < nints) {
-		res = get_option (&str, ints + i);
+		res = get_option ((char **)&str, ints + i);
 		if (res == 0)
 			break;
 		i++;
@@ -77,7 +77,7 @@ char *get_options (char *str, int nints,
 			break;
 	}
 	ints[0] = i - 1;
-	return (str);
+	return (char *)str;
 }
 
 /**