blob: f9eef0e8f0b770b16a88bd74a6aac592d9646276 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vineet Gupta3be80aa2013-01-18 15:12:17 +05302/*
3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4 *
Vineet Gupta3be80aa2013-01-18 15:12:17 +05305 * Vineetg: Oct 2009
6 * No need for ARC specific thread_info allocator (kmalloc/free). This is
7 * anyways one page allocation, thus slab alloc can be short-circuited and
8 * the generic version (get_free_page) would be loads better.
9 *
10 * Sameer Dhavale: Codito Technologies 2004
11 */
12
13#ifndef _ASM_THREAD_INFO_H
14#define _ASM_THREAD_INFO_H
15
Vineet Gupta3be80aa2013-01-18 15:12:17 +053016#include <asm/page.h>
17
18#ifdef CONFIG_16KSTACKS
19#define THREAD_SIZE_ORDER 1
20#else
21#define THREAD_SIZE_ORDER 0
22#endif
23
24#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
Vineet Gupta1f6ccff2013-05-13 18:30:41 +053025#define THREAD_SHIFT (PAGE_SHIFT << THREAD_SIZE_ORDER)
Vineet Gupta3be80aa2013-01-18 15:12:17 +053026
27#ifndef __ASSEMBLY__
28
29#include <linux/thread_info.h>
30#include <asm/segment.h>
31
32/*
33 * low level task data that entry.S needs immediate access to
34 * - this struct should fit entirely inside of one cache line
35 * - this struct shares the supervisor stack pages
36 * - if the contents of this structure are changed, the assembly constants
37 * must also be changed
38 */
39struct thread_info {
40 unsigned long flags; /* low level flags */
41 int preempt_count; /* 0 => preemptable, <0 => BUG */
42 struct task_struct *task; /* main task structure */
43 mm_segment_t addr_limit; /* thread address space */
Vineet Gupta3be80aa2013-01-18 15:12:17 +053044 __u32 cpu; /* current CPU */
45 unsigned long thr_ptr; /* TLS ptr */
Vineet Gupta3be80aa2013-01-18 15:12:17 +053046};
47
48/*
49 * macros/functions for gaining access to the thread information structure
50 *
51 * preempt_count needs to be 1 initially, until the scheduler is functional.
52 */
53#define INIT_THREAD_INFO(tsk) \
54{ \
55 .task = &tsk, \
Vineet Gupta3be80aa2013-01-18 15:12:17 +053056 .flags = 0, \
57 .cpu = 0, \
58 .preempt_count = INIT_PREEMPT_COUNT, \
59 .addr_limit = KERNEL_DS, \
Vineet Gupta3be80aa2013-01-18 15:12:17 +053060}
61
Vineet Gupta3be80aa2013-01-18 15:12:17 +053062static inline __attribute_const__ struct thread_info *current_thread_info(void)
63{
64 register unsigned long sp asm("sp");
65 return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
66}
67
68#endif /* !__ASSEMBLY__ */
69
Vineet Gupta3be80aa2013-01-18 15:12:17 +053070/*
71 * thread information flags
72 * - these are process state flags that various assembly files may need to
73 * access
74 * - pending work-to-be-done flags are in LSW
75 * - other flags in MSW
76 */
77#define TIF_RESTORE_SIGMASK 0 /* restore sig mask in do_signal() */
78#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
79#define TIF_SIGPENDING 2 /* signal pending */
80#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
81#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
82#define TIF_SYSCALL_TRACE 15 /* syscall trace active */
83
84/* true if poll_idle() is polling TIF_NEED_RESCHED */
85#define TIF_MEMDIE 16
86
87#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
88#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
89#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
90#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
91#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
92#define _TIF_MEMDIE (1<<TIF_MEMDIE)
93
94/* work to do on interrupt/exception return */
95#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
96 _TIF_NOTIFY_RESUME)
97
98/*
99 * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
Andrea Gelmini25474762016-05-21 13:45:35 +0200100 * SYSCALL_TRACE is anyway seperately/unconditionally tested right after a
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530101 * syscall, so all that reamins to be tested is _TIF_WORK_MASK
102 */
103
Vineet Gupta3be80aa2013-01-18 15:12:17 +0530104#endif /* _ASM_THREAD_INFO_H */