thread_info.h 5.3 KB

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