1 #ifndef _UAPI_ASM_X86_SIGCONTEXT_H
2 #define _UAPI_ASM_X86_SIGCONTEXT_H
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.
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.
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!
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 are
27 * used to extend the fpstate pointer in the sigcontext, which now includes the
28 * extended state information along with fpstate information.
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
33 * fpstate+extended_size-FP_XSTATE_MAGIC2_SIZE address) is set to
34 * FP_XSTATE_MAGIC2 so that you can sanity check your size calculations.)
36 * This extended area typically grows with newer CPUs that have larger and
39 struct _fpx_sw_bytes
{
41 * If set to FP_XSTATE_MAGIC1 then this is an xstate context.
42 * 0 if a legacy frame.
47 * Total size of the fpstate area:
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)
56 * Feature bit mask (including FP/SSE/extended state) that is present
57 * in the memory layout:
62 * Actual XSAVE state size, based on the xfeatures saved in the layout.
63 * 'extended_size' is greater than 'xstate_size':
72 * As documented in the iBCS2 standard:
74 * The first part of "struct _fpstate" is just the normal i387 hardware setup,
75 * the extra "status" word is used to save the coprocessor status word before
76 * entering the handler.
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
80 * standard to accomplish this at the moment.
83 /* 10-byte legacy floating point register: */
89 /* 16-byte floating point register: */
96 /* 16-byte XMM register: */
101 #define X86_FXSR_MAGIC 0x0000
104 * The 32-bit FPU frame:
107 /* Legacy FPU environment: */
115 struct _fpreg _st
[8];
117 __u16 magic
; /* 0xffff: regular FPU data only */
118 /* 0x0000: FXSR FPU data */
120 /* FXSR FPU environment */
121 __u32 _fxsr_env
[6]; /* FXSR FPU env is ignored */
124 struct _fpxreg _fxsr_st
[8]; /* FXSR FPU reg data is ignored */
125 struct _xmmreg _xmm
[8]; /* First 8 XMM registers */
127 __u32 padding1
[44]; /* Second 8 XMM registers plus padding */
128 __u32 padding
[44]; /* Alias name for old user-space */
133 struct _fpx_sw_bytes sw_reserved
; /* Potential extended state is encoded here */
138 * The 64-bit FPU frame. (FXSAVE format and later)
140 * Note1: If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then the structure is
141 * larger: 'struct _xstate'. Note that 'struct _xstate' embedds
142 * 'struct _fpstate' so that you can always assume the _fpstate portion
143 * exists so that you can check the magic value.
145 * Note2: Reserved fields may someday contain valuable data. Always
146 * save/restore them when you change signal frames.
151 /* Note this is not the same as the 32-bit/x87/FSAVE twd: */
158 __u32 st_space
[32]; /* 8x FP registers, 16 bytes each */
159 __u32 xmm_space
[64]; /* 16x XMM registers, 16 bytes each */
163 struct _fpx_sw_bytes sw_reserved
; /* Potential extended state is encoded here */
168 # define _fpstate _fpstate_32
170 # define _fpstate _fpstate_64
180 /* 16x YMM registers, 16 bytes each: */
181 __u32 ymmh_space
[64];
185 * Extended state pointed to by sigcontext::fpstate.
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:
192 struct _fpstate fpstate
;
193 struct _header xstate_hdr
;
194 struct _ymmh_state ymmh
;
195 /* New processor state extensions go here: */
199 * The 32-bit signal frame:
201 struct sigcontext_32
{
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)
229 __u32 fpstate
; /* Zero when no FPU/extended context */
235 * The 64-bit signal frame:
237 struct sigcontext_64
{
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)
272 __u64 fpstate
; /* Zero when no FPU/extended context */
277 * Create the real 'struct sigcontext' type:
281 # define sigcontext sigcontext_32
283 # define sigcontext sigcontext_64
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.
294 #define _fpstate_ia32 _fpstate_32
295 #define sigcontext_ia32 sigcontext_32
319 struct _fpstate __user
*fpstate
;
323 # else /* __x86_64__: */
342 __u64 eflags
; /* RFLAGS */
351 struct _fpstate __user
*fpstate
; /* Zero when no FPU context */
357 # endif /* __x86_64__ */
358 #endif /* !__KERNEL__ */
360 #endif /* _UAPI_ASM_X86_SIGCONTEXT_H */