]> Git Repo - linux.git/commitdiff
x86/fpu: Do not BUG_ON() in early FPU code
authorDave Hansen <[email protected]>
Wed, 20 Jul 2016 19:45:51 +0000 (12:45 -0700)
committerIngo Molnar <[email protected]>
Thu, 21 Jul 2016 16:18:45 +0000 (18:18 +0200)
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 <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Quentin Casasnovas <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/kernel/fpu/xstate.c

index 3169bcaf93913ab18d541fd2edb8db1ecc6b11e0..680049aa4593ca773d9860a2b8af77eab3839f31 100644 (file)
@@ -714,8 +714,13 @@ void __init fpu__init_system_xstate(void)
        xfeatures_mask = eax + ((u64)edx << 32);
 
        if ((xfeatures_mask & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) {
+               /*
+                * This indicates that something really unexpected happened
+                * with the enumeration.  Disable XSAVE and try to continue
+                * booting without it.  This is too early to BUG().
+                */
                pr_err("x86/fpu: FP/SSE not present amongst the CPU's xstate features: 0x%llx.\n", xfeatures_mask);
-               BUG();
+               goto out_disable;
        }
 
        xfeatures_mask &= fpu__get_supported_xfeatures_mask();
@@ -723,11 +728,8 @@ void __init fpu__init_system_xstate(void)
        /* Enable xstate instructions to be able to continue with initialization: */
        fpu__init_cpu_xstate();
        err = init_xstate_size();
-       if (err) {
-               /* something went wrong, boot without any XSAVE support */
-               fpu__init_disable_system_xstate();
-               return;
-       }
+       if (err)
+               goto out_disable;
 
        /*
         * Update info used for ptrace frames; use standard-format size and no
@@ -744,6 +746,11 @@ void __init fpu__init_system_xstate(void)
                xfeatures_mask,
                fpu_kernel_xstate_size,
                boot_cpu_has(X86_FEATURE_XSAVES) ? "compacted" : "standard");
+       return;
+
+out_disable:
+       /* something went wrong, try to boot without any XSAVE support */
+       fpu__init_disable_system_xstate();
 }
 
 /*
This page took 0.065606 seconds and 4 git commands to generate.