thread_info_64.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /* thread_info.h: sparc64 low-level thread information
  2. *
  3. * Copyright (C) 2002 David S. Miller (davem@redhat.com)
  4. */
  5. #ifndef _ASM_THREAD_INFO_H
  6. #define _ASM_THREAD_INFO_H
  7. #ifdef __KERNEL__
  8. #define NSWINS 7
  9. #define TI_FLAG_BYTE_FAULT_CODE 0
  10. #define TI_FLAG_FAULT_CODE_SHIFT 56
  11. #define TI_FLAG_BYTE_WSTATE 1
  12. #define TI_FLAG_WSTATE_SHIFT 48
  13. #define TI_FLAG_BYTE_CWP 2
  14. #define TI_FLAG_CWP_SHIFT 40
  15. #define TI_FLAG_BYTE_CURRENT_DS 3
  16. #define TI_FLAG_CURRENT_DS_SHIFT 32
  17. #define TI_FLAG_BYTE_FPDEPTH 4
  18. #define TI_FLAG_FPDEPTH_SHIFT 24
  19. #define TI_FLAG_BYTE_WSAVED 5
  20. #define TI_FLAG_WSAVED_SHIFT 16
  21. #include <asm/page.h>
  22. #ifndef __ASSEMBLY__
  23. #include <asm/ptrace.h>
  24. #include <asm/types.h>
  25. struct task_struct;
  26. struct exec_domain;
  27. struct thread_info {
  28. /* D$ line 1 */
  29. struct task_struct *task;
  30. unsigned long flags;
  31. __u8 fpsaved[7];
  32. __u8 status;
  33. unsigned long ksp;
  34. /* D$ line 2 */
  35. unsigned long fault_address;
  36. struct pt_regs *kregs;
  37. struct exec_domain *exec_domain;
  38. int preempt_count; /* 0 => preemptable, <0 => BUG */
  39. __u8 new_child;
  40. __u8 syscall_noerror;
  41. __u16 cpu;
  42. unsigned long *utraps;
  43. struct reg_window reg_window[NSWINS];
  44. unsigned long rwbuf_stkptrs[NSWINS];
  45. unsigned long gsr[7];
  46. unsigned long xfsr[7];
  47. struct restart_block restart_block;
  48. struct pt_regs *kern_una_regs;
  49. unsigned int kern_una_insn;
  50. unsigned long fpregs[0] __attribute__ ((aligned(64)));
  51. };
  52. #endif /* !(__ASSEMBLY__) */
  53. /* offsets into the thread_info struct for assembly code access */
  54. #define TI_TASK 0x00000000
  55. #define TI_FLAGS 0x00000008
  56. #define TI_FAULT_CODE (TI_FLAGS + TI_FLAG_BYTE_FAULT_CODE)
  57. #define TI_WSTATE (TI_FLAGS + TI_FLAG_BYTE_WSTATE)
  58. #define TI_CWP (TI_FLAGS + TI_FLAG_BYTE_CWP)
  59. #define TI_CURRENT_DS (TI_FLAGS + TI_FLAG_BYTE_CURRENT_DS)
  60. #define TI_FPDEPTH (TI_FLAGS + TI_FLAG_BYTE_FPDEPTH)
  61. #define TI_WSAVED (TI_FLAGS + TI_FLAG_BYTE_WSAVED)
  62. #define TI_FPSAVED 0x00000010
  63. #define TI_KSP 0x00000018
  64. #define TI_FAULT_ADDR 0x00000020
  65. #define TI_KREGS 0x00000028
  66. #define TI_EXEC_DOMAIN 0x00000030
  67. #define TI_PRE_COUNT 0x00000038
  68. #define TI_NEW_CHILD 0x0000003c
  69. #define TI_SYS_NOERROR 0x0000003d
  70. #define TI_CPU 0x0000003e
  71. #define TI_UTRAPS 0x00000040
  72. #define TI_REG_WINDOW 0x00000048
  73. #define TI_RWIN_SPTRS 0x000003c8
  74. #define TI_GSR 0x00000400
  75. #define TI_XFSR 0x00000438
  76. #define TI_RESTART_BLOCK 0x00000470
  77. #define TI_KUNA_REGS 0x000004a0
  78. #define TI_KUNA_INSN 0x000004a8
  79. #define TI_FPREGS 0x000004c0
  80. /* We embed this in the uppermost byte of thread_info->flags */
  81. #define FAULT_CODE_WRITE 0x01 /* Write access, implies D-TLB */
  82. #define FAULT_CODE_DTLB 0x02 /* Miss happened in D-TLB */
  83. #define FAULT_CODE_ITLB 0x04 /* Miss happened in I-TLB */
  84. #define FAULT_CODE_WINFIXUP 0x08 /* Miss happened during spill/fill */
  85. #define FAULT_CODE_BLKCOMMIT 0x10 /* Use blk-commit ASI in copy_page */
  86. #if PAGE_SHIFT == 13
  87. #define THREAD_SIZE (2*PAGE_SIZE)
  88. #define THREAD_SHIFT (PAGE_SHIFT + 1)
  89. #else /* PAGE_SHIFT == 13 */
  90. #define THREAD_SIZE PAGE_SIZE
  91. #define THREAD_SHIFT PAGE_SHIFT
  92. #endif /* PAGE_SHIFT == 13 */
  93. #define PREEMPT_ACTIVE 0x10000000
  94. /*
  95. * macros/functions for gaining access to the thread information structure
  96. */
  97. #ifndef __ASSEMBLY__
  98. #define INIT_THREAD_INFO(tsk) \
  99. { \
  100. .task = &tsk, \
  101. .flags = ((unsigned long)ASI_P) << TI_FLAG_CURRENT_DS_SHIFT, \
  102. .exec_domain = &default_exec_domain, \
  103. .preempt_count = INIT_PREEMPT_COUNT, \
  104. .restart_block = { \
  105. .fn = do_no_restart_syscall, \
  106. }, \
  107. }
  108. #define init_thread_info (init_thread_union.thread_info)
  109. #define init_stack (init_thread_union.stack)
  110. /* how to get the thread information struct from C */
  111. register struct thread_info *current_thread_info_reg asm("g6");
  112. #define current_thread_info() (current_thread_info_reg)
  113. /* thread information allocation */
  114. #if PAGE_SHIFT == 13
  115. #define __THREAD_INFO_ORDER 1
  116. #else /* PAGE_SHIFT == 13 */
  117. #define __THREAD_INFO_ORDER 0
  118. #endif /* PAGE_SHIFT == 13 */
  119. #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
  120. #ifdef CONFIG_DEBUG_STACK_USAGE
  121. #define alloc_thread_info(tsk) \
  122. ({ \
  123. struct thread_info *ret; \
  124. \
  125. ret = (struct thread_info *) \
  126. __get_free_pages(GFP_KERNEL, __THREAD_INFO_ORDER); \
  127. if (ret) \
  128. memset(ret, 0, PAGE_SIZE<<__THREAD_INFO_ORDER); \
  129. ret; \
  130. })
  131. #else
  132. #define alloc_thread_info(tsk) \
  133. ((struct thread_info *)__get_free_pages(GFP_KERNEL, __THREAD_INFO_ORDER))
  134. #endif
  135. #define free_thread_info(ti) \
  136. free_pages((unsigned long)(ti),__THREAD_INFO_ORDER)
  137. #define __thread_flag_byte_ptr(ti) \
  138. ((unsigned char *)(&((ti)->flags)))
  139. #define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
  140. #define get_thread_fault_code() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FAULT_CODE])
  141. #define set_thread_fault_code(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FAULT_CODE] = (val))
  142. #define get_thread_wstate() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE])
  143. #define set_thread_wstate(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE] = (val))
  144. #define get_thread_cwp() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP])
  145. #define set_thread_cwp(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP] = (val))
  146. #define get_thread_current_ds() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS])
  147. #define set_thread_current_ds(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS] = (val))
  148. #define get_thread_fpdepth() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH])
  149. #define set_thread_fpdepth(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH] = (val))
  150. #define get_thread_wsaved() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED])
  151. #define set_thread_wsaved(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED] = (val))
  152. #endif /* !(__ASSEMBLY__) */
  153. /*
  154. * Thread information flags, only 16 bits are available as we encode
  155. * other values into the upper 6 bytes.
  156. *
  157. * On trap return we need to test several values:
  158. *
  159. * user: need_resched, notify_resume, sigpending, wsaved
  160. * kernel: fpdepth
  161. *
  162. * So to check for work in the kernel case we simply load the fpdepth
  163. * byte out of the flags and test it. For the user case we encode the
  164. * lower 3 bytes of flags as follows:
  165. * ----------------------------------------
  166. * | wsaved | flags byte 1 | flags byte 2 |
  167. * ----------------------------------------
  168. * This optimizes the user test into:
  169. * ldx [%g6 + TI_FLAGS], REG1
  170. * sethi %hi(_TIF_USER_WORK_MASK), REG2
  171. * or REG2, %lo(_TIF_USER_WORK_MASK), REG2
  172. * andcc REG1, REG2, %g0
  173. * be,pt no_work_to_do
  174. * nop
  175. */
  176. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  177. #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
  178. #define TIF_SIGPENDING 2 /* signal pending */
  179. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  180. /* flag bit 4 is available */
  181. #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
  182. /* flag bit 6 is available */
  183. #define TIF_32BIT 7 /* 32-bit binary */
  184. /* flag bit 8 is available */
  185. #define TIF_SECCOMP 9 /* secure computing */
  186. #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
  187. #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
  188. /* NOTE: Thread flags >= 12 should be ones we have no interest
  189. * in using in assembly, else we can't use the mask as
  190. * an immediate value in instructions such as andcc.
  191. */
  192. /* flag bit 12 is available */
  193. #define TIF_MEMDIE 13 /* is terminating due to OOM killer */
  194. #define TIF_POLLING_NRFLAG 14
  195. #define TIF_FREEZE 15 /* is freezing for suspend */
  196. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  197. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  198. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  199. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  200. #define _TIF_UNALIGNED (1<<TIF_UNALIGNED)
  201. #define _TIF_32BIT (1<<TIF_32BIT)
  202. #define _TIF_SECCOMP (1<<TIF_SECCOMP)
  203. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  204. #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
  205. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  206. #define _TIF_FREEZE (1<<TIF_FREEZE)
  207. #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
  208. _TIF_DO_NOTIFY_RESUME_MASK | \
  209. _TIF_NEED_RESCHED)
  210. #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
  211. /*
  212. * Thread-synchronous status.
  213. *
  214. * This is different from the flags in that nobody else
  215. * ever touches our thread-synchronous status, so we don't
  216. * have to worry about atomic accesses.
  217. *
  218. * Note that there are only 8 bits available.
  219. */
  220. #define TS_RESTORE_SIGMASK 0x0001 /* restore signal mask in do_signal() */
  221. #ifndef __ASSEMBLY__
  222. #define HAVE_SET_RESTORE_SIGMASK 1
  223. static inline void set_restore_sigmask(void)
  224. {
  225. struct thread_info *ti = current_thread_info();
  226. ti->status |= TS_RESTORE_SIGMASK;
  227. set_bit(TIF_SIGPENDING, &ti->flags);
  228. }
  229. #endif /* !__ASSEMBLY__ */
  230. #endif /* __KERNEL__ */
  231. #endif /* _ASM_THREAD_INFO_H */