aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorDave Hansen <dave.hansen@linux.intel.com>2016-07-20 15:45:51 -0400
committerIngo Molnar <mingo@kernel.org>2016-07-21 12:18:45 -0400
commitec3ed4a2104b8d1ab8da2db5b1221b2ba8a7a6e1 (patch)
tree2889b08cebb04dfb937b9915d3ae31a683dc512e /arch/x86/kernel
parentb8be15d588060a03569ac85dc4a0247460988f5b (diff)
x86/fpu: Do not BUG_ON() in early FPU code
I don't think it is really possible to have a system where CPUID enumerates support for XSAVE but that it does not have FP/SSE (they are "legacy" features and always present). But, I did manage to hit this case in qemu when I enabled its somewhat shaky XSAVE support. The bummer is that the FPU is set up before we parse the command-line or have *any* console support including earlyprintk. That turned what should have been an easy thing to debug in to a bit more of an odyssey. So a BUG() here is worthless. All it does it guarantee that if/when we hit this case we have an empty console. So, remove the BUG() and try to limp along by disabling XSAVE and trying to continue. Add a comment on why we are doing this, and also add a common "out_disable" path for leaving fpu__init_system_xstate(). Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave@sr71.net> 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: Peter Zijlstra <peterz@infradead.org> Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20160720194551.63BB2B58@viggo.jf.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/fpu/xstate.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 3169bcaf9391..680049aa4593 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -714,8 +714,13 @@ void __init fpu__init_system_xstate(void)
714 xfeatures_mask = eax + ((u64)edx << 32); 714 xfeatures_mask = eax + ((u64)edx << 32);
715 715
716 if ((xfeatures_mask & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) { 716 if ((xfeatures_mask & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) {
717 /*
718 * This indicates that something really unexpected happened
719 * with the enumeration. Disable XSAVE and try to continue
720 * booting without it. This is too early to BUG().
721 */
717 pr_err("x86/fpu: FP/SSE not present amongst the CPU's xstate features: 0x%llx.\n", xfeatures_mask); 722 pr_err("x86/fpu: FP/SSE not present amongst the CPU's xstate features: 0x%llx.\n", xfeatures_mask);
718 BUG(); 723 goto out_disable;
719 } 724 }
720 725
721 xfeatures_mask &= fpu__get_supported_xfeatures_mask(); 726 xfeatures_mask &= fpu__get_supported_xfeatures_mask();
@@ -723,11 +728,8 @@ void __init fpu__init_system_xstate(void)
723 /* Enable xstate instructions to be able to continue with initialization: */ 728 /* Enable xstate instructions to be able to continue with initialization: */
724 fpu__init_cpu_xstate(); 729 fpu__init_cpu_xstate();
725 err = init_xstate_size(); 730 err = init_xstate_size();
726 if (err) { 731 if (err)
727 /* something went wrong, boot without any XSAVE support */ 732 goto out_disable;
728 fpu__init_disable_system_xstate();
729 return;
730 }
731 733
732 /* 734 /*
733 * Update info used for ptrace frames; use standard-format size and no 735 * Update info used for ptrace frames; use standard-format size and no
@@ -744,6 +746,11 @@ void __init fpu__init_system_xstate(void)
744 xfeatures_mask, 746 xfeatures_mask,
745 fpu_kernel_xstate_size, 747 fpu_kernel_xstate_size,
746 boot_cpu_has(X86_FEATURE_XSAVES) ? "compacted" : "standard"); 748 boot_cpu_has(X86_FEATURE_XSAVES) ? "compacted" : "standard");
749 return;
750
751out_disable:
752 /* something went wrong, try to boot without any XSAVE support */
753 fpu__init_disable_system_xstate();
747} 754}
748 755
749/* 756/*