]>
git.ipfire.org Git - thirdparty/linux.git/blob - arch/arm64/include/asm/stacktrace.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 ARM Ltd.
5 #ifndef __ASM_STACKTRACE_H
6 #define __ASM_STACKTRACE_H
8 #include <linux/percpu.h>
9 #include <linux/sched.h>
10 #include <linux/sched/task_stack.h>
12 #include <asm/memory.h>
13 #include <asm/ptrace.h>
19 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
29 STACK_TYPE_SDEI_NORMAL
,
30 STACK_TYPE_SDEI_CRITICAL
,
39 extern int unwind_frame(struct task_struct
*tsk
, struct stackframe
*frame
);
40 extern void walk_stackframe(struct task_struct
*tsk
, struct stackframe
*frame
,
41 int (*fn
)(struct stackframe
*, void *), void *data
);
42 extern void dump_backtrace(struct pt_regs
*regs
, struct task_struct
*tsk
);
44 DECLARE_PER_CPU(unsigned long *, irq_stack_ptr
);
46 static inline bool on_irq_stack(unsigned long sp
,
47 struct stack_info
*info
)
49 unsigned long low
= (unsigned long)raw_cpu_read(irq_stack_ptr
);
50 unsigned long high
= low
+ IRQ_STACK_SIZE
;
55 if (sp
< low
|| sp
>= high
)
61 info
->type
= STACK_TYPE_IRQ
;
67 static inline bool on_task_stack(struct task_struct
*tsk
, unsigned long sp
,
68 struct stack_info
*info
)
70 unsigned long low
= (unsigned long)task_stack_page(tsk
);
71 unsigned long high
= low
+ THREAD_SIZE
;
73 if (sp
< low
|| sp
>= high
)
79 info
->type
= STACK_TYPE_TASK
;
85 #ifdef CONFIG_VMAP_STACK
86 DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE
/sizeof(long)], overflow_stack
);
88 static inline bool on_overflow_stack(unsigned long sp
,
89 struct stack_info
*info
)
91 unsigned long low
= (unsigned long)raw_cpu_ptr(overflow_stack
);
92 unsigned long high
= low
+ OVERFLOW_STACK_SIZE
;
94 if (sp
< low
|| sp
>= high
)
100 info
->type
= STACK_TYPE_OVERFLOW
;
106 static inline bool on_overflow_stack(unsigned long sp
,
107 struct stack_info
*info
) { return false; }
112 * We can only safely access per-cpu stacks from current in a non-preemptible
115 static inline bool on_accessible_stack(struct task_struct
*tsk
,
117 struct stack_info
*info
)
119 if (on_task_stack(tsk
, sp
, info
))
121 if (tsk
!= current
|| preemptible())
123 if (on_irq_stack(sp
, info
))
125 if (on_overflow_stack(sp
, info
))
127 if (on_sdei_stack(sp
, info
))
133 #endif /* __ASM_STACKTRACE_H */