ftrace.c (a49468240e89628236b738b5ab9416eae8f90c15) ftrace.c (1a7d0890dd4a502a202aaec792a6c04e6e049547)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Dynamic function tracer architecture backend.
4 *
5 * Copyright IBM Corp. 2009,2014
6 *
7 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
8 */
9
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Dynamic function tracer architecture backend.
4 *
5 * Copyright IBM Corp. 2009,2014
6 *
7 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
8 */
9
10#include <linux/moduleloader.h>
10#include <linux/hardirq.h>
11#include <linux/uaccess.h>
12#include <linux/ftrace.h>
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/kprobes.h>
11#include <linux/hardirq.h>
12#include <linux/uaccess.h>
13#include <linux/ftrace.h>
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/kprobes.h>
16#include <linux/execmem.h>
17#include <trace/syscall.h>
18#include <asm/asm-offsets.h>
19#include <asm/text-patching.h>
20#include <asm/cacheflush.h>
21#include <asm/ftrace.lds.h>
22#include <asm/nospec-branch.h>
23#include <asm/set_memory.h>
24#include "entry.h"

--- 190 unchanged lines hidden (view full) ---

215}
216
217#ifdef CONFIG_MODULES
218
219static int __init ftrace_plt_init(void)
220{
221 const char *start, *end;
222
17#include <trace/syscall.h>
18#include <asm/asm-offsets.h>
19#include <asm/text-patching.h>
20#include <asm/cacheflush.h>
21#include <asm/ftrace.lds.h>
22#include <asm/nospec-branch.h>
23#include <asm/set_memory.h>
24#include "entry.h"

--- 190 unchanged lines hidden (view full) ---

215}
216
217#ifdef CONFIG_MODULES
218
219static int __init ftrace_plt_init(void)
220{
221 const char *start, *end;
222
223 ftrace_plt = execmem_alloc(EXECMEM_FTRACE, PAGE_SIZE);
223 ftrace_plt = module_alloc(PAGE_SIZE);
224 if (!ftrace_plt)
225 panic("cannot allocate ftrace plt\n");
226
227 start = ftrace_shared_hotpatch_trampoline(&end);
228 memcpy(ftrace_plt, start, end - start);
229 set_memory_rox((unsigned long)ftrace_plt, 1);
230 return 0;
231}

--- 59 unchanged lines hidden (view full) ---

291void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
292 struct ftrace_ops *ops, struct ftrace_regs *fregs)
293{
294 struct kprobe_ctlblk *kcb;
295 struct pt_regs *regs;
296 struct kprobe *p;
297 int bit;
298
224 if (!ftrace_plt)
225 panic("cannot allocate ftrace plt\n");
226
227 start = ftrace_shared_hotpatch_trampoline(&end);
228 memcpy(ftrace_plt, start, end - start);
229 set_memory_rox((unsigned long)ftrace_plt, 1);
230 return 0;
231}

--- 59 unchanged lines hidden (view full) ---

291void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
292 struct ftrace_ops *ops, struct ftrace_regs *fregs)
293{
294 struct kprobe_ctlblk *kcb;
295 struct pt_regs *regs;
296 struct kprobe *p;
297 int bit;
298
299 if (unlikely(kprobe_ftrace_disabled))
300 return;
301
299 bit = ftrace_test_recursion_trylock(ip, parent_ip);
300 if (bit < 0)
301 return;
302
303 regs = ftrace_get_regs(fregs);
304 p = get_kprobe((kprobe_opcode_t *)ip);
305 if (!regs || unlikely(!p) || kprobe_disabled(p))
306 goto out;

--- 34 unchanged lines hidden ---
302 bit = ftrace_test_recursion_trylock(ip, parent_ip);
303 if (bit < 0)
304 return;
305
306 regs = ftrace_get_regs(fregs);
307 p = get_kprobe((kprobe_opcode_t *)ip);
308 if (!regs || unlikely(!p) || kprobe_disabled(p))
309 goto out;

--- 34 unchanged lines hidden ---