blob: b1385e1dca63f828811a7b881b843171a368a399 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _LINUX__INIT_TASK_H
3#define _LINUX__INIT_TASK_H
4
Dipankar Sarmaab2af1f2005-09-09 13:04:13 -07005#include <linux/rcupdate.h>
Ingo Molnarde30a2b2006-07-03 00:24:42 -07006#include <linux/irqflags.h>
Serge E. Hallyn4865ecf2006-10-02 02:18:14 -07007#include <linux/utsname.h>
Ingo Molnarfbb9ce952006-07-03 00:24:50 -07008#include <linux/lockdep.h>
Steven Rostedt5ac9f622009-03-25 20:55:00 -04009#include <linux/ftrace.h>
Kirill Korotaev73ea4132006-10-02 02:18:20 -070010#include <linux/ipc.h>
Cedric Le Goater9a575a92006-12-08 02:37:59 -080011#include <linux/pid_namespace.h>
Cedric Le Goateracce2922007-07-15 23:40:59 -070012#include <linux/user_namespace.h>
Andrew G. Morgan3898b1b2008-04-28 02:13:40 -070013#include <linux/securebits.h>
Frederic Weisbecker6a616712012-12-16 20:00:34 +010014#include <linux/seqlock.h>
Peter Zijlstrafb00aca2013-11-07 14:43:43 +010015#include <linux/rbtree.h>
Ingo Molnardfc34012017-02-03 23:15:21 +010016#include <linux/sched/autogroup.h>
Eric W. Biederman772698f2007-09-12 11:55:17 +020017#include <net/net_namespace.h>
Ingo Molnar77852fe2013-02-16 09:46:48 +010018#include <linux/sched/rt.h>
Josh Poimboeufd83a7cb2017-02-13 19:42:40 -060019#include <linux/livepatch.h>
Ingo Molnar589ee622017-02-04 00:16:44 +010020#include <linux/mm_types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Andy Lutomirskic65eacb2016-09-13 14:29:24 -070022#include <asm/thread_info.h>
23
Al Virof52111b2008-05-08 18:19:16 -040024extern struct files_struct init_files;
Al Viro18d8fda2008-12-26 00:35:37 -050025extern struct fs_struct init_fs;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Peter Zijlstra9d7fb042015-06-30 11:30:54 +020027#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
Nicolas Pitreb18b6a92017-01-21 00:09:08 -050035#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
Cedric Le Goater1ec320a2006-12-08 02:37:55 -080056#define INIT_SIGNALS(sig) { \
Oleg Nesterovb3ac0222010-05-26 14:43:24 -070057 .nr_threads = 1, \
Oleg Nesterov0c740d02014-01-21 15:49:56 -080058 .thread_head = LIST_HEAD_INIT(init_task.thread_node), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
Cedric Le Goater1ec320a2006-12-08 02:37:55 -080060 .shared_pending = { \
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 .list = LIST_HEAD_INIT(sig.shared_pending.list), \
Cedric Le Goater1ec320a2006-12-08 02:37:55 -080062 .signal = {{0}}}, \
Nicolas Pitreb18b6a92017-01-21 00:09:08 -050063 INIT_POSIX_TIMERS(sig) \
64 INIT_CPU_TIMERS(sig) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 .rlim = INIT_RLIMITS, \
Nicolas Pitreb18b6a92017-01-21 00:09:08 -050066 INIT_CPUTIMER(sig) \
Peter Zijlstra9d7fb042015-06-30 11:30:54 +020067 INIT_PREV_CPUTIME(sig) \
KOSAKI Motohiro9b1bf122010-10-27 15:34:08 -070068 .cred_guard_mutex = \
69 __MUTEX_INITIALIZER(sig.cred_guard_mutex), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
Serge E. Hallynab516012006-10-02 02:18:06 -070072extern struct nsproxy init_nsproxy;
Serge E. Hallynab516012006-10-02 02:18:06 -070073
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#define INIT_SIGHAND(sighand) { \
75 .count = ATOMIC_INIT(1), \
Oleg Nesterov0a14a132010-05-26 14:44:12 -070076 .action = { { { .sa_handler = SIG_DFL, } }, }, \
Ingo Molnare4d91912006-07-03 00:24:34 -070077 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
Davide Libenzib8fceee2007-09-20 12:40:16 -070078 .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
81extern struct group_info init_groups;
82
Sukadev Bhattiprolu820e45d2007-05-10 22:23:00 -070083#define INIT_STRUCT_PID { \
84 .count = ATOMIC_INIT(1), \
Sukadev Bhattiprolu820e45d2007-05-10 22:23:00 -070085 .tasks = { \
Oleg Nesterovf2001142010-05-26 14:44:10 -070086 { .first = NULL }, \
87 { .first = NULL }, \
88 { .first = NULL }, \
Sukadev Bhattiprolu820e45d2007-05-10 22:23:00 -070089 }, \
Sukadev Bhattiprolu4c3f2ea2007-10-18 23:40:03 -070090 .level = 0, \
91 .numbers = { { \
92 .nr = 0, \
93 .ns = &init_pid_ns, \
Sukadev Bhattiprolu4c3f2ea2007-10-18 23:40:03 -070094 }, } \
Sukadev Bhattiprolu820e45d2007-05-10 22:23:00 -070095}
96
97#define INIT_PID_LINK(type) \
98{ \
99 .node = { \
100 .next = NULL, \
Oleg Nesterovf2001142010-05-26 14:44:10 -0700101 .pprev = NULL, \
Sukadev Bhattiprolu820e45d2007-05-10 22:23:00 -0700102 }, \
103 .pid = &init_struct_pid, \
104}
105
David Howellsb6dff3e2008-11-14 10:39:16 +1100106extern struct cred init_cred;
107
Carsten Emdef1c6f1a2011-10-26 23:14:16 +0200108#define INIT_TASK_COMM "swapper"
109
Tim Abbott857ecee2009-06-23 19:59:36 -0400110/* Attach to the init_task data structure for proper alignment */
David Howellsd11ed3a2018-01-02 15:12:01 +0000111#ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK
Tim Abbott2af76872010-02-20 01:03:35 +0100112#define __init_task_data __attribute__((__section__(".data..init_task")))
David Howellsd11ed3a2018-01-02 15:12:01 +0000113#else
114#define __init_task_data /**/
115#endif
Tim Abbott857ecee2009-06-23 19:59:36 -0400116
David Howells05008712018-01-02 15:12:01 +0000117/* Attach to the thread_info data structure for proper alignment */
118#define __init_thread_info __attribute__((__section__(".data..init_thread_info")))
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120#endif