Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


sigcontext.h
001: #ifndef _ASM_X86_SIGCONTEXT_H
002: #define _ASM_X86_SIGCONTEXT_H
003: 
004: 
005: #include <linux/types.h>
006: 
007: #define FP_XSTATE_MAGIC1        0x46505853U
008: #define FP_XSTATE_MAGIC2        0x46505845U
009: #define FP_XSTATE_MAGIC2_SIZE   sizeof(FP_XSTATE_MAGIC2)
010: 
011: /*
012:  * bytes 464..511 in the current 512byte layout of fxsave/fxrstor frame
013:  * are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes
014:  * are used to extended the fpstate pointer in the sigcontext, which now
015:  * includes the extended state information along with fpstate information.
016:  *
017:  * Presence of FP_XSTATE_MAGIC1 at the beginning of this SW reserved
018:  * area and FP_XSTATE_MAGIC2 at the end of memory layout
019:  * (extended_size - FP_XSTATE_MAGIC2_SIZE) indicates the presence of the
020:  * extended state information in the memory layout pointed by the fpstate
021:  * pointer in sigcontext.
022:  */
023: struct _fpx_sw_bytes {
024:         __u32 magic1;           /* FP_XSTATE_MAGIC1 */
025:         __u32 extended_size;    /* total size of the layout referred by
026:                                  * fpstate pointer in the sigcontext.
027:                                  */
028:         __u64 xstate_bv;
029:                                 /* feature bit mask (including fp/sse/extended
030:                                  * state) that is present in the memory
031:                                  * layout.
032:                                  */
033:         __u32 xstate_size;      /* actual xsave state size, based on the
034:                                  * features saved in the layout.
035:                                  * 'extended_size' will be greater than
036:                                  * 'xstate_size'.
037:                                  */
038:         __u32 padding[7];       /*  for future use. */
039: };
040: 
041: #ifdef __i386__
042: /*
043:  * As documented in the iBCS2 standard..
044:  *
045:  * The first part of "struct _fpstate" is just the normal i387
046:  * hardware setup, the extra "status" word is used to save the
047:  * coprocessor status word before entering the handler.
048:  *
049:  * Pentium III FXSR, SSE support
050:  *      Gareth Hughes <gareth@valinux.com>, May 2000
051:  *
052:  * The FPU state data structure has had to grow to accommodate the
053:  * extended FPU state required by the Streaming SIMD Extensions.
054:  * There is no documented standard to accomplish this at the moment.
055:  */
056: struct _fpreg {
057:         unsigned short significand[4];
058:         unsigned short exponent;
059: };
060: 
061: struct _fpxreg {
062:         unsigned short significand[4];
063:         unsigned short exponent;
064:         unsigned short padding[3];
065: };
066: 
067: struct _xmmreg {
068:         unsigned long element[4];
069: };
070: 
071: struct _fpstate {
072:         /* Regular FPU environment */
073:         unsigned long   cw;
074:         unsigned long   sw;
075:         unsigned long   tag;
076:         unsigned long   ipoff;
077:         unsigned long   cssel;
078:         unsigned long   dataoff;
079:         unsigned long   datasel;
080:         struct _fpreg   _st[8];
081:         unsigned short  status;
082:         unsigned short  magic;          /* 0xffff = regular FPU data only */
083: 
084:         /* FXSR FPU environment */
085:         unsigned long   _fxsr_env[6];   /* FXSR FPU env is ignored */
086:         unsigned long   mxcsr;
087:         unsigned long   reserved;
088:         struct _fpxreg  _fxsr_st[8];    /* FXSR FPU reg data is ignored */
089:         struct _xmmreg  _xmm[8];
090:         unsigned long   padding1[44];
091: 
092:         union {
093:                 unsigned long   padding2[12];
094:                 struct _fpx_sw_bytes sw_reserved; /* represents the extended
095:                                                    * state info */
096:         };
097: };
098: 
099: #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:         unsigned long r8;
159:         unsigned long r9;
160:         unsigned long r10;
161:         unsigned long r11;
162:         unsigned long r12;
163:         unsigned long r13;
164:         unsigned long r14;
165:         unsigned long r15;
166:         unsigned long rdi;
167:         unsigned long rsi;
168:         unsigned long rbp;
169:         unsigned long rbx;
170:         unsigned long rdx;
171:         unsigned long rax;
172:         unsigned long rcx;
173:         unsigned long rsp;
174:         unsigned long rip;
175:         unsigned long eflags;           /* RFLAGS */
176:         unsigned short cs;
177:         unsigned short gs;
178:         unsigned short fs;
179:         unsigned short __pad0;
180:         unsigned long err;
181:         unsigned long trapno;
182:         unsigned long oldmask;
183:         unsigned long cr2;
184:         struct _fpstate *fpstate;       /* zero when no FPU context */
185:         unsigned long reserved1[8];
186: };
187: 
188: #endif /* !__i386__ */
189: 
190: struct _xsave_hdr {
191:         __u64 xstate_bv;
192:         __u64 reserved1[2];
193:         __u64 reserved2[5];
194: };
195: 
196: struct _ymmh_state {
197:         /* 16 * 16 bytes for each YMMH-reg */
198:         __u32 ymmh_space[64];
199: };
200: 
201: /*
202:  * Extended state pointed by the fpstate pointer in the sigcontext.
203:  * In addition to the fpstate, information encoded in the xstate_hdr
204:  * indicates the presence of other extended state information
205:  * supported by the processor and OS.
206:  */
207: struct _xstate {
208:         struct _fpstate fpstate;
209:         struct _xsave_hdr xstate_hdr;
210:         struct _ymmh_state ymmh;
211:         /* new processor state extensions go here */
212: };
213: 
214: #endif /* _ASM_X86_SIGCONTEXT_H */
215: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/