sigcontext.h 5.3 KB

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