thread_info.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * thread_info.h: LoongArch low-level thread information
  4. *
  5. * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
  6. */
  7. #ifndef _ASM_THREAD_INFO_H
  8. #define _ASM_THREAD_INFO_H
  9. #ifdef __KERNEL__
  10. #ifndef __ASSEMBLER__
  11. #include <asm/processor.h>
  12. /*
  13. * low level task data that entry.S needs immediate access to
  14. * - this struct should fit entirely inside of one cache line
  15. * - this struct shares the supervisor stack pages
  16. * - if the contents of this structure are changed, the assembly constants
  17. * must also be changed
  18. */
  19. struct thread_info {
  20. struct task_struct *task; /* main task structure */
  21. unsigned long flags; /* low level flags */
  22. unsigned long tp_value; /* thread pointer */
  23. __u32 cpu; /* current CPU */
  24. int preempt_count; /* 0 => preemptible, <0 => BUG */
  25. struct pt_regs *regs;
  26. unsigned long syscall; /* syscall number */
  27. unsigned long syscall_work; /* SYSCALL_WORK_ flags */
  28. };
  29. /*
  30. * macros/functions for gaining access to the thread information structure
  31. */
  32. #define INIT_THREAD_INFO(tsk) \
  33. { \
  34. .task = &tsk, \
  35. .flags = _TIF_FIXADE, \
  36. .cpu = 0, \
  37. .preempt_count = INIT_PREEMPT_COUNT, \
  38. }
  39. /* How to get the thread information struct from C. */
  40. register struct thread_info *__current_thread_info __asm__("$tp");
  41. static inline struct thread_info *current_thread_info(void)
  42. {
  43. return __current_thread_info;
  44. }
  45. register unsigned long current_stack_pointer __asm__("$sp");
  46. #endif /* !__ASSEMBLER__ */
  47. /* thread information allocation */
  48. #define THREAD_SIZE SZ_16K
  49. #define THREAD_MASK (THREAD_SIZE - 1UL)
  50. #define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE)
  51. /*
  52. * thread information flags
  53. * - these are process state flags that various assembly files may need to
  54. * access
  55. * - pending work-to-be-done flags are in LSW
  56. * - other flags in MSW
  57. *
  58. * Tell the generic TIF infrastructure which special bits loongarch supports
  59. */
  60. #define HAVE_TIF_NEED_RESCHED_LAZY
  61. #define HAVE_TIF_RESTORE_SIGMASK
  62. #include <asm-generic/thread_info_tif.h>
  63. /* Architecture specific bits */
  64. #define TIF_NOHZ 16 /* in adaptive nohz mode */
  65. #define TIF_USEDFPU 17 /* FPU was used by this task this quantum (SMP) */
  66. #define TIF_USEDSIMD 18 /* SIMD has been used this quantum */
  67. #define TIF_FIXADE 19 /* Fix address errors in software */
  68. #define TIF_LOGADE 20 /* Log address errors to syslog */
  69. #define TIF_32BIT_REGS 21 /* 32-bit general purpose registers */
  70. #define TIF_32BIT_ADDR 22 /* 32-bit address space */
  71. #define TIF_LOAD_WATCH 23 /* If set, load watch registers */
  72. #define TIF_SINGLESTEP 24 /* Single Step */
  73. #define TIF_LSX_CTX_LIVE 25 /* LSX context must be preserved */
  74. #define TIF_LASX_CTX_LIVE 26 /* LASX context must be preserved */
  75. #define TIF_USEDLBT 27 /* LBT was used by this task this quantum (SMP) */
  76. #define TIF_LBT_CTX_LIVE 28 /* LBT context must be preserved */
  77. #define _TIF_NOHZ BIT(TIF_NOHZ)
  78. #define _TIF_USEDFPU BIT(TIF_USEDFPU)
  79. #define _TIF_USEDSIMD BIT(TIF_USEDSIMD)
  80. #define _TIF_FIXADE BIT(TIF_FIXADE)
  81. #define _TIF_LOGADE BIT(TIF_LOGADE)
  82. #define _TIF_32BIT_REGS BIT(TIF_32BIT_REGS)
  83. #define _TIF_32BIT_ADDR BIT(TIF_32BIT_ADDR)
  84. #define _TIF_LOAD_WATCH BIT(TIF_LOAD_WATCH)
  85. #define _TIF_SINGLESTEP BIT(TIF_SINGLESTEP)
  86. #define _TIF_LSX_CTX_LIVE BIT(TIF_LSX_CTX_LIVE)
  87. #define _TIF_LASX_CTX_LIVE BIT(TIF_LASX_CTX_LIVE)
  88. #define _TIF_USEDLBT BIT(TIF_USEDLBT)
  89. #define _TIF_LBT_CTX_LIVE BIT(TIF_LBT_CTX_LIVE)
  90. #endif /* __KERNEL__ */
  91. #endif /* _ASM_THREAD_INFO_H */