ftrace.h 2.5 KB
Newer Older
A
AKASHI Takahiro 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * arch/arm64/include/asm/ftrace.h
 *
 * Copyright (C) 2013 Linaro Limited
 * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __ASM_FTRACE_H
#define __ASM_FTRACE_H

#include <asm/insn.h>

T
Torsten Duwe 已提交
16 17 18 19

#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
#define ARCH_SUPPORTS_FTRACE_OPS 1
#else
A
AKASHI Takahiro 已提交
20
#define MCOUNT_ADDR		((unsigned long)_mcount)
T
Torsten Duwe 已提交
21 22 23
#endif

/* The BL at the callsite's adjusted rec->ip */
A
AKASHI Takahiro 已提交
24 25
#define MCOUNT_INSN_SIZE	AARCH64_INSN_SIZE

T
Torsten Duwe 已提交
26 27 28 29
#define FTRACE_PLT_IDX		0
#define FTRACE_REGS_PLT_IDX	1
#define NR_FTRACE_PLTS		2

A
AKASHI Takahiro 已提交
30
#ifndef __ASSEMBLY__
31 32
#include <linux/compat.h>

A
AKASHI Takahiro 已提交
33
extern void _mcount(unsigned long);
34
extern void *return_address(unsigned int);
35 36 37 38 39 40 41

struct dyn_arch_ftrace {
	/* No extra data needed for arm64 */
};

extern unsigned long ftrace_graph_call;

42 43
extern void return_to_handler(void);

44 45
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
T
Torsten Duwe 已提交
46 47 48 49 50 51
	/*
	 * Adjust addr to point at the BL in the callsite.
	 * See ftrace_init_nop() for the callsite sequence.
	 */
	if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
		return addr + AARCH64_INSN_SIZE;
52 53 54 55 56 57
	/*
	 * addr is the address of the mcount call instruction.
	 * recordmcount does the necessary offset calculation.
	 */
	return addr;
}
58

T
Torsten Duwe 已提交
59 60 61 62 63 64
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
struct dyn_ftrace;
int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
#define ftrace_init_nop ftrace_init_nop
#endif

65
#define ftrace_return_address(n) return_address(n)
66 67 68 69 70 71 72 73

/*
 * Because AArch32 mode does not share the same syscall table with AArch64,
 * tracing compat syscalls may result in reporting bogus syscalls or even
 * hang-up, so just do not trace them.
 * See kernel/trace/trace_syscalls.c
 *
 * x86 code says:
74
 * If the user really wants these, then they should use the
75 76 77 78 79 80 81
 * raw syscall tracepoints with filtering.
 */
#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
{
	return is_compat_task();
}
82 83 84 85 86 87 88 89 90 91 92 93 94

#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME

static inline bool arch_syscall_match_sym_name(const char *sym,
					       const char *name)
{
	/*
	 * Since all syscall functions have __arm64_ prefix, we must skip it.
	 * However, as we described above, we decided to ignore compat
	 * syscalls, so we don't care about __arm64_compat_ prefix here.
	 */
	return !strcmp(sym + 8, name);
}
95
#endif /* ifndef __ASSEMBLY__ */
A
AKASHI Takahiro 已提交
96 97

#endif /* __ASM_FTRACE_H */