xref: /linux-6.15/include/linux/init_task.h (revision 4e7e3adb)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX__INIT_TASK_H
3 #define _LINUX__INIT_TASK_H
4 
5 #include <linux/rcupdate.h>
6 #include <linux/irqflags.h>
7 #include <linux/utsname.h>
8 #include <linux/lockdep.h>
9 #include <linux/ftrace.h>
10 #include <linux/ipc.h>
11 #include <linux/pid_namespace.h>
12 #include <linux/user_namespace.h>
13 #include <linux/securebits.h>
14 #include <linux/seqlock.h>
15 #include <linux/rbtree.h>
16 #include <linux/sched/autogroup.h>
17 #include <net/net_namespace.h>
18 #include <linux/sched/rt.h>
19 #include <linux/livepatch.h>
20 #include <linux/mm_types.h>
21 
22 #include <asm/thread_info.h>
23 
24 extern struct files_struct init_files;
25 extern struct fs_struct init_fs;
26 
27 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
28 #define INIT_PREV_CPUTIME(x)	.prev_cputime = {			\
29 	.lock = __RAW_SPIN_LOCK_UNLOCKED(x.prev_cputime.lock),		\
30 },
31 #else
32 #define INIT_PREV_CPUTIME(x)
33 #endif
34 
35 #ifdef CONFIG_POSIX_TIMERS
36 #define INIT_POSIX_TIMERS(s)						\
37 	.posix_timers = LIST_HEAD_INIT(s.posix_timers),
38 #define INIT_CPU_TIMERS(s)						\
39 	.cpu_timers = {							\
40 		LIST_HEAD_INIT(s.cpu_timers[0]),			\
41 		LIST_HEAD_INIT(s.cpu_timers[1]),			\
42 		LIST_HEAD_INIT(s.cpu_timers[2]),								\
43 	},
44 #define INIT_CPUTIMER(s)						\
45 	.cputimer	= { 						\
46 		.cputime_atomic	= INIT_CPUTIME_ATOMIC,			\
47 		.running	= false,				\
48 		.checking_timer = false,				\
49 	},
50 #else
51 #define INIT_POSIX_TIMERS(s)
52 #define INIT_CPU_TIMERS(s)
53 #define INIT_CPUTIMER(s)
54 #endif
55 
56 #define INIT_SIGNALS(sig) {						\
57 	.nr_threads	= 1,						\
58 	.thread_head	= LIST_HEAD_INIT(init_task.thread_node),	\
59 	.wait_chldexit	= __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
60 	.shared_pending	= { 						\
61 		.list = LIST_HEAD_INIT(sig.shared_pending.list),	\
62 		.signal =  {{0}}},					\
63 	INIT_POSIX_TIMERS(sig)						\
64 	INIT_CPU_TIMERS(sig)						\
65 	.rlim		= INIT_RLIMITS,					\
66 	INIT_CPUTIMER(sig)						\
67 	INIT_PREV_CPUTIME(sig)						\
68 	.cred_guard_mutex =						\
69 		 __MUTEX_INITIALIZER(sig.cred_guard_mutex),		\
70 }
71 
72 extern struct nsproxy init_nsproxy;
73 
74 #define INIT_SIGHAND(sighand) {						\
75 	.count		= ATOMIC_INIT(1), 				\
76 	.action		= { { { .sa_handler = SIG_DFL, } }, },		\
77 	.siglock	= __SPIN_LOCK_UNLOCKED(sighand.siglock),	\
78 	.signalfd_wqh	= __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh),	\
79 }
80 
81 extern struct group_info init_groups;
82 
83 #define INIT_STRUCT_PID {						\
84 	.count 		= ATOMIC_INIT(1),				\
85 	.tasks		= {						\
86 		{ .first = NULL },					\
87 		{ .first = NULL },					\
88 		{ .first = NULL },					\
89 	},								\
90 	.level		= 0,						\
91 	.numbers	= { {						\
92 		.nr		= 0,					\
93 		.ns		= &init_pid_ns,				\
94 	}, }								\
95 }
96 
97 #define INIT_PID_LINK(type) 					\
98 {								\
99 	.node = {						\
100 		.next = NULL,					\
101 		.pprev = NULL,					\
102 	},							\
103 	.pid = &init_struct_pid,				\
104 }
105 
106 extern struct cred init_cred;
107 
108 #define INIT_TASK_COMM "swapper"
109 
110 /* Attach to the init_task data structure for proper alignment */
111 #ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK
112 #define __init_task_data __attribute__((__section__(".data..init_task")))
113 #else
114 #define __init_task_data /**/
115 #endif
116 
117 /* Attach to the thread_info data structure for proper alignment */
118 #define __init_thread_info __attribute__((__section__(".data..init_thread_info")))
119 
120 #endif
121