@@ -209,7 +209,8 @@ static inline void fpstate_init_xstate(s
* XRSTORS requires these bits set in xcomp_bv, or it will
* trigger #GP:
*/
- xsave->header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT | xfeatures_mask_all;
+ xsave->header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
+ xfeatures_mask_fpstate();
}
static inline void fpstate_init_fxstate(struct fxregs_state *fx)
@@ -389,8 +390,9 @@ void fpu__clear_user_states(struct fpu *
os_xrstor(&fpu->state.xsave, xfeatures_mask_supervisor());
}
- /* Reset user states in registers. */
- load_fpregs_from_init_fpstate(xfeatures_mask_restore_user());
+ /* Reset user registers maintained in fpstate. */
+ load_fpregs_from_init_fpstate(xfeatures_mask_fpstate() &
+ xfeatures_mask_restore_user());
/*
* Now all FPU registers have their desired values. Inform the FPU
@@ -437,6 +437,7 @@ int fpu__restore_sig(void __user *buf, i
int ret;
if (unlikely(!buf)) {
+ write_pkru(pkru_get_init_value());
fpu__clear_user_states(¤t->thread.fpu);
return 0;
}
@@ -468,8 +469,10 @@ int fpu__restore_sig(void __user *buf, i
ret = __fpu_restore_sig(buf, buf_fx, ia32_fxstate);
out:
- if (unlikely(ret))
+ if (unlikely(ret)) {
+ write_pkru(pkru_get_init_value());
fpu__clear_user_states(¤t->thread.fpu);
+ }
return ret;
}
@@ -835,6 +835,7 @@ handle_signal(struct ksignal *ksig, stru
/*
* Ensure the signal handler starts with the new fpu state.
*/
+ write_pkru(pkru_get_init_value());
fpu__clear_user_states(fpu);
}
signal_setup_done(failed, ksig, stepping);