drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / arm64 / include / asm / stacktrace.h
blob66ec8caa6ac07fa0d70865e40b594bdd7079d585
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2012 ARM Ltd.
4 */
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>
11 #include <linux/llist.h>
13 #include <asm/memory.h>
14 #include <asm/pointer_auth.h>
15 #include <asm/ptrace.h>
16 #include <asm/sdei.h>
18 #include <asm/stacktrace/common.h>
20 extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
21 const char *loglvl);
23 DECLARE_PER_CPU(unsigned long *, irq_stack_ptr);
25 static inline struct stack_info stackinfo_get_irq(void)
27 unsigned long low = (unsigned long)raw_cpu_read(irq_stack_ptr);
28 unsigned long high = low + IRQ_STACK_SIZE;
30 return (struct stack_info) {
31 .low = low,
32 .high = high,
36 static inline bool on_irq_stack(unsigned long sp, unsigned long size)
38 struct stack_info info = stackinfo_get_irq();
39 return stackinfo_on_stack(&info, sp, size);
42 static inline struct stack_info stackinfo_get_task(const struct task_struct *tsk)
44 unsigned long low = (unsigned long)task_stack_page(tsk);
45 unsigned long high = low + THREAD_SIZE;
47 return (struct stack_info) {
48 .low = low,
49 .high = high,
53 static inline bool on_task_stack(const struct task_struct *tsk,
54 unsigned long sp, unsigned long size)
56 struct stack_info info = stackinfo_get_task(tsk);
57 return stackinfo_on_stack(&info, sp, size);
60 #define on_thread_stack() (on_task_stack(current, current_stack_pointer, 1))
62 #ifdef CONFIG_VMAP_STACK
63 DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack);
65 static inline struct stack_info stackinfo_get_overflow(void)
67 unsigned long low = (unsigned long)raw_cpu_ptr(overflow_stack);
68 unsigned long high = low + OVERFLOW_STACK_SIZE;
70 return (struct stack_info) {
71 .low = low,
72 .high = high,
75 #else
76 #define stackinfo_get_overflow() stackinfo_get_unknown()
77 #endif
79 #if defined(CONFIG_ARM_SDE_INTERFACE) && defined(CONFIG_VMAP_STACK)
80 DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
81 DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
83 static inline struct stack_info stackinfo_get_sdei_normal(void)
85 unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
86 unsigned long high = low + SDEI_STACK_SIZE;
88 return (struct stack_info) {
89 .low = low,
90 .high = high,
94 static inline struct stack_info stackinfo_get_sdei_critical(void)
96 unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
97 unsigned long high = low + SDEI_STACK_SIZE;
99 return (struct stack_info) {
100 .low = low,
101 .high = high,
104 #else
105 #define stackinfo_get_sdei_normal() stackinfo_get_unknown()
106 #define stackinfo_get_sdei_critical() stackinfo_get_unknown()
107 #endif
109 #ifdef CONFIG_EFI
110 extern u64 *efi_rt_stack_top;
112 static inline struct stack_info stackinfo_get_efi(void)
114 unsigned long high = (u64)efi_rt_stack_top;
115 unsigned long low = high - THREAD_SIZE;
117 return (struct stack_info) {
118 .low = low,
119 .high = high,
122 #endif
124 #endif /* __ASM_STACKTRACE_H */