aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/extable.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/extable.c')
-rw-r--r--kernel/extable.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/kernel/extable.c b/kernel/extable.c
index e136ed8d82ba..7f8f263f8524 100644
--- a/kernel/extable.c
+++ b/kernel/extable.c
@@ -15,11 +15,22 @@
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18#include <linux/ftrace.h>
19#include <linux/memory.h>
18#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/mutex.h>
19#include <linux/init.h> 22#include <linux/init.h>
20#include <linux/ftrace.h> 23
21#include <asm/uaccess.h>
22#include <asm/sections.h> 24#include <asm/sections.h>
25#include <asm/uaccess.h>
26
27/*
28 * mutex protecting text section modification (dynamic code patching).
29 * some users need to sleep (allocating memory...) while they hold this lock.
30 *
31 * NOT exported to modules - patching kernel text is a really delicate matter.
32 */
33DEFINE_MUTEX(text_mutex);
23 34
24extern struct exception_table_entry __start___ex_table[]; 35extern struct exception_table_entry __start___ex_table[];
25extern struct exception_table_entry __stop___ex_table[]; 36extern struct exception_table_entry __stop___ex_table[];
@@ -41,31 +52,50 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr)
41 return e; 52 return e;
42} 53}
43 54
44__notrace_funcgraph int core_kernel_text(unsigned long addr) 55static inline int init_kernel_text(unsigned long addr)
56{
57 if (addr >= (unsigned long)_sinittext &&
58 addr <= (unsigned long)_einittext)
59 return 1;
60 return 0;
61}
62
63int core_kernel_text(unsigned long addr)
45{ 64{
46 if (addr >= (unsigned long)_stext && 65 if (addr >= (unsigned long)_stext &&
47 addr <= (unsigned long)_etext) 66 addr <= (unsigned long)_etext)
48 return 1; 67 return 1;
49 68
50 if (system_state == SYSTEM_BOOTING && 69 if (system_state == SYSTEM_BOOTING &&
51 addr >= (unsigned long)_sinittext && 70 init_kernel_text(addr))
52 addr <= (unsigned long)_einittext)
53 return 1; 71 return 1;
54 return 0; 72 return 0;
55} 73}
56 74
57__notrace_funcgraph int __kernel_text_address(unsigned long addr) 75int __kernel_text_address(unsigned long addr)
58{ 76{
59 if (core_kernel_text(addr)) 77 if (core_kernel_text(addr))
60 return 1; 78 return 1;
61 return __module_text_address(addr) != NULL; 79 if (is_module_text_address(addr))
80 return 1;
81 /*
82 * There might be init symbols in saved stacktraces.
83 * Give those symbols a chance to be printed in
84 * backtraces (such as lockdep traces).
85 *
86 * Since we are after the module-symbols check, there's
87 * no danger of address overlap:
88 */
89 if (init_kernel_text(addr))
90 return 1;
91 return 0;
62} 92}
63 93
64int kernel_text_address(unsigned long addr) 94int kernel_text_address(unsigned long addr)
65{ 95{
66 if (core_kernel_text(addr)) 96 if (core_kernel_text(addr))
67 return 1; 97 return 1;
68 return module_text_address(addr) != NULL; 98 return is_module_text_address(addr);
69} 99}
70 100
71/* 101/*
@@ -81,5 +111,5 @@ int func_ptr_is_kernel_text(void *ptr)
81 addr = (unsigned long) dereference_function_descriptor(ptr); 111 addr = (unsigned long) dereference_function_descriptor(ptr);
82 if (core_kernel_text(addr)) 112 if (core_kernel_text(addr))
83 return 1; 113 return 1;
84 return module_text_address(addr) != NULL; 114 return is_module_text_address(addr);
85} 115}