aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2014-04-17 04:18:14 -0400
committerIngo Molnar <mingo@kernel.org>2014-04-24 04:26:38 -0400
commit9326638cbee2d36b051ed2a69f3e4e107e5f86bd (patch)
tree995433e24b135a2858765519aec8fe9e889afd68 /arch/x86/mm
parent9c54b6164eeb292a0eac86c6913bd8daaff35e62 (diff)
kprobes, x86: Use NOKPROBE_SYMBOL() instead of __kprobes annotation
Use NOKPROBE_SYMBOL macro for protecting functions from kprobes instead of __kprobes annotation under arch/x86. This applies nokprobe_inline annotation for some cases, because NOKPROBE_SYMBOL() will inhibit inlining by referring the symbol address. This just folds a bunch of previous NOKPROBE_SYMBOL() cleanup patches for x86 to one patch. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Link: http://lkml.kernel.org/r/20140417081814.26341.51656.stgit@ltc230.yrl.intra.hitachi.co.jp Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Borislav Petkov <bp@suse.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Fernando Luis Vázquez Cao <fernando_b1@lab.ntt.co.jp> Cc: Gleb Natapov <gleb@redhat.com> Cc: Jason Wang <jasowang@redhat.com> Cc: Jesper Nilsson <jesper.nilsson@axis.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Jonathan Lebon <jlebon@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Matt Fleming <matt.fleming@intel.com> Cc: Michel Lespinasse <walken@google.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Seiji Aguchi <seiji.aguchi@hds.com> Cc: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com> Cc: Tejun Heo <tj@kernel.org> Cc: Vineet Gupta <vgupta@synopsys.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r--arch/x86/mm/fault.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 8e5722992677..f83bd0de5eef 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -8,7 +8,7 @@
8#include <linux/kdebug.h> /* oops_begin/end, ... */ 8#include <linux/kdebug.h> /* oops_begin/end, ... */
9#include <linux/module.h> /* search_exception_table */ 9#include <linux/module.h> /* search_exception_table */
10#include <linux/bootmem.h> /* max_low_pfn */ 10#include <linux/bootmem.h> /* max_low_pfn */
11#include <linux/kprobes.h> /* __kprobes, ... */ 11#include <linux/kprobes.h> /* NOKPROBE_SYMBOL, ... */
12#include <linux/mmiotrace.h> /* kmmio_handler, ... */ 12#include <linux/mmiotrace.h> /* kmmio_handler, ... */
13#include <linux/perf_event.h> /* perf_sw_event */ 13#include <linux/perf_event.h> /* perf_sw_event */
14#include <linux/hugetlb.h> /* hstate_index_to_shift */ 14#include <linux/hugetlb.h> /* hstate_index_to_shift */
@@ -45,7 +45,7 @@ enum x86_pf_error_code {
45 * Returns 0 if mmiotrace is disabled, or if the fault is not 45 * Returns 0 if mmiotrace is disabled, or if the fault is not
46 * handled by mmiotrace: 46 * handled by mmiotrace:
47 */ 47 */
48static inline int __kprobes 48static nokprobe_inline int
49kmmio_fault(struct pt_regs *regs, unsigned long addr) 49kmmio_fault(struct pt_regs *regs, unsigned long addr)
50{ 50{
51 if (unlikely(is_kmmio_active())) 51 if (unlikely(is_kmmio_active()))
@@ -54,7 +54,7 @@ kmmio_fault(struct pt_regs *regs, unsigned long addr)
54 return 0; 54 return 0;
55} 55}
56 56
57static inline int __kprobes kprobes_fault(struct pt_regs *regs) 57static nokprobe_inline int kprobes_fault(struct pt_regs *regs)
58{ 58{
59 int ret = 0; 59 int ret = 0;
60 60
@@ -261,7 +261,7 @@ void vmalloc_sync_all(void)
261 * 261 *
262 * Handle a fault on the vmalloc or module mapping area 262 * Handle a fault on the vmalloc or module mapping area
263 */ 263 */
264static noinline __kprobes int vmalloc_fault(unsigned long address) 264static noinline int vmalloc_fault(unsigned long address)
265{ 265{
266 unsigned long pgd_paddr; 266 unsigned long pgd_paddr;
267 pmd_t *pmd_k; 267 pmd_t *pmd_k;
@@ -291,6 +291,7 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
291 291
292 return 0; 292 return 0;
293} 293}
294NOKPROBE_SYMBOL(vmalloc_fault);
294 295
295/* 296/*
296 * Did it hit the DOS screen memory VA from vm86 mode? 297 * Did it hit the DOS screen memory VA from vm86 mode?
@@ -358,7 +359,7 @@ void vmalloc_sync_all(void)
358 * 359 *
359 * This assumes no large pages in there. 360 * This assumes no large pages in there.
360 */ 361 */
361static noinline __kprobes int vmalloc_fault(unsigned long address) 362static noinline int vmalloc_fault(unsigned long address)
362{ 363{
363 pgd_t *pgd, *pgd_ref; 364 pgd_t *pgd, *pgd_ref;
364 pud_t *pud, *pud_ref; 365 pud_t *pud, *pud_ref;
@@ -425,6 +426,7 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
425 426
426 return 0; 427 return 0;
427} 428}
429NOKPROBE_SYMBOL(vmalloc_fault);
428 430
429#ifdef CONFIG_CPU_SUP_AMD 431#ifdef CONFIG_CPU_SUP_AMD
430static const char errata93_warning[] = 432static const char errata93_warning[] =
@@ -927,7 +929,7 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
927 * There are no security implications to leaving a stale TLB when 929 * There are no security implications to leaving a stale TLB when
928 * increasing the permissions on a page. 930 * increasing the permissions on a page.
929 */ 931 */
930static noinline __kprobes int 932static noinline int
931spurious_fault(unsigned long error_code, unsigned long address) 933spurious_fault(unsigned long error_code, unsigned long address)
932{ 934{
933 pgd_t *pgd; 935 pgd_t *pgd;
@@ -975,6 +977,7 @@ spurious_fault(unsigned long error_code, unsigned long address)
975 977
976 return ret; 978 return ret;
977} 979}
980NOKPROBE_SYMBOL(spurious_fault);
978 981
979int show_unhandled_signals = 1; 982int show_unhandled_signals = 1;
980 983
@@ -1030,7 +1033,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
1030 * {,trace_}do_page_fault() have notrace on. Having this an actual function 1033 * {,trace_}do_page_fault() have notrace on. Having this an actual function
1031 * guarantees there's a function trace entry. 1034 * guarantees there's a function trace entry.
1032 */ 1035 */
1033static void __kprobes noinline 1036static noinline void
1034__do_page_fault(struct pt_regs *regs, unsigned long error_code, 1037__do_page_fault(struct pt_regs *regs, unsigned long error_code,
1035 unsigned long address) 1038 unsigned long address)
1036{ 1039{
@@ -1253,8 +1256,9 @@ good_area:
1253 1256
1254 up_read(&mm->mmap_sem); 1257 up_read(&mm->mmap_sem);
1255} 1258}
1259NOKPROBE_SYMBOL(__do_page_fault);
1256 1260
1257dotraplinkage void __kprobes notrace 1261dotraplinkage void notrace
1258do_page_fault(struct pt_regs *regs, unsigned long error_code) 1262do_page_fault(struct pt_regs *regs, unsigned long error_code)
1259{ 1263{
1260 unsigned long address = read_cr2(); /* Get the faulting address */ 1264 unsigned long address = read_cr2(); /* Get the faulting address */
@@ -1272,10 +1276,12 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
1272 __do_page_fault(regs, error_code, address); 1276 __do_page_fault(regs, error_code, address);
1273 exception_exit(prev_state); 1277 exception_exit(prev_state);
1274} 1278}
1279NOKPROBE_SYMBOL(do_page_fault);
1275 1280
1276#ifdef CONFIG_TRACING 1281#ifdef CONFIG_TRACING
1277static void trace_page_fault_entries(unsigned long address, struct pt_regs *regs, 1282static nokprobe_inline void
1278 unsigned long error_code) 1283trace_page_fault_entries(unsigned long address, struct pt_regs *regs,
1284 unsigned long error_code)
1279{ 1285{
1280 if (user_mode(regs)) 1286 if (user_mode(regs))
1281 trace_page_fault_user(address, regs, error_code); 1287 trace_page_fault_user(address, regs, error_code);
@@ -1283,7 +1289,7 @@ static void trace_page_fault_entries(unsigned long address, struct pt_regs *regs
1283 trace_page_fault_kernel(address, regs, error_code); 1289 trace_page_fault_kernel(address, regs, error_code);
1284} 1290}
1285 1291
1286dotraplinkage void __kprobes notrace 1292dotraplinkage void notrace
1287trace_do_page_fault(struct pt_regs *regs, unsigned long error_code) 1293trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
1288{ 1294{
1289 /* 1295 /*
@@ -1300,4 +1306,5 @@ trace_do_page_fault(struct pt_regs *regs, unsigned long error_code)
1300 __do_page_fault(regs, error_code, address); 1306 __do_page_fault(regs, error_code, address);
1301 exception_exit(prev_state); 1307 exception_exit(prev_state);
1302} 1308}
1309NOKPROBE_SYMBOL(trace_do_page_fault);
1303#endif /* CONFIG_TRACING */ 1310#endif /* CONFIG_TRACING */