1 /* thread_info.h: MIPS low-level thread information
2 *
3 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
4 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
5 */
6
7 #ifndef _ASM_THREAD_INFO_H
8 #define _ASM_THREAD_INFO_H
9
10 #ifdef __KERNEL__
11
12
13 #ifndef __ASSEMBLY__
14
15 #include <asm/processor.h>
16
17 /*
18 * low level task data that entry.S needs immediate access to
19 * - this struct should fit entirely inside of one cache line
20 * - this struct shares the supervisor stack pages
21 * - if the contents of this structure are changed, the assembly constants
22 * must also be changed
23 */
24 struct thread_info {
25 struct task_struct *task; /* main task structure */
26 struct exec_domain *exec_domain; /* execution domain */
27 unsigned long flags; /* low level flags */
28 unsigned long local_flags; /* low level flags, no locking access */
29 unsigned long tp_value; /* thread pointer */
30 __u32 cpu; /* current CPU */
31 int preempt_count; /* 0 => preemptable, <0 => BUG */
32
33 mm_segment_t addr_limit; /*
34 * thread address space limit:
35 * 0x7fffffff for user-thead
36 * 0xffffffff for kernel-thread
37 */
38 unsigned long vdso_offset;
39 struct page *vdso_page;
40 struct restart_block restart_block;
41 struct pt_regs *regs;
42 };
43
44 /*
45 * macros/functions for gaining access to the thread information structure
46 */
47 #define INIT_THREAD_INFO(tsk) \
48 { \
49 .task = &tsk, \
50 .exec_domain = &default_exec_domain, \
51 .flags = _TIF_FIXADE, \
52 .local_flags = 0, \
53 .cpu = 0, \
54 .preempt_count = INIT_PREEMPT_COUNT, \
55 .addr_limit = KERNEL_DS, \
56 .vdso_page = NULL, \
57 .restart_block = { \
58 .fn = do_no_restart_syscall, \
59 }, \
60 }
61
62 #define init_thread_info (init_thread_union.thread_info)
63 #define init_stack (init_thread_union.stack)
64
65 /* How to get the thread information struct from C. */
current_thread_info(void)66 static inline struct thread_info *current_thread_info(void)
67 {
68 register struct thread_info *__current_thread_info __asm__("$28");
69
70 return __current_thread_info;
71 }
72
73 #endif /* !__ASSEMBLY__ */
74
75 /* thread information allocation */
76 #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_32BIT)
77 #define THREAD_SIZE_ORDER (1)
78 #endif
79 #if defined(CONFIG_PAGE_SIZE_4KB) && defined(CONFIG_64BIT)
80 #define THREAD_SIZE_ORDER (2)
81 #endif
82 #ifdef CONFIG_PAGE_SIZE_8KB
83 #define THREAD_SIZE_ORDER (1)
84 #endif
85 #ifdef CONFIG_PAGE_SIZE_16KB
86 #define THREAD_SIZE_ORDER (0)
87 #endif
88 #ifdef CONFIG_PAGE_SIZE_32KB
89 #define THREAD_SIZE_ORDER (0)
90 #endif
91 #ifdef CONFIG_PAGE_SIZE_64KB
92 #define THREAD_SIZE_ORDER (0)
93 #endif
94
95 #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
96 #define THREAD_MASK (THREAD_SIZE - 1UL)
97
98 #define STACK_WARN (THREAD_SIZE / 8)
99
100 #define PREEMPT_ACTIVE 0x10000000
101
102 /*
103 * thread information flags
104 * - these are process state flags that various assembly files may need to
105 * access
106 * - pending work-to-be-done flags are in LSW
107 * - other flags in MSW
108 */
109 #define TIF_FPU_LOSE_REQUEST 0 /* request to lose FPU from IPI call */
110 #define TIF_SIGPENDING 1 /* signal pending */
111 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
112 #define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
113 #define TIF_SECCOMP 4 /* secure computing */
114 #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
115 #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
116 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
117 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
118 #define TIF_NOHZ 19 /* in adaptive nohz mode */
119 #define TIF_FIXADE 20 /* Fix address errors in software */
120 #define TIF_LOGADE 21 /* Log address errors to syslog */
121 #define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */
122 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
123 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
124 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
125 #define TIF_SYSCALL_TRACEPOINT 26 /* syscall tracepoint instrumentation */
126 #define TIF_USEDMSA 29 /* MSA has been used this quantum */
127 #define TIF_MSA_CTX_LIVE 30 /* MSA context must be preserved */
128 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
129
130 #define _TIF_FPU_LOSE_REQUEST (1<<TIF_FPU_LOSE_REQUEST)
131 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
132 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
133 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
134 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
135 #define _TIF_SECCOMP (1<<TIF_SECCOMP)
136 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
137 #define _TIF_USEDFPU (1<<TIF_USEDFPU)
138 #define _TIF_NOHZ (1<<TIF_NOHZ)
139 #define _TIF_FIXADE (1<<TIF_FIXADE)
140 #define _TIF_LOGADE (1<<TIF_LOGADE)
141 #define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS)
142 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
143 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
144 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
145 #define _TIF_USEDMSA (1<<TIF_USEDMSA)
146 #define _TIF_MSA_CTX_LIVE (1<<TIF_MSA_CTX_LIVE)
147 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
148
149 #define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
150 _TIF_SYSCALL_AUDIT | \
151 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
152
153 /* work to do in syscall_trace_leave() */
154 #define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
155 _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
156
157 /* work to do on interrupt/exception return */
158 #define _TIF_WORK_MASK \
159 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
160 /* work to do on any return to u-space */
161 #define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
162 _TIF_WORK_SYSCALL_EXIT | \
163 _TIF_SYSCALL_TRACEPOINT)
164
165 /* local thread information flags, update only from thread itself = no locking */
166 #define LTIF_FPU_FR 0x00000001 /* Status.FR bit state for this thread */
167 #define LTIF_FPU_FRE 0x00000002 /* Mixed FPU mode emulation */
168
169 #ifndef __ASSEMBLY__
set_thread_local_flags(unsigned long x)170 static inline void set_thread_local_flags(unsigned long x)
171 {
172 current_thread_info()->local_flags |= x;
173 }
174
clear_thread_local_flags(unsigned long x)175 static inline void clear_thread_local_flags(unsigned long x)
176 {
177 current_thread_info()->local_flags &= ~x;
178 }
179
change_thread_local_flags(unsigned long x,unsigned long f)180 static inline void change_thread_local_flags(unsigned long x, unsigned long f)
181 {
182 current_thread_info()->local_flags =
183 (current_thread_info()->local_flags & ~x) | f;
184 }
185
test_thread_local_flags(unsigned long x)186 static inline int test_thread_local_flags(unsigned long x)
187 {
188 return ((current_thread_info()->local_flags & x)? 1 : 0);
189 }
190 #endif
191
192 #endif /* __KERNEL__ */
193
194 #endif /* _ASM_THREAD_INFO_H */
195