blob: 9749a3a67153f3bbd76a4877b8b809ade4a28f37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 30 Apr 2019 10:31:26 +0200
Subject: [PATCH] x86/fpu: Remove unnecessary saving of FPU registers in
copy_fpstate_to_sigframe()
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.0/older/patches-5.0.10-rt7.tar.xz
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 necessary 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>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason@zx2c4.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>
Cc: bp@suse.de
Cc: jannh@google.com
Cc: kurt.kanzenbach@linutronix.de
Cc: kvm@vger.kernel.org
Cc: pbonzini@redhat.com
Cc: riel@surriel.com
Cc: rkrcmar@redhat.com
Link: http://lkml.kernel.org/r/20190430083126.rilbb76yc27vrem5@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/fpu/signal.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -157,10 +157,9 @@ static inline int copy_fpregs_to_sigfram
*/
int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size)
{
- struct fpu *fpu = ¤t->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));
@@ -187,9 +186,6 @@ int copy_fpstate_to_sigframe(void __user
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) {
|