membuf_zero(&to, to.left);
}
+static inline bool mxcsr_valid(struct xstate_header *hdr, const u32 *mxcsr)
+{
+ u64 mask = XFEATURE_MASK_FP | XFEATURE_MASK_SSE | XFEATURE_MASK_YMM;
+
+ /* Only check if it is in use */
+ if (hdr->xfeatures & mask) {
+ /* Reserved bits in MXCSR must be zero. */
+ if (*mxcsr & ~mxcsr_feature_mask)
+ return false;
+ }
+ return true;
+}
+
/*
* Convert from a ptrace standard-format kernel buffer to kernel XSAVE[S] format
* and copy to the target thread. This is called from xstateregs_set().
if (validate_user_xstate_header(&hdr))
return -EINVAL;
+ if (!mxcsr_valid(&hdr, kbuf + offsetof(struct fxregs_state, mxcsr)))
+ return -EINVAL;
+
for (i = 0; i < XFEATURE_MAX; i++) {
u64 mask = ((u64)1 << i);
*/
xsave->header.xfeatures |= hdr.xfeatures;
- /* mxcsr reserved bits must be masked to zero for historical reasons. */
- xsave->i387.mxcsr &= mxcsr_feature_mask;
-
return 0;
}