X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=kernel%2Fextable.c;h=7f8f263f85249a15ca8492fa5056c868262aa0f1;hb=af901ca181d92aac3a7dc265144a9081a86d8f39;hp=7fe2628553172eadc0d49a3cbaf9d779b80b5a7c;hpb=5e376613899076396d0c97de67ad072587267370;p=safe%2Fjmp%2Flinux-2.6 diff --git a/kernel/extable.c b/kernel/extable.c index 7fe2628..7f8f263 100644 --- a/kernel/extable.c +++ b/kernel/extable.c @@ -15,10 +15,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include #include +#include #include -#include + #include +#include + +/* + * mutex protecting text section modification (dynamic code patching). + * some users need to sleep (allocating memory...) while they hold this lock. + * + * NOT exported to modules - patching kernel text is a really delicate matter. + */ +DEFINE_MUTEX(text_mutex); extern struct exception_table_entry __start___ex_table[]; extern struct exception_table_entry __stop___ex_table[]; @@ -40,14 +52,22 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr) return e; } +static inline int init_kernel_text(unsigned long addr) +{ + if (addr >= (unsigned long)_sinittext && + addr <= (unsigned long)_einittext) + return 1; + return 0; +} + int core_kernel_text(unsigned long addr) { if (addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) return 1; - if (addr >= (unsigned long)_sinittext && - addr <= (unsigned long)_einittext) + if (system_state == SYSTEM_BOOTING && + init_kernel_text(addr)) return 1; return 0; } @@ -56,12 +76,40 @@ int __kernel_text_address(unsigned long addr) { if (core_kernel_text(addr)) return 1; - return __module_text_address(addr) != NULL; + if (is_module_text_address(addr)) + return 1; + /* + * There might be init symbols in saved stacktraces. + * Give those symbols a chance to be printed in + * backtraces (such as lockdep traces). + * + * Since we are after the module-symbols check, there's + * no danger of address overlap: + */ + if (init_kernel_text(addr)) + return 1; + return 0; } int kernel_text_address(unsigned long addr) { if (core_kernel_text(addr)) return 1; - return module_text_address(addr) != NULL; + return is_module_text_address(addr); +} + +/* + * On some architectures (PPC64, IA64) function pointers + * are actually only tokens to some data that then holds the + * real function address. As a result, to find if a function + * pointer is part of the kernel text, we need to do some + * special dereferencing first. + */ +int func_ptr_is_kernel_text(void *ptr) +{ + unsigned long addr; + addr = (unsigned long) dereference_function_descriptor(ptr); + if (core_kernel_text(addr)) + return 1; + return is_module_text_address(addr); }