1 #ifndef _UAPI_ASM_X86_SIGCONTEXT_H
2 #define _UAPI_ASM_X86_SIGCONTEXT_H
5 * Linux signal context definitions. The sigcontext includes a complex hierarchy of CPU
6 * and FPU state, available to user-space (on the stack) when a signal handler is
9 * As over the years this ABI grew from its very simple roots towards supporting more and
10 * more CPU state organically, some of the details (which were rather clever hacks back
11 * in the days) became a bit quirky by today.
13 * The current ABI includes flexible provisions for future extensions, so we won't have
14 * to grow new quirks for quite some time. Promise!
17 #include <linux/compiler.h>
18 #include <linux/types.h>
20 #define FP_XSTATE_MAGIC1 0x46505853U
21 #define FP_XSTATE_MAGIC2 0x46505845U
22 #define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2)
25 * Bytes 464..511 in the current 512-byte layout of the FXSAVE/FXRSTOR frame
26 * are reserved for SW usage. On CPUs supporting XSAVE/XRSTOR, these bytes
27 * are used to extend the fpstate pointer in the sigcontext, which now
28 * includes the extended state information along with fpstate information.
30 * If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then there's a sw_reserved.extended_size
31 * bytes large extended context area present. (The last 32-bit word of this extended
32 * area (at the fpstate+extended_size-FP_XSTATE_MAGIC2_SIZE address) is set to
33 * FP_XSTATE_MAGIC2 so that you can sanity check your size calculations.)
35 * This extended area typically grows with newer CPUs that have larger and larger
38 struct _fpx_sw_bytes {
39 /* If set to FP_XSTATE_MAGIC1 then this is an xstate context. 0 if a legacy frame. */
43 * Total size of the fpstate area:
45 * - if magic1 == 0 then it's sizeof(struct _fpstate)
46 * - if magic1 == FP_XSTATE_MAGIC1 then it's sizeof(struct _xstate) plus extensions (if any)
51 * Feature bit mask (including FP/SSE/extended state) that is present
52 * in the memory layout:
57 * Actual XSAVE state size, based on the xfeatures saved in the layout.
58 * 'extended_size' is greater than 'xstate_size':
67 * As documented in the iBCS2 standard:
69 * The first part of "struct _fpstate" is just the normal i387
70 * hardware setup, the extra "status" word is used to save the
71 * coprocessor status word before entering the handler.
73 * The FPU state data structure has had to grow to accommodate the
74 * extended FPU state required by the Streaming SIMD Extensions.
75 * There is no documented standard to accomplish this at the moment.
78 /* 10-byte legacy floating point register: */
84 /* 16-byte floating point register: */
91 /* 16-byte XMM register: */
96 #define X86_FXSR_MAGIC 0x0000
99 * The 32-bit FPU frame:
102 /* Legacy FPU environment: */
110 struct _fpreg _st[8];
112 __u16 magic; /* 0xffff: regular FPU data only */
113 /* 0x0000: FXSR FPU data */
115 /* FXSR FPU environment */
116 __u32 _fxsr_env[6]; /* FXSR FPU env is ignored */
119 struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */
120 struct _xmmreg _xmm[8]; /* First 8 XMM registers */
122 __u32 padding1[44]; /* Second 8 XMM registers plus padding */
123 __u32 padding[44]; /* Alias name for old user-space */
128 struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */
133 * The 64-bit FPU frame. (FXSAVE format and later)
135 * Note1: If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then the structure is
136 * larger: 'struct _xstate'. Note that 'struct _xstate' embedds
137 * 'struct _fpstate' so that you can always assume the _fpstate portion
138 * exists so that you can check the magic value.
140 * Note2: Reserved fields may someday contain valuable data. Always save/restore
141 * them when you change signal frames.
146 /* Note this is not the same as the 32-bit/x87/FSAVE twd: */
153 __u32 st_space[32]; /* 8x FP registers, 16 bytes each */
154 __u32 xmm_space[64]; /* 16x XMM registers, 16 bytes each */
158 struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */
163 # define _fpstate _fpstate_32
165 # define _fpstate _fpstate_64
175 /* 16x YMM registers, 16 bytes each: */
176 __u32 ymmh_space[64];
180 * Extended state pointed to by sigcontext::fpstate.
182 * In addition to the fpstate, information encoded in _xstate::xstate_hdr
183 * indicates the presence of other extended state information supported
184 * by the CPU and kernel:
187 struct _fpstate fpstate;
188 struct _header xstate_hdr;
189 struct _ymmh_state ymmh;
190 /* New processor state extensions go here: */
193 struct sigcontext_32 {
215 * fpstate is really (struct _fpstate *) or (struct _xstate *)
216 * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved
217 * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end
218 * of extended memory layout. See comments at the definition of
219 * (struct _fpx_sw_bytes)
221 void __user *fpstate; /* Zero when no FPU/extended context */
226 struct sigcontext_64 {
255 * fpstate is really (struct _fpstate *) or (struct _xstate *)
256 * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved
257 * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end
258 * of extended memory layout. See comments at the definition of
259 * (struct _fpx_sw_bytes)
261 void __user *fpstate; /* Zero when no FPU/extended context */
266 * Create the real 'struct sigcontext' type:
270 # define sigcontext sigcontext_32
272 # define sigcontext sigcontext_64
277 * The old user-space sigcontext definition, just in case user-space still
278 * relies on it. The kernel definition (in asm/sigcontext.h) has unified
279 * field names but otherwise the same layout.
283 #define _fpstate_ia32 _fpstate_32
306 struct _fpstate __user *fpstate;
310 # else /* __x86_64__: */
329 __u64 eflags; /* RFLAGS */
338 struct _fpstate __user *fpstate; /* Zero when no FPU context */
344 # endif /* __x86_64__ */
345 #endif /* !__KERNEL__ */
347 #endif /* _UAPI_ASM_X86_SIGCONTEXT_H */