diff options
Diffstat (limited to 'include/linux/module.h')
| -rw-r--r-- | include/linux/module.h | 99 |
1 files changed, 82 insertions, 17 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index 8e1954a89913..54214da9a651 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -21,7 +21,6 @@ #include <asm/uaccess.h> /* For struct exception_table_entry */ /* Not Yet Implemented */ -#define MODULE_LICENSE(name) #define MODULE_AUTHOR(name) #define MODULE_DESCRIPTION(desc) #define MODULE_SUPPORTED_DEVICE(name) @@ -44,6 +43,12 @@ struct kernel_symbol extern int init_module(void); extern void cleanup_module(void); +/* Archs provide a method of finding the correct exception table. */ +const struct exception_table_entry * +search_extable(const struct exception_table_entry *first, + const struct exception_table_entry *last, + unsigned long value); + #ifdef MODULE /* For replacement modutils, use an alias not a pointer. */ @@ -57,11 +62,41 @@ extern const struct gtype##_id __mod_##gtype##_table \ #define THIS_MODULE (&__this_module) +/* + * The following license idents are currently accepted as indicating free + * software modules + * + * "GPL" [GNU Public License v2 or later] + * "GPL v2" [GNU Public License v2] + * "GPL and additional rights" [GNU Public License v2 rights and more] + * "Dual BSD/GPL" [GNU Public License v2 + * or BSD license choice] + * "Dual MPL/GPL" [GNU Public License v2 + * or Mozilla license choice] + * + * The following other idents are available + * + * "Proprietary" [Non free products] + * + * There are dual licensed components, but when running with Linux it is the + * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL + * is a GPL combined work. + * + * This exists for several reasons + * 1. So modinfo can show license info for users wanting to vet their setup + * is free + * 2. So the community can ignore bug reports including proprietary modules + * 3. So vendors can do likewise based on their own policies + */ +#define MODULE_LICENSE(license) \ + static const char __module_license[] \ + __attribute__((section(".init.license"))) = license + #else /* !MODULE */ #define MODULE_GENERIC_TABLE(gtype,name) #define THIS_MODULE ((struct module *)0) - +#define MODULE_LICENSE(license) #endif #define MODULE_DEVICE_TABLE(type,name) \ @@ -75,10 +110,16 @@ struct kernel_symbol_group /* Module which owns it (if any) */ struct module *owner; + /* Are we internal use only? */ + int gplonly; + unsigned int num_syms; const struct kernel_symbol *syms; }; +/* Given an address, look for it in the exception tables */ +const struct exception_table_entry *search_exception_tables(unsigned long add); + struct exception_table { struct list_head list; @@ -101,7 +142,11 @@ void *__symbol_get_gpl(const char *symbol); = { (unsigned long)&sym, MODULE_SYMBOL_PREFIX #sym } #define EXPORT_SYMBOL_NOVERS(sym) EXPORT_SYMBOL(sym) -#define EXPORT_SYMBOL_GPL(sym) EXPORT_SYMBOL(sym) + +#define EXPORT_SYMBOL_GPL(sym) \ + const struct kernel_symbol __ksymtab_##sym \ + __attribute__((section("__gpl_ksymtab"))) \ + = { (unsigned long)&sym, #sym } struct module_ref { @@ -128,6 +173,9 @@ struct module /* Exported symbols */ struct kernel_symbol_group symbols; + /* GPL-only exported symbols. */ + struct kernel_symbol_group gpl_symbols; + /* Exception tables */ struct exception_table extable; @@ -149,6 +197,9 @@ struct module /* Am I unsafe to unload? */ int unsafe; + /* Am I GPL-compatible */ + int license_gplok; + #ifdef CONFIG_MODULE_UNLOAD /* Reference counts */ struct module_ref ref[NR_CPUS]; @@ -183,6 +234,9 @@ static inline int module_is_live(struct module *mod) return mod->state != MODULE_STATE_GOING; } +/* Is this address in a module? */ +int module_text_address(unsigned long addr); + #ifdef CONFIG_MODULE_UNLOAD void __symbol_put(const char *symbol); @@ -258,18 +312,40 @@ const char *module_address_lookup(unsigned long addr, unsigned long *offset, char **modname); +/* For extable.c to search modules' exception tables. */ +const struct exception_table_entry *search_module_extables(unsigned long addr); + #else /* !CONFIG_MODULES... */ #define EXPORT_SYMBOL(sym) #define EXPORT_SYMBOL_GPL(sym) #define EXPORT_SYMBOL_NOVERS(sym) +/* Given an address, look for it in the exception tables. */ +static inline const struct exception_table_entry * +search_module_extables(unsigned long addr) +{ + return NULL; +} + +/* Is this address in a module? */ +static int module_text_address(unsigned long addr) +{ + return 0; +} + /* Get/put a kernel symbol (calls should be symmetric) */ #define symbol_get(x) (&(x)) #define symbol_put(x) do { } while(0) #define symbol_put_addr(x) do { } while(0) -#define try_module_get(module) 1 -#define module_put(module) do { } while(0) +static inline int try_module_get(struct module *module) +{ + return 1; +} + +static inline void module_put(struct module *module) +{ +} #define module_name(mod) "kernel" @@ -293,6 +369,7 @@ struct module __this_module __attribute__((section(".gnu.linkonce.this_module"))) = { .name = __stringify(KBUILD_MODNAME), .symbols = { .owner = &__this_module }, + .gpl_symbols = { .owner = &__this_module, .gplonly = 1 }, .init = init_module, #ifdef CONFIG_MODULE_UNLOAD .exit = cleanup_module, @@ -301,10 +378,6 @@ __attribute__((section(".gnu.linkonce.this_module"))) = { #endif /* KBUILD_MODNAME */ #endif /* MODULE */ -/* For archs to search exception tables */ -extern struct list_head extables; -extern spinlock_t modlist_lock; - #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ @@ -362,14 +435,6 @@ 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) \ - && (a_start)+(a_len) <= (b_start)+(b_len))) -#define mod_bound(p, n, m) \ -(((m)->module_init \ - && __mod_between((p),(n),(m)->module_init,(m)->init_size)) \ - || __mod_between((p),(n),(m)->module_core,(m)->core_size)) /* * The exception and symbol tables, and the lock |
