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

kprobes: Pass the original kprobe for preparing optimized kprobe

Pass the original kprobe for preparing an optimized kprobe arch-dep
part, since for some architecture (e.g. ARM32) requires the information
in original kprobe.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>

authored by

Masami Hiramatsu and committed by
Jon Medhurst
cbf6ab52 8d257e95

+6 -4
+2 -1
arch/x86/kernel/kprobes/opt.c
··· 322 322 * Target instructions MUST be relocatable (checked inside) 323 323 * This is called when new aggr(opt)probe is allocated or reused. 324 324 */ 325 - int arch_prepare_optimized_kprobe(struct optimized_kprobe *op) 325 + int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, 326 + struct kprobe *__unused) 326 327 { 327 328 u8 *buf; 328 329 int ret;
+2 -1
include/linux/kprobes.h
··· 308 308 /* Architecture dependent functions for direct jump optimization */ 309 309 extern int arch_prepared_optinsn(struct arch_optimized_insn *optinsn); 310 310 extern int arch_check_optimized_kprobe(struct optimized_kprobe *op); 311 - extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op); 311 + extern int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, 312 + struct kprobe *orig); 312 313 extern void arch_remove_optimized_kprobe(struct optimized_kprobe *op); 313 314 extern void arch_optimize_kprobes(struct list_head *oplist); 314 315 extern void arch_unoptimize_kprobes(struct list_head *oplist,
+2 -2
kernel/kprobes.c
··· 717 717 struct optimized_kprobe *op; 718 718 719 719 op = container_of(p, struct optimized_kprobe, kp); 720 - arch_prepare_optimized_kprobe(op); 720 + arch_prepare_optimized_kprobe(op, p); 721 721 } 722 722 723 723 /* Allocate new optimized_kprobe and try to prepare optimized instructions */ ··· 731 731 732 732 INIT_LIST_HEAD(&op->list); 733 733 op->kp.addr = p->addr; 734 - arch_prepare_optimized_kprobe(op); 734 + arch_prepare_optimized_kprobe(op, p); 735 735 736 736 return &op->kp; 737 737 }