Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_MODULE_H |
| 2 | #define _LINUX_MODULE_H |
| 3 | /* |
| 4 | * Dynamic loading of modules into the kernel. |
| 5 | * |
| 6 | * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996 |
| 7 | * Rewritten again by Rusty Russell, 2002 |
| 8 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/list.h> |
| 10 | #include <linux/stat.h> |
| 11 | #include <linux/compiler.h> |
| 12 | #include <linux/cache.h> |
| 13 | #include <linux/kmod.h> |
| 14 | #include <linux/elf.h> |
| 15 | #include <linux/stringify.h> |
| 16 | #include <linux/kobject.h> |
| 17 | #include <linux/moduleparam.h> |
Mathieu Desnoyers | 97e1c18 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 18 | #include <linux/tracepoint.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Christoph Lameter | e1783a2 | 2010-01-05 15:34:50 +0900 | [diff] [blame] | 20 | #include <linux/percpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/module.h> |
| 22 | |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 23 | #include <trace/events/module.h> |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | /* Not Yet Implemented */ |
| 26 | #define MODULE_SUPPORTED_DEVICE(name) |
| 27 | |
Alan Jenkins | 9e1b9b8 | 2009-11-07 21:03:54 +0000 | [diff] [blame] | 28 | /* Some toolchains use a `_' prefix for all user symbols. */ |
| 29 | #ifdef CONFIG_SYMBOL_PREFIX |
| 30 | #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX |
| 31 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #define MODULE_SYMBOL_PREFIX "" |
| 33 | #endif |
| 34 | |
Rusty Russell | 730b69d | 2008-10-22 10:00:22 -0500 | [diff] [blame] | 35 | #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | struct kernel_symbol |
| 38 | { |
| 39 | unsigned long value; |
| 40 | const char *name; |
| 41 | }; |
| 42 | |
| 43 | struct modversion_info |
| 44 | { |
| 45 | unsigned long crc; |
| 46 | char name[MODULE_NAME_LEN]; |
| 47 | }; |
| 48 | |
| 49 | struct module; |
| 50 | |
| 51 | struct module_attribute { |
| 52 | struct attribute attr; |
| 53 | ssize_t (*show)(struct module_attribute *, struct module *, char *); |
| 54 | ssize_t (*store)(struct module_attribute *, struct module *, |
| 55 | const char *, size_t count); |
Matt Domsch | c988d2b | 2005-06-23 22:05:15 -0700 | [diff] [blame] | 56 | void (*setup)(struct module *, const char *); |
| 57 | int (*test)(struct module *); |
| 58 | void (*free)(struct module *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
Dmitry Torokhov | e94965e | 2010-12-15 14:00:19 -0800 | [diff] [blame] | 61 | struct module_version_attribute { |
| 62 | struct module_attribute mattr; |
| 63 | const char *module_name; |
| 64 | const char *version; |
Dmitry Torokhov | 98562ad | 2011-02-04 13:30:10 -0800 | [diff] [blame] | 65 | } __attribute__ ((__aligned__(sizeof(void *)))); |
Dmitry Torokhov | e94965e | 2010-12-15 14:00:19 -0800 | [diff] [blame] | 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | struct module_kobject |
| 68 | { |
| 69 | struct kobject kobj; |
| 70 | struct module *mod; |
Kay Sievers | f30c53a | 2007-01-15 20:22:02 +0100 | [diff] [blame] | 71 | struct kobject *drivers_dir; |
Rusty Russell | 9b473de | 2008-10-22 10:00:22 -0500 | [diff] [blame] | 72 | struct module_param_attrs *mp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | /* These are either module local, or the kernel's dummy ones. */ |
| 76 | extern int init_module(void); |
| 77 | extern void cleanup_module(void); |
| 78 | |
| 79 | /* Archs provide a method of finding the correct exception table. */ |
| 80 | struct exception_table_entry; |
| 81 | |
| 82 | const struct exception_table_entry * |
| 83 | search_extable(const struct exception_table_entry *first, |
| 84 | const struct exception_table_entry *last, |
| 85 | unsigned long value); |
| 86 | void sort_extable(struct exception_table_entry *start, |
| 87 | struct exception_table_entry *finish); |
| 88 | void sort_main_extable(void); |
Rusty Russell | ad6561d | 2009-06-12 21:47:03 -0600 | [diff] [blame] | 89 | void trim_init_extable(struct module *m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | #ifdef MODULE |
| 92 | #define MODULE_GENERIC_TABLE(gtype,name) \ |
| 93 | extern const struct gtype##_id __mod_##gtype##_table \ |
| 94 | __attribute__ ((unused, alias(__stringify(name)))) |
| 95 | |
| 96 | extern struct module __this_module; |
| 97 | #define THIS_MODULE (&__this_module) |
| 98 | #else /* !MODULE */ |
| 99 | #define MODULE_GENERIC_TABLE(gtype,name) |
| 100 | #define THIS_MODULE ((struct module *)0) |
| 101 | #endif |
| 102 | |
| 103 | /* Generic info of form tag = "info" */ |
| 104 | #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) |
| 105 | |
| 106 | /* For userspace: you can also call me... */ |
| 107 | #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) |
| 108 | |
| 109 | /* |
| 110 | * The following license idents are currently accepted as indicating free |
| 111 | * software modules |
| 112 | * |
| 113 | * "GPL" [GNU Public License v2 or later] |
| 114 | * "GPL v2" [GNU Public License v2] |
| 115 | * "GPL and additional rights" [GNU Public License v2 rights and more] |
| 116 | * "Dual BSD/GPL" [GNU Public License v2 |
| 117 | * or BSD license choice] |
Xose Vazquez Perez | 8d27e90 | 2006-06-23 02:05:13 -0700 | [diff] [blame] | 118 | * "Dual MIT/GPL" [GNU Public License v2 |
| 119 | * or MIT license choice] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | * "Dual MPL/GPL" [GNU Public License v2 |
| 121 | * or Mozilla license choice] |
| 122 | * |
| 123 | * The following other idents are available |
| 124 | * |
| 125 | * "Proprietary" [Non free products] |
| 126 | * |
| 127 | * There are dual licensed components, but when running with Linux it is the |
| 128 | * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL |
| 129 | * is a GPL combined work. |
| 130 | * |
| 131 | * This exists for several reasons |
| 132 | * 1. So modinfo can show license info for users wanting to vet their setup |
| 133 | * is free |
| 134 | * 2. So the community can ignore bug reports including proprietary modules |
| 135 | * 3. So vendors can do likewise based on their own policies |
| 136 | */ |
| 137 | #define MODULE_LICENSE(_license) MODULE_INFO(license, _license) |
| 138 | |
Johannes Berg | 1d7015c | 2009-09-25 00:32:58 -0600 | [diff] [blame] | 139 | /* |
| 140 | * Author(s), use "Name <email>" or just "Name", for multiple |
| 141 | * authors use multiple MODULE_AUTHOR() statements/lines. |
| 142 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) |
| 144 | |
| 145 | /* What your module does. */ |
| 146 | #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) |
| 147 | |
| 148 | /* One for each parameter, describing how to use it. Some files do |
| 149 | multiple of these per line, so can't just use MODULE_INFO. */ |
| 150 | #define MODULE_PARM_DESC(_parm, desc) \ |
| 151 | __MODULE_INFO(parm, _parm, #_parm ":" desc) |
| 152 | |
| 153 | #define MODULE_DEVICE_TABLE(type,name) \ |
| 154 | MODULE_GENERIC_TABLE(type##_device,name) |
| 155 | |
| 156 | /* Version of form [<epoch>:]<version>[-<extra-version>]. |
| 157 | Or for CVS/RCS ID version, everything but the number is stripped. |
| 158 | <epoch>: A (small) unsigned integer which allows you to start versions |
| 159 | anew. If not mentioned, it's zero. eg. "2:1.0" is after |
| 160 | "1:2.0". |
| 161 | <version>: The <version> may contain only alphanumerics and the |
| 162 | character `.'. Ordered by numeric sort for numeric parts, |
| 163 | ascii sort for ascii parts (as per RPM or DEB algorithm). |
| 164 | <extraversion>: Like <version>, but inserted for local |
| 165 | customizations, eg "rh3" or "rusty1". |
| 166 | |
| 167 | Using this automatically adds a checksum of the .c files and the |
| 168 | local headers in "srcversion". |
| 169 | */ |
Dmitry Torokhov | e94965e | 2010-12-15 14:00:19 -0800 | [diff] [blame] | 170 | |
Rusty Russell | 3b90a5b | 2011-01-24 14:32:51 -0600 | [diff] [blame] | 171 | #if defined(MODULE) || !defined(CONFIG_SYSFS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) |
Dmitry Torokhov | e94965e | 2010-12-15 14:00:19 -0800 | [diff] [blame] | 173 | #else |
| 174 | #define MODULE_VERSION(_version) \ |
| 175 | extern ssize_t __modver_version_show(struct module_attribute *, \ |
| 176 | struct module *, char *); \ |
| 177 | static struct module_version_attribute __modver_version_attr \ |
| 178 | __used \ |
| 179 | __attribute__ ((__section__ ("__modver"),aligned(sizeof(void *)))) \ |
| 180 | = { \ |
| 181 | .mattr = { \ |
| 182 | .attr = { \ |
| 183 | .name = "version", \ |
| 184 | .mode = S_IRUGO, \ |
| 185 | }, \ |
| 186 | .show = __modver_version_show, \ |
| 187 | }, \ |
| 188 | .module_name = KBUILD_MODNAME, \ |
| 189 | .version = _version, \ |
| 190 | } |
| 191 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Jon Masters | 187afbe | 2006-08-28 17:08:21 -0500 | [diff] [blame] | 193 | /* Optional firmware file (or files) needed by the module |
| 194 | * format is simply firmware file name. Multiple firmware |
| 195 | * files require multiple MODULE_FIRMWARE() specifiers */ |
| 196 | #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware) |
| 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | /* Given an address, look for it in the exception tables */ |
| 199 | const struct exception_table_entry *search_exception_tables(unsigned long add); |
| 200 | |
| 201 | struct notifier_block; |
| 202 | |
| 203 | #ifdef CONFIG_MODULES |
| 204 | |
Dave Young | 5ed1091 | 2010-03-10 15:24:06 -0800 | [diff] [blame] | 205 | extern int modules_disabled; /* for sysctl */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | /* Get/put a kernel symbol (calls must be symmetric) */ |
| 207 | void *__symbol_get(const char *symbol); |
| 208 | void *__symbol_get_gpl(const char *symbol); |
| 209 | #define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x))) |
| 210 | |
Rusty Russell | c8e21ce | 2010-06-05 11:17:35 -0600 | [diff] [blame] | 211 | /* modules using other modules: kdb wants to see this. */ |
| 212 | struct module_use { |
| 213 | struct list_head source_list; |
| 214 | struct list_head target_list; |
| 215 | struct module *source, *target; |
| 216 | }; |
| 217 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | #ifndef __GENKSYMS__ |
| 219 | #ifdef CONFIG_MODVERSIONS |
| 220 | /* Mark the CRC weak since genksyms apparently decides not to |
| 221 | * generate a checksums for some symbols */ |
| 222 | #define __CRC_SYMBOL(sym, sec) \ |
| 223 | extern void *__crc_##sym __attribute__((weak)); \ |
| 224 | static const unsigned long __kcrctab_##sym \ |
Adrian Bunk | 3ff6eec | 2008-01-24 22:16:20 +0100 | [diff] [blame] | 225 | __used \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | __attribute__((section("__kcrctab" sec), unused)) \ |
| 227 | = (unsigned long) &__crc_##sym; |
| 228 | #else |
| 229 | #define __CRC_SYMBOL(sym, sec) |
| 230 | #endif |
| 231 | |
| 232 | /* For every exported symbol, place a struct in the __ksymtab section */ |
| 233 | #define __EXPORT_SYMBOL(sym, sec) \ |
Patrick McHardy | a1a8fee | 2006-03-23 22:07:34 -0800 | [diff] [blame] | 234 | extern typeof(sym) sym; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | __CRC_SYMBOL(sym, sec) \ |
| 236 | static const char __kstrtab_##sym[] \ |
Rusty Russell | ea01e79 | 2008-03-13 09:02:17 +0000 | [diff] [blame] | 237 | __attribute__((section("__ksymtab_strings"), aligned(1))) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | = MODULE_SYMBOL_PREFIX #sym; \ |
| 239 | static const struct kernel_symbol __ksymtab_##sym \ |
Adrian Bunk | 3ff6eec | 2008-01-24 22:16:20 +0100 | [diff] [blame] | 240 | __used \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | __attribute__((section("__ksymtab" sec), unused)) \ |
| 242 | = { (unsigned long)&sym, __kstrtab_##sym } |
| 243 | |
| 244 | #define EXPORT_SYMBOL(sym) \ |
| 245 | __EXPORT_SYMBOL(sym, "") |
| 246 | |
| 247 | #define EXPORT_SYMBOL_GPL(sym) \ |
| 248 | __EXPORT_SYMBOL(sym, "_gpl") |
| 249 | |
Greg Kroah-Hartman | 9f28bb7 | 2006-03-20 13:17:13 -0800 | [diff] [blame] | 250 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) \ |
| 251 | __EXPORT_SYMBOL(sym, "_gpl_future") |
| 252 | |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 253 | |
| 254 | #ifdef CONFIG_UNUSED_SYMBOLS |
| 255 | #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") |
| 256 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") |
| 257 | #else |
| 258 | #define EXPORT_UNUSED_SYMBOL(sym) |
| 259 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) |
| 260 | #endif |
| 261 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | #endif |
| 263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | enum module_state |
| 265 | { |
| 266 | MODULE_STATE_LIVE, |
| 267 | MODULE_STATE_COMING, |
| 268 | MODULE_STATE_GOING, |
| 269 | }; |
| 270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | struct module |
| 272 | { |
| 273 | enum module_state state; |
| 274 | |
| 275 | /* Member of list of modules */ |
| 276 | struct list_head list; |
| 277 | |
| 278 | /* Unique handle for this module */ |
| 279 | char name[MODULE_NAME_LEN]; |
| 280 | |
| 281 | /* Sysfs stuff. */ |
| 282 | struct module_kobject mkobj; |
Greg Kroah-Hartman | 03e88ae | 2006-02-16 13:50:23 -0800 | [diff] [blame] | 283 | struct module_attribute *modinfo_attrs; |
Matt Domsch | c988d2b | 2005-06-23 22:05:15 -0700 | [diff] [blame] | 284 | const char *version; |
| 285 | const char *srcversion; |
Kay Sievers | 270a6c4 | 2007-01-18 13:26:15 +0100 | [diff] [blame] | 286 | struct kobject *holders_dir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
| 288 | /* Exported symbols */ |
| 289 | const struct kernel_symbol *syms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | const unsigned long *crcs; |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 291 | unsigned int num_syms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
Rusty Russell | e180a6b | 2009-03-31 13:05:29 -0600 | [diff] [blame] | 293 | /* Kernel parameters. */ |
| 294 | struct kernel_param *kp; |
| 295 | unsigned int num_kp; |
| 296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | /* GPL-only exported symbols. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | unsigned int num_gpl_syms; |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 299 | const struct kernel_symbol *gpl_syms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | const unsigned long *gpl_crcs; |
| 301 | |
Denys Vlasenko | f7f5b67 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 302 | #ifdef CONFIG_UNUSED_SYMBOLS |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 303 | /* unused exported symbols. */ |
| 304 | const struct kernel_symbol *unused_syms; |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 305 | const unsigned long *unused_crcs; |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 306 | unsigned int num_unused_syms; |
| 307 | |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 308 | /* GPL-only, unused exported symbols. */ |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 309 | unsigned int num_unused_gpl_syms; |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 310 | const struct kernel_symbol *unused_gpl_syms; |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 311 | const unsigned long *unused_gpl_crcs; |
Denys Vlasenko | f7f5b67 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 312 | #endif |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 313 | |
Greg Kroah-Hartman | 9f28bb7 | 2006-03-20 13:17:13 -0800 | [diff] [blame] | 314 | /* symbols that will be GPL-only in the near future. */ |
| 315 | const struct kernel_symbol *gpl_future_syms; |
Greg Kroah-Hartman | 9f28bb7 | 2006-03-20 13:17:13 -0800 | [diff] [blame] | 316 | const unsigned long *gpl_future_crcs; |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 317 | unsigned int num_gpl_future_syms; |
Greg Kroah-Hartman | 9f28bb7 | 2006-03-20 13:17:13 -0800 | [diff] [blame] | 318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | /* Exception table */ |
| 320 | unsigned int num_exentries; |
Rusty Russell | 5e458cc | 2008-10-22 10:00:13 -0500 | [diff] [blame] | 321 | struct exception_table_entry *extable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
| 323 | /* Startup function. */ |
| 324 | int (*init)(void); |
| 325 | |
| 326 | /* If this is non-NULL, vfree after init() returns */ |
| 327 | void *module_init; |
| 328 | |
| 329 | /* Here is the actual code + data, vfree'd on unload. */ |
| 330 | void *module_core; |
| 331 | |
| 332 | /* Here are the sizes of the init and core sections */ |
Denys Vlasenko | 2f0f2a3 | 2008-07-22 19:24:27 -0500 | [diff] [blame] | 333 | unsigned int init_size, core_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
| 335 | /* The size of the executable code in each section. */ |
Denys Vlasenko | 2f0f2a3 | 2008-07-22 19:24:27 -0500 | [diff] [blame] | 336 | unsigned int init_text_size, core_text_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
matthieu castet | 84e1c6b | 2010-11-16 22:35:16 +0100 | [diff] [blame] | 338 | /* Size of RO sections of the module (text+rodata) */ |
| 339 | unsigned int init_ro_size, core_ro_size; |
| 340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | /* Arch-specific module values */ |
| 342 | struct mod_arch_specific arch; |
| 343 | |
Randy Dunlap | 2bc2d61 | 2006-10-02 02:17:02 -0700 | [diff] [blame] | 344 | unsigned int taints; /* same bits as kernel:tainted */ |
| 345 | |
Jeremy Fitzhardinge | 7664c5a | 2006-12-08 02:36:19 -0800 | [diff] [blame] | 346 | #ifdef CONFIG_GENERIC_BUG |
| 347 | /* Support for BUG */ |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 348 | unsigned num_bugs; |
Jeremy Fitzhardinge | 7664c5a | 2006-12-08 02:36:19 -0800 | [diff] [blame] | 349 | struct list_head bug_list; |
| 350 | struct bug_entry *bug_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | #endif |
| 352 | |
| 353 | #ifdef CONFIG_KALLSYMS |
Jan Beulich | 4a49622 | 2009-07-06 14:50:42 +0100 | [diff] [blame] | 354 | /* |
| 355 | * We keep the symbol and string tables for kallsyms. |
| 356 | * The core_* fields below are temporary, loader-only (they |
| 357 | * could really be discarded after module init). |
| 358 | */ |
| 359 | Elf_Sym *symtab, *core_symtab; |
| 360 | unsigned int num_symtab, core_num_syms; |
Jan Beulich | 554bdfe | 2009-07-06 14:51:44 +0100 | [diff] [blame] | 361 | char *strtab, *core_strtab; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
| 363 | /* Section attributes */ |
| 364 | struct module_sect_attrs *sect_attrs; |
Roland McGrath | 6d76013 | 2007-10-16 23:26:40 -0700 | [diff] [blame] | 365 | |
| 366 | /* Notes attributes */ |
| 367 | struct module_notes_attrs *notes_attrs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | #endif |
| 369 | |
Tejun Heo | 259354d | 2010-03-10 18:56:10 +0900 | [diff] [blame] | 370 | #ifdef CONFIG_SMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | /* Per-cpu data. */ |
Tejun Heo | 259354d | 2010-03-10 18:56:10 +0900 | [diff] [blame] | 372 | void __percpu *percpu; |
| 373 | unsigned int percpu_size; |
| 374 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
| 376 | /* The command line arguments (may be mangled). People like |
| 377 | keeping pointers to this stuff */ |
| 378 | char *args; |
Mathieu Desnoyers | 97e1c18 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 379 | #ifdef CONFIG_TRACEPOINTS |
Mathieu Desnoyers | 6549864 | 2011-01-26 17:26:22 -0500 | [diff] [blame] | 380 | struct tracepoint * const *tracepoints_ptrs; |
Mathieu Desnoyers | 97e1c18 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 381 | unsigned int num_tracepoints; |
| 382 | #endif |
Jason Baron | bf5438fc | 2010-09-17 11:09:00 -0400 | [diff] [blame] | 383 | #ifdef HAVE_JUMP_LABEL |
| 384 | struct jump_entry *jump_entries; |
| 385 | unsigned int num_jump_entries; |
| 386 | #endif |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 387 | #ifdef CONFIG_TRACING |
Lai Jiangshan | 1ba28e0 | 2009-03-06 17:21:48 +0100 | [diff] [blame] | 388 | const char **trace_bprintk_fmt_start; |
| 389 | unsigned int num_trace_bprintk_fmt; |
| 390 | #endif |
Steven Rostedt | 6d72373 | 2009-04-10 14:53:50 -0400 | [diff] [blame] | 391 | #ifdef CONFIG_EVENT_TRACING |
Steven Rostedt | e4a9ea5 | 2011-01-27 09:15:30 -0500 | [diff] [blame] | 392 | struct ftrace_event_call **trace_events; |
Steven Rostedt | 6d72373 | 2009-04-10 14:53:50 -0400 | [diff] [blame] | 393 | unsigned int num_trace_events; |
| 394 | #endif |
Steven Rostedt | 93eb677 | 2009-04-15 13:24:06 -0400 | [diff] [blame] | 395 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 396 | unsigned long *ftrace_callsites; |
| 397 | unsigned int num_ftrace_callsites; |
| 398 | #endif |
Lai Jiangshan | 1ba28e0 | 2009-03-06 17:21:48 +0100 | [diff] [blame] | 399 | |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 400 | #ifdef CONFIG_MODULE_UNLOAD |
| 401 | /* What modules depend on me? */ |
Linus Torvalds | 2c02dfe | 2010-05-31 12:19:37 -0700 | [diff] [blame] | 402 | struct list_head source_list; |
| 403 | /* What modules do I depend on? */ |
| 404 | struct list_head target_list; |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 405 | |
| 406 | /* Who is waiting for us to be unloaded */ |
| 407 | struct task_struct *waiter; |
| 408 | |
| 409 | /* Destruction function. */ |
| 410 | void (*exit)(void); |
| 411 | |
Christoph Lameter | e1783a2 | 2010-01-05 15:34:50 +0900 | [diff] [blame] | 412 | struct module_ref { |
Nick Piggin | 5fbfb18 | 2010-04-01 19:09:40 +1100 | [diff] [blame] | 413 | unsigned int incs; |
| 414 | unsigned int decs; |
Tejun Heo | 43cf38e | 2010-02-02 14:38:57 +0900 | [diff] [blame] | 415 | } __percpu *refptr; |
Richard Kennedy | af54068 | 2008-07-22 19:24:26 -0500 | [diff] [blame] | 416 | #endif |
Peter Oberparleiter | b99b87f | 2009-06-17 16:28:03 -0700 | [diff] [blame] | 417 | |
| 418 | #ifdef CONFIG_CONSTRUCTORS |
| 419 | /* Constructor functions. */ |
| 420 | ctor_fn_t *ctors; |
| 421 | unsigned int num_ctors; |
| 422 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | }; |
Roman Zippel | e61a1c1 | 2007-05-09 02:35:15 -0700 | [diff] [blame] | 424 | #ifndef MODULE_ARCH_INIT |
| 425 | #define MODULE_ARCH_INIT {} |
| 426 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | |
Tim Abbott | c6b3780 | 2008-12-05 19:03:59 -0500 | [diff] [blame] | 428 | extern struct mutex module_mutex; |
| 429 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | /* FIXME: It'd be nice to isolate modules during init, too, so they |
| 431 | aren't used before they (may) fail. But presently too much code |
| 432 | (IDE & SCSI) require entry into the module during init.*/ |
| 433 | static inline int module_is_live(struct module *mod) |
| 434 | { |
| 435 | return mod->state != MODULE_STATE_GOING; |
| 436 | } |
| 437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | struct module *__module_text_address(unsigned long addr); |
Rusty Russell | e610499 | 2009-03-31 13:05:31 -0600 | [diff] [blame] | 439 | struct module *__module_address(unsigned long addr); |
| 440 | bool is_module_address(unsigned long addr); |
Tejun Heo | 10fad5e | 2010-03-10 18:57:54 +0900 | [diff] [blame] | 441 | bool is_module_percpu_address(unsigned long addr); |
Rusty Russell | e610499 | 2009-03-31 13:05:31 -0600 | [diff] [blame] | 442 | bool is_module_text_address(unsigned long addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | |
Masami Hiramatsu | a06f621 | 2009-01-06 14:41:49 -0800 | [diff] [blame] | 444 | static inline int within_module_core(unsigned long addr, struct module *mod) |
| 445 | { |
| 446 | return (unsigned long)mod->module_core <= addr && |
| 447 | addr < (unsigned long)mod->module_core + mod->core_size; |
| 448 | } |
| 449 | |
| 450 | static inline int within_module_init(unsigned long addr, struct module *mod) |
| 451 | { |
| 452 | return (unsigned long)mod->module_init <= addr && |
| 453 | addr < (unsigned long)mod->module_init + mod->init_size; |
| 454 | } |
| 455 | |
Tim Abbott | c6b3780 | 2008-12-05 19:03:59 -0500 | [diff] [blame] | 456 | /* Search for module by name: must hold module_mutex. */ |
| 457 | struct module *find_module(const char *name); |
| 458 | |
| 459 | struct symsearch { |
| 460 | const struct kernel_symbol *start, *stop; |
| 461 | const unsigned long *crcs; |
| 462 | enum { |
| 463 | NOT_GPL_ONLY, |
| 464 | GPL_ONLY, |
| 465 | WILL_BE_GPL_ONLY, |
| 466 | } licence; |
| 467 | bool unused; |
| 468 | }; |
| 469 | |
| 470 | /* Search for an exported symbol by name. */ |
| 471 | const struct kernel_symbol *find_symbol(const char *name, |
| 472 | struct module **owner, |
| 473 | const unsigned long **crc, |
| 474 | bool gplok, |
| 475 | bool warn); |
| 476 | |
| 477 | /* Walk the exported symbol table */ |
| 478 | bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner, |
| 479 | unsigned int symnum, void *data), void *data); |
| 480 | |
Alexey Dobriyan | ea07890 | 2007-05-08 00:28:39 -0700 | [diff] [blame] | 481 | /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | symnum out of range. */ |
Alexey Dobriyan | ea07890 | 2007-05-08 00:28:39 -0700 | [diff] [blame] | 483 | int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, |
| 484 | char *name, char *module_name, int *exported); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | |
| 486 | /* Look for this name: can be of form module:name. */ |
| 487 | unsigned long module_kallsyms_lookup_name(const char *name); |
| 488 | |
Anders Kaseorg | 75a6661 | 2008-12-05 19:03:58 -0500 | [diff] [blame] | 489 | int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, |
| 490 | struct module *, unsigned long), |
| 491 | void *data); |
| 492 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | extern void __module_put_and_exit(struct module *mod, long code) |
| 494 | __attribute__((noreturn)); |
| 495 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); |
| 496 | |
| 497 | #ifdef CONFIG_MODULE_UNLOAD |
| 498 | unsigned int module_refcount(struct module *mod); |
| 499 | void __symbol_put(const char *symbol); |
| 500 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) |
| 501 | void symbol_put_addr(void *addr); |
| 502 | |
| 503 | /* Sometimes we know we already have a refcount, and it's easier not |
| 504 | to handle the error case (which only happens with rmmod --wait). */ |
| 505 | static inline void __module_get(struct module *module) |
| 506 | { |
| 507 | if (module) { |
Christoph Lameter | e1783a2 | 2010-01-05 15:34:50 +0900 | [diff] [blame] | 508 | preempt_disable(); |
Nick Piggin | 5fbfb18 | 2010-04-01 19:09:40 +1100 | [diff] [blame] | 509 | __this_cpu_inc(module->refptr->incs); |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 510 | trace_module_get(module, _THIS_IP_); |
Christoph Lameter | e1783a2 | 2010-01-05 15:34:50 +0900 | [diff] [blame] | 511 | preempt_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | } |
| 513 | } |
| 514 | |
| 515 | static inline int try_module_get(struct module *module) |
| 516 | { |
| 517 | int ret = 1; |
| 518 | |
| 519 | if (module) { |
Christoph Lameter | e1783a2 | 2010-01-05 15:34:50 +0900 | [diff] [blame] | 520 | preempt_disable(); |
| 521 | |
Li Zefan | 7ead8b8 | 2009-08-17 16:56:28 +0800 | [diff] [blame] | 522 | if (likely(module_is_live(module))) { |
Nick Piggin | 5fbfb18 | 2010-04-01 19:09:40 +1100 | [diff] [blame] | 523 | __this_cpu_inc(module->refptr->incs); |
Li Zefan | ae832d1 | 2010-03-24 10:57:43 +0800 | [diff] [blame] | 524 | trace_module_get(module, _THIS_IP_); |
Nick Piggin | 5fbfb18 | 2010-04-01 19:09:40 +1100 | [diff] [blame] | 525 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | ret = 0; |
Christoph Lameter | e1783a2 | 2010-01-05 15:34:50 +0900 | [diff] [blame] | 527 | |
| 528 | preempt_enable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | } |
| 530 | return ret; |
| 531 | } |
| 532 | |
Al Viro | f6a5703 | 2006-10-18 01:47:25 -0400 | [diff] [blame] | 533 | extern void module_put(struct module *module); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
| 535 | #else /*!CONFIG_MODULE_UNLOAD*/ |
| 536 | static inline int try_module_get(struct module *module) |
| 537 | { |
| 538 | return !module || module_is_live(module); |
| 539 | } |
| 540 | static inline void module_put(struct module *module) |
| 541 | { |
| 542 | } |
| 543 | static inline void __module_get(struct module *module) |
| 544 | { |
| 545 | } |
| 546 | #define symbol_put(x) do { } while(0) |
| 547 | #define symbol_put_addr(p) do { } while(0) |
| 548 | |
| 549 | #endif /* CONFIG_MODULE_UNLOAD */ |
Anders Kaseorg | dfd62d1 | 2010-11-24 15:21:10 -0600 | [diff] [blame] | 550 | int ref_module(struct module *a, struct module *b); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
| 552 | /* This is a #define so the string doesn't get put in every .o file */ |
| 553 | #define module_name(mod) \ |
| 554 | ({ \ |
| 555 | struct module *__mod = (mod); \ |
| 556 | __mod ? __mod->name : "kernel"; \ |
| 557 | }) |
| 558 | |
Rusty Russell | 6dd06c9 | 2008-01-29 17:13:22 -0500 | [diff] [blame] | 559 | /* For kallsyms to ask for address resolution. namebuf should be at |
| 560 | * least KSYM_NAME_LEN long: a pointer to namebuf is returned if |
| 561 | * found, otherwise NULL. */ |
Andrew Morton | 92dfc9d | 2008-02-08 04:18:43 -0800 | [diff] [blame] | 562 | const char *module_address_lookup(unsigned long addr, |
Rusty Russell | 6dd06c9 | 2008-01-29 17:13:22 -0500 | [diff] [blame] | 563 | unsigned long *symbolsize, |
| 564 | unsigned long *offset, |
| 565 | char **modname, |
| 566 | char *namebuf); |
Alexey Dobriyan | 9d65cb4 | 2007-05-08 00:28:43 -0700 | [diff] [blame] | 567 | int lookup_module_symbol_name(unsigned long addr, char *symname); |
Alexey Dobriyan | a5c43da | 2007-05-08 00:28:47 -0700 | [diff] [blame] | 568 | int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | |
| 570 | /* For extable.c to search modules' exception tables. */ |
| 571 | const struct exception_table_entry *search_module_extables(unsigned long addr); |
| 572 | |
| 573 | int register_module_notifier(struct notifier_block * nb); |
| 574 | int unregister_module_notifier(struct notifier_block * nb); |
| 575 | |
| 576 | extern void print_modules(void); |
| 577 | |
Mathieu Desnoyers | 97e1c18 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 578 | extern void module_update_tracepoints(void); |
| 579 | extern int module_get_iter_tracepoints(struct tracepoint_iter *iter); |
| 580 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | #else /* !CONFIG_MODULES... */ |
| 582 | #define EXPORT_SYMBOL(sym) |
| 583 | #define EXPORT_SYMBOL_GPL(sym) |
Greg Kroah-Hartman | 9f28bb7 | 2006-03-20 13:17:13 -0800 | [diff] [blame] | 584 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) |
Arjan van de Ven | f71d20e | 2006-06-28 04:26:45 -0700 | [diff] [blame] | 585 | #define EXPORT_UNUSED_SYMBOL(sym) |
| 586 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
| 588 | /* Given an address, look for it in the exception tables. */ |
| 589 | static inline const struct exception_table_entry * |
| 590 | search_module_extables(unsigned long addr) |
| 591 | { |
| 592 | return NULL; |
| 593 | } |
| 594 | |
Rusty Russell | e610499 | 2009-03-31 13:05:31 -0600 | [diff] [blame] | 595 | static inline struct module *__module_address(unsigned long addr) |
| 596 | { |
| 597 | return NULL; |
| 598 | } |
| 599 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | static inline struct module *__module_text_address(unsigned long addr) |
| 601 | { |
| 602 | return NULL; |
| 603 | } |
| 604 | |
Rusty Russell | e610499 | 2009-03-31 13:05:31 -0600 | [diff] [blame] | 605 | static inline bool is_module_address(unsigned long addr) |
Ingo Molnar | 4d435f9 | 2006-07-03 00:24:24 -0700 | [diff] [blame] | 606 | { |
Rusty Russell | e610499 | 2009-03-31 13:05:31 -0600 | [diff] [blame] | 607 | return false; |
| 608 | } |
| 609 | |
Randy Dunlap | d5e50da | 2010-03-31 11:33:42 +0900 | [diff] [blame] | 610 | static inline bool is_module_percpu_address(unsigned long addr) |
| 611 | { |
| 612 | return false; |
| 613 | } |
| 614 | |
Rusty Russell | e610499 | 2009-03-31 13:05:31 -0600 | [diff] [blame] | 615 | static inline bool is_module_text_address(unsigned long addr) |
| 616 | { |
| 617 | return false; |
Ingo Molnar | 4d435f9 | 2006-07-03 00:24:24 -0700 | [diff] [blame] | 618 | } |
| 619 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | /* Get/put a kernel symbol (calls should be symmetric) */ |
| 621 | #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); }) |
| 622 | #define symbol_put(x) do { } while(0) |
| 623 | #define symbol_put_addr(x) do { } while(0) |
| 624 | |
| 625 | static inline void __module_get(struct module *module) |
| 626 | { |
| 627 | } |
| 628 | |
| 629 | static inline int try_module_get(struct module *module) |
| 630 | { |
| 631 | return 1; |
| 632 | } |
| 633 | |
| 634 | static inline void module_put(struct module *module) |
| 635 | { |
| 636 | } |
| 637 | |
| 638 | #define module_name(mod) "kernel" |
| 639 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | /* For kallsyms to ask for address resolution. NULL means not found. */ |
Andrew Morton | 92dfc9d | 2008-02-08 04:18:43 -0800 | [diff] [blame] | 641 | static inline const char *module_address_lookup(unsigned long addr, |
Rusty Russell | 6dd06c9 | 2008-01-29 17:13:22 -0500 | [diff] [blame] | 642 | unsigned long *symbolsize, |
| 643 | unsigned long *offset, |
| 644 | char **modname, |
| 645 | char *namebuf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | { |
| 647 | return NULL; |
| 648 | } |
| 649 | |
Alexey Dobriyan | 9d65cb4 | 2007-05-08 00:28:43 -0700 | [diff] [blame] | 650 | static inline int lookup_module_symbol_name(unsigned long addr, char *symname) |
| 651 | { |
| 652 | return -ERANGE; |
| 653 | } |
| 654 | |
Alexey Dobriyan | a5c43da | 2007-05-08 00:28:47 -0700 | [diff] [blame] | 655 | static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name) |
| 656 | { |
| 657 | return -ERANGE; |
| 658 | } |
| 659 | |
Alexey Dobriyan | ea07890 | 2007-05-08 00:28:39 -0700 | [diff] [blame] | 660 | static inline int module_get_kallsym(unsigned int symnum, unsigned long *value, |
| 661 | char *type, char *name, |
| 662 | char *module_name, int *exported) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | { |
Alexey Dobriyan | ea07890 | 2007-05-08 00:28:39 -0700 | [diff] [blame] | 664 | return -ERANGE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | static inline unsigned long module_kallsyms_lookup_name(const char *name) |
| 668 | { |
| 669 | return 0; |
| 670 | } |
| 671 | |
Anders Kaseorg | 75a6661 | 2008-12-05 19:03:58 -0500 | [diff] [blame] | 672 | static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, |
| 673 | struct module *, |
| 674 | unsigned long), |
| 675 | void *data) |
| 676 | { |
| 677 | return 0; |
| 678 | } |
| 679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | static inline int register_module_notifier(struct notifier_block * nb) |
| 681 | { |
| 682 | /* no events will happen anyway, so this can always succeed */ |
| 683 | return 0; |
| 684 | } |
| 685 | |
| 686 | static inline int unregister_module_notifier(struct notifier_block * nb) |
| 687 | { |
| 688 | return 0; |
| 689 | } |
| 690 | |
| 691 | #define module_put_and_exit(code) do_exit(code) |
| 692 | |
| 693 | static inline void print_modules(void) |
| 694 | { |
| 695 | } |
| 696 | |
Mathieu Desnoyers | 97e1c18 | 2008-07-18 12:16:16 -0400 | [diff] [blame] | 697 | static inline void module_update_tracepoints(void) |
| 698 | { |
| 699 | } |
| 700 | |
| 701 | static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter) |
| 702 | { |
| 703 | return 0; |
| 704 | } |
Randy Dunlap | ef665c1 | 2007-02-13 15:19:06 -0800 | [diff] [blame] | 705 | #endif /* CONFIG_MODULES */ |
| 706 | |
Randy Dunlap | ef665c1 | 2007-02-13 15:19:06 -0800 | [diff] [blame] | 707 | #ifdef CONFIG_SYSFS |
Greg Kroah-Hartman | 7405c1e | 2007-11-01 10:39:50 -0700 | [diff] [blame] | 708 | extern struct kset *module_kset; |
| 709 | extern struct kobj_type module_ktype; |
| 710 | extern int module_sysfs_initialized; |
Randy Dunlap | ef665c1 | 2007-02-13 15:19:06 -0800 | [diff] [blame] | 711 | #endif /* CONFIG_SYSFS */ |
| 712 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) |
| 714 | |
| 715 | /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ |
| 716 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | #define __MODULE_STRING(x) __stringify(x) |
| 718 | |
matthieu castet | 84e1c6b | 2010-11-16 22:35:16 +0100 | [diff] [blame] | 719 | #ifdef CONFIG_DEBUG_SET_MODULE_RONX |
| 720 | extern void set_all_modules_text_rw(void); |
| 721 | extern void set_all_modules_text_ro(void); |
| 722 | #else |
| 723 | static inline void set_all_modules_text_rw(void) { } |
| 724 | static inline void set_all_modules_text_ro(void) { } |
| 725 | #endif |
Andrew Morton | 0d9c25d | 2009-06-16 15:33:37 -0700 | [diff] [blame] | 726 | |
| 727 | #ifdef CONFIG_GENERIC_BUG |
Linus Torvalds | 5336377 | 2010-10-05 11:29:27 -0700 | [diff] [blame] | 728 | void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *, |
Andrew Morton | 0d9c25d | 2009-06-16 15:33:37 -0700 | [diff] [blame] | 729 | struct module *); |
| 730 | void module_bug_cleanup(struct module *); |
| 731 | |
| 732 | #else /* !CONFIG_GENERIC_BUG */ |
| 733 | |
Linus Torvalds | 5336377 | 2010-10-05 11:29:27 -0700 | [diff] [blame] | 734 | static inline void module_bug_finalize(const Elf_Ehdr *hdr, |
Andrew Morton | 0d9c25d | 2009-06-16 15:33:37 -0700 | [diff] [blame] | 735 | const Elf_Shdr *sechdrs, |
| 736 | struct module *mod) |
| 737 | { |
Andrew Morton | 0d9c25d | 2009-06-16 15:33:37 -0700 | [diff] [blame] | 738 | } |
| 739 | static inline void module_bug_cleanup(struct module *mod) {} |
| 740 | #endif /* CONFIG_GENERIC_BUG */ |
| 741 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | #endif /* _LINUX_MODULE_H */ |