[PATCH 07/23] x86/fpu: Remove fpu->initialized usage in copy_fpstate_to_sigframe()

2018-11-07 Thread Sebastian Andrzej Siewior
Since ->initialized is always true for user tasks and kernel threads
don't get this far, we always save the registers directly to userspace.

Remove check for ->initialized because it is always true and remove the
false condition.

Signed-off-by: Sebastian Andrzej Siewior 
---
 arch/x86/kernel/fpu/signal.c | 30 ++
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index 5777ee0c32fed..30e65085dc4d9 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -157,7 +157,6 @@ static inline int copy_fpregs_to_sigframe(struct 
xregs_state __user *buf)
 int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
 {
struct fpu *fpu = >thread.fpu;
-   struct xregs_state *xsave = >state.xsave;
struct task_struct *tsk = current;
int ia32_fxstate = (buf != buf_fx);
 
@@ -172,29 +171,12 @@ int copy_fpstate_to_sigframe(void __user *buf, void 
__user *buf_fx, int size)
sizeof(struct user_i387_ia32_struct), NULL,
(struct _fpstate_32 __user *) buf) ? -1 : 1;
 
-   if (fpu->initialized || using_compacted_format()) {
-   /* Save the live register state to the user directly. */
-   if (copy_fpregs_to_sigframe(buf_fx))
-   return -1;
-   /* Update the thread's fxstate to save the fsave header. */
-   if (ia32_fxstate)
-   copy_fxregs_to_kernel(fpu);
-   } else {
-   /*
-* It is a *bug* if kernel uses compacted-format for xsave
-* area and we copy it out directly to a signal frame. It
-* should have been handled above by saving the registers
-* directly.
-*/
-   if (boot_cpu_has(X86_FEATURE_XSAVES)) {
-   WARN_ONCE(1, "x86/fpu: saving compacted-format xsave 
area to a signal frame!\n");
-   return -1;
-   }
-
-   fpstate_sanitize_xstate(fpu);
-   if (__copy_to_user(buf_fx, xsave, fpu_user_xstate_size))
-   return -1;
-   }
+   /* Save the live register state to the user directly. */
+   if (copy_fpregs_to_sigframe(buf_fx))
+   return -1;
+   /* Update the thread's fxstate to save the fsave header. */
+   if (ia32_fxstate)
+   copy_fxregs_to_kernel(fpu);
 
/* Save the fsave header for the 32-bit frames. */
if ((ia32_fxstate || !use_fxsr()) && save_fsave_header(tsk, buf))
-- 
2.19.1



[PATCH 07/23] x86/fpu: Remove fpu->initialized usage in copy_fpstate_to_sigframe()

2018-11-07 Thread Sebastian Andrzej Siewior
Since ->initialized is always true for user tasks and kernel threads
don't get this far, we always save the registers directly to userspace.

Remove check for ->initialized because it is always true and remove the
false condition.

Signed-off-by: Sebastian Andrzej Siewior 
---
 arch/x86/kernel/fpu/signal.c | 30 ++
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index 5777ee0c32fed..30e65085dc4d9 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -157,7 +157,6 @@ static inline int copy_fpregs_to_sigframe(struct 
xregs_state __user *buf)
 int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
 {
struct fpu *fpu = >thread.fpu;
-   struct xregs_state *xsave = >state.xsave;
struct task_struct *tsk = current;
int ia32_fxstate = (buf != buf_fx);
 
@@ -172,29 +171,12 @@ int copy_fpstate_to_sigframe(void __user *buf, void 
__user *buf_fx, int size)
sizeof(struct user_i387_ia32_struct), NULL,
(struct _fpstate_32 __user *) buf) ? -1 : 1;
 
-   if (fpu->initialized || using_compacted_format()) {
-   /* Save the live register state to the user directly. */
-   if (copy_fpregs_to_sigframe(buf_fx))
-   return -1;
-   /* Update the thread's fxstate to save the fsave header. */
-   if (ia32_fxstate)
-   copy_fxregs_to_kernel(fpu);
-   } else {
-   /*
-* It is a *bug* if kernel uses compacted-format for xsave
-* area and we copy it out directly to a signal frame. It
-* should have been handled above by saving the registers
-* directly.
-*/
-   if (boot_cpu_has(X86_FEATURE_XSAVES)) {
-   WARN_ONCE(1, "x86/fpu: saving compacted-format xsave 
area to a signal frame!\n");
-   return -1;
-   }
-
-   fpstate_sanitize_xstate(fpu);
-   if (__copy_to_user(buf_fx, xsave, fpu_user_xstate_size))
-   return -1;
-   }
+   /* Save the live register state to the user directly. */
+   if (copy_fpregs_to_sigframe(buf_fx))
+   return -1;
+   /* Update the thread's fxstate to save the fsave header. */
+   if (ia32_fxstate)
+   copy_fxregs_to_kernel(fpu);
 
/* Save the fsave header for the 32-bit frames. */
if ((ia32_fxstate || !use_fxsr()) && save_fsave_header(tsk, buf))
-- 
2.19.1