1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Based on arch/arm/include/asm/thread_info.h
4  *
5  * Copyright (C) 2002 Russell King.
6  * Copyright (C) 2012 ARM Ltd.
7  */
8 #ifndef __ASM_THREAD_INFO_H
9 #define __ASM_THREAD_INFO_H
10 
11 #ifdef __KERNEL__
12 
13 #include <linux/compiler.h>
14 
15 #ifndef __ASSEMBLY__
16 
17 struct task_struct;
18 
19 #include <asm/memory.h>
20 #include <asm/stack_pointer.h>
21 #include <asm/types.h>
22 
23 typedef unsigned long mm_segment_t;
24 
25 /*
26  * low level task data that entry.S needs immediate access to.
27  */
28 struct thread_info {
29 	unsigned long		flags;		/* low level flags */
30 	mm_segment_t		addr_limit;	/* address limit */
31 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
32 	u64			ttbr0;		/* saved TTBR0_EL1 */
33 #endif
34 	union {
35 		u64		preempt_count;	/* 0 => preemptible, <0 => bug */
36 		struct {
37 #ifdef CONFIG_CPU_BIG_ENDIAN
38 			u32	need_resched;
39 			u32	count;
40 #else
41 			u32	count;
42 			u32	need_resched;
43 #endif
44 		} preempt;
45 	};
46 };
47 
48 #define thread_saved_pc(tsk)	\
49 	((unsigned long)(tsk->thread.cpu_context.pc))
50 #define thread_saved_sp(tsk)	\
51 	((unsigned long)(tsk->thread.cpu_context.sp))
52 #define thread_saved_fp(tsk)	\
53 	((unsigned long)(tsk->thread.cpu_context.fp))
54 
55 void arch_setup_new_exec(void);
56 #define arch_setup_new_exec     arch_setup_new_exec
57 
58 void arch_release_task_struct(struct task_struct *tsk);
59 
60 #endif
61 
62 /*
63  * thread information flags:
64  *  TIF_SYSCALL_TRACE	- syscall trace active
65  *  TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace
66  *  TIF_SYSCALL_AUDIT	- syscall auditing
67  *  TIF_SECCOMP		- syscall secure computing
68  *  TIF_SYSCALL_EMU     - syscall emulation active
69  *  TIF_SIGPENDING	- signal pending
70  *  TIF_NEED_RESCHED	- rescheduling necessary
71  *  TIF_NOTIFY_RESUME	- callback before returning to user
72  */
73 #define TIF_SIGPENDING		0
74 #define TIF_NEED_RESCHED	1
75 #define TIF_NOTIFY_RESUME	2	/* callback before returning to user */
76 #define TIF_FOREIGN_FPSTATE	3	/* CPU's FP state is not current's */
77 #define TIF_UPROBE		4	/* uprobe breakpoint or singlestep */
78 #define TIF_FSCHECK		5	/* Check FS is USER_DS on return */
79 #define TIF_NOHZ		7
80 #define TIF_SYSCALL_TRACE	8
81 #define TIF_SYSCALL_AUDIT	9
82 #define TIF_SYSCALL_TRACEPOINT	10
83 #define TIF_SECCOMP		11
84 #define TIF_SYSCALL_EMU		12
85 #define TIF_MEMDIE		18	/* is terminating due to OOM killer */
86 #define TIF_FREEZE		19
87 #define TIF_RESTORE_SIGMASK	20
88 #define TIF_SINGLESTEP		21
89 #define TIF_32BIT		22	/* 32bit process */
90 #define TIF_SVE			23	/* Scalable Vector Extension in use */
91 #define TIF_SVE_VL_INHERIT	24	/* Inherit sve_vl_onexec across exec */
92 #define TIF_SSBD		25	/* Wants SSB mitigation */
93 
94 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
95 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
96 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
97 #define _TIF_FOREIGN_FPSTATE	(1 << TIF_FOREIGN_FPSTATE)
98 #define _TIF_NOHZ		(1 << TIF_NOHZ)
99 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
100 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
101 #define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
102 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
103 #define _TIF_SYSCALL_EMU	(1 << TIF_SYSCALL_EMU)
104 #define _TIF_UPROBE		(1 << TIF_UPROBE)
105 #define _TIF_FSCHECK		(1 << TIF_FSCHECK)
106 #define _TIF_32BIT		(1 << TIF_32BIT)
107 #define _TIF_SVE		(1 << TIF_SVE)
108 
109 #define _TIF_WORK_MASK		(_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
110 				 _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
111 				 _TIF_UPROBE | _TIF_FSCHECK)
112 
113 #define _TIF_SYSCALL_WORK	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
114 				 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
115 				 _TIF_NOHZ | _TIF_SYSCALL_EMU)
116 
117 #define INIT_THREAD_INFO(tsk)						\
118 {									\
119 	.flags		= _TIF_FOREIGN_FPSTATE,				\
120 	.preempt_count	= INIT_PREEMPT_COUNT,				\
121 	.addr_limit	= KERNEL_DS,					\
122 }
123 
124 #endif /* __KERNEL__ */
125 #endif /* __ASM_THREAD_INFO_H */
126