thread_info.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* thread_info.h: PowerPC low-level thread information
  2. * adapted from the i386 version by Paul Mackerras
  3. *
  4. * Copyright (C) 2002 David Howells (dhowells@redhat.com)
  5. * - Incorporating suggestions made by Linus Torvalds and Dave Miller
  6. */
  7. #ifndef _ASM_POWERPC_THREAD_INFO_H
  8. #define _ASM_POWERPC_THREAD_INFO_H
  9. #ifdef __KERNEL__
  10. /* We have 8k stacks on ppc32 and 16k on ppc64 */
  11. #if defined(CONFIG_PPC64)
  12. #define THREAD_SHIFT 14
  13. #elif defined(CONFIG_PPC_256K_PAGES)
  14. #define THREAD_SHIFT 15
  15. #else
  16. #define THREAD_SHIFT 13
  17. #endif
  18. #define THREAD_SIZE (1 << THREAD_SHIFT)
  19. #ifdef CONFIG_PPC64
  20. #define CURRENT_THREAD_INFO(dest, sp) stringify_in_c(clrrdi dest, sp, THREAD_SHIFT)
  21. #else
  22. #define CURRENT_THREAD_INFO(dest, sp) stringify_in_c(rlwinm dest, sp, 0, 0, 31-THREAD_SHIFT)
  23. #endif
  24. #ifndef __ASSEMBLY__
  25. #include <linux/cache.h>
  26. #include <asm/processor.h>
  27. #include <asm/page.h>
  28. #include <linux/stringify.h>
  29. #include <asm/accounting.h>
  30. /*
  31. * low level task data.
  32. */
  33. struct thread_info {
  34. struct task_struct *task; /* main task structure */
  35. int cpu; /* cpu we're on */
  36. int preempt_count; /* 0 => preemptable,
  37. <0 => BUG */
  38. unsigned long local_flags; /* private flags for thread */
  39. #ifdef CONFIG_LIVEPATCH
  40. unsigned long *livepatch_sp;
  41. #endif
  42. #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32)
  43. struct cpu_accounting_data accounting;
  44. #endif
  45. /* low level flags - has atomic operations done on it */
  46. unsigned long flags ____cacheline_aligned_in_smp;
  47. };
  48. /*
  49. * macros/functions for gaining access to the thread information structure
  50. */
  51. #define INIT_THREAD_INFO(tsk) \
  52. { \
  53. .task = &tsk, \
  54. .cpu = 0, \
  55. .preempt_count = INIT_PREEMPT_COUNT, \
  56. .flags = 0, \
  57. }
  58. #define init_thread_info (init_thread_union.thread_info)
  59. #define init_stack (init_thread_union.stack)
  60. #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
  61. /* how to get the thread information struct from C */
  62. static inline struct thread_info *current_thread_info(void)
  63. {
  64. unsigned long val;
  65. asm (CURRENT_THREAD_INFO(%0,1) : "=r" (val));
  66. return (struct thread_info *)val;
  67. }
  68. #endif /* __ASSEMBLY__ */
  69. /*
  70. * thread information flag bit numbers
  71. */
  72. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  73. #define TIF_SIGPENDING 1 /* signal pending */
  74. #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
  75. #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
  76. TIF_NEED_RESCHED */
  77. #define TIF_32BIT 4 /* 32 bit binary */
  78. #define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */
  79. #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
  80. #define TIF_SINGLESTEP 8 /* singlestepping active */
  81. #define TIF_NOHZ 9 /* in adaptive nohz mode */
  82. #define TIF_SECCOMP 10 /* secure computing */
  83. #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
  84. #define TIF_NOERROR 12 /* Force successful syscall return */
  85. #define TIF_NOTIFY_RESUME 13 /* callback before returning to user */
  86. #define TIF_UPROBE 14 /* breakpointed or single-stepping */
  87. #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
  88. #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
  89. for stack store? */
  90. #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
  91. #if defined(CONFIG_PPC64)
  92. #define TIF_ELF2ABI 18 /* function descriptors must die! */
  93. #endif
  94. /* as above, but as bit values */
  95. #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
  96. #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
  97. #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
  98. #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
  99. #define _TIF_32BIT (1<<TIF_32BIT)
  100. #define _TIF_RESTORE_TM (1<<TIF_RESTORE_TM)
  101. #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  102. #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
  103. #define _TIF_SECCOMP (1<<TIF_SECCOMP)
  104. #define _TIF_RESTOREALL (1<<TIF_RESTOREALL)
  105. #define _TIF_NOERROR (1<<TIF_NOERROR)
  106. #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
  107. #define _TIF_UPROBE (1<<TIF_UPROBE)
  108. #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
  109. #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
  110. #define _TIF_NOHZ (1<<TIF_NOHZ)
  111. #define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
  112. _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
  113. _TIF_NOHZ)
  114. #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
  115. _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
  116. _TIF_RESTORE_TM)
  117. #define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
  118. /* Bits in local_flags */
  119. /* Don't move TLF_NAPPING without adjusting the code in entry_32.S */
  120. #define TLF_NAPPING 0 /* idle thread enabled NAP mode */
  121. #define TLF_SLEEPING 1 /* suspend code enabled SLEEP mode */
  122. #define TLF_LAZY_MMU 3 /* tlb_batch is active */
  123. #define TLF_RUNLATCH 4 /* Is the runlatch enabled? */
  124. #define _TLF_NAPPING (1 << TLF_NAPPING)
  125. #define _TLF_SLEEPING (1 << TLF_SLEEPING)
  126. #define _TLF_LAZY_MMU (1 << TLF_LAZY_MMU)
  127. #define _TLF_RUNLATCH (1 << TLF_RUNLATCH)
  128. #ifndef __ASSEMBLY__
  129. static inline bool test_thread_local_flags(unsigned int flags)
  130. {
  131. struct thread_info *ti = current_thread_info();
  132. return (ti->local_flags & flags) != 0;
  133. }
  134. #ifdef CONFIG_PPC64
  135. #define is_32bit_task() (test_thread_flag(TIF_32BIT))
  136. #else
  137. #define is_32bit_task() (1)
  138. #endif
  139. #if defined(CONFIG_PPC64)
  140. #define is_elf2_task() (test_thread_flag(TIF_ELF2ABI))
  141. #else
  142. #define is_elf2_task() (0)
  143. #endif
  144. #endif /* !__ASSEMBLY__ */
  145. #endif /* __KERNEL__ */
  146. #endif /* _ASM_POWERPC_THREAD_INFO_H */