Merge tag 'dma-mapping-4.16' of git://git.infradead.org/users/hch/dma-mapping
[sfrench/cifs-2.6.git] / arch / metag / include / asm / thread_info.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* thread_info.h: Meta low-level thread information
3  *
4  * Copyright (C) 2002  David Howells (dhowells@redhat.com)
5  * - Incorporating suggestions made by Linus Torvalds and Dave Miller
6  *
7  * Meta port by Imagination Technologies
8  */
9
10 #ifndef _ASM_THREAD_INFO_H
11 #define _ASM_THREAD_INFO_H
12
13 #include <linux/compiler.h>
14 #include <asm/page.h>
15
16 #ifndef __ASSEMBLY__
17 #include <asm/processor.h>
18 #endif
19
20 /*
21  * low level task data that entry.S needs immediate access to
22  * - this struct should fit entirely inside of one cache line
23  * - this struct shares the supervisor stack pages
24  * - if the contents of this structure are changed, the assembly constants must
25  *   also be changed
26  */
27 #ifndef __ASSEMBLY__
28
29 /* This must be 8 byte aligned so we can ensure stack alignment. */
30 struct thread_info {
31         struct task_struct *task;       /* main task structure */
32         unsigned long flags;    /* low level flags */
33         unsigned long status;   /* thread-synchronous flags */
34         u32 cpu;                /* current CPU */
35         int preempt_count;      /* 0 => preemptable, <0 => BUG */
36
37         mm_segment_t addr_limit;        /* thread address space */
38
39         u8 supervisor_stack[0] __aligned(8);
40 };
41
42 #else /* !__ASSEMBLY__ */
43
44 #include <generated/asm-offsets.h>
45
46 #endif
47
48 #ifdef CONFIG_4KSTACKS
49 #define THREAD_SHIFT            12
50 #else
51 #define THREAD_SHIFT            13
52 #endif
53
54 #if THREAD_SHIFT >= PAGE_SHIFT
55 #define THREAD_SIZE_ORDER       (THREAD_SHIFT - PAGE_SHIFT)
56 #else
57 #define THREAD_SIZE_ORDER       0
58 #endif
59
60 #define THREAD_SIZE             (PAGE_SIZE << THREAD_SIZE_ORDER)
61
62 #define STACK_WARN              (THREAD_SIZE/8)
63 /*
64  * macros/functions for gaining access to the thread information structure
65  */
66 #ifndef __ASSEMBLY__
67
68 #define INIT_THREAD_INFO(tsk)                   \
69 {                                               \
70         .task           = &tsk,                 \
71         .flags          = 0,                    \
72         .cpu            = 0,                    \
73         .preempt_count  = INIT_PREEMPT_COUNT,   \
74         .addr_limit     = KERNEL_DS,            \
75 }
76
77 /* how to get the current stack pointer from C */
78 register unsigned long current_stack_pointer asm("A0StP") __used;
79
80 /* how to get the thread information struct from C */
81 static inline struct thread_info *current_thread_info(void)
82 {
83         return (struct thread_info *)(current_stack_pointer &
84                                       ~(THREAD_SIZE - 1));
85 }
86
87 #define __HAVE_ARCH_KSTACK_END
88 static inline int kstack_end(void *addr)
89 {
90         return addr == (void *) (((unsigned long) addr & ~(THREAD_SIZE - 1))
91                                  + sizeof(struct thread_info));
92 }
93
94 #endif
95
96 /*
97  * thread information flags
98  * - these are process state flags that various assembly files may need to
99  *   access
100  * - pending work-to-be-done flags are in LSW
101  * - other flags in MSW
102  */
103 #define TIF_SYSCALL_TRACE       0       /* syscall trace active */
104 #define TIF_SIGPENDING          1       /* signal pending */
105 #define TIF_NEED_RESCHED        2       /* rescheduling necessary */
106 #define TIF_SINGLESTEP          3       /* restore singlestep on return to user
107                                            mode */
108 #define TIF_SYSCALL_AUDIT       4       /* syscall auditing active */
109 #define TIF_SECCOMP             5       /* secure computing */
110 #define TIF_RESTORE_SIGMASK     6       /* restore signal mask in do_signal() */
111 #define TIF_NOTIFY_RESUME       7       /* callback before returning to user */
112 #define TIF_MEMDIE              8       /* is terminating due to OOM killer */
113 #define TIF_SYSCALL_TRACEPOINT  9       /* syscall tracepoint instrumentation */
114
115
116 #define _TIF_SYSCALL_TRACE      (1<<TIF_SYSCALL_TRACE)
117 #define _TIF_SIGPENDING         (1<<TIF_SIGPENDING)
118 #define _TIF_NEED_RESCHED       (1<<TIF_NEED_RESCHED)
119 #define _TIF_SINGLESTEP         (1<<TIF_SINGLESTEP)
120 #define _TIF_SYSCALL_AUDIT      (1<<TIF_SYSCALL_AUDIT)
121 #define _TIF_SECCOMP            (1<<TIF_SECCOMP)
122 #define _TIF_NOTIFY_RESUME      (1<<TIF_NOTIFY_RESUME)
123 #define _TIF_RESTORE_SIGMASK    (1<<TIF_RESTORE_SIGMASK)
124 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
125
126 /* work to do in syscall trace */
127 #define _TIF_WORK_SYSCALL_MASK  (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
128                                  _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
129                                  _TIF_SYSCALL_TRACEPOINT)
130
131 /* work to do on any return to u-space */
132 #define _TIF_ALLWORK_MASK       (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING      | \
133                                  _TIF_NEED_RESCHED  | _TIF_SYSCALL_AUDIT   | \
134                                  _TIF_SINGLESTEP    | _TIF_RESTORE_SIGMASK | \
135                                  _TIF_NOTIFY_RESUME)
136
137 /* work to do on interrupt/exception return */
138 #define _TIF_WORK_MASK          (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
139                                  _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
140
141 #endif /* _ASM_THREAD_INFO_H */