| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * arch/arm64/include/asm/ftrace.h |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2013 Linaro Limited |
|---|
| 5 | 6 | * Author: AKASHI Takahiro <takahiro.akashi@linaro.org> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 9 | | - * published by the Free Software Foundation. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | #ifndef __ASM_FTRACE_H |
|---|
| 12 | 9 | #define __ASM_FTRACE_H |
|---|
| 13 | 10 | |
|---|
| 14 | 11 | #include <asm/insn.h> |
|---|
| 15 | 12 | |
|---|
| 13 | +#define HAVE_FUNCTION_GRAPH_FP_TEST |
|---|
| 14 | + |
|---|
| 15 | +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS |
|---|
| 16 | +#define ARCH_SUPPORTS_FTRACE_OPS 1 |
|---|
| 17 | +#else |
|---|
| 16 | 18 | #define MCOUNT_ADDR ((unsigned long)_mcount) |
|---|
| 19 | +#endif |
|---|
| 20 | + |
|---|
| 21 | +/* The BL at the callsite's adjusted rec->ip */ |
|---|
| 17 | 22 | #define MCOUNT_INSN_SIZE AARCH64_INSN_SIZE |
|---|
| 23 | + |
|---|
| 24 | +#define FTRACE_PLT_IDX 0 |
|---|
| 25 | +#define FTRACE_REGS_PLT_IDX 1 |
|---|
| 26 | +#define NR_FTRACE_PLTS 2 |
|---|
| 27 | + |
|---|
| 28 | +/* |
|---|
| 29 | + * Currently, gcc tends to save the link register after the local variables |
|---|
| 30 | + * on the stack. This causes the max stack tracer to report the function |
|---|
| 31 | + * frame sizes for the wrong functions. By defining |
|---|
| 32 | + * ARCH_FTRACE_SHIFT_STACK_TRACER, it will tell the stack tracer to expect |
|---|
| 33 | + * to find the return address on the stack after the local variables have |
|---|
| 34 | + * been set up. |
|---|
| 35 | + * |
|---|
| 36 | + * Note, this may change in the future, and we will need to deal with that |
|---|
| 37 | + * if it were to happen. |
|---|
| 38 | + */ |
|---|
| 39 | +#define ARCH_FTRACE_SHIFT_STACK_TRACER 1 |
|---|
| 18 | 40 | |
|---|
| 19 | 41 | #ifndef __ASSEMBLY__ |
|---|
| 20 | 42 | #include <linux/compat.h> |
|---|
| .. | .. |
|---|
| 33 | 55 | static inline unsigned long ftrace_call_adjust(unsigned long addr) |
|---|
| 34 | 56 | { |
|---|
| 35 | 57 | /* |
|---|
| 58 | + * Adjust addr to point at the BL in the callsite. |
|---|
| 59 | + * See ftrace_init_nop() for the callsite sequence. |
|---|
| 60 | + */ |
|---|
| 61 | + if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS)) |
|---|
| 62 | + return addr + AARCH64_INSN_SIZE; |
|---|
| 63 | + /* |
|---|
| 36 | 64 | * addr is the address of the mcount call instruction. |
|---|
| 37 | 65 | * recordmcount does the necessary offset calculation. |
|---|
| 38 | 66 | */ |
|---|
| 39 | 67 | return addr; |
|---|
| 40 | 68 | } |
|---|
| 41 | 69 | |
|---|
| 70 | +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS |
|---|
| 71 | +struct dyn_ftrace; |
|---|
| 72 | +int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec); |
|---|
| 73 | +#define ftrace_init_nop ftrace_init_nop |
|---|
| 74 | +#endif |
|---|
| 75 | + |
|---|
| 42 | 76 | #define ftrace_return_address(n) return_address(n) |
|---|
| 43 | 77 | |
|---|
| 44 | 78 | /* |
|---|