Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4 *
5 * 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
16#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)
25#define THREAD_SHIFT (PAGE_SHIFT << THREAD_SIZE_ORDER)
26
27#ifndef __ASSEMBLY__
28
29#include <linux/thread_info.h>
30
31/*
32 * low level task data that entry.S needs immediate access to
33 * - this struct should fit entirely inside of one cache line
34 * - this struct shares the supervisor stack pages
35 * - if the contents of this structure are changed, the assembly constants
36 * must also be changed
37 */
38struct thread_info {
39 unsigned long flags; /* low level flags */
40 unsigned long ksp; /* kernel mode stack top in __switch_to */
41 int preempt_count; /* 0 => preemptable, <0 => BUG */
42 int cpu; /* current CPU */
43 unsigned long thr_ptr; /* TLS ptr */
44 struct task_struct *task; /* main task structure */
45};
46
47/*
48 * initilaize thread_info for any @tsk
49 * - this is not related to init_task per se
50 */
51#define INIT_THREAD_INFO(tsk) \
52{ \
53 .task = &tsk, \
54 .flags = 0, \
55 .cpu = 0, \
56 .preempt_count = INIT_PREEMPT_COUNT, \
57}
58
59static inline __attribute_const__ struct thread_info *current_thread_info(void)
60{
61 register unsigned long sp asm("sp");
62 return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
63}
64
65#endif /* !__ASSEMBLY__ */
66
67/*
68 * thread information flags
69 * - these are process state flags that various assembly files may need to
70 * access
71 * - pending work-to-be-done flags are in LSW
72 * - other flags in MSW
73 */
74#define TIF_RESTORE_SIGMASK 0 /* restore sig mask in do_signal() */
75#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
76#define TIF_SIGPENDING 2 /* signal pending */
77#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
78#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
79#define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */
80#define TIF_SYSCALL_TRACE 15 /* syscall trace active */
81/* true if poll_idle() is polling TIF_NEED_RESCHED */
82#define TIF_MEMDIE 16
83#define TIF_SYSCALL_TRACEPOINT 17 /* syscall tracepoint instrumentation */
84
85#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
86#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
87#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
88#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
89#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
90#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
91#define _TIF_MEMDIE (1<<TIF_MEMDIE)
92#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
93
94/* work to do on interrupt/exception return */
95#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
96 _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL)
97
98#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
99
100/*
101 * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
102 * SYSCALL_TRACE is anyway separately/unconditionally tested right after a
103 * syscall, so all that remains to be tested is _TIF_WORK_MASK
104 */
105
106#endif /* _ASM_THREAD_INFO_H */
1/*
2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Vineetg: Oct 2009
9 * No need for ARC specific thread_info allocator (kmalloc/free). This is
10 * anyways one page allocation, thus slab alloc can be short-circuited and
11 * the generic version (get_free_page) would be loads better.
12 *
13 * Sameer Dhavale: Codito Technologies 2004
14 */
15
16#ifndef _ASM_THREAD_INFO_H
17#define _ASM_THREAD_INFO_H
18
19#ifdef __KERNEL__
20
21#include <asm/page.h>
22
23#ifdef CONFIG_16KSTACKS
24#define THREAD_SIZE_ORDER 1
25#else
26#define THREAD_SIZE_ORDER 0
27#endif
28
29#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
30
31#ifndef __ASSEMBLY__
32
33#include <linux/thread_info.h>
34#include <asm/segment.h>
35
36/*
37 * low level task data that entry.S needs immediate access to
38 * - this struct should fit entirely inside of one cache line
39 * - this struct shares the supervisor stack pages
40 * - if the contents of this structure are changed, the assembly constants
41 * must also be changed
42 */
43struct thread_info {
44 unsigned long flags; /* low level flags */
45 int preempt_count; /* 0 => preemptable, <0 => BUG */
46 struct task_struct *task; /* main task structure */
47 mm_segment_t addr_limit; /* thread address space */
48 struct exec_domain *exec_domain;/* execution domain */
49 __u32 cpu; /* current CPU */
50 unsigned long thr_ptr; /* TLS ptr */
51 struct restart_block restart_block;
52};
53
54/*
55 * macros/functions for gaining access to the thread information structure
56 *
57 * preempt_count needs to be 1 initially, until the scheduler is functional.
58 */
59#define INIT_THREAD_INFO(tsk) \
60{ \
61 .task = &tsk, \
62 .exec_domain = &default_exec_domain, \
63 .flags = 0, \
64 .cpu = 0, \
65 .preempt_count = INIT_PREEMPT_COUNT, \
66 .addr_limit = KERNEL_DS, \
67 .restart_block = { \
68 .fn = do_no_restart_syscall, \
69 }, \
70}
71
72#define init_thread_info (init_thread_union.thread_info)
73#define init_stack (init_thread_union.stack)
74
75static inline __attribute_const__ struct thread_info *current_thread_info(void)
76{
77 register unsigned long sp asm("sp");
78 return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
79}
80
81#endif /* !__ASSEMBLY__ */
82
83/*
84 * thread information flags
85 * - these are process state flags that various assembly files may need to
86 * access
87 * - pending work-to-be-done flags are in LSW
88 * - other flags in MSW
89 */
90#define TIF_RESTORE_SIGMASK 0 /* restore sig mask in do_signal() */
91#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
92#define TIF_SIGPENDING 2 /* signal pending */
93#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
94#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
95#define TIF_SYSCALL_TRACE 15 /* syscall trace active */
96
97/* true if poll_idle() is polling TIF_NEED_RESCHED */
98#define TIF_MEMDIE 16
99
100#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
101#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
102#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
103#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
104#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
105#define _TIF_MEMDIE (1<<TIF_MEMDIE)
106
107/* work to do on interrupt/exception return */
108#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
109 _TIF_NOTIFY_RESUME)
110
111/*
112 * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
113 * SYSCALL_TRACE is anways seperately/unconditionally tested right after a
114 * syscall, so all that reamins to be tested is _TIF_WORK_MASK
115 */
116
117#endif /* __KERNEL__ */
118
119#endif /* _ASM_THREAD_INFO_H */