init_task.h 3.1 KB

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