Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] lockdep: add is_module_address()

Add is_module_address() method - to be used by lockdep.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Ingo Molnar and committed by
Linus Torvalds
4d435f9d 93e02814

+29
+6
include/linux/module.h
··· 358 358 /* Is this address in a module? (second is with no locks, for oops) */ 359 359 struct module *module_text_address(unsigned long addr); 360 360 struct module *__module_text_address(unsigned long addr); 361 + int is_module_address(unsigned long addr); 361 362 362 363 /* Returns module and fills in value, defined and namebuf, or NULL if 363 364 symnum out of range. */ ··· 495 494 static inline struct module *__module_text_address(unsigned long addr) 496 495 { 497 496 return NULL; 497 + } 498 + 499 + static inline int is_module_address(unsigned long addr) 500 + { 501 + return 0; 498 502 } 499 503 500 504 /* Get/put a kernel symbol (calls should be symmetric) */
+23
kernel/module.c
··· 2159 2159 return e; 2160 2160 } 2161 2161 2162 + /* 2163 + * Is this a valid module address? 2164 + */ 2165 + int is_module_address(unsigned long addr) 2166 + { 2167 + unsigned long flags; 2168 + struct module *mod; 2169 + 2170 + spin_lock_irqsave(&modlist_lock, flags); 2171 + 2172 + list_for_each_entry(mod, &modules, list) { 2173 + if (within(addr, mod->module_core, mod->core_size)) { 2174 + spin_unlock_irqrestore(&modlist_lock, flags); 2175 + return 1; 2176 + } 2177 + } 2178 + 2179 + spin_unlock_irqrestore(&modlist_lock, flags); 2180 + 2181 + return 0; 2182 + } 2183 + 2184 + 2162 2185 /* Is this a valid kernel address? We don't grab the lock: we are oopsing. */ 2163 2186 struct module *__module_text_address(unsigned long addr) 2164 2187 {