Skip to content

Commit 39388e8

Browse files
Sebastian Andrzej Siewiorsuryasaimadhu
authored andcommitted
x86/fpu: Don't save fxregs for ia32 frames in copy_fpstate_to_sigframe()
In commit 72a671c ("x86, fpu: Unify signal handling code paths for x86 and x86_64 kernels") the 32bit and 64bit path of the signal delivery code were merged. The 32bit version: int save_i387_xstate_ia32(void __user *buf) … if (cpu_has_xsave) return save_i387_xsave(fp); if (cpu_has_fxsr) return save_i387_fxsave(fp); The 64bit version: int save_i387_xstate(void __user *buf) … if (user_has_fpu()) { if (use_xsave()) err = xsave_user(buf); else err = fxsave_user(buf); if (unlikely(err)) { __clear_user(buf, xstate_size); return err; The merge: int save_xstate_sig(void __user *buf, void __user *buf_fx, int size) … if (user_has_fpu()) { /* Save the live register state to the user directly. */ if (save_user_xstate(buf_fx)) return -1; /* Update the thread's fxstate to save the fsave header. */ if (ia32_fxstate) fpu_fxsave(&tsk->thread.fpu); I don't think that we needed to save the FPU registers to ->thread.fpu because the registers were stored in buf_fx. Today the state will be restored from buf_fx after the signal was handled (I assume that this was also the case with lazy-FPU). Since commit 66463db ("x86, fpu: shift drop_init_fpu() from save_xstate_sig() to handle_signal()") it is ensured that the signal handler starts with clear/fresh set of FPU registers which means that the previous store is futile. Remove the copy_fxregs_to_kernel() call because task's FPU state is cleared later in handle_signal() via fpu__clear(). Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Dave Hansen <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jann Horn <[email protected]> Cc: "Jason A. Donenfeld" <[email protected]> Cc: kvm ML <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Radim Krčmář <[email protected]> Cc: Rik van Riel <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent fbcc9e0 commit 39388e8

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

arch/x86/kernel/fpu/signal.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf)
155155
*/
156156
int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
157157
{
158-
struct fpu *fpu = &current->thread.fpu;
159158
struct task_struct *tsk = current;
160159
int ia32_fxstate = (buf != buf_fx);
161160

@@ -173,9 +172,6 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
173172
/* Save the live registers state to the user frame directly. */
174173
if (copy_fpregs_to_sigframe(buf_fx))
175174
return -1;
176-
/* Update the thread's fxstate to save the fsave header. */
177-
if (ia32_fxstate)
178-
copy_fxregs_to_kernel(fpu);
179175

180176
/* Save the fsave header for the 32-bit frames. */
181177
if ((ia32_fxstate || !use_fxsr()) && save_fsave_header(tsk, buf))

0 commit comments

Comments
 (0)