aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2016-10-31 18:18:47 -0400
committerIngo Molnar <mingo@kernel.org>2016-11-01 02:47:54 -0400
commitbef8b6da95229f780a0a7f63e23124058bfad6d3 (patch)
treec754093dab4dfe4262457d82c98eacd271c2c899
parentcd95ea81f25608c403052d0508ee5c9b32e2bc7d (diff)
x86/fpu: Handle #NM without FPU emulation as an error
Don't use CR0.TS. Make it an error rather than making nonsensical changes to the FPU state. (The cond_local_irq_enable() appears to have been pointless, too.) Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com> Cc: Rik van Riel <riel@redhat.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: kvm list <kvm@vger.kernel.org> Link: http://lkml.kernel.org/r/f1ee6bf73ed1025fccaab321ba43d0594245f927.1477951965.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/traps.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index bd4e3d4d3625..bf0c6d049080 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -853,6 +853,8 @@ do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
853dotraplinkage void 853dotraplinkage void
854do_device_not_available(struct pt_regs *regs, long error_code) 854do_device_not_available(struct pt_regs *regs, long error_code)
855{ 855{
856 unsigned long cr0;
857
856 RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU"); 858 RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
857 859
858#ifdef CONFIG_MATH_EMULATION 860#ifdef CONFIG_MATH_EMULATION
@@ -866,10 +868,20 @@ do_device_not_available(struct pt_regs *regs, long error_code)
866 return; 868 return;
867 } 869 }
868#endif 870#endif
869 fpu__restore(&current->thread.fpu); /* interrupts still off */ 871
870#ifdef CONFIG_X86_32 872 /* This should not happen. */
871 cond_local_irq_enable(regs); 873 cr0 = read_cr0();
872#endif 874 if (WARN(cr0 & X86_CR0_TS, "CR0.TS was set")) {
875 /* Try to fix it up and carry on. */
876 write_cr0(cr0 & ~X86_CR0_TS);
877 } else {
878 /*
879 * Something terrible happened, and we're better off trying
880 * to kill the task than getting stuck in a never-ending
881 * loop of #NM faults.
882 */
883 die("unexpected #NM exception", regs, error_code);
884 }
873} 885}
874NOKPROBE_SYMBOL(do_device_not_available); 886NOKPROBE_SYMBOL(do_device_not_available);
875 887