sigcontext.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #ifndef _UAPI_ASM_X86_SIGCONTEXT_H
  2. #define _UAPI_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. #ifndef __KERNEL__
  91. /*
  92. * User-space might still rely on the old definition:
  93. */
  94. struct sigcontext {
  95. unsigned short gs, __gsh;
  96. unsigned short fs, __fsh;
  97. unsigned short es, __esh;
  98. unsigned short ds, __dsh;
  99. unsigned long edi;
  100. unsigned long esi;
  101. unsigned long ebp;
  102. unsigned long esp;
  103. unsigned long ebx;
  104. unsigned long edx;
  105. unsigned long ecx;
  106. unsigned long eax;
  107. unsigned long trapno;
  108. unsigned long err;
  109. unsigned long eip;
  110. unsigned short cs, __csh;
  111. unsigned long eflags;
  112. unsigned long esp_at_signal;
  113. unsigned short ss, __ssh;
  114. struct _fpstate __user *fpstate;
  115. unsigned long oldmask;
  116. unsigned long cr2;
  117. };
  118. #endif /* !__KERNEL__ */
  119. #else /* __i386__ */
  120. /* FXSAVE frame */
  121. /* Note: reserved1/2 may someday contain valuable data. Always save/restore
  122. them when you change signal frames. */
  123. struct _fpstate {
  124. __u16 cwd;
  125. __u16 swd;
  126. __u16 twd; /* Note this is not the same as the
  127. 32bit/x87/FSAVE twd */
  128. __u16 fop;
  129. __u64 rip;
  130. __u64 rdp;
  131. __u32 mxcsr;
  132. __u32 mxcsr_mask;
  133. __u32 st_space[32]; /* 8*16 bytes for each FP-reg */
  134. __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */
  135. __u32 reserved2[12];
  136. union {
  137. __u32 reserved3[12];
  138. struct _fpx_sw_bytes sw_reserved; /* represents the extended
  139. * state information */
  140. };
  141. };
  142. #ifndef __KERNEL__
  143. /*
  144. * User-space might still rely on the old definition:
  145. */
  146. struct sigcontext {
  147. __u64 r8;
  148. __u64 r9;
  149. __u64 r10;
  150. __u64 r11;
  151. __u64 r12;
  152. __u64 r13;
  153. __u64 r14;
  154. __u64 r15;
  155. __u64 rdi;
  156. __u64 rsi;
  157. __u64 rbp;
  158. __u64 rbx;
  159. __u64 rdx;
  160. __u64 rax;
  161. __u64 rcx;
  162. __u64 rsp;
  163. __u64 rip;
  164. __u64 eflags; /* RFLAGS */
  165. __u16 cs;
  166. __u16 gs;
  167. __u16 fs;
  168. __u16 __pad0;
  169. __u64 err;
  170. __u64 trapno;
  171. __u64 oldmask;
  172. __u64 cr2;
  173. struct _fpstate __user *fpstate; /* zero when no FPU context */
  174. #ifdef __ILP32__
  175. __u32 __fpstate_pad;
  176. #endif
  177. __u64 reserved1[8];
  178. };
  179. #endif /* !__KERNEL__ */
  180. #endif /* !__i386__ */
  181. struct _xsave_hdr {
  182. __u64 xstate_bv;
  183. __u64 reserved1[2];
  184. __u64 reserved2[5];
  185. };
  186. struct _ymmh_state {
  187. /* 16 * 16 bytes for each YMMH-reg */
  188. __u32 ymmh_space[64];
  189. };
  190. /*
  191. * Extended state pointed by the fpstate pointer in the sigcontext.
  192. * In addition to the fpstate, information encoded in the xstate_hdr
  193. * indicates the presence of other extended state information
  194. * supported by the processor and OS.
  195. */
  196. struct _xstate {
  197. struct _fpstate fpstate;
  198. struct _xsave_hdr xstate_hdr;
  199. struct _ymmh_state ymmh;
  200. /* new processor state extensions go here */
  201. };
  202. #endif /* _UAPI_ASM_X86_SIGCONTEXT_H */