module_param() 1/3
Subsystems (2)
PATCH 1/1 module_param() 1/3
Linus,
This is the core support, with the out-by-one error which made
it not boot with 0 params fixed (Doh!). Tested on 2.5.49 (with a test parameter and without).
The comment says __setup() is obsolete, but you might want to
delete that: there are some real cases where a top-level argument is desired, and __module_param_call() is a bit of a mouthful 8)
Cheers,
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.49
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 __module_param_call there
D: are several helpers, eg "module_param(foo, int, 000)". The final argument
D: is the permissions bits, for exposing parameters in sysfs (if
D: non-zero) at a later stage.
arch/i386/vmlinux.lds.S +3 -0
@@ -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
@@ -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
@@ -103,6 +103,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
@@ -91,6 +91,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/sparc64/vmlinux.lds.S +3 -0
@@ -51,6 +51,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/linux/init.h +13 -7
@@ -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
@@ -71,7 +71,7 @@ extern int sscanf(const char *, const chextern 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/moduleparam.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
@@ -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 extable.o + rcupdate.o intermodule.o extable.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 +3 -3
@@ -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; }/**
PATCH 1/1 module_param() 2/3
This enables it in the module code.
Name: Parameter Implementation for modules
Author: Rusty Russell
Status: Tested on 2.5.49
Depends: Module/param.patch.gz
D: This activates parameter parsing for module_param() declarations in modules.
kernel/module.c +2 -3
@@ -25,6 +25,7 @@#include <linux/fcntl.h> #include <linux/rcupdate.h> #include <linux/cpu.h> +#include <linux/moduleparam.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.
PATCH 1/1 module_param() 3/3
In reply to Rusty RussellAnd this is the backwards compat wedge for MODULE_PARM(), so they "just work".
Name: MODULE_PARM support for older modules
Author: Rusty Russell
Status: Tested on 2.5.49
Depends: Module/param-modules.patch.gz
Depends: Module/forceunload.patch.gz
D: This is the backwards compatibility code for MODULE_PARM, and moves
D: __MODULE_STRING() down to the graveyard at the bottom of module.h.
include/linux/module.h +13 -5
@@ -13,16 +13,13 @@#include <linux/stat.h> #include <linux/compiler.h> #include <linux/cache.h> +#include <linux/stringify.h> #include <linux/kmod.h> #include <linux/elf.h> #include <asm/module.h> #include <asm/uaccess.h> /* For struct exception_table_entry */ -/* Indirect stringification */ -#define __MODULE_STRING_1 (x) #x -#define __MODULE_STRING (x) __MODULE_STRING_1(x) -/* Not Yet Implemented */ #define MODULE_LICENSE (name)#define MODULE_AUTHOR (name)
@@ -277,6 +274,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... */
@@ -289,11 +297,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
@@ -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
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 4 lines · Rusty Russell
Linus,
This is the core support, with the out-by-one error which made
it not boot with 0 params fixed (Doh!). Tested on 2.5.49 (with a test parameter and without).
System is RedHat 8.0 with mod-init tools 0.7 added. I pulled down a fresh 2.5.49 tarball and added all three of your patches.
modprobe pcmcia_core gives the following error:
pcmcia_core: falsely claims to have parameter t
FATAL: Error inserting /lib/modules/2.5.49/kernel/pcmcia_core.o: Invalid argument
In message <[email protected]> you write:
Quoted 4 lines
System is RedHat 8.0 with mod-init tools 0.7 added. I pulled down a fresh 2.5.49 tarball and added all three of your patches.
modprobe
pcmcia_coregives the following error:
Fuck! A user! 8)
Thanks, reproduced here. 3/3 patch fixed (and attached below).
Padding had been inserted in between the obsolete_modparm entries in the section, because I wasn't careful enough about the size. pcmcia_core has enough parameters to show up this bug clearly.
Thanks very much for the bug report! Does this work for you now? Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: MODULE_PARM support for older modules
Author: Rusty Russell
Status: Tested on 2.5.50
Depends: Module/param-modules.patch.gz
D: This is the backwards compatibility code for MODULE_PARM, and moves
D: __MODULE_STRING() down to the graveyard at the bottom of module.h.
include/linux/module.h +17 -5
@@ -13,16 +13,13 @@#include <linux/stat.h> #include <linux/compiler.h> #include <linux/cache.h> +#include <linux/stringify.h> #include <linux/kmod.h> #include <linux/elf.h> #include <asm/module.h> #include <asm/uaccess.h> /* For struct exception_table_entry */ -/* Indirect stringification */ -#define __MODULE_STRING_1 (x) #x -#define __MODULE_STRING (x) __MODULE_STRING_1(x) -/* Not Yet Implemented */ #define MODULE_LICENSE (name)#define MODULE_AUTHOR (name)
@@ -277,6 +274,21 @@ 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 -sizeof (void *)]; +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... */
@@ -289,11 +301,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 -0
@@ -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
kernel/module.c +152 -9
191 lines not on this page · raw message