drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / riscv / kernel / return_address.c
blobc8115ec8fb304bb5b44fdbfc38c5d55605f3c5c2
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * This code come from arch/arm64/kernel/return_address.c
5 * Copyright (C) 2023 SiFive.
6 */
8 #include <linux/export.h>
9 #include <linux/kprobes.h>
10 #include <linux/stacktrace.h>
12 struct return_address_data {
13 unsigned int level;
14 void *addr;
17 static bool save_return_addr(void *d, unsigned long pc)
19 struct return_address_data *data = d;
21 if (!data->level) {
22 data->addr = (void *)pc;
23 return false;
26 --data->level;
28 return true;
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;
37 data.addr = NULL;
39 arch_stack_walk(save_return_addr, &data, current, NULL);
41 if (!data.level)
42 return data.addr;
43 else
44 return NULL;
47 EXPORT_SYMBOL_GPL(return_address);
48 NOKPROBE_SYMBOL(return_address);