]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
a4a2eb49 TG |
2 | #include <linux/init_task.h> |
3 | #include <linux/export.h> | |
4 | #include <linux/mqueue.h> | |
5 | #include <linux/sched.h> | |
cf4aebc2 | 6 | #include <linux/sched/sysctl.h> |
8bd75c77 | 7 | #include <linux/sched/rt.h> |
9164bb4a | 8 | #include <linux/sched/task.h> |
a4a2eb49 TG |
9 | #include <linux/init.h> |
10 | #include <linux/fs.h> | |
11 | #include <linux/mm.h> | |
f0b75216 | 12 | #include <linux/audit.h> |
a4a2eb49 TG |
13 | |
14 | #include <asm/pgtable.h> | |
7c0f6ba6 | 15 | #include <linux/uaccess.h> |
a4a2eb49 | 16 | |
3678e2fc DH |
17 | static struct signal_struct init_signals = { |
18 | .nr_threads = 1, | |
19 | .thread_head = LIST_HEAD_INIT(init_task.thread_node), | |
20 | .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(init_signals.wait_chldexit), | |
21 | .shared_pending = { | |
22 | .list = LIST_HEAD_INIT(init_signals.shared_pending.list), | |
23 | .signal = {{0}} | |
24 | }, | |
25 | .rlim = INIT_RLIMITS, | |
26 | .cred_guard_mutex = __MUTEX_INITIALIZER(init_signals.cred_guard_mutex), | |
27 | #ifdef CONFIG_POSIX_TIMERS | |
28 | .posix_timers = LIST_HEAD_INIT(init_signals.posix_timers), | |
29 | .cputimer = { | |
30 | .cputime_atomic = INIT_CPUTIME_ATOMIC, | |
31 | .running = false, | |
32 | .checking_timer = false, | |
33 | }, | |
34 | #endif | |
35 | INIT_CPU_TIMERS(init_signals) | |
2896b0f0 | 36 | .leader_pid = &init_struct_pid, |
3678e2fc DH |
37 | INIT_PREV_CPUTIME(init_signals) |
38 | }; | |
39 | ||
40 | static struct sighand_struct init_sighand = { | |
41 | .count = ATOMIC_INIT(1), | |
42 | .action = { { { .sa_handler = SIG_DFL, } }, }, | |
43 | .siglock = __SPIN_LOCK_UNLOCKED(init_sighand.siglock), | |
44 | .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(init_sighand.signalfd_wqh), | |
45 | }; | |
a4a2eb49 | 46 | |
d11ed3ab DH |
47 | /* |
48 | * Set up the first task table, touch at your own risk!. Base=0, | |
49 | * limit=0x1fffff (=2MB) | |
50 | */ | |
0500871f DH |
51 | struct task_struct init_task |
52 | #ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK | |
53 | __init_task_data | |
54 | #endif | |
d11ed3ab | 55 | = { |
4e7e3adb DH |
56 | #ifdef CONFIG_THREAD_INFO_IN_TASK |
57 | .thread_info = INIT_THREAD_INFO(init_task), | |
58 | .stack_refcount = ATOMIC_INIT(1), | |
59 | #endif | |
d11ed3ab DH |
60 | .state = 0, |
61 | .stack = init_stack, | |
62 | .usage = ATOMIC_INIT(2), | |
63 | .flags = PF_KTHREAD, | |
4e7e3adb DH |
64 | .prio = MAX_PRIO - 20, |
65 | .static_prio = MAX_PRIO - 20, | |
66 | .normal_prio = MAX_PRIO - 20, | |
d11ed3ab DH |
67 | .policy = SCHED_NORMAL, |
68 | .cpus_allowed = CPU_MASK_ALL, | |
69 | .nr_cpus_allowed= NR_CPUS, | |
70 | .mm = NULL, | |
71 | .active_mm = &init_mm, | |
4e7e3adb | 72 | .restart_block = { |
d11ed3ab DH |
73 | .fn = do_no_restart_syscall, |
74 | }, | |
75 | .se = { | |
76 | .group_node = LIST_HEAD_INIT(init_task.se.group_node), | |
77 | }, | |
78 | .rt = { | |
79 | .run_list = LIST_HEAD_INIT(init_task.rt.run_list), | |
80 | .time_slice = RR_TIMESLICE, | |
81 | }, | |
82 | .tasks = LIST_HEAD_INIT(init_task.tasks), | |
4e7e3adb DH |
83 | #ifdef CONFIG_SMP |
84 | .pushable_tasks = PLIST_NODE_INIT(init_task.pushable_tasks, MAX_PRIO), | |
85 | #endif | |
86 | #ifdef CONFIG_CGROUP_SCHED | |
87 | .sched_task_group = &root_task_group, | |
88 | #endif | |
d11ed3ab DH |
89 | .ptraced = LIST_HEAD_INIT(init_task.ptraced), |
90 | .ptrace_entry = LIST_HEAD_INIT(init_task.ptrace_entry), | |
91 | .real_parent = &init_task, | |
92 | .parent = &init_task, | |
93 | .children = LIST_HEAD_INIT(init_task.children), | |
94 | .sibling = LIST_HEAD_INIT(init_task.sibling), | |
95 | .group_leader = &init_task, | |
96 | RCU_POINTER_INITIALIZER(real_cred, &init_cred), | |
97 | RCU_POINTER_INITIALIZER(cred, &init_cred), | |
98 | .comm = INIT_TASK_COMM, | |
99 | .thread = INIT_THREAD, | |
100 | .fs = &init_fs, | |
101 | .files = &init_files, | |
102 | .signal = &init_signals, | |
103 | .sighand = &init_sighand, | |
104 | .nsproxy = &init_nsproxy, | |
105 | .pending = { | |
106 | .list = LIST_HEAD_INIT(init_task.pending.list), | |
107 | .signal = {{0}} | |
108 | }, | |
109 | .blocked = {{0}}, | |
110 | .alloc_lock = __SPIN_LOCK_UNLOCKED(init_task.alloc_lock), | |
111 | .journal_info = NULL, | |
112 | INIT_CPU_TIMERS(init_task) | |
113 | .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock), | |
114 | .timer_slack_ns = 50000, /* 50 usec default slack */ | |
115 | .pids = { | |
116 | [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), | |
117 | [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), | |
118 | [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), | |
119 | }, | |
120 | .thread_group = LIST_HEAD_INIT(init_task.thread_group), | |
121 | .thread_node = LIST_HEAD_INIT(init_signals.thread_head), | |
4e7e3adb DH |
122 | #ifdef CONFIG_AUDITSYSCALL |
123 | .loginuid = INVALID_UID, | |
f0b75216 | 124 | .sessionid = AUDIT_SID_UNSET, |
4e7e3adb DH |
125 | #endif |
126 | #ifdef CONFIG_PERF_EVENTS | |
127 | .perf_event_mutex = __MUTEX_INITIALIZER(init_task.perf_event_mutex), | |
128 | .perf_event_list = LIST_HEAD_INIT(init_task.perf_event_list), | |
129 | #endif | |
130 | #ifdef CONFIG_PREEMPT_RCU | |
131 | .rcu_read_lock_nesting = 0, | |
132 | .rcu_read_unlock_special.s = 0, | |
133 | .rcu_node_entry = LIST_HEAD_INIT(init_task.rcu_node_entry), | |
134 | .rcu_blocked_node = NULL, | |
135 | #endif | |
136 | #ifdef CONFIG_TASKS_RCU | |
137 | .rcu_tasks_holdout = false, | |
138 | .rcu_tasks_holdout_list = LIST_HEAD_INIT(init_task.rcu_tasks_holdout_list), | |
139 | .rcu_tasks_idle_cpu = -1, | |
140 | #endif | |
141 | #ifdef CONFIG_CPUSETS | |
142 | .mems_allowed_seq = SEQCNT_ZERO(init_task.mems_allowed_seq), | |
143 | #endif | |
144 | #ifdef CONFIG_RT_MUTEXES | |
145 | .pi_waiters = RB_ROOT_CACHED, | |
146 | .pi_top_task = NULL, | |
147 | #endif | |
d11ed3ab | 148 | INIT_PREV_CPUTIME(init_task) |
4e7e3adb DH |
149 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN |
150 | .vtime.seqcount = SEQCNT_ZERO(init_task.vtime_seqcount), | |
151 | .vtime.starttime = 0, | |
152 | .vtime.state = VTIME_SYS, | |
153 | #endif | |
154 | #ifdef CONFIG_NUMA_BALANCING | |
155 | .numa_preferred_nid = -1, | |
156 | .numa_group = NULL, | |
157 | .numa_faults = NULL, | |
158 | #endif | |
159 | #ifdef CONFIG_KASAN | |
160 | .kasan_depth = 1, | |
161 | #endif | |
162 | #ifdef CONFIG_TRACE_IRQFLAGS | |
163 | .softirqs_enabled = 1, | |
164 | #endif | |
165 | #ifdef CONFIG_LOCKDEP | |
166 | .lockdep_recursion = 0, | |
167 | #endif | |
168 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | |
169 | .ret_stack = NULL, | |
170 | #endif | |
171 | #if defined(CONFIG_TRACING) && defined(CONFIG_PREEMPT) | |
172 | .trace_recursion = 0, | |
173 | #endif | |
174 | #ifdef CONFIG_LIVEPATCH | |
175 | .patch_state = KLP_UNDEFINED, | |
176 | #endif | |
177 | #ifdef CONFIG_SECURITY | |
178 | .security = NULL, | |
179 | #endif | |
d11ed3ab | 180 | }; |
a4a2eb49 TG |
181 | EXPORT_SYMBOL(init_task); |
182 | ||
183 | /* | |
184 | * Initial thread structure. Alignment of this is handled by a special | |
185 | * linker map entry. | |
186 | */ | |
c65eacbe | 187 | #ifndef CONFIG_THREAD_INFO_IN_TASK |
0500871f | 188 | struct thread_info init_thread_info __init_thread_info = INIT_THREAD_INFO(init_task); |
c65eacbe | 189 | #endif |