Rev 5270 | Rev 6934 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5270 | Rev 6082 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _UAPI_ASM_X86_SIGCONTEXT_H |
1 | #ifndef _UAPI_ASM_X86_SIGCONTEXT_H |
2 | #define _UAPI_ASM_X86_SIGCONTEXT_H |
2 | #define _UAPI_ASM_X86_SIGCONTEXT_H |
Line -... | Line 3... | ||
- | 3 | ||
- | 4 | /* |
|
- | 5 | * Linux signal context definitions. The sigcontext includes a complex |
|
- | 6 | * hierarchy of CPU and FPU state, available to user-space (on the stack) when |
|
- | 7 | * a signal handler is executed. |
|
- | 8 | * |
|
- | 9 | * As over the years this ABI grew from its very simple roots towards |
|
- | 10 | * supporting more and more CPU state organically, some of the details (which |
|
- | 11 | * were rather clever hacks back in the days) became a bit quirky by today. |
|
- | 12 | * |
|
- | 13 | * The current ABI includes flexible provisions for future extensions, so we |
|
- | 14 | * won't have to grow new quirks for quite some time. Promise! |
|
- | 15 | */ |
|
3 | 16 | ||
4 | #include |
17 | #include |
Line 5... | Line 18... | ||
5 | #include |
18 | #include |
6 | 19 | ||
7 | #define FP_XSTATE_MAGIC1 0x46505853U |
20 | #define FP_XSTATE_MAGIC1 0x46505853U |
Line 8... | Line 21... | ||
8 | #define FP_XSTATE_MAGIC2 0x46505845U |
21 | #define FP_XSTATE_MAGIC2 0x46505845U |
9 | #define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) |
22 | #define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) |
10 | 23 | ||
11 | /* |
24 | /* |
12 | * bytes 464..511 in the current 512byte layout of fxsave/fxrstor frame |
25 | * Bytes 464..511 in the current 512-byte layout of the FXSAVE/FXRSTOR frame |
13 | * are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes |
26 | * are reserved for SW usage. On CPUs supporting XSAVE/XRSTOR, these bytes are |
14 | * are used to extended the fpstate pointer in the sigcontext, which now |
27 | * used to extend the fpstate pointer in the sigcontext, which now includes the |
- | 28 | * extended state information along with fpstate information. |
|
15 | * includes the extended state information along with fpstate information. |
29 | * |
16 | * |
30 | * If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then there's a |
- | 31 | * sw_reserved.extended_size bytes large extended context area present. (The |
|
- | 32 | * last 32-bit word of this extended area (at the |
|
17 | * Presence of FP_XSTATE_MAGIC1 at the beginning of this SW reserved |
33 | * fpstate+extended_size-FP_XSTATE_MAGIC2_SIZE address) is set to |
18 | * area and FP_XSTATE_MAGIC2 at the end of memory layout |
34 | * FP_XSTATE_MAGIC2 so that you can sanity check your size calculations.) |
19 | * (extended_size - FP_XSTATE_MAGIC2_SIZE) indicates the presence of the |
35 | * |
20 | * extended state information in the memory layout pointed by the fpstate |
36 | * This extended area typically grows with newer CPUs that have larger and |
21 | * pointer in sigcontext. |
- | |
22 | */ |
- | |
23 | struct _fpx_sw_bytes { |
- | |
24 | __u32 magic1; /* FP_XSTATE_MAGIC1 */ |
37 | * larger XSAVE areas. |
25 | __u32 extended_size; /* total size of the layout referred by |
- | |
26 | * fpstate pointer in the sigcontext. |
- | |
27 | */ |
- | |
28 | __u64 xstate_bv; |
- | |
29 | /* feature bit mask (including fp/sse/extended |
- | |
30 | * state) that is present in the memory |
38 | */ |
31 | * layout. |
- | |
32 | */ |
- | |
33 | __u32 xstate_size; /* actual xsave state size, based on the |
39 | struct _fpx_sw_bytes { |
34 | * features saved in the layout. |
40 | /* |
- | 41 | * If set to FP_XSTATE_MAGIC1 then this is an xstate context. |
|
- | 42 | * 0 if a legacy frame. |
|
- | 43 | */ |
|
- | 44 | __u32 magic1; |
|
- | 45 | ||
- | 46 | /* |
|
- | 47 | * Total size of the fpstate area: |
|
- | 48 | * |
|
- | 49 | * - if magic1 == 0 then it's sizeof(struct _fpstate) |
|
- | 50 | * - if magic1 == FP_XSTATE_MAGIC1 then it's sizeof(struct _xstate) |
|
- | 51 | * plus extensions (if any) |
|
- | 52 | */ |
|
- | 53 | __u32 extended_size; |
|
- | 54 | ||
- | 55 | /* |
|
- | 56 | * Feature bit mask (including FP/SSE/extended state) that is present |
|
- | 57 | * in the memory layout: |
|
- | 58 | */ |
|
- | 59 | __u64 xfeatures; |
|
- | 60 | ||
- | 61 | /* |
|
- | 62 | * Actual XSAVE state size, based on the xfeatures saved in the layout. |
|
- | 63 | * 'extended_size' is greater than 'xstate_size': |
|
35 | * 'extended_size' will be greater than |
64 | */ |
- | 65 | __u32 xstate_size; |
|
36 | * 'xstate_size'. |
66 | |
Line 37... | Line -... | ||
37 | */ |
- | |
38 | __u32 padding[7]; /* for future use. */ |
67 | /* For future use: */ |
39 | }; |
68 | __u32 padding[7]; |
40 | 69 | }; |
|
41 | #ifdef __i386__ |
70 | |
42 | /* |
71 | /* |
43 | * As documented in the iBCS2 standard.. |
72 | * As documented in the iBCS2 standard: |
44 | * |
- | |
45 | * The first part of "struct _fpstate" is just the normal i387 |
- | |
46 | * hardware setup, the extra "status" word is used to save the |
- | |
47 | * coprocessor status word before entering the handler. |
73 | * |
48 | * |
74 | * The first part of "struct _fpstate" is just the normal i387 hardware setup, |
49 | * Pentium III FXSR, SSE support |
75 | * the extra "status" word is used to save the coprocessor status word before |
50 | * Gareth Hughes |
76 | * entering the handler. |
51 | * |
77 | * |
- | 78 | * The FPU state data structure has had to grow to accommodate the extended FPU |
|
- | 79 | * state required by the Streaming SIMD Extensions. There is no documented |
|
52 | * The FPU state data structure has had to grow to accommodate the |
80 | * standard to accomplish this at the moment. |
53 | * extended FPU state required by the Streaming SIMD Extensions. |
81 | */ |
54 | * There is no documented standard to accomplish this at the moment. |
82 | |
55 | */ |
83 | /* 10-byte legacy floating point register: */ |
Line -... | Line 84... | ||
- | 84 | struct _fpreg { |
|
56 | struct _fpreg { |
85 | __u16 significand[4]; |
57 | unsigned short significand[4]; |
86 | __u16 exponent; |
58 | unsigned short exponent; |
87 | }; |
59 | }; |
88 | |
60 | 89 | /* 16-byte floating point register: */ |
|
Line -... | Line 90... | ||
- | 90 | struct _fpxreg { |
|
61 | struct _fpxreg { |
91 | __u16 significand[4]; |
62 | unsigned short significand[4]; |
92 | __u16 exponent; |
63 | unsigned short exponent; |
93 | __u16 padding[3]; |
Line -... | Line 94... | ||
- | 94 | }; |
|
- | 95 | ||
- | 96 | /* 16-byte XMM register: */ |
|
- | 97 | struct _xmmreg { |
|
- | 98 | __u32 element[4]; |
|
64 | unsigned short padding[3]; |
99 | }; |
65 | }; |
100 | |
66 | 101 | #define X86_FXSR_MAGIC 0x0000 |
|
67 | struct _xmmreg { |
102 | |
68 | unsigned long element[4]; |
103 | /* |
69 | }; |
104 | * The 32-bit FPU frame: |
70 | 105 | */ |
|
71 | struct _fpstate { |
106 | struct _fpstate_32 { |
72 | /* Regular FPU environment */ |
107 | /* Legacy FPU environment: */ |
73 | unsigned long cw; |
108 | __u32 cw; |
74 | unsigned long sw; |
109 | __u32 sw; |
75 | unsigned long tag; |
110 | __u32 tag; |
- | 111 | __u32 ipoff; |
|
Line 76... | Line 112... | ||
76 | unsigned long ipoff; |
112 | __u32 cssel; |
77 | unsigned long cssel; |
113 | __u32 dataoff; |
78 | unsigned long dataoff; |
114 | __u32 datasel; |
79 | unsigned long datasel; |
115 | struct _fpreg _st[8]; |
80 | struct _fpreg _st[8]; |
116 | __u16 status; |
81 | unsigned short status; |
117 | __u16 magic; /* 0xffff: regular FPU data only */ |
- | 118 | /* 0x0000: FXSR FPU data */ |
|
82 | unsigned short magic; /* 0xffff = regular FPU data only */ |
119 | |
- | 120 | /* FXSR FPU environment */ |
|
- | 121 | __u32 _fxsr_env[6]; /* FXSR FPU env is ignored */ |
|
Line 83... | Line 122... | ||
83 | 122 | __u32 mxcsr; |
|
84 | /* FXSR FPU environment */ |
123 | __u32 reserved; |
85 | unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ |
124 | struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ |
86 | unsigned long mxcsr; |
- | |
87 | unsigned long reserved; |
125 | struct _xmmreg _xmm[8]; /* First 8 XMM registers */ |
88 | struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ |
126 | union { |
Line 89... | Line -... | ||
89 | struct _xmmreg _xmm[8]; |
- | |
90 | unsigned long padding1[44]; |
- | |
91 | - | ||
92 | union { |
127 | __u32 padding1[44]; /* Second 8 XMM registers plus padding */ |
- | 128 | __u32 padding[44]; /* Alias name for old user-space */ |
|
- | 129 | }; |
|
- | 130 | ||
- | 131 | union { |
|
- | 132 | __u32 padding2[12]; |
|
93 | unsigned long padding2[12]; |
133 | struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */ |
- | 134 | }; |
|
- | 135 | }; |
|
- | 136 | ||
94 | struct _fpx_sw_bytes sw_reserved; /* represents the extended |
137 | /* |
95 | * state info */ |
- | |
96 | }; |
- | |
97 | }; |
- | |
98 | - | ||
99 | #define X86_FXSR_MAGIC 0x0000 |
- | |
100 | - | ||
101 | #ifndef __KERNEL__ |
- | |
102 | /* |
- | |
103 | * User-space might still rely on the old definition: |
- | |
104 | */ |
- | |
105 | struct sigcontext { |
- | |
106 | unsigned short gs, __gsh; |
- | |
107 | unsigned short fs, __fsh; |
- | |
108 | unsigned short es, __esh; |
- | |
109 | unsigned short ds, __dsh; |
- | |
110 | unsigned long edi; |
- | |
111 | unsigned long esi; |
- | |
112 | unsigned long ebp; |
- | |
113 | unsigned long esp; |
- | |
114 | unsigned long ebx; |
- | |
115 | unsigned long edx; |
- | |
116 | unsigned long ecx; |
- | |
117 | unsigned long eax; |
- | |
118 | unsigned long trapno; |
- | |
119 | unsigned long err; |
- | |
120 | unsigned long eip; |
- | |
121 | unsigned short cs, __csh; |
- | |
122 | unsigned long eflags; |
- | |
123 | unsigned long esp_at_signal; |
- | |
124 | unsigned short ss, __ssh; |
- | |
125 | struct _fpstate __user *fpstate; |
- | |
126 | unsigned long oldmask; |
138 | * The 64-bit FPU frame. (FXSAVE format and later) |
127 | unsigned long cr2; |
139 | * |
128 | }; |
140 | * Note1: If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then the structure is |
129 | #endif /* !__KERNEL__ */ |
141 | * larger: 'struct _xstate'. Note that 'struct _xstate' embedds |
130 | 142 | * 'struct _fpstate' so that you can always assume the _fpstate portion |
|
131 | #else /* __i386__ */ |
143 | * exists so that you can check the magic value. |
132 | 144 | * |
|
133 | /* FXSAVE frame */ |
145 | * Note2: Reserved fields may someday contain valuable data. Always |
134 | /* Note: reserved1/2 may someday contain valuable data. Always save/restore |
146 | * save/restore them when you change signal frames. |
135 | them when you change signal frames. */ |
147 | */ |
136 | struct _fpstate { |
148 | struct _fpstate_64 { |
137 | __u16 cwd; |
149 | __u16 cwd; |
138 | __u16 swd; |
150 | __u16 swd; |
139 | __u16 twd; /* Note this is not the same as the |
151 | /* Note this is not the same as the 32-bit/x87/FSAVE twd: */ |
140 | 32bit/x87/FSAVE twd */ |
152 | __u16 twd; |
141 | __u16 fop; |
153 | __u16 fop; |
142 | __u64 rip; |
- | |
143 | __u64 rdp; |
154 | __u64 rip; |
144 | __u32 mxcsr; |
155 | __u64 rdp; |
Line 145... | Line 156... | ||
145 | __u32 mxcsr_mask; |
156 | __u32 mxcsr; |
- | 157 | __u32 mxcsr_mask; |
|
- | 158 | __u32 st_space[32]; /* 8x FP registers, 16 bytes each */ |
|
- | 159 | __u32 xmm_space[64]; /* 16x XMM registers, 16 bytes each */ |
|
- | 160 | __u32 reserved2[12]; |
|
- | 161 | union { |
|
- | 162 | __u32 reserved3[12]; |
|
- | 163 | struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */ |
|
- | 164 | }; |
|
- | 165 | }; |
|
- | 166 | ||
- | 167 | #ifdef __i386__ |
|
- | 168 | # define _fpstate _fpstate_32 |
|
- | 169 | #else |
|
- | 170 | # define _fpstate _fpstate_64 |
|
- | 171 | #endif |
|
- | 172 | ||
146 | __u32 st_space[32]; /* 8*16 bytes for each FP-reg */ |
173 | struct _header { |
147 | __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */ |
174 | __u64 xfeatures; |
- | 175 | __u64 reserved1[2]; |
|
- | 176 | __u64 reserved2[5]; |
|
- | 177 | }; |
|
- | 178 | ||
148 | __u32 reserved2[12]; |
179 | struct _ymmh_state { |
- | 180 | /* 16x YMM registers, 16 bytes each: */ |
|
- | 181 | __u32 ymmh_space[64]; |
|
- | 182 | }; |
|
- | 183 | ||
- | 184 | /* |
|
- | 185 | * Extended state pointed to by sigcontext::fpstate. |
|
- | 186 | * |
|
- | 187 | * In addition to the fpstate, information encoded in _xstate::xstate_hdr |
|
- | 188 | * indicates the presence of other extended state information supported |
|
- | 189 | * by the CPU and kernel: |
|
- | 190 | */ |
|
- | 191 | struct _xstate { |
|
- | 192 | struct _fpstate fpstate; |
|
- | 193 | struct _header xstate_hdr; |
|
- | 194 | struct _ymmh_state ymmh; |
|
- | 195 | /* New processor state extensions go here: */ |
|
- | 196 | }; |
|
- | 197 | ||
- | 198 | /* |
|
- | 199 | * The 32-bit signal frame: |
|
- | 200 | */ |
|
- | 201 | struct sigcontext_32 { |
|
- | 202 | __u16 gs, __gsh; |
|
- | 203 | __u16 fs, __fsh; |
|
- | 204 | __u16 es, __esh; |
|
- | 205 | __u16 ds, __dsh; |
|
- | 206 | __u32 di; |
|
- | 207 | __u32 si; |
|
- | 208 | __u32 bp; |
|
- | 209 | __u32 sp; |
|
- | 210 | __u32 bx; |
|
- | 211 | __u32 dx; |
|
- | 212 | __u32 cx; |
|
- | 213 | __u32 ax; |
|
- | 214 | __u32 trapno; |
|
- | 215 | __u32 err; |
|
- | 216 | __u32 ip; |
|
- | 217 | __u16 cs, __csh; |
|
- | 218 | __u32 flags; |
|
- | 219 | __u32 sp_at_signal; |
|
- | 220 | __u16 ss, __ssh; |
|
- | 221 | ||
- | 222 | /* |
|
- | 223 | * fpstate is really (struct _fpstate *) or (struct _xstate *) |
|
- | 224 | * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved |
|
- | 225 | * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end |
|
- | 226 | * of extended memory layout. See comments at the definition of |
|
- | 227 | * (struct _fpx_sw_bytes) |
|
- | 228 | */ |
|
- | 229 | __u32 fpstate; /* Zero when no FPU/extended context */ |
|
- | 230 | __u32 oldmask; |
|
- | 231 | __u32 cr2; |
|
- | 232 | }; |
|
- | 233 | ||
- | 234 | /* |
|
- | 235 | * The 64-bit signal frame: |
|
- | 236 | */ |
|
- | 237 | struct sigcontext_64 { |
|
- | 238 | __u64 r8; |
|
- | 239 | __u64 r9; |
|
- | 240 | __u64 r10; |
|
- | 241 | __u64 r11; |
|
- | 242 | __u64 r12; |
|
- | 243 | __u64 r13; |
|
- | 244 | __u64 r14; |
|
- | 245 | __u64 r15; |
|
- | 246 | __u64 di; |
|
- | 247 | __u64 si; |
|
- | 248 | __u64 bp; |
|
- | 249 | __u64 bx; |
|
- | 250 | __u64 dx; |
|
- | 251 | __u64 ax; |
|
- | 252 | __u64 cx; |
|
- | 253 | __u64 sp; |
|
- | 254 | __u64 ip; |
|
- | 255 | __u64 flags; |
|
- | 256 | __u16 cs; |
|
- | 257 | __u16 gs; |
|
- | 258 | __u16 fs; |
|
- | 259 | __u16 __pad0; |
|
- | 260 | __u64 err; |
|
- | 261 | __u64 trapno; |
|
- | 262 | __u64 oldmask; |
|
- | 263 | __u64 cr2; |
|
- | 264 | ||
- | 265 | /* |
|
- | 266 | * fpstate is really (struct _fpstate *) or (struct _xstate *) |
|
- | 267 | * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved |
|
- | 268 | * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end |
|
- | 269 | * of extended memory layout. See comments at the definition of |
|
- | 270 | * (struct _fpx_sw_bytes) |
|
- | 271 | */ |
|
- | 272 | __u64 fpstate; /* Zero when no FPU/extended context */ |
|
- | 273 | __u64 reserved1[8]; |
|
- | 274 | }; |
|
- | 275 | ||
- | 276 | /* |
|
- | 277 | * Create the real 'struct sigcontext' type: |
|
- | 278 | */ |
|
- | 279 | #ifdef __KERNEL__ |
|
- | 280 | # ifdef __i386__ |
|
- | 281 | # define sigcontext sigcontext_32 |
|
- | 282 | # else |
|
- | 283 | # define sigcontext sigcontext_64 |
|
- | 284 | # endif |
|
- | 285 | #endif |
|
- | 286 | ||
- | 287 | /* |
|
- | 288 | * The old user-space sigcontext definition, just in case user-space still |
|
- | 289 | * relies on it. The kernel definition (in asm/sigcontext.h) has unified |
|
- | 290 | * field names but otherwise the same layout. |
|
- | 291 | */ |
|
- | 292 | #ifndef __KERNEL__ |
|
- | 293 | ||
- | 294 | #define _fpstate_ia32 _fpstate_32 |
|
- | 295 | #define sigcontext_ia32 sigcontext_32 |
|
- | 296 | ||
- | 297 | ||
- | 298 | # ifdef __i386__ |
|
- | 299 | struct sigcontext { |
|
- | 300 | __u16 gs, __gsh; |
|
- | 301 | __u16 fs, __fsh; |
|
- | 302 | __u16 es, __esh; |
|
- | 303 | __u16 ds, __dsh; |
|
- | 304 | __u32 edi; |
|
- | 305 | __u32 esi; |
|
- | 306 | __u32 ebp; |
|
- | 307 | __u32 esp; |
|
- | 308 | __u32 ebx; |
|
- | 309 | __u32 edx; |
|
- | 310 | __u32 ecx; |
|
- | 311 | __u32 eax; |
|
- | 312 | __u32 trapno; |
|
149 | union { |
313 | __u32 err; |
150 | __u32 reserved3[12]; |
314 | __u32 eip; |
151 | struct _fpx_sw_bytes sw_reserved; /* represents the extended |
315 | __u16 cs, __csh; |
152 | * state information */ |
316 | __u32 eflags; |
153 | }; |
317 | __u32 esp_at_signal; |
Line 182... | Line 346... | ||
182 | __u16 __pad0; |
346 | __u16 __pad0; |
183 | __u64 err; |
347 | __u64 err; |
184 | __u64 trapno; |
348 | __u64 trapno; |
185 | __u64 oldmask; |
349 | __u64 oldmask; |
186 | __u64 cr2; |
350 | __u64 cr2; |
187 | struct _fpstate __user *fpstate; /* zero when no FPU context */ |
351 | struct _fpstate __user *fpstate; /* Zero when no FPU context */ |
188 | #ifdef __ILP32__ |
352 | # ifdef __ILP32__ |
189 | __u32 __fpstate_pad; |
353 | __u32 __fpstate_pad; |
190 | #endif |
354 | # endif |
191 | __u64 reserved1[8]; |
355 | __u64 reserved1[8]; |
192 | }; |
356 | }; |
- | 357 | # endif /* __x86_64__ */ |
|
193 | #endif /* !__KERNEL__ */ |
358 | #endif /* !__KERNEL__ */ |
Line 194... | Line -... | ||
194 | - | ||
195 | #endif /* !__i386__ */ |
- | |
196 | - | ||
197 | struct _xsave_hdr { |
- | |
198 | __u64 xstate_bv; |
- | |
199 | __u64 reserved1[2]; |
- | |
200 | __u64 reserved2[5]; |
- | |
201 | }; |
- | |
202 | - | ||
203 | struct _ymmh_state { |
- | |
204 | /* 16 * 16 bytes for each YMMH-reg */ |
- | |
205 | __u32 ymmh_space[64]; |
- | |
206 | }; |
- | |
207 | - | ||
208 | /* |
- | |
209 | * Extended state pointed by the fpstate pointer in the sigcontext. |
- | |
210 | * In addition to the fpstate, information encoded in the xstate_hdr |
- | |
211 | * indicates the presence of other extended state information |
- | |
212 | * supported by the processor and OS. |
- | |
213 | */ |
- | |
214 | struct _xstate { |
- | |
215 | struct _fpstate fpstate; |
- | |
216 | struct _xsave_hdr xstate_hdr; |
- | |
217 | struct _ymmh_state ymmh; |
- | |
218 | /* new processor state extensions go here */ |
- | |
219 | }; |
- | |
220 | 359 |