The function prepare_kprobe() is called during kprobe registration and is responsible for ensuring any architecture related preparation for the kprobe is done before returning. One of two versions of prepare_kprobe() is chosen depending on the availability of KPROBE_ON_FTRACE in the kernel configuration. Simplify the code by dropping the version when KPROBE_ON_FTRACE is not selected - instead relying on kprobe_ftrace() to return false when KPROBE_ON_FTRACE is not set. No functional change. Link: https://lkml.kernel.org/r/163163033696.489837.9264661820279300788.stgit@devnote2
Unified · Split
| @@ -354,6 +354,11 @@ static inline void wait_for_kprobe_optimizer(void) { } · 353 unmodified lines | ||
| 354 | 354 | extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, |
| 355 | 355 | struct ftrace_ops *ops, struct ftrace_regs *fregs); |
| 356 | 356 | extern int arch_prepare_kprobe_ftrace(struct kprobe *p); |
| 357 | +#else | |
| 358 | +static inline int arch_prepare_kprobe_ftrace(struct kprobe *p) | |
| 359 | +{ | |
| 360 | + return -EINVAL; | |
| 361 | +} | |
| 357 | 362 | #endif |
| 358 | 363 | |
| 359 | 364 | int arch_check_ftrace_location(struct kprobe *p); |
| @@ -1033,15 +1033,6 @@ static struct ftrace_ops kprobe_ipmodify_ops __read_mostly = { · 1032 unmodified lines | ||
| 1033 | 1033 | static int kprobe_ipmodify_enabled; |
| 1034 | 1034 | static int kprobe_ftrace_enabled; |
| 1035 | 1035 | |
| 1036 | −/* Must ensure p->addr is really on ftrace */ | |
| 1037 | −static int prepare_kprobe(struct kprobe *p) | |
| 1038 | −{ | |
| 1039 | − if (!kprobe_ftrace(p)) | |
| 1040 | − return arch_prepare_kprobe(p); | |
| 1041 | − | |
| 1042 | − return arch_prepare_kprobe_ftrace(p); | |
| 1043 | −} | |
| 1044 | − | |
| 1045 | 1036 | /* Caller must lock kprobe_mutex */ |
| 1046 | 1037 | static int __arm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops, |
| 1047 | 1038 | int *cnt) |
| @@ -1113,11 +1104,6 @@ static int disarm_kprobe_ftrace(struct kprobe *p) · 65 unmodified lines | ||
| 1113 | 1104 | ipmodify ? &kprobe_ipmodify_enabled : &kprobe_ftrace_enabled); |
| 1114 | 1105 | } |
| 1115 | 1106 | #else /* !CONFIG_KPROBES_ON_FTRACE */ |
| 1116 | −static inline int prepare_kprobe(struct kprobe *p) | |
| 1117 | −{ | |
| 1118 | − return arch_prepare_kprobe(p); | |
| 1119 | −} | |
| 1120 | − | |
| 1121 | 1107 | static inline int arm_kprobe_ftrace(struct kprobe *p) |
| 1122 | 1108 | { |
| 1123 | 1109 | return -ENODEV; |
| @@ -1129,6 +1115,15 @@ static inline int disarm_kprobe_ftrace(struct kprobe *p) · 5 unmodified lines | ||
| 1129 | 1115 | } |
| 1130 | 1116 | #endif |
| 1131 | 1117 | |
| 1118 | +static int prepare_kprobe(struct kprobe *p) | |
| 1119 | +{ | |
| 1120 | + /* Must ensure p->addr is really on ftrace */ | |
| 1121 | + if (kprobe_ftrace(p)) | |
| 1122 | + return arch_prepare_kprobe_ftrace(p); | |
| 1123 | + | |
| 1124 | + return arch_prepare_kprobe(p); | |
| 1125 | +} | |
| 1126 | + | |
| 1132 | 1127 | /* Arm a kprobe with text_mutex */ |
| 1133 | 1128 | static int arm_kprobe(struct kprobe *kp) |
| 1134 | 1129 | { |