Commit 9edddaa200df18e08fe0cf21036e8ae467b1363c

Authored by Ananth N Mavinakayanahalli
Committed by Linus Torvalds
1 parent 8182ec49a7

Kprobes: indicate kretprobe support in Kconfig

Add CONFIG_HAVE_KRETPROBES to the arch/<arch>/Kconfig file for relevant
architectures with kprobes support.  This facilitates easy handling of
in-kernel modules (like samples/kprobes/kretprobe_example.c) that depend on
kretprobes being present in the kernel.

Thanks to Sam Ravnborg for helping make the patch more lean.

Per Mathieu's suggestion, added CONFIG_KRETPROBES and fixed up dependencies.

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 15 changed files with 19 additions and 16 deletions Side-by-side Diff

... ... @@ -27,6 +27,13 @@
27 27 for kernel debugging, non-intrusive instrumentation and testing.
28 28 If in doubt, say "N".
29 29  
  30 +config KRETPROBES
  31 + def_bool y
  32 + depends on KPROBES && HAVE_KRETPROBES
  33 +
30 34 config HAVE_KPROBES
  35 + def_bool n
  36 +
  37 +config HAVE_KRETPROBES
31 38 def_bool n
... ... @@ -12,6 +12,7 @@
12 12 select SYS_SUPPORTS_APM_EMULATION
13 13 select HAVE_OPROFILE
14 14 select HAVE_KPROBES if (!XIP_KERNEL)
  15 + select HAVE_KRETPROBES if (HAVE_KPROBES)
15 16 help
16 17 The ARM series is a line of low-power-consumption RISC chip designs
17 18 licensed by ARM Ltd and targeted at embedded applications and
... ... @@ -18,6 +18,7 @@
18 18 select HAVE_IDE
19 19 select HAVE_OPROFILE
20 20 select HAVE_KPROBES
  21 + select HAVE_KRETPROBES
21 22 default y
22 23 help
23 24 The Itanium Processor Family is Intel's 64-bit successor to
arch/powerpc/Kconfig
... ... @@ -90,6 +90,7 @@
90 90 select HAVE_IDE
91 91 select HAVE_OPROFILE
92 92 select HAVE_KPROBES
  93 + select HAVE_KRETPROBES
93 94  
94 95 config EARLY_PRINTK
95 96 bool
... ... @@ -61,6 +61,7 @@
61 61 def_bool y
62 62 select HAVE_OPROFILE
63 63 select HAVE_KPROBES
  64 + select HAVE_KRETPROBES
64 65  
65 66 source "init/Kconfig"
66 67  
arch/sparc64/Kconfig
... ... @@ -10,6 +10,7 @@
10 10 default y
11 11 select HAVE_OPROFILE
12 12 select HAVE_KPROBES
  13 + select HAVE_KRETPROBES
13 14  
14 15 config SPARC64
15 16 bool
... ... @@ -21,6 +21,7 @@
21 21 select HAVE_IDE
22 22 select HAVE_OPROFILE
23 23 select HAVE_KPROBES
  24 + select HAVE_KRETPROBES
24 25 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64)
25 26  
26 27  
include/asm-arm/kprobes.h
... ... @@ -20,7 +20,6 @@
20 20 #include <linux/ptrace.h>
21 21 #include <linux/percpu.h>
22 22  
23   -#define ARCH_SUPPORTS_KRETPROBES
24 23 #define __ARCH_WANT_KPROBES_INSN_SLOT
25 24 #define MAX_INSN_SIZE 2
26 25 #define MAX_STACK_SIZE 64 /* 32 would probably be OK */
include/asm-ia64/kprobes.h
... ... @@ -82,7 +82,6 @@
82 82 struct prev_kprobe prev_kprobe[ARCH_PREV_KPROBE_SZ];
83 83 };
84 84  
85   -#define ARCH_SUPPORTS_KRETPROBES
86 85 #define kretprobe_blacklist_size 0
87 86  
88 87 #define SLOT0_OPCODE_SHIFT (37)
include/asm-powerpc/kprobes.h
... ... @@ -80,7 +80,6 @@
80 80 #define is_trap(instr) (IS_TW(instr) || IS_TWI(instr))
81 81 #endif
82 82  
83   -#define ARCH_SUPPORTS_KRETPROBES
84 83 #define flush_insn_slot(p) do { } while (0)
85 84 #define kretprobe_blacklist_size 0
86 85  
include/asm-s390/kprobes.h
... ... @@ -46,7 +46,6 @@
46 46 ? (MAX_STACK_SIZE) \
47 47 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
48 48  
49   -#define ARCH_SUPPORTS_KRETPROBES
50 49 #define kretprobe_blacklist_size 0
51 50  
52 51 #define KPROBE_SWAP_INST 0x10
include/asm-sparc64/kprobes.h
... ... @@ -14,8 +14,6 @@
14 14  
15 15 #define arch_remove_kprobe(p) do {} while (0)
16 16  
17   -#define ARCH_SUPPORTS_KRETPROBES
18   -
19 17 #define flush_insn_slot(p) \
20 18 do { flushi(&(p)->ainsn.insn[0]); \
21 19 flushi(&(p)->ainsn.insn[1]); \
include/asm-x86/kprobes.h
... ... @@ -42,7 +42,6 @@
42 42 : (((unsigned long)current_thread_info()) + THREAD_SIZE \
43 43 - (unsigned long)(ADDR)))
44 44  
45   -#define ARCH_SUPPORTS_KRETPROBES
46 45 #define flush_insn_slot(p) do { } while (0)
47 46  
48 47 extern const int kretprobe_blacklist_size;
include/linux/kprobes.h
... ... @@ -125,11 +125,11 @@
125 125 DECLARE_PER_CPU(struct kprobe *, current_kprobe);
126 126 DECLARE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
127 127  
128   -#ifdef ARCH_SUPPORTS_KRETPROBES
  128 +#ifdef CONFIG_KRETPROBES
129 129 extern void arch_prepare_kretprobe(struct kretprobe_instance *ri,
130 130 struct pt_regs *regs);
131 131 extern int arch_trampoline_kprobe(struct kprobe *p);
132   -#else /* ARCH_SUPPORTS_KRETPROBES */
  132 +#else /* CONFIG_KRETPROBES */
133 133 static inline void arch_prepare_kretprobe(struct kretprobe *rp,
134 134 struct pt_regs *regs)
135 135 {
... ... @@ -138,7 +138,7 @@
138 138 {
139 139 return 0;
140 140 }
141   -#endif /* ARCH_SUPPORTS_KRETPROBES */
  141 +#endif /* CONFIG_KRETPROBES */
142 142 /*
143 143 * Function-return probe -
144 144 * Note:
... ... @@ -678,8 +678,7 @@
678 678 unregister_kprobe(&jp->kp);
679 679 }
680 680  
681   -#ifdef ARCH_SUPPORTS_KRETPROBES
682   -
  681 +#ifdef CONFIG_KRETPROBES
683 682 /*
684 683 * This kprobe pre_handler is registered with every kretprobe. When probe
685 684 * hits it will set up the return probe.
... ... @@ -769,8 +768,7 @@
769 768 return ret;
770 769 }
771 770  
772   -#else /* ARCH_SUPPORTS_KRETPROBES */
773   -
  771 +#else /* CONFIG_KRETPROBES */
774 772 int __kprobes register_kretprobe(struct kretprobe *rp)
775 773 {
776 774 return -ENOSYS;
... ... @@ -781,8 +779,7 @@
781 779 {
782 780 return 0;
783 781 }
784   -
785   -#endif /* ARCH_SUPPORTS_KRETPROBES */
  782 +#endif /* CONFIG_KRETPROBES */
786 783  
787 784 void __kprobes unregister_kretprobe(struct kretprobe *rp)
788 785 {