Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1315477
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/5] x86/fpu: Fix FNSAVE usage in eagerfpu mode |
| Date | 2016-01-23 02:00 +0100 |
| Message-ID | <qTUIy-3qs-11@gated-at.bofh.it> (permalink) |
| References | <qTUIx-3qs-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
In eager fpu mode, having deactivated fpu without immediately
reloading some other context is illegal. Therefore, to recover from
FNSAVE, we can't just deactivate the state -- we need to reload it
if we're not actively context switching.
We had this wrong in fpu__save and fpu__copy. Fix both.
__kernel_fpu_begin was fine -- add a comment.
This fixes a warning triggerable with nofxsr eagerfpu=on.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/kernel/fpu/core.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 08e1e11a05ca..7a9244df33e2 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -114,6 +114,10 @@ void __kernel_fpu_begin(void)
kernel_fpu_disable();
if (fpu->fpregs_active) {
+ /*
+ * Ignore return value -- we don't care if reg state
+ * is clobbered.
+ */
copy_fpregs_to_fpstate(fpu);
} else {
this_cpu_write(fpu_fpregs_owner_ctx, NULL);
@@ -189,8 +193,12 @@ void fpu__save(struct fpu *fpu)
preempt_disable();
if (fpu->fpregs_active) {
- if (!copy_fpregs_to_fpstate(fpu))
- fpregs_deactivate(fpu);
+ if (!copy_fpregs_to_fpstate(fpu)) {
+ if (use_eager_fpu())
+ copy_kernel_to_fpregs(&fpu->state);
+ else
+ fpregs_deactivate(fpu);
+ }
}
preempt_enable();
}
@@ -259,7 +267,11 @@ static void fpu_copy(struct fpu *dst_fpu, struct fpu *src_fpu)
preempt_disable();
if (!copy_fpregs_to_fpstate(dst_fpu)) {
memcpy(&src_fpu->state, &dst_fpu->state, xstate_size);
- fpregs_deactivate(src_fpu);
+
+ if (use_eager_fpu())
+ copy_kernel_to_fpregs(&src_fpu->state);
+ else
+ fpregs_deactivate(src_fpu);
}
preempt_enable();
}
--
2.5.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] x86/fpu: eagerfpu fixes, speedups, and default enablement Andy Lutomirski <luto@kernel.org> - 2016-01-23 02:00 +0100
[PATCH 2/5] x86/fpu: Fix FNSAVE usage in eagerfpu mode Andy Lutomirski <luto@kernel.org> - 2016-01-23 02:00 +0100
[PATCH 4/5] x86/fpu: Speed up lazy FPU restores slightly Andy Lutomirski <luto@kernel.org> - 2016-01-23 02:00 +0100
Re: [PATCH 4/5] x86/fpu: Speed up lazy FPU restores slightly Borislav Petkov <bp@alien8.de> - 2016-01-23 11:20 +0100
Re: [PATCH 4/5] x86/fpu: Speed up lazy FPU restores slightly Andy Lutomirski <luto@amacapital.net> - 2016-01-23 23:20 +0100
Re: [PATCH 4/5] x86/fpu: Speed up lazy FPU restores slightly Borislav Petkov <bp@alien8.de> - 2016-01-24 00:40 +0100
[PATCH 5/5] x86/fpu: Default eagerfpu=on on all CPUs Andy Lutomirski <luto@kernel.org> - 2016-01-23 02:00 +0100
Re: [PATCH 5/5] x86/fpu: Default eagerfpu=on on all CPUs Borislav Petkov <bp@alien8.de> - 2016-01-23 11:30 +0100
[PATCH 1/5] x86/fpu: Fix math emulation in eager fpu mode Andy Lutomirski <luto@kernel.org> - 2016-01-23 02:00 +0100
Re: [PATCH 1/5] x86/fpu: Fix math emulation in eager fpu mode Borislav Petkov <bp@alien8.de> - 2016-01-23 11:10 +0100
Re: [PATCH 1/5] x86/fpu: Fix math emulation in eager fpu mode Andy Lutomirski <luto@amacapital.net> - 2016-01-23 18:50 +0100
Re: [PATCH 1/5] x86/fpu: Fix math emulation in eager fpu mode Borislav Petkov <bp@alien8.de> - 2016-01-23 19:00 +0100
csiph-web