0001
0002
0003
0004
0005
0006
0007 #ifndef _ASM_THREAD_INFO_H
0008 #define _ASM_THREAD_INFO_H
0009
0010 #ifdef __KERNEL__
0011
0012 #define NSWINS 7
0013
0014 #define TI_FLAG_BYTE_FAULT_CODE 0
0015 #define TI_FLAG_FAULT_CODE_SHIFT 56
0016 #define TI_FLAG_BYTE_WSTATE 1
0017 #define TI_FLAG_WSTATE_SHIFT 48
0018 #define TI_FLAG_BYTE_NOERROR 2
0019 #define TI_FLAG_BYTE_NOERROR_SHIFT 40
0020 #define TI_FLAG_BYTE_FPDEPTH 3
0021 #define TI_FLAG_FPDEPTH_SHIFT 32
0022 #define TI_FLAG_BYTE_CWP 4
0023 #define TI_FLAG_CWP_SHIFT 24
0024 #define TI_FLAG_BYTE_WSAVED 5
0025 #define TI_FLAG_WSAVED_SHIFT 16
0026
0027 #include <asm/page.h>
0028
0029 #ifndef __ASSEMBLY__
0030
0031 #include <asm/ptrace.h>
0032 #include <asm/types.h>
0033
0034 struct task_struct;
0035
0036 struct thread_info {
0037
0038 struct task_struct *task;
0039 unsigned long flags;
0040 __u8 fpsaved[7];
0041 __u8 status;
0042 unsigned long ksp;
0043
0044
0045 unsigned long fault_address;
0046 struct pt_regs *kregs;
0047 int preempt_count;
0048 __u8 new_child;
0049 __u8 __pad;
0050 __u16 cpu;
0051
0052 unsigned long *utraps;
0053
0054 struct reg_window reg_window[NSWINS];
0055 unsigned long rwbuf_stkptrs[NSWINS];
0056
0057 unsigned long gsr[7];
0058 unsigned long xfsr[7];
0059
0060 struct pt_regs *kern_una_regs;
0061 unsigned int kern_una_insn;
0062
0063 unsigned long fpregs[(7 * 256) / sizeof(unsigned long)]
0064 __attribute__ ((aligned(64)));
0065 };
0066
0067 #endif
0068
0069
0070 #define TI_TASK 0x00000000
0071 #define TI_FLAGS 0x00000008
0072 #define TI_FAULT_CODE (TI_FLAGS + TI_FLAG_BYTE_FAULT_CODE)
0073 #define TI_WSTATE (TI_FLAGS + TI_FLAG_BYTE_WSTATE)
0074 #define TI_CWP (TI_FLAGS + TI_FLAG_BYTE_CWP)
0075 #define TI_FPDEPTH (TI_FLAGS + TI_FLAG_BYTE_FPDEPTH)
0076 #define TI_WSAVED (TI_FLAGS + TI_FLAG_BYTE_WSAVED)
0077 #define TI_SYS_NOERROR (TI_FLAGS + TI_FLAG_BYTE_NOERROR)
0078 #define TI_FPSAVED 0x00000010
0079 #define TI_KSP 0x00000018
0080 #define TI_FAULT_ADDR 0x00000020
0081 #define TI_KREGS 0x00000028
0082 #define TI_PRE_COUNT 0x00000030
0083 #define TI_NEW_CHILD 0x00000034
0084 #define TI_CPU 0x00000036
0085 #define TI_UTRAPS 0x00000038
0086 #define TI_REG_WINDOW 0x00000040
0087 #define TI_RWIN_SPTRS 0x000003c0
0088 #define TI_GSR 0x000003f8
0089 #define TI_XFSR 0x00000430
0090 #define TI_KUNA_REGS 0x00000468
0091 #define TI_KUNA_INSN 0x00000470
0092 #define TI_FPREGS 0x00000480
0093
0094
0095 #define FAULT_CODE_WRITE 0x01
0096 #define FAULT_CODE_DTLB 0x02
0097 #define FAULT_CODE_ITLB 0x04
0098 #define FAULT_CODE_WINFIXUP 0x08
0099 #define FAULT_CODE_BLKCOMMIT 0x10
0100 #define FAULT_CODE_BAD_RA 0x20
0101
0102 #if PAGE_SHIFT == 13
0103 #define THREAD_SIZE (2*PAGE_SIZE)
0104 #define THREAD_SHIFT (PAGE_SHIFT + 1)
0105 #else
0106 #define THREAD_SIZE PAGE_SIZE
0107 #define THREAD_SHIFT PAGE_SHIFT
0108 #endif
0109
0110
0111
0112
0113 #ifndef __ASSEMBLY__
0114
0115 #define INIT_THREAD_INFO(tsk) \
0116 { \
0117 .task = &tsk, \
0118 .preempt_count = INIT_PREEMPT_COUNT, \
0119 .kregs = (struct pt_regs *)(init_stack+THREAD_SIZE)-1 \
0120 }
0121
0122
0123 #ifndef BUILD_VDSO
0124 register struct thread_info *current_thread_info_reg asm("g6");
0125 #define current_thread_info() (current_thread_info_reg)
0126 #else
0127 extern struct thread_info *current_thread_info(void);
0128 #endif
0129
0130
0131 #if PAGE_SHIFT == 13
0132 #define THREAD_SIZE_ORDER 1
0133 #else
0134 #define THREAD_SIZE_ORDER 0
0135 #endif
0136
0137 #define __thread_flag_byte_ptr(ti) \
0138 ((unsigned char *)(&((ti)->flags)))
0139 #define __cur_thread_flag_byte_ptr __thread_flag_byte_ptr(current_thread_info())
0140
0141 #define get_thread_fault_code() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FAULT_CODE])
0142 #define set_thread_fault_code(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FAULT_CODE] = (val))
0143 #define get_thread_wstate() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE])
0144 #define set_thread_wstate(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE] = (val))
0145 #define get_thread_cwp() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP])
0146 #define set_thread_cwp(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP] = (val))
0147 #define get_thread_noerror() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_NOERROR])
0148 #define set_thread_noerror(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_NOERROR] = (val))
0149 #define get_thread_fpdepth() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH])
0150 #define set_thread_fpdepth(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH] = (val))
0151 #define get_thread_wsaved() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED])
0152 #define set_thread_wsaved(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED] = (val))
0153 #endif
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178 #define TIF_SYSCALL_TRACE 0
0179 #define TIF_NOTIFY_RESUME 1
0180 #define TIF_SIGPENDING 2
0181 #define TIF_NEED_RESCHED 3
0182 #define TIF_NOTIFY_SIGNAL 4
0183 #define TIF_UNALIGNED 5
0184 #define TIF_UPROBE 6
0185 #define TIF_32BIT 7
0186 #define TIF_NOHZ 8
0187 #define TIF_SECCOMP 9
0188 #define TIF_SYSCALL_AUDIT 10
0189 #define TIF_SYSCALL_TRACEPOINT 11
0190
0191
0192
0193
0194 #define TIF_MCDPER 12
0195 #define TIF_MEMDIE 13
0196 #define TIF_POLLING_NRFLAG 14
0197
0198 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
0199 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
0200 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
0201 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
0202 #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
0203 #define _TIF_UNALIGNED (1<<TIF_UNALIGNED)
0204 #define _TIF_UPROBE (1<<TIF_UPROBE)
0205 #define _TIF_32BIT (1<<TIF_32BIT)
0206 #define _TIF_NOHZ (1<<TIF_NOHZ)
0207 #define _TIF_SECCOMP (1<<TIF_SECCOMP)
0208 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
0209 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
0210 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
0211
0212 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
0213 _TIF_DO_NOTIFY_RESUME_MASK | \
0214 _TIF_NEED_RESCHED)
0215 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | \
0216 _TIF_SIGPENDING | _TIF_UPROBE | \
0217 _TIF_NOTIFY_SIGNAL)
0218
0219 #define is_32bit_task() (test_thread_flag(TIF_32BIT))
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231 #ifndef __ASSEMBLY__
0232
0233 #define thread32_stack_is_64bit(__SP) (((__SP) & 0x1) != 0)
0234 #define test_thread_64bit_stack(__SP) \
0235 ((test_thread_flag(TIF_32BIT) && !thread32_stack_is_64bit(__SP)) ? \
0236 false : true)
0237
0238 #endif
0239
0240 #endif
0241
0242 #endif