diff options
| author | Takashi Iwai <tiwai@suse.de> | 2011-08-08 08:30:29 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2011-08-08 08:30:29 -0400 |
| commit | 0a2d31b62dba9b5b92a38c67c9cc42630513662a (patch) | |
| tree | f755d74ec85248de645e10c45ed1a2ed467530f6 /kernel/module.c | |
| parent | 8039290a91c5dc4414093c086987a5d7738fe2fd (diff) | |
| parent | df944f66784e6d4f2f50739263a4947885d8b6ae (diff) | |
Merge branch 'fix/kconfig' into for-linus
Diffstat (limited to 'kernel/module.c')
| -rw-r--r-- | kernel/module.c | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/kernel/module.c b/kernel/module.c index 795bdc7f5c3f..04379f92f843 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
| @@ -545,9 +545,9 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \ | |||
| 545 | mod->field = kstrdup(s, GFP_KERNEL); \ | 545 | mod->field = kstrdup(s, GFP_KERNEL); \ |
| 546 | } \ | 546 | } \ |
| 547 | static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ | 547 | static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ |
| 548 | struct module *mod, char *buffer) \ | 548 | struct module_kobject *mk, char *buffer) \ |
| 549 | { \ | 549 | { \ |
| 550 | return sprintf(buffer, "%s\n", mod->field); \ | 550 | return sprintf(buffer, "%s\n", mk->mod->field); \ |
| 551 | } \ | 551 | } \ |
| 552 | static int modinfo_##field##_exists(struct module *mod) \ | 552 | static int modinfo_##field##_exists(struct module *mod) \ |
| 553 | { \ | 553 | { \ |
| @@ -902,9 +902,9 @@ void symbol_put_addr(void *addr) | |||
| 902 | EXPORT_SYMBOL_GPL(symbol_put_addr); | 902 | EXPORT_SYMBOL_GPL(symbol_put_addr); |
| 903 | 903 | ||
| 904 | static ssize_t show_refcnt(struct module_attribute *mattr, | 904 | static ssize_t show_refcnt(struct module_attribute *mattr, |
| 905 | struct module *mod, char *buffer) | 905 | struct module_kobject *mk, char *buffer) |
| 906 | { | 906 | { |
| 907 | return sprintf(buffer, "%u\n", module_refcount(mod)); | 907 | return sprintf(buffer, "%u\n", module_refcount(mk->mod)); |
| 908 | } | 908 | } |
| 909 | 909 | ||
| 910 | static struct module_attribute refcnt = { | 910 | static struct module_attribute refcnt = { |
| @@ -952,11 +952,11 @@ static inline int module_unload_init(struct module *mod) | |||
| 952 | #endif /* CONFIG_MODULE_UNLOAD */ | 952 | #endif /* CONFIG_MODULE_UNLOAD */ |
| 953 | 953 | ||
| 954 | static ssize_t show_initstate(struct module_attribute *mattr, | 954 | static ssize_t show_initstate(struct module_attribute *mattr, |
| 955 | struct module *mod, char *buffer) | 955 | struct module_kobject *mk, char *buffer) |
| 956 | { | 956 | { |
| 957 | const char *state = "unknown"; | 957 | const char *state = "unknown"; |
| 958 | 958 | ||
| 959 | switch (mod->state) { | 959 | switch (mk->mod->state) { |
| 960 | case MODULE_STATE_LIVE: | 960 | case MODULE_STATE_LIVE: |
| 961 | state = "live"; | 961 | state = "live"; |
| 962 | break; | 962 | break; |
| @@ -975,10 +975,27 @@ static struct module_attribute initstate = { | |||
| 975 | .show = show_initstate, | 975 | .show = show_initstate, |
| 976 | }; | 976 | }; |
| 977 | 977 | ||
| 978 | static ssize_t store_uevent(struct module_attribute *mattr, | ||
| 979 | struct module_kobject *mk, | ||
| 980 | const char *buffer, size_t count) | ||
| 981 | { | ||
| 982 | enum kobject_action action; | ||
| 983 | |||
| 984 | if (kobject_action_type(buffer, count, &action) == 0) | ||
| 985 | kobject_uevent(&mk->kobj, action); | ||
| 986 | return count; | ||
| 987 | } | ||
| 988 | |||
| 989 | struct module_attribute module_uevent = { | ||
| 990 | .attr = { .name = "uevent", .mode = 0200 }, | ||
| 991 | .store = store_uevent, | ||
| 992 | }; | ||
| 993 | |||
| 978 | static struct module_attribute *modinfo_attrs[] = { | 994 | static struct module_attribute *modinfo_attrs[] = { |
| 979 | &modinfo_version, | 995 | &modinfo_version, |
| 980 | &modinfo_srcversion, | 996 | &modinfo_srcversion, |
| 981 | &initstate, | 997 | &initstate, |
| 998 | &module_uevent, | ||
| 982 | #ifdef CONFIG_MODULE_UNLOAD | 999 | #ifdef CONFIG_MODULE_UNLOAD |
| 983 | &refcnt, | 1000 | &refcnt, |
| 984 | #endif | 1001 | #endif |
| @@ -1187,7 +1204,7 @@ struct module_sect_attrs | |||
| 1187 | }; | 1204 | }; |
| 1188 | 1205 | ||
| 1189 | static ssize_t module_sect_show(struct module_attribute *mattr, | 1206 | static ssize_t module_sect_show(struct module_attribute *mattr, |
| 1190 | struct module *mod, char *buf) | 1207 | struct module_kobject *mk, char *buf) |
| 1191 | { | 1208 | { |
| 1192 | struct module_sect_attr *sattr = | 1209 | struct module_sect_attr *sattr = |
| 1193 | container_of(mattr, struct module_sect_attr, mattr); | 1210 | container_of(mattr, struct module_sect_attr, mattr); |
| @@ -1697,6 +1714,15 @@ static void unset_module_core_ro_nx(struct module *mod) { } | |||
| 1697 | static void unset_module_init_ro_nx(struct module *mod) { } | 1714 | static void unset_module_init_ro_nx(struct module *mod) { } |
| 1698 | #endif | 1715 | #endif |
| 1699 | 1716 | ||
| 1717 | void __weak module_free(struct module *mod, void *module_region) | ||
| 1718 | { | ||
| 1719 | vfree(module_region); | ||
| 1720 | } | ||
| 1721 | |||
| 1722 | void __weak module_arch_cleanup(struct module *mod) | ||
| 1723 | { | ||
| 1724 | } | ||
| 1725 | |||
| 1700 | /* Free a module, remove from lists, etc. */ | 1726 | /* Free a module, remove from lists, etc. */ |
| 1701 | static void free_module(struct module *mod) | 1727 | static void free_module(struct module *mod) |
| 1702 | { | 1728 | { |
| @@ -1851,6 +1877,26 @@ static int simplify_symbols(struct module *mod, const struct load_info *info) | |||
| 1851 | return ret; | 1877 | return ret; |
| 1852 | } | 1878 | } |
| 1853 | 1879 | ||
| 1880 | int __weak apply_relocate(Elf_Shdr *sechdrs, | ||
| 1881 | const char *strtab, | ||
| 1882 | unsigned int symindex, | ||
| 1883 | unsigned int relsec, | ||
| 1884 | struct module *me) | ||
| 1885 | { | ||
| 1886 | pr_err("module %s: REL relocation unsupported\n", me->name); | ||
| 1887 | return -ENOEXEC; | ||
| 1888 | } | ||
| 1889 | |||
| 1890 | int __weak apply_relocate_add(Elf_Shdr *sechdrs, | ||
| 1891 | const char *strtab, | ||
| 1892 | unsigned int symindex, | ||
| 1893 | unsigned int relsec, | ||
| 1894 | struct module *me) | ||
| 1895 | { | ||
| 1896 | pr_err("module %s: RELA relocation unsupported\n", me->name); | ||
| 1897 | return -ENOEXEC; | ||
| 1898 | } | ||
| 1899 | |||
| 1854 | static int apply_relocations(struct module *mod, const struct load_info *info) | 1900 | static int apply_relocations(struct module *mod, const struct load_info *info) |
| 1855 | { | 1901 | { |
| 1856 | unsigned int i; | 1902 | unsigned int i; |
| @@ -2235,6 +2281,11 @@ static void dynamic_debug_remove(struct _ddebug *debug) | |||
| 2235 | ddebug_remove_module(debug->modname); | 2281 | ddebug_remove_module(debug->modname); |
| 2236 | } | 2282 | } |
| 2237 | 2283 | ||
| 2284 | void * __weak module_alloc(unsigned long size) | ||
| 2285 | { | ||
| 2286 | return size == 0 ? NULL : vmalloc_exec(size); | ||
| 2287 | } | ||
| 2288 | |||
| 2238 | static void *module_alloc_update_bounds(unsigned long size) | 2289 | static void *module_alloc_update_bounds(unsigned long size) |
| 2239 | { | 2290 | { |
| 2240 | void *ret = module_alloc(size); | 2291 | void *ret = module_alloc(size); |
| @@ -2645,6 +2696,14 @@ static void flush_module_icache(const struct module *mod) | |||
| 2645 | set_fs(old_fs); | 2696 | set_fs(old_fs); |
| 2646 | } | 2697 | } |
| 2647 | 2698 | ||
| 2699 | int __weak module_frob_arch_sections(Elf_Ehdr *hdr, | ||
| 2700 | Elf_Shdr *sechdrs, | ||
| 2701 | char *secstrings, | ||
| 2702 | struct module *mod) | ||
| 2703 | { | ||
| 2704 | return 0; | ||
| 2705 | } | ||
| 2706 | |||
| 2648 | static struct module *layout_and_allocate(struct load_info *info) | 2707 | static struct module *layout_and_allocate(struct load_info *info) |
| 2649 | { | 2708 | { |
| 2650 | /* Module within temporary copy. */ | 2709 | /* Module within temporary copy. */ |
| @@ -2716,6 +2775,13 @@ static void module_deallocate(struct module *mod, struct load_info *info) | |||
| 2716 | module_free(mod, mod->module_core); | 2775 | module_free(mod, mod->module_core); |
| 2717 | } | 2776 | } |
| 2718 | 2777 | ||
| 2778 | int __weak module_finalize(const Elf_Ehdr *hdr, | ||
| 2779 | const Elf_Shdr *sechdrs, | ||
| 2780 | struct module *me) | ||
| 2781 | { | ||
| 2782 | return 0; | ||
| 2783 | } | ||
| 2784 | |||
| 2719 | static int post_relocation(struct module *mod, const struct load_info *info) | 2785 | static int post_relocation(struct module *mod, const struct load_info *info) |
| 2720 | { | 2786 | { |
| 2721 | /* Sort exception table now relocations are done. */ | 2787 | /* Sort exception table now relocations are done. */ |
