thread_info.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2009 Chen Liqin <liqin.chen@sunplusct.com>
  4. * Copyright (C) 2012 Regents of the University of California
  5. * Copyright (C) 2017 SiFive
  6. */
  7. #ifndef _ASM_RISCV_THREAD_INFO_H
  8. #define _ASM_RISCV_THREAD_INFO_H
  9. #include <asm/page.h>
  10. #include <linux/const.h>
  11. #ifdef CONFIG_KASAN
  12. #define KASAN_STACK_ORDER 1
  13. #else
  14. #define KASAN_STACK_ORDER 0
  15. #endif
  16. /* thread information allocation */
  17. #ifdef CONFIG_64BIT
  18. #define THREAD_SIZE_ORDER (2 + KASAN_STACK_ORDER)
  19. #else
  20. #define THREAD_SIZE_ORDER (1 + KASAN_STACK_ORDER)
  21. #endif
  22. #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
  23. #ifndef __ASSEMBLY__
  24. #include <asm/processor.h>
  25. #include <asm/csr.h>
  26. /*
  27. * low level task data that entry.S needs immediate access to
  28. * - this struct should fit entirely inside of one cache line
  29. * - if the members of this struct changes, the assembly constants
  30. * in asm-offsets.c must be updated accordingly
  31. * - thread_info is included in task_struct at an offset of 0. This means that
  32. * tp points to both thread_info and task_struct.
  33. */
  34. struct thread_info {
  35. unsigned long flags; /* low level flags */
  36. int preempt_count; /* 0=>preemptible, <0=>BUG */
  37. /*
  38. * These stack pointers are overwritten on every system call or
  39. * exception. SP is also saved to the stack it can be recovered when
  40. * overwritten.
  41. */
  42. long kernel_sp; /* Kernel stack pointer */
  43. long user_sp; /* User stack pointer */
  44. int cpu;
  45. };
  46. /*
  47. * macros/functions for gaining access to the thread information structure
  48. *
  49. * preempt_count needs to be 1 initially, until the scheduler is functional.
  50. */
  51. #define INIT_THREAD_INFO(tsk) \
  52. { \
  53. .flags = 0, \
  54. .preempt_count = INIT_PREEMPT_COUNT, \
  55. }
  56. #endif /* !__ASSEMBLY__ */
  57. /*
  58. * thread information flags
  59. * - these are process state flags that various assembly files may need to
  60. * access
  61. * - pending work-to-be-done flags are in lowest half-word
  62. * - other flags in upper half-word(s)
  63. */
  64. #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
  65. #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
  66. #define TIF_SIGPENDING 2 /* signal pending */
  67. #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
  68. #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
  69. #define TIF_MEMDIE 5 /* is terminating due to OOM killer */
  70. #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
  71. #define TIF_SYSCALL_AUDIT 7 /* syscall auditing */
  72. #define TIF_SECCOMP 8 /* syscall secure computing */
  73. #define TIF_UPROBE 9 /* uprobe breakpoint or singlestep */
  74. #define TIF_32BIT 11 /* 32bit process */
  75. #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
  76. #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
  77. #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
  78. #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
  79. #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
  80. #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
  81. #define _TIF_SECCOMP (1 << TIF_SECCOMP)
  82. #define _TIF_UPROBE (1 << TIF_UPROBE)
  83. #define _TIF_WORK_MASK \
  84. (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_UPROBE)
  85. #define _TIF_SYSCALL_WORK \
  86. (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT | _TIF_SYSCALL_AUDIT | \
  87. _TIF_SECCOMP)
  88. #endif /* _ASM_RISCV_THREAD_INFO_H */