thread_info.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (C) 2002-2003 Hewlett-Packard Co
  3. * David Mosberger-Tang <davidm@hpl.hp.com>
  4. */
  5. #ifndef _ASM_IA64_THREAD_INFO_H
  6. #define _ASM_IA64_THREAD_INFO_H
  7. #ifndef ASM_OFFSETS_C
  8. #include <asm/asm-offsets.h>
  9. #endif
  10. #include <asm/processor.h>
  11. #include <asm/ptrace.h>
  12. #ifndef __ASSEMBLY__
  13. /*
  14. * On IA-64, we want to keep the task structure and kernel stack together, so they can be
  15. * mapped by a single TLB entry and so they can be addressed by the "current" pointer
  16. * without having to do pointer masking.
  17. */
  18. struct thread_info {
  19. struct task_struct *task; /* XXX not really needed, except for dup_task_struct() */
  20. struct exec_domain *exec_domain;/* execution domain */
  21. __u32 flags; /* thread_info flags (see TIF_*) */
  22. __u32 cpu; /* current CPU */
  23. __u32 last_cpu; /* Last CPU thread ran on */
  24. __u32 status; /* Thread synchronous flags */
  25. mm_segment_t addr_limit; /* user-level address space limit */
  26. int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */
  27. struct restart_block restart_block;
  28. #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
  29. __u64 ac_stamp;
  30. __u64 ac_leave;
  31. __u64 ac_stime;
  32. __u64 ac_utime;
  33. #endif
  34. };
  35. #define THREAD_SIZE KERNEL_STACK_SIZE
  36. #define INIT_THREAD_INFO(tsk) \
  37. { \
  38. .task = &tsk, \
  39. .exec_domain = &default_exec_domain, \
  40. .flags = 0, \
  41. .cpu = 0, \
  42. .addr_limit = KERNEL_DS, \
  43. .preempt_count = INIT_PREEMPT_COUNT, \
  44. .restart_block = { \
  45. .fn = do_no_restart_syscall, \
  46. }, \
  47. }
  48. #ifndef ASM_OFFSETS_C
  49. /* how to get the thread information struct from C */
  50. #define current_thread_info() ((struct thread_info *) ((char *) current + IA64_TASK_SIZE))
  51. #define alloc_thread_info_node(tsk, node) \
  52. ((struct thread_info *) ((char *) (tsk) + IA64_TASK_SIZE))
  53. #define task_thread_info(tsk) ((struct thread_info *) ((char *) (tsk) + IA64_TASK_SIZE))
  54. #else
  55. #define current_thread_info() ((struct thread_info *) 0)
  56. #define alloc_thread_info_node(tsk, node) ((struct thread_info *) 0)
  57. #define task_thread_info(tsk) ((struct thread_info *) 0)
  58. #endif
  59. #define free_thread_info(ti) /* nothing */
  60. #define task_stack_page(tsk) ((void *)(tsk))
  61. #define __HAVE_THREAD_FUNCTIONS
  62. #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
  63. #define setup_thread_stack(p, org) \
  64. *task_thread_info(p) = *task_thread_info(org); \
  65. task_thread_info(p)->ac_stime = 0; \
  66. task_thread_info(p)->ac_utime = 0; \
  67. task_thread_info(p)->task = (p);
  68. #else
  69. #define setup_thread_stack(p, org) \
  70. *task_thread_info(p) = *task_thread_info(org); \
  71. task_thread_info(p)->task = (p);
  72. #endif
  73. #define end_of_stack(p) (unsigned long *)((void *)(p) + IA64_RBS_OFFSET)
  74. #define alloc_task_struct_node(node) \
  75. ({ \
  76. struct page *page = alloc_pages_node(node, GFP_KERNEL | __GFP_COMP, \
  77. KERNEL_STACK_SIZE_ORDER); \
  78. struct task_struct *ret = page ? page_address(page) : NULL; \
  79. \
  80. ret; \
  81. })
  82. #define free_task_struct(tsk) free_pages((unsigned long) (tsk), KERNEL_STACK_SIZE_ORDER)
  83. #endif /* !__ASSEMBLY */
  84. /*
  85. * thread information flags
  86. * - these are process state flags that various assembly files may need to access
  87. * - pending work-to-be-done flags are in least-significant 16 bits, other flags
  88. * in top 16 bits
  89. */
  90. #define TIF_SIGPENDING 0 /* signal pending */
  91. #define TIF_NEED_RESCHED 1 /* rescheduling necessary */
  92. #define TIF_SYSCALL_TRACE 2 /* syscall trace active */
  93. #define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
  94. #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
  95. #define TIF_NOTIFY_RESUME 6 /* resumption notification requested */
  96. #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
  97. #define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */
  98. #define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */
  99. #define TIF_RESTORE_RSE 21 /* user RBS is newer than kernel RBS */
  100. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  101. #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
  102. #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
  103. #define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP)
  104. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  105. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  106. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  107. #define _TIF_MCA_INIT (1 << TIF_MCA_INIT)
  108. #define _TIF_DB_DISABLED (1 << TIF_DB_DISABLED)
  109. #define _TIF_RESTORE_RSE (1 << TIF_RESTORE_RSE)
  110. /* "work to do on user-return" bits */
  111. #define TIF_ALLWORK_MASK (_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SYSCALL_AUDIT|\
  112. _TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE)
  113. /* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */
  114. #define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT))
  115. #define TS_POLLING 1 /* true if in idle loop and not sleeping */
  116. #define TS_RESTORE_SIGMASK 2 /* restore signal mask in do_signal() */
  117. #ifndef __ASSEMBLY__
  118. #define HAVE_SET_RESTORE_SIGMASK 1
  119. static inline void set_restore_sigmask(void)
  120. {
  121. struct thread_info *ti = current_thread_info();
  122. ti->status |= TS_RESTORE_SIGMASK;
  123. WARN_ON(!test_bit(TIF_SIGPENDING, &ti->flags));
  124. }
  125. static inline void clear_restore_sigmask(void)
  126. {
  127. current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
  128. }
  129. static inline bool test_restore_sigmask(void)
  130. {
  131. return current_thread_info()->status & TS_RESTORE_SIGMASK;
  132. }
  133. static inline bool test_and_clear_restore_sigmask(void)
  134. {
  135. struct thread_info *ti = current_thread_info();
  136. if (!(ti->status & TS_RESTORE_SIGMASK))
  137. return false;
  138. ti->status &= ~TS_RESTORE_SIGMASK;
  139. return true;
  140. }
  141. #endif /* !__ASSEMBLY__ */
  142. #endif /* _ASM_IA64_THREAD_INFO_H */