]> Git Repo - linux.git/blob - arch/arm/kernel/return_address.c
mm/page_isolation: unset migratetype directly for non Buddy page
[linux.git] / arch / arm / kernel / return_address.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * arch/arm/kernel/return_address.c
4  *
5  * Copyright (C) 2009 Uwe Kleine-Koenig <[email protected]>
6  * for Pengutronix
7  */
8 #include <linux/export.h>
9 #include <linux/ftrace.h>
10 #include <linux/sched.h>
11
12 #include <asm/stacktrace.h>
13
14 struct return_address_data {
15         unsigned int level;
16         void *addr;
17 };
18
19 static int save_return_addr(struct stackframe *frame, void *d)
20 {
21         struct return_address_data *data = d;
22
23         if (!data->level) {
24                 data->addr = (void *)frame->pc;
25
26                 return 1;
27         } else {
28                 --data->level;
29                 return 0;
30         }
31 }
32
33 void *return_address(unsigned int level)
34 {
35         struct return_address_data data;
36         struct stackframe frame;
37
38         data.level = level + 2;
39         data.addr = NULL;
40
41         frame.fp = (unsigned long)__builtin_frame_address(0);
42         frame.sp = current_stack_pointer;
43         frame.lr = (unsigned long)__builtin_return_address(0);
44         frame.pc = (unsigned long)return_address;
45 #ifdef CONFIG_KRETPROBES
46         frame.kr_cur = NULL;
47         frame.tsk = current;
48 #endif
49
50         walk_stackframe(&frame, save_return_addr, &data);
51
52         if (!data.level)
53                 return data.addr;
54         else
55                 return NULL;
56 }
57
58 EXPORT_SYMBOL_GPL(return_address);
This page took 0.034822 seconds and 4 git commands to generate.