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

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>

authored by

Ananth N Mavinakayanahalli and committed by
Linus Torvalds
9edddaa2 8182ec49

+19 -16
+7
arch/Kconfig
··· 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
+1
arch/arm/Kconfig
··· 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
+1
arch/ia64/Kconfig
··· 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
+1
arch/powerpc/Kconfig
··· 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
+1
arch/s390/Kconfig
··· 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
+1
arch/sparc64/Kconfig
··· 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
+1
arch/x86/Kconfig
··· 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
-1
include/asm-arm/kprobes.h
··· 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 */
-1
include/asm-ia64/kprobes.h
··· 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)
-1
include/asm-powerpc/kprobes.h
··· 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
-1
include/asm-s390/kprobes.h
··· 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
-2
include/asm-sparc64/kprobes.h
··· 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]); \
-1
include/asm-x86/kprobes.h
··· 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;
+3 -3
include/linux/kprobes.h
··· 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 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:
+3 -6
kernel/kprobes.c
··· 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. ··· 768 769 return ret; 769 770 } 770 771 771 - #else /* ARCH_SUPPORTS_KRETPROBES */ 772 - 772 + #else /* CONFIG_KRETPROBES */ 773 773 int __kprobes register_kretprobe(struct kretprobe *rp) 774 774 { 775 775 return -ENOSYS; ··· 779 781 { 780 782 return 0; 781 783 } 782 - 783 - #endif /* ARCH_SUPPORTS_KRETPROBES */ 784 + #endif /* CONFIG_KRETPROBES */ 784 785 785 786 void __kprobes unregister_kretprobe(struct kretprobe *rp) 786 787 {