0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _ASM_X86_THREAD_INFO_H
0009 #define _ASM_X86_THREAD_INFO_H
0010
0011 #include <linux/compiler.h>
0012 #include <asm/page.h>
0013 #include <asm/percpu.h>
0014 #include <asm/types.h>
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifdef CONFIG_X86_32
0037 # ifdef CONFIG_VM86
0038 # define TOP_OF_KERNEL_STACK_PADDING 16
0039 # else
0040 # define TOP_OF_KERNEL_STACK_PADDING 8
0041 # endif
0042 #else
0043 # define TOP_OF_KERNEL_STACK_PADDING 0
0044 #endif
0045
0046
0047
0048
0049
0050
0051 #ifndef __ASSEMBLY__
0052 struct task_struct;
0053 #include <asm/cpufeature.h>
0054 #include <linux/atomic.h>
0055
0056 struct thread_info {
0057 unsigned long flags;
0058 unsigned long syscall_work;
0059 u32 status;
0060 #ifdef CONFIG_SMP
0061 u32 cpu;
0062 #endif
0063 };
0064
0065 #define INIT_THREAD_INFO(tsk) \
0066 { \
0067 .flags = 0, \
0068 }
0069
0070 #else
0071
0072 #include <asm/asm-offsets.h>
0073
0074 #endif
0075
0076
0077
0078
0079
0080
0081 #define TIF_NOTIFY_RESUME 1
0082 #define TIF_SIGPENDING 2
0083 #define TIF_NEED_RESCHED 3
0084 #define TIF_SINGLESTEP 4
0085 #define TIF_SSBD 5
0086 #define TIF_SPEC_IB 9
0087 #define TIF_SPEC_L1D_FLUSH 10
0088 #define TIF_USER_RETURN_NOTIFY 11
0089 #define TIF_UPROBE 12
0090 #define TIF_PATCH_PENDING 13
0091 #define TIF_NEED_FPU_LOAD 14
0092 #define TIF_NOCPUID 15
0093 #define TIF_NOTSC 16
0094 #define TIF_NOTIFY_SIGNAL 17
0095 #define TIF_MEMDIE 20
0096 #define TIF_POLLING_NRFLAG 21
0097 #define TIF_IO_BITMAP 22
0098 #define TIF_SPEC_FORCE_UPDATE 23
0099 #define TIF_FORCED_TF 24
0100 #define TIF_BLOCKSTEP 25
0101 #define TIF_LAZY_MMU_UPDATES 27
0102 #define TIF_ADDR32 29
0103
0104 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
0105 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
0106 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
0107 #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
0108 #define _TIF_SSBD (1 << TIF_SSBD)
0109 #define _TIF_SPEC_IB (1 << TIF_SPEC_IB)
0110 #define _TIF_SPEC_L1D_FLUSH (1 << TIF_SPEC_L1D_FLUSH)
0111 #define _TIF_USER_RETURN_NOTIFY (1 << TIF_USER_RETURN_NOTIFY)
0112 #define _TIF_UPROBE (1 << TIF_UPROBE)
0113 #define _TIF_PATCH_PENDING (1 << TIF_PATCH_PENDING)
0114 #define _TIF_NEED_FPU_LOAD (1 << TIF_NEED_FPU_LOAD)
0115 #define _TIF_NOCPUID (1 << TIF_NOCPUID)
0116 #define _TIF_NOTSC (1 << TIF_NOTSC)
0117 #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL)
0118 #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
0119 #define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)
0120 #define _TIF_SPEC_FORCE_UPDATE (1 << TIF_SPEC_FORCE_UPDATE)
0121 #define _TIF_FORCED_TF (1 << TIF_FORCED_TF)
0122 #define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP)
0123 #define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES)
0124 #define _TIF_ADDR32 (1 << TIF_ADDR32)
0125
0126
0127 #define _TIF_WORK_CTXSW_BASE \
0128 (_TIF_NOCPUID | _TIF_NOTSC | _TIF_BLOCKSTEP | \
0129 _TIF_SSBD | _TIF_SPEC_FORCE_UPDATE)
0130
0131
0132
0133
0134 #ifdef CONFIG_SMP
0135 # define _TIF_WORK_CTXSW (_TIF_WORK_CTXSW_BASE | _TIF_SPEC_IB)
0136 #else
0137 # define _TIF_WORK_CTXSW (_TIF_WORK_CTXSW_BASE)
0138 #endif
0139
0140 #ifdef CONFIG_X86_IOPL_IOPERM
0141 # define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW| _TIF_USER_RETURN_NOTIFY | \
0142 _TIF_IO_BITMAP)
0143 #else
0144 # define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW| _TIF_USER_RETURN_NOTIFY)
0145 #endif
0146
0147 #define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW)
0148
0149 #define STACK_WARN (THREAD_SIZE/8)
0150
0151
0152
0153
0154
0155
0156 #ifndef __ASSEMBLY__
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167 static inline int arch_within_stack_frames(const void * const stack,
0168 const void * const stackend,
0169 const void *obj, unsigned long len)
0170 {
0171 #if defined(CONFIG_FRAME_POINTER)
0172 const void *frame = NULL;
0173 const void *oldframe;
0174
0175 oldframe = __builtin_frame_address(1);
0176 if (oldframe)
0177 frame = __builtin_frame_address(2);
0178
0179
0180
0181
0182
0183
0184 while (stack <= frame && frame < stackend) {
0185
0186
0187
0188
0189
0190
0191 if (obj + len <= frame)
0192 return obj >= oldframe + 2 * sizeof(void *) ?
0193 GOOD_FRAME : BAD_STACK;
0194 oldframe = frame;
0195 frame = *(const void * const *)frame;
0196 }
0197 return BAD_STACK;
0198 #else
0199 return NOT_STACK;
0200 #endif
0201 }
0202
0203 #endif
0204
0205
0206
0207
0208
0209
0210
0211
0212 #define TS_COMPAT 0x0002
0213
0214 #ifndef __ASSEMBLY__
0215 #ifdef CONFIG_COMPAT
0216 #define TS_I386_REGS_POKED 0x0004
0217
0218 #define arch_set_restart_data(restart) \
0219 do { restart->arch_data = current_thread_info()->status; } while (0)
0220
0221 #endif
0222
0223 #ifdef CONFIG_X86_32
0224 #define in_ia32_syscall() true
0225 #else
0226 #define in_ia32_syscall() (IS_ENABLED(CONFIG_IA32_EMULATION) && \
0227 current_thread_info()->status & TS_COMPAT)
0228 #endif
0229
0230 extern void arch_task_cache_init(void);
0231 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
0232 extern void arch_release_task_struct(struct task_struct *tsk);
0233 extern void arch_setup_new_exec(void);
0234 #define arch_setup_new_exec arch_setup_new_exec
0235 #endif
0236
0237 #endif