linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/fpu: Remove unneeded saving of FPU registers in copy_fpstate_to_sigframe()
@ 2019-04-30  8:31 Sebastian Andrzej Siewior
  2019-04-30 11:30 ` [tip:x86/fpu] x86/fpu: Remove unnecessary " tip-bot for Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-04-30  8:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: x86, jannh, riel, mingo, bp, Jason, luto, tglx, rkrcmar, mingo,
	hpa, kvm, pbonzini, kurt.kanzenbach, Dave Hansen

Since commit

  eeec00d73be2e ("x86/fpu: Fault-in user stack if copy_fpstate_to_sigframe() fails")

there is no need to have FPU registers saved if
copy_fpregs_to_sigframe() fails because we retry it after we resolved
the fault condition.
Saving the registers is not wrong but it is not needed and it forces us
to load the FPU registers on the retry attempt.

Don't save the FPU registers if copy_fpstate_to_sigframe() fails.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 arch/x86/kernel/fpu/signal.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index 9834ff8b570b7..eaddb185cac95 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -134,10 +134,9 @@ 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 = &current->thread.fpu;
 	struct task_struct *tsk = current;
 	int ia32_fxstate = (buf != buf_fx);
-	int ret = -EFAULT;
+	int ret;
 
 	ia32_fxstate &= (IS_ENABLED(CONFIG_X86_32) ||
 			 IS_ENABLED(CONFIG_IA32_EMULATION));
@@ -164,9 +163,6 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
 	pagefault_disable();
 	ret = copy_fpregs_to_sigframe(buf_fx);
 	pagefault_enable();
-	if (ret && !test_thread_flag(TIF_NEED_FPU_LOAD))
-		copy_fpregs_to_fpstate(fpu);
-	set_thread_flag(TIF_NEED_FPU_LOAD);
 	fpregs_unlock();
 
 	if (ret) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-30 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30  8:31 [PATCH] x86/fpu: Remove unneeded saving of FPU registers in copy_fpstate_to_sigframe() Sebastian Andrzej Siewior
2019-04-30 11:30 ` [tip:x86/fpu] x86/fpu: Remove unnecessary " tip-bot for Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).