Skip to content

Commit

Permalink
x86/fpu: Use fpstate in fpu_copy_kvm_uabi_to_fpstate()
Browse files Browse the repository at this point in the history
Straight forward conversion. No functional change.

Signed-off-by: Thomas Gleixner <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
KAGA-KOKO authored and suryasaimadhu committed Oct 21, 2021
1 parent 0b2d39a commit ad6ede4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arch/x86/kernel/fpu/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ EXPORT_SYMBOL_GPL(fpu_copy_fpstate_to_kvm_uabi);
int fpu_copy_kvm_uabi_to_fpstate(struct fpu *fpu, const void *buf, u64 xcr0,
u32 *vpkru)
{
union fpregs_state *kstate = &fpu->fpstate->regs;
struct fpstate *kstate = fpu->fpstate;
const union fpregs_state *ustate = buf;
struct pkru_state *xpkru;
int ret;
Expand All @@ -215,25 +215,25 @@ int fpu_copy_kvm_uabi_to_fpstate(struct fpu *fpu, const void *buf, u64 xcr0,
return -EINVAL;
if (ustate->fxsave.mxcsr & ~mxcsr_feature_mask)
return -EINVAL;
memcpy(&kstate->fxsave, &ustate->fxsave, sizeof(ustate->fxsave));
memcpy(&kstate->regs.fxsave, &ustate->fxsave, sizeof(ustate->fxsave));
return 0;
}

if (ustate->xsave.header.xfeatures & ~xcr0)
return -EINVAL;

ret = copy_uabi_from_kernel_to_xstate(&kstate->xsave, ustate);
ret = copy_uabi_from_kernel_to_xstate(&kstate->regs.xsave, ustate);
if (ret)
return ret;

/* Retrieve PKRU if not in init state */
if (kstate->xsave.header.xfeatures & XFEATURE_MASK_PKRU) {
xpkru = get_xsave_addr(&kstate->xsave, XFEATURE_PKRU);
if (kstate->regs.xsave.header.xfeatures & XFEATURE_MASK_PKRU) {
xpkru = get_xsave_addr(&kstate->regs.xsave, XFEATURE_PKRU);
*vpkru = xpkru->pkru;
}

/* Ensure that XCOMP_BV is set up for XSAVES */
xstate_init_xcomp_bv(&kstate->xsave, xfeatures_mask_uabi());
xstate_init_xcomp_bv(&kstate->regs.xsave, xfeatures_mask_uabi());
return 0;
}
EXPORT_SYMBOL_GPL(fpu_copy_kvm_uabi_to_fpstate);
Expand Down

0 comments on commit ad6ede4

Please sign in to comment.