kprobes-ftrace.c (773c16705058e9be7b0f4ce124e89cd231c120a2) kprobes-ftrace.c (d19ad0775dcd64b49eecf4fa79c17959ebfbd26b)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Dynamic Ftrace based Kprobes Optimization
4 *
5 * Copyright (C) Hitachi Ltd., 2012
6 * Copyright 2016 Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7 * IBM Corporation
8 */
9#include <linux/kprobes.h>
10#include <linux/ptrace.h>
11#include <linux/hardirq.h>
12#include <linux/preempt.h>
13#include <linux/ftrace.h>
14
15/* Ftrace callback handler for kprobes */
16void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Dynamic Ftrace based Kprobes Optimization
4 *
5 * Copyright (C) Hitachi Ltd., 2012
6 * Copyright 2016 Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
7 * IBM Corporation
8 */
9#include <linux/kprobes.h>
10#include <linux/ptrace.h>
11#include <linux/hardirq.h>
12#include <linux/preempt.h>
13#include <linux/ftrace.h>
14
15/* Ftrace callback handler for kprobes */
16void kprobe_ftrace_handler(unsigned long nip, unsigned long parent_nip,
17 struct ftrace_ops *ops, struct pt_regs *regs)
17 struct ftrace_ops *ops, struct ftrace_regs *fregs)
18{
19 struct kprobe *p;
20 struct kprobe_ctlblk *kcb;
18{
19 struct kprobe *p;
20 struct kprobe_ctlblk *kcb;
21 struct pt_regs *regs;
21 int bit;
22
23 bit = ftrace_test_recursion_trylock(nip, parent_nip);
24 if (bit < 0)
25 return;
26
22 int bit;
23
24 bit = ftrace_test_recursion_trylock(nip, parent_nip);
25 if (bit < 0)
26 return;
27
28 regs = ftrace_get_regs(fregs);
27 preempt_disable_notrace();
28 p = get_kprobe((kprobe_opcode_t *)nip);
29 if (unlikely(!p) || kprobe_disabled(p))
30 goto out;
31
32 kcb = get_kprobe_ctlblk();
33 if (kprobe_running()) {
34 kprobes_inc_nmissed_count(p);

--- 38 unchanged lines hidden ---
29 preempt_disable_notrace();
30 p = get_kprobe((kprobe_opcode_t *)nip);
31 if (unlikely(!p) || kprobe_disabled(p))
32 goto out;
33
34 kcb = get_kprobe_ctlblk();
35 if (kprobe_running()) {
36 kprobes_inc_nmissed_count(p);

--- 38 unchanged lines hidden ---