thread_info.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * arch/arm/include/asm/thread_info.h
  4. *
  5. * Copyright (C) 2002 Russell King.
  6. */
  7. #ifndef __ASM_ARM_THREAD_INFO_H
  8. #define __ASM_ARM_THREAD_INFO_H
  9. #ifdef __KERNEL__
  10. #include <linux/compiler.h>
  11. #include <asm/fpstate.h>
  12. #include <asm/page.h>
  13. #ifdef CONFIG_KASAN
  14. /*
  15. * KASan uses a lot of extra stack space so the thread size order needs to
  16. * be increased.
  17. */
  18. #define THREAD_SIZE_ORDER 2
  19. #else
  20. #define THREAD_SIZE_ORDER 1
  21. #endif
  22. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  23. #define THREAD_START_SP (THREAD_SIZE - 8)
  24. #ifdef CONFIG_VMAP_STACK
  25. #define THREAD_ALIGN (2 * THREAD_SIZE)
  26. #else
  27. #define THREAD_ALIGN THREAD_SIZE
  28. #endif
  29. #define OVERFLOW_STACK_SIZE SZ_4K
  30. #ifndef __ASSEMBLY__
  31. struct task_struct;
  32. DECLARE_PER_CPU(struct task_struct *, __entry_task);
  33. #include <asm/types.h>
  34. struct cpu_context_save {
  35. __u32 r4;
  36. __u32 r5;
  37. __u32 r6;
  38. __u32 r7;
  39. __u32 r8;
  40. __u32 r9;
  41. __u32 sl;
  42. __u32 fp;
  43. __u32 sp;
  44. __u32 pc;
  45. __u32 extra[2]; /* Xscale 'acc' register, etc */
  46. };
  47. /*
  48. * low level task data that entry.S needs immediate access to.
  49. * __switch_to() assumes cpu_context follows immediately after cpu_domain.
  50. */
  51. struct thread_info {
  52. unsigned long flags; /* low level flags */
  53. int preempt_count; /* 0 => preemptable, <0 => bug */
  54. __u32 cpu; /* cpu */
  55. __u32 cpu_domain; /* cpu domain */
  56. struct cpu_context_save cpu_context; /* cpu context */
  57. __u32 abi_syscall; /* ABI type and syscall nr */
  58. __u8 used_cp[16]; /* thread used copro */
  59. unsigned long tp_value[2]; /* TLS registers */
  60. union fp_state fpstate __attribute__((aligned(8)));
  61. union vfp_state vfpstate;
  62. #ifdef CONFIG_ARM_THUMBEE
  63. unsigned long thumbee_state; /* ThumbEE Handler Base register */
  64. #endif
  65. };
  66. #define INIT_THREAD_INFO(tsk) \
  67. { \
  68. .flags = 0, \
  69. .preempt_count = INIT_PREEMPT_COUNT, \
  70. }
  71. static inline struct task_struct *thread_task(struct thread_info* ti)
  72. {
  73. return (struct task_struct *)ti;
  74. }
  75. #define thread_saved_pc(tsk) \
  76. ((unsigned long)(task_thread_info(tsk)->cpu_context.pc))
  77. #define thread_saved_sp(tsk) \
  78. ((unsigned long)(task_thread_info(tsk)->cpu_context.sp))
  79. #ifndef CONFIG_THUMB2_KERNEL
  80. #define thread_saved_fp(tsk) \
  81. ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
  82. #else
  83. #define thread_saved_fp(tsk) \
  84. ((unsigned long)(task_thread_info(tsk)->cpu_context.r7))
  85. #endif
  86. extern void iwmmxt_task_disable(struct thread_info *);
  87. extern void iwmmxt_task_copy(struct thread_info *, void *);
  88. extern void iwmmxt_task_restore(struct thread_info *, void *);
  89. extern void iwmmxt_task_release(struct thread_info *);
  90. extern void iwmmxt_task_switch(struct thread_info *);
  91. extern void vfp_sync_hwstate(struct thread_info *);
  92. extern void vfp_flush_hwstate(struct thread_info *);
  93. struct user_vfp;
  94. struct user_vfp_exc;
  95. extern int vfp_preserve_user_clear_hwstate(struct user_vfp *,
  96. struct user_vfp_exc *);
  97. extern int vfp_restore_user_hwstate(struct user_vfp *,
  98. struct user_vfp_exc *);
  99. #endif
  100. /*
  101. * thread information flags:
  102. * TIF_USEDFPU - FPU was used by this task this quantum (SMP)
  103. * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED
  104. *
  105. * Any bit in the range of 0..15 will cause do_work_pending() to be invoked.
  106. */
  107. #define TIF_SIGPENDING 0 /* signal pending */
  108. #define TIF_NEED_RESCHED 1 /* rescheduling necessary */
  109. #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
  110. #define TIF_UPROBE 3 /* breakpointed or singlestepping */
  111. #define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */
  112. #define TIF_USING_IWMMXT 17
  113. #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
  114. #define TIF_RESTORE_SIGMASK 19
  115. #define TIF_SYSCALL_TRACE 20 /* syscall trace active */
  116. #define TIF_SYSCALL_AUDIT 21 /* syscall auditing active */
  117. #define TIF_SYSCALL_TRACEPOINT 22 /* syscall tracepoint instrumentation */
  118. #define TIF_SECCOMP 23 /* seccomp syscall filtering active */
  119. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  120. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  121. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  122. #define _TIF_UPROBE (1 << TIF_UPROBE)
  123. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  124. #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
  125. #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
  126. #define _TIF_SECCOMP (1 << TIF_SECCOMP)
  127. #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
  128. #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
  129. /* Checks for any syscall work in entry-common.S */
  130. #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
  131. _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
  132. /*
  133. * Change these and you break ASM code in entry-common.S
  134. */
  135. #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
  136. _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
  137. _TIF_NOTIFY_SIGNAL)
  138. #endif /* __KERNEL__ */
  139. #endif /* __ASM_ARM_THREAD_INFO_H */