void fpu_copy_fpstate_to_kvm_uabi(struct fpu *fpu, void *buf,
unsigned int size, u32 pkru)
{
- union fpregs_state *kstate = &fpu->fpstate->regs;
+ struct fpstate *kstate = fpu->fpstate;
union fpregs_state *ustate = buf;
struct membuf mb = { .p = buf, .left = size };
if (cpu_feature_enabled(X86_FEATURE_XSAVE)) {
- __copy_xstate_to_uabi_buf(mb, &kstate->xsave, pkru,
- XSTATE_COPY_XSAVE);
+ __copy_xstate_to_uabi_buf(mb, kstate, pkru, XSTATE_COPY_XSAVE);
} else {
- memcpy(&ustate->fxsave, &kstate->fxsave, sizeof(ustate->fxsave));
+ memcpy(&ustate->fxsave, &kstate->regs.fxsave,
+ sizeof(ustate->fxsave));
/* Make it restorable on a XSAVE enabled host */
ustate->xsave.header.xfeatures = XFEATURE_MASK_FPSSE;
}
/**
* __copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
* @to: membuf descriptor
- * @xsave: The xsave from which to copy
+ * @fpstate: The fpstate buffer from which to copy
* @pkru_val: The PKRU value to store in the PKRU component
* @copy_mode: The requested copy mode
*
*
* It supports partial copy but @to.pos always starts from zero.
*/
-void __copy_xstate_to_uabi_buf(struct membuf to, struct xregs_state *xsave,
+void __copy_xstate_to_uabi_buf(struct membuf to, struct fpstate *fpstate,
u32 pkru_val, enum xstate_copy_mode copy_mode)
{
const unsigned int off_mxcsr = offsetof(struct fxregs_state, mxcsr);
struct xregs_state *xinit = &init_fpstate.regs.xsave;
+ struct xregs_state *xsave = &fpstate->regs.xsave;
struct xstate_header header;
unsigned int zerofrom;
u64 mask;
break;
case XSTATE_COPY_XSAVE:
- header.xfeatures &= xfeatures_mask_uabi();
+ header.xfeatures &= fpstate->user_xfeatures;
break;
}
* but there is no state to copy from in the compacted
* init_fpstate. The gap tracking will zero these states.
*/
- mask = xfeatures_mask_uabi();
+ mask = fpstate->user_xfeatures;
for_each_extended_xfeature(i, mask) {
/*
void copy_xstate_to_uabi_buf(struct membuf to, struct task_struct *tsk,
enum xstate_copy_mode copy_mode)
{
- __copy_xstate_to_uabi_buf(to, &tsk->thread.fpu.fpstate->regs.xsave,
+ __copy_xstate_to_uabi_buf(to, tsk->thread.fpu.fpstate,
tsk->thread.pkru, copy_mode);
}
xsave->header.xcomp_bv = mask | XCOMP_BV_COMPACTED_FORMAT;
}
-extern void __copy_xstate_to_uabi_buf(struct membuf to, struct xregs_state *xsave,
+extern void __copy_xstate_to_uabi_buf(struct membuf to, struct fpstate *fpstate,
u32 pkru_val, enum xstate_copy_mode copy_mode);
extern void fpu__init_cpu_xstate(void);