arm64: perf: move to common attr_group fields
[deliverable/linux.git] / arch / arm64 / kernel / return_address.c
CommitLineData
3711784e
AT
1/*
2 * arch/arm64/kernel/return_address.c
3 *
4 * Copyright (C) 2013 Linaro Limited
5 * 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 */
11
12#include <linux/export.h>
13#include <linux/ftrace.h>
14
15#include <asm/stacktrace.h>
16
17struct return_address_data {
18 unsigned int level;
19 void *addr;
20};
21
22static int save_return_addr(struct stackframe *frame, void *d)
23{
24 struct return_address_data *data = d;
25
26 if (!data->level) {
27 data->addr = (void *)frame->pc;
28 return 1;
29 } else {
30 --data->level;
31 return 0;
32 }
33}
34
35void *return_address(unsigned int level)
36{
37 struct return_address_data data;
38 struct stackframe frame;
3711784e
AT
39
40 data.level = level + 2;
41 data.addr = NULL;
42
43 frame.fp = (unsigned long)__builtin_frame_address(0);
a4ceab1a 44 frame.sp = current_stack_pointer;
3711784e 45 frame.pc = (unsigned long)return_address; /* dummy */
20380bb3
AT
46#ifdef CONFIG_FUNCTION_GRAPH_TRACER
47 frame.graph = current->curr_ret_stack;
48#endif
3711784e 49
fe13f95b 50 walk_stackframe(current, &frame, save_return_addr, &data);
3711784e
AT
51
52 if (!data.level)
53 return data.addr;
54 else
55 return NULL;
56}
57EXPORT_SYMBOL_GPL(return_address);
This page took 0.134046 seconds and 5 git commands to generate.