1 /* SPDX-License-Identifier: GPL-2.0 */
3 * thread_info.h: LoongArch low-level thread information
5 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
8 #ifndef _ASM_THREAD_INFO_H
9 #define _ASM_THREAD_INFO_H
15 #include <asm/processor.h>
18 * low level task data that entry.S needs immediate access to
19 * - this struct should fit entirely inside of one cache line
20 * - this struct shares the supervisor stack pages
21 * - if the contents of this structure are changed, the assembly constants
22 * must also be changed
25 struct task_struct
*task
; /* main task structure */
26 unsigned long flags
; /* low level flags */
27 unsigned long tp_value
; /* thread pointer */
28 __u32 cpu
; /* current CPU */
29 int preempt_count
; /* 0 => preemptible, <0 => BUG */
31 unsigned long syscall
; /* syscall number */
32 unsigned long syscall_work
; /* SYSCALL_WORK_ flags */
36 * macros/functions for gaining access to the thread information structure
38 #define INIT_THREAD_INFO(tsk) \
41 .flags = _TIF_FIXADE, \
43 .preempt_count = INIT_PREEMPT_COUNT, \
46 /* How to get the thread information struct from C. */
47 register struct thread_info
*__current_thread_info
__asm__("$tp");
49 static inline struct thread_info
*current_thread_info(void)
51 return __current_thread_info
;
54 register unsigned long current_stack_pointer
__asm__("$sp");
56 #endif /* !__ASSEMBLY__ */
58 /* thread information allocation */
59 #define THREAD_SIZE SZ_16K
60 #define THREAD_MASK (THREAD_SIZE - 1UL)
61 #define THREAD_SIZE_ORDER ilog2(THREAD_SIZE / PAGE_SIZE)
63 * thread information flags
64 * - these are process state flags that various assembly files may need to
66 * - pending work-to-be-done flags are in LSW
67 * - other flags in MSW
69 #define TIF_NEED_RESCHED 0 /* rescheduling necessary */
70 #define TIF_NEED_RESCHED_LAZY 1 /* lazy rescheduling necessary */
71 #define TIF_SIGPENDING 2 /* signal pending */
72 #define TIF_NOTIFY_RESUME 3 /* callback before returning to user */
73 #define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */
74 #define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
75 #define TIF_NOHZ 6 /* in adaptive nohz mode */
76 #define TIF_UPROBE 7 /* breakpointed or singlestepping */
77 #define TIF_USEDFPU 8 /* FPU was used by this task this quantum (SMP) */
78 #define TIF_USEDSIMD 9 /* SIMD has been used this quantum */
79 #define TIF_MEMDIE 10 /* is terminating due to OOM killer */
80 #define TIF_FIXADE 11 /* Fix address errors in software */
81 #define TIF_LOGADE 12 /* Log address errors to syslog */
82 #define TIF_32BIT_REGS 13 /* 32-bit general purpose registers */
83 #define TIF_32BIT_ADDR 14 /* 32-bit address space */
84 #define TIF_LOAD_WATCH 15 /* If set, load watch registers */
85 #define TIF_SINGLESTEP 16 /* Single Step */
86 #define TIF_LSX_CTX_LIVE 17 /* LSX context must be preserved */
87 #define TIF_LASX_CTX_LIVE 18 /* LASX context must be preserved */
88 #define TIF_USEDLBT 19 /* LBT was used by this task this quantum (SMP) */
89 #define TIF_LBT_CTX_LIVE 20 /* LBT context must be preserved */
90 #define TIF_PATCH_PENDING 21 /* pending live patching update */
92 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
93 #define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY)
94 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
95 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
96 #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
97 #define _TIF_NOHZ (1<<TIF_NOHZ)
98 #define _TIF_UPROBE (1<<TIF_UPROBE)
99 #define _TIF_USEDFPU (1<<TIF_USEDFPU)
100 #define _TIF_USEDSIMD (1<<TIF_USEDSIMD)
101 #define _TIF_FIXADE (1<<TIF_FIXADE)
102 #define _TIF_LOGADE (1<<TIF_LOGADE)
103 #define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS)
104 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
105 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
106 #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
107 #define _TIF_LSX_CTX_LIVE (1<<TIF_LSX_CTX_LIVE)
108 #define _TIF_LASX_CTX_LIVE (1<<TIF_LASX_CTX_LIVE)
109 #define _TIF_USEDLBT (1<<TIF_USEDLBT)
110 #define _TIF_LBT_CTX_LIVE (1<<TIF_LBT_CTX_LIVE)
111 #define _TIF_PATCH_PENDING (1<<TIF_PATCH_PENDING)
113 #endif /* __KERNEL__ */
114 #endif /* _ASM_THREAD_INFO_H */