1 #ifndef _ASM_X86_SIGCONTEXT_H 2 #define _ASM_X86_SIGCONTEXT_H 3 4 5 #include <linux/types.h> 6 7 #define FP_XSTATE_MAGIC1 0x46505853U 8 #define FP_XSTATE_MAGIC2 0x46505845U 9 #define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) 10 11 /* 12 * bytes 464..511 in the current 512byte layout of fxsave/fxrstor frame 13 * are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes 14 * are used to extended the fpstate pointer in the sigcontext, which now 15 * includes the extended state information along with fpstate information. 16 * 17 * Presence of FP_XSTATE_MAGIC1 at the beginning of this SW reserved 18 * area and FP_XSTATE_MAGIC2 at the end of memory layout 19 * (extended_size - FP_XSTATE_MAGIC2_SIZE) indicates the presence of the 20 * extended state information in the memory layout pointed by the fpstate 21 * pointer in sigcontext. 22 */ 23 struct _fpx_sw_bytes { 24 __u32 magic1; /* FP_XSTATE_MAGIC1 */ 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 31 * layout. 32 */ 33 __u32 xstate_size; /* actual xsave state size, based on the 34 * features saved in the layout. 35 * 'extended_size' will be greater than 36 * 'xstate_size'. 37 */ 38 __u32 padding[7]; /* for future use. */ 39 }; 40 41 #ifdef __i386__ 42 /* 43 * 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. 48 * 49 * Pentium III FXSR, SSE support 50 * Gareth Hughes <[email protected]>, May 2000 51 * 52 * The FPU state data structure has had to grow to accommodate the 53 * extended FPU state required by the Streaming SIMD Extensions. 54 * There is no documented standard to accomplish this at the moment. 55 */ 56 struct _fpreg { 57 unsigned short significand[4]; 58 unsigned short exponent; 59 }; 60 61 struct _fpxreg { 62 unsigned short significand[4]; 63 unsigned short exponent; 64 unsigned short padding[3]; 65 }; 66 67 struct _xmmreg { 68 unsigned long element[4]; 69 }; 70 71 struct _fpstate { 72 /* Regular FPU environment */ 73 unsigned long cw; 74 unsigned long sw; 75 unsigned long tag; 76 unsigned long ipoff; 77 unsigned long cssel; 78 unsigned long dataoff; 79 unsigned long datasel; 80 struct _fpreg _st[8]; 81 unsigned short status; 82 unsigned short magic; /* 0xffff = regular FPU data only */ 83 84 /* FXSR FPU environment */ 85 unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ 86 unsigned long mxcsr; 87 unsigned long reserved; 88 struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ 89 struct _xmmreg _xmm[8]; 90 unsigned long padding1[44]; 91 92 union { 93 unsigned long padding2[12]; 94 struct _fpx_sw_bytes sw_reserved; /* represents the extended 95 * state info */ 96 }; 97 }; 98 99 #define X86_FXSR_MAGIC 0x0000 100 101 /* 102 * User-space might still rely on the old definition: 103 */ 104 struct sigcontext { 105 unsigned short gs, __gsh; 106 unsigned short fs, __fsh; 107 unsigned short es, __esh; 108 unsigned short ds, __dsh; 109 unsigned long edi; 110 unsigned long esi; 111 unsigned long ebp; 112 unsigned long esp; 113 unsigned long ebx; 114 unsigned long edx; 115 unsigned long ecx; 116 unsigned long eax; 117 unsigned long trapno; 118 unsigned long err; 119 unsigned long eip; 120 unsigned short cs, __csh; 121 unsigned long eflags; 122 unsigned long esp_at_signal; 123 unsigned short ss, __ssh; 124 struct _fpstate *fpstate; 125 unsigned long oldmask; 126 unsigned long cr2; 127 }; 128 129 #else /* __i386__ */ 130 131 /* FXSAVE frame */ 132 /* Note: reserved1/2 may someday contain valuable data. Always save/restore 133 them when you change signal frames. */ 134 struct _fpstate { 135 __u16 cwd; 136 __u16 swd; 137 __u16 twd; /* Note this is not the same as the 138 32bit/x87/FSAVE twd */ 139 __u16 fop; 140 __u64 rip; 141 __u64 rdp; 142 __u32 mxcsr; 143 __u32 mxcsr_mask; 144 __u32 st_space[32]; /* 8*16 bytes for each FP-reg */ 145 __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */ 146 __u32 reserved2[12]; 147 union { 148 __u32 reserved3[12]; 149 struct _fpx_sw_bytes sw_reserved; /* represents the extended 150 * state information */ 151 }; 152 }; 153 154 /* 155 * User-space might still rely on the old definition: 156 */ 157 struct sigcontext { 158 __u64 r8; 159 __u64 r9; 160 __u64 r10; 161 __u64 r11; 162 __u64 r12; 163 __u64 r13; 164 __u64 r14; 165 __u64 r15; 166 __u64 rdi; 167 __u64 rsi; 168 __u64 rbp; 169 __u64 rbx; 170 __u64 rdx; 171 __u64 rax; 172 __u64 rcx; 173 __u64 rsp; 174 __u64 rip; 175 __u64 eflags; /* RFLAGS */ 176 __u16 cs; 177 __u16 gs; 178 __u16 fs; 179 __u16 __pad0; 180 __u64 err; 181 __u64 trapno; 182 __u64 oldmask; 183 __u64 cr2; 184 struct _fpstate *fpstate; /* zero when no FPU context */ 185 #ifdef __ILP32__ 186 __u32 __fpstate_pad; 187 #endif 188 __u64 reserved1[8]; 189 }; 190 191 #endif /* !__i386__ */ 192 193 struct _xsave_hdr { 194 __u64 xstate_bv; 195 __u64 reserved1[2]; 196 __u64 reserved2[5]; 197 }; 198 199 struct _ymmh_state { 200 /* 16 * 16 bytes for each YMMH-reg */ 201 __u32 ymmh_space[64]; 202 }; 203 204 /* 205 * Extended state pointed by the fpstate pointer in the sigcontext. 206 * In addition to the fpstate, information encoded in the xstate_hdr 207 * indicates the presence of other extended state information 208 * supported by the processor and OS. 209 */ 210 struct _xstate { 211 struct _fpstate fpstate; 212 struct _xsave_hdr xstate_hdr; 213 struct _ymmh_state ymmh; 214 /* new processor state extensions go here */ 215 }; 216 217 #endif /* _ASM_X86_SIGCONTEXT_H */ 218