Skip to content

Commit

Permalink
x86/fpu: Clean up regset functions
Browse files Browse the repository at this point in the history
Clean up various regset handlers: use the 'fpu' pointer which
is available in most cases.

Reviewed-by: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed May 19, 2015
1 parent 9254aaa commit 8dcea8d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions arch/x86/kernel/fpu/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,
sanitize_i387_state(target);

return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
&target->thread.fpu.state->fxsave, 0, -1);
&fpu->state->fxsave, 0, -1);
}

int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
Expand All @@ -458,19 +458,19 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
sanitize_i387_state(target);

ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&target->thread.fpu.state->fxsave, 0, -1);
&fpu->state->fxsave, 0, -1);

/*
* mxcsr reserved bits must be masked to zero for security reasons.
*/
target->thread.fpu.state->fxsave.mxcsr &= mxcsr_feature_mask;
fpu->state->fxsave.mxcsr &= mxcsr_feature_mask;

/*
* update the header bits in the xsave header, indicating the
* presence of FP and SSE state.
*/
if (cpu_has_xsave)
target->thread.fpu.state->xsave.xsave_hdr.xstate_bv |= XSTATE_FPSSE;
fpu->state->xsave.xsave_hdr.xstate_bv |= XSTATE_FPSSE;

return ret;
}
Expand All @@ -490,7 +490,7 @@ int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
if (ret)
return ret;

xsave = &target->thread.fpu.state->xsave;
xsave = &fpu->state->xsave;

/*
* Copy the 48bytes defined by the software first into the xstate
Expand Down Expand Up @@ -521,7 +521,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
if (ret)
return ret;

xsave = &target->thread.fpu.state->xsave;
xsave = &fpu->state->xsave;

ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);
/*
Expand All @@ -533,6 +533,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
* These bits must be zero.
*/
memset(&xsave->xsave_hdr.reserved, 0, 48);

return ret;
}

Expand Down Expand Up @@ -690,7 +691,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,

if (!cpu_has_fxsr)
return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
&target->thread.fpu.state->fsave, 0,
&fpu->state->fsave, 0,
-1);

sanitize_i387_state(target);
Expand Down Expand Up @@ -724,7 +725,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,

if (!cpu_has_fxsr)
return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&target->thread.fpu.state->fsave, 0,
&fpu->state->fsave, 0,
-1);

if (pos > 0 || count < sizeof(env))
Expand All @@ -739,7 +740,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
* presence of FP.
*/
if (cpu_has_xsave)
target->thread.fpu.state->xsave.xsave_hdr.xstate_bv |= XSTATE_FP;
fpu->state->xsave.xsave_hdr.xstate_bv |= XSTATE_FP;
return ret;
}

Expand Down

0 comments on commit 8dcea8d

Please sign in to comment.