sigcontext.h 7.0 KB

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