thread_info.h 5.4 KB

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