Skip to contentSkip to conversation

x86, fpu: do not BUG_ON() in early FPU code

PATCH Superseded Dave Hansen 2 participants 2 messages Jul 20, 2016 x86

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, fpu: do not BUG_ON() in early FPU code

From: Dave Hansen <[email protected]>

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.

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.

---

 b/arch/x86/kernel/fpu/xstate.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/fpu/xstate.c renamed from arch/x86/kernel/fpu/xstate.c~x86-fpu-do-not-BUG_ON-early +2 -1
diff -puN arch/x86/kernel/fpu/xstate.c~x86-fpu-do-not-BUG_ON-early arch/x86/kernel/fpu/xstate.c
@@ -715,7 +715,8 @@ void __init fpu__init_system_xstate(void
 
 	if ((xfeatures_mask & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) {
 		pr_err("x86/fpu: FP/SSE not present amongst the CPU's xstate features: 0x%llx.\n", xfeatures_mask);
-		BUG();
+		fpu__init_disable_system_xstate();
+		return;
 	}
 
 	xfeatures_mask &= fpu__get_supported_xfeatures_mask();

_

#1 lore raw
Quoted 27 lines · Dave Hansen

From: Dave Hansen <[email protected]>

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.

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.

---

 b/arch/x86/kernel/fpu/xstate.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff -puN arch/x86/kernel/fpu/xstate.c~x86-fpu-do-not-BUG_ON-early arch/x86/kernel/fpu/xstate.c

arch/x86/kernel/fpu/xstate.c void __init fpu__init_system_xstate(void · line 719

Quoted 6 lines
arch/x86/kernel/fpu/xstate.c renamed from arch/x86/kernel/fpu/xstate.c~x86-fpu-do-not-BUG_ON-early +2 -1
@@ -715,7 +715,8 @@ void __init fpu__init_system_xstate(void
 
 	if ((xfeatures_mask & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) {
 		pr_err("x86/fpu: FP/SSE not present amongst the CPU's xstate features: 0x%llx.\n", xfeatures_mask);
-		BUG();
+		fpu__init_disable_system_xstate();
+		return;

Ok, but please put a comment there explaining why we are not stopping the system.

Thanks,

Ingo