1 // SPDX-License-Identifier: GPL-2.0-only
3 * This code come from arch/arm64/kernel/return_address.c
5 * Copyright (C) 2023 SiFive.
8 #include <linux/export.h>
9 #include <linux/kprobes.h>
10 #include <linux/stacktrace.h>
12 struct return_address_data
{
17 static bool save_return_addr(void *d
, unsigned long pc
)
19 struct return_address_data
*data
= d
;
22 data
->addr
= (void *)pc
;
30 NOKPROBE_SYMBOL(save_return_addr
);
32 noinline
void *return_address(unsigned int level
)
34 struct return_address_data data
;
36 data
.level
= level
+ 3;
39 arch_stack_walk(save_return_addr
, &data
, current
, NULL
);
47 EXPORT_SYMBOL_GPL(return_address
);
48 NOKPROBE_SYMBOL(return_address
);