arm64: add basic VMAP_STACK support
[linux-block.git] / arch / arm64 / include / asm / stacktrace.h
CommitLineData
60ffc30d
CM
1/*
2 * Copyright (C) 2012 ARM Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef __ASM_STACKTRACE_H
17#define __ASM_STACKTRACE_H
18
f60ad4ed
MR
19#include <linux/percpu.h>
20#include <linux/sched.h>
21#include <linux/sched/task_stack.h>
22
23#include <asm/memory.h>
24#include <asm/ptrace.h>
fe13f95b 25
60ffc30d
CM
26struct stackframe {
27 unsigned long fp;
60ffc30d 28 unsigned long pc;
20380bb3
AT
29#ifdef CONFIG_FUNCTION_GRAPH_TRACER
30 unsigned int graph;
31#endif
60ffc30d
CM
32};
33
fe13f95b
AT
34extern int unwind_frame(struct task_struct *tsk, struct stackframe *frame);
35extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,
60ffc30d 36 int (*fn)(struct stackframe *, void *), void *data);
1149aad1 37extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk);
60ffc30d 38
f60fe78f 39DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
f60ad4ed
MR
40
41static inline bool on_irq_stack(unsigned long sp)
42{
f60fe78f 43 unsigned long low = (unsigned long)raw_cpu_read(irq_stack_ptr);
f60ad4ed
MR
44 unsigned long high = low + IRQ_STACK_SIZE;
45
f60fe78f
MR
46 if (!low)
47 return false;
48
f60ad4ed
MR
49 return (low <= sp && sp < high);
50}
51
52static inline bool on_task_stack(struct task_struct *tsk, unsigned long sp)
53{
54 unsigned long low = (unsigned long)task_stack_page(tsk);
55 unsigned long high = low + THREAD_SIZE;
56
57 return (low <= sp && sp < high);
58}
59
60ffc30d 60#endif /* __ASM_STACKTRACE_H */