@@ -151,6 +151,13 @@ using asm_sigcontext::_xstate;
151
151
152
152
#ifdef XSTATE_SUPPORTED
153
153
154
+ // The mask for YMM registers presence flag stored in the xstate_bv. On current Linuxes, this definition is
155
+ // only in internal headers, so we define it here. The xstate_bv is extracted from the processor xstate bit
156
+ // vector register, so the value is OS independent.
157
+ #ifndef XSTATE_YMM
158
+ #define XSTATE_YMM 4
159
+ #endif
160
+
154
161
inline _fpx_sw_bytes *FPREG_FpxSwBytes (const ucontext_t *uc)
155
162
{
156
163
// Bytes 464..511 in the FXSAVE format are available for software to use for any purpose. In this case, they are used to
@@ -168,7 +175,7 @@ inline UINT32 FPREG_ExtendedSize(const ucontext_t *uc)
168
175
return FPREG_FpxSwBytes (uc)->extended_size ;
169
176
}
170
177
171
- inline bool FPREG_HasExtendedState (const ucontext_t *uc)
178
+ inline bool FPREG_HasYmmRegisters (const ucontext_t *uc)
172
179
{
173
180
// See comments in /usr/include/x86_64-linux-gnu/asm/sigcontext.h for info on how to detect if extended state is present
174
181
static_assert_no_msg (FP_XSTATE_MAGIC2_SIZE == sizeof (UINT32));
@@ -185,14 +192,19 @@ inline bool FPREG_HasExtendedState(const ucontext_t *uc)
185
192
}
186
193
187
194
_ASSERTE (extendedSize >= FP_XSTATE_MAGIC2_SIZE);
188
- return *reinterpret_cast <UINT32 *>(reinterpret_cast <UINT8 *>(FPREG_Fpstate (uc)) + (extendedSize - FP_XSTATE_MAGIC2_SIZE))
189
- == FP_XSTATE_MAGIC2;
195
+ if (*reinterpret_cast <UINT32 *>(reinterpret_cast <UINT8 *>(FPREG_Fpstate (uc)) + (extendedSize - FP_XSTATE_MAGIC2_SIZE))
196
+ != FP_XSTATE_MAGIC2)
197
+ {
198
+ return false ;
199
+ }
200
+
201
+ return (FPREG_FpxSwBytes (uc)->xstate_bv & XSTATE_YMM) != 0 ;
190
202
}
191
203
192
204
inline void *FPREG_Xstate_Ymmh (const ucontext_t *uc)
193
205
{
194
206
static_assert_no_msg (sizeof (reinterpret_cast <_xstate *>(FPREG_Fpstate (uc))->ymmh .ymmh_space ) == 16 * 16 );
195
- _ASSERTE (FPREG_HasExtendedState (uc));
207
+ _ASSERTE (FPREG_HasYmmRegisters (uc));
196
208
197
209
return reinterpret_cast <_xstate *>(FPREG_Fpstate (uc))->ymmh .ymmh_space ;
198
210
}
0 commit comments