x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU
PATCH 1/1 x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU
Since commit ab05214025ee ("x86/fpu: Remove MATH_EMULATION and related glue code"), X86_FEATURE_FPU is mandatory. If it's absent, the kernel halts execution in fpu__init_system_early_generic(). Remove unnecessary checks for X86_FEATURE_FPU that occur later in core x86 code.
--- arch/x86/kernel/fpu/bugs.c | 4 ---- arch/x86/kernel/fpu/core.c | 2 +- arch/x86/kernel/fpu/init.c | 2 -- arch/x86/kernel/fpu/xstate.c | 5 ----- 4 files changed, 1 insertion(+), 12 deletions(-)
arch/x86/kernel/fpu/bugs.c +0 -4
@@ -29,10 +29,6 @@ void __init fpu__init_check_bugs(void) {s32 fdiv_bug; -/* kernel_fpu_begin/end() relies on patched alternative instructions. */ -if (!boot_cpu_has (X86_FEATURE_FPU )) -return ; -kernel_fpu_begin ();/*
arch/x86/kernel/fpu/core.c +1 -1
@@ -491,7 +491,7 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)if (likely (kfpu_mask &KFPU_MXCSR ) &&boot_cpu_has (X86_FEATURE_XMM ))ldmxcsr (MXCSR_DEFAULT ); -if (unlikely (kfpu_mask &KFPU_387 ) &&boot_cpu_has (X86_FEATURE_FPU )) +if (unlikely (kfpu_mask &KFPU_387 )) asmvolatile ("fninit" ); }EXPORT_SYMBOL_GPL (kernel_fpu_begin_mask);
arch/x86/kernel/fpu/init.c +0 -2
@@ -31,8 +31,6 @@ static void fpu__init_cpu_generic(void) cr0 =read_cr0 (); cr0 &= ~(X86_CR0_TS |X86_CR0_EM );/* clear TS and EM */ -if (!boot_cpu_has (X86_FEATURE_FPU )) - cr0 |=X86_CR0_EM ;write_cr0 (cr0);/* Flush out any pending x87 state: */
arch/x86/kernel/fpu/xstate.c +0 -5
@@ -810,11 +810,6 @@ void __init fpu__init_system_xstate(unsigned int legacy_size)int err;int i; -if (!boot_cpu_has (X86_FEATURE_FPU )) { -pr_info ("x86/fpu: No FPU detected\n" ); -return ; - } -if (!boot_cpu_has (X86_FEATURE_XSAVE )) {pr_info ("x86/fpu: x87 FPU will use %s\n" ,boot_cpu_has (X86_FEATURE_FXSR ) ?"FXSAVE" :"FSAVE" );
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
Signature · 1 line
2.55.0
Quoted 6 lines · Eric Biggers
Since commit
ab05214025ee("x86/fpu: RemoveMATH_EMULATIONand related glue code"),X86_FEATURE_FPUis mandatory. If it's absent, the kernel halts execution infpu__init_system_early_generic(). Remove unnecessary checks forX86_FEATURE_FPUthat occur later in core x86 code.Signed-off-by Eric Biggers <[email protected]>
-hpa
Borislav Petkov
maintainerQuoted 5 lines · Eric Biggers
Since commit
ab05214025ee("x86/fpu: RemoveMATH_EMULATIONand related glue code"),X86_FEATURE_FPUis mandatory. If it's absent, the kernel halts execution infpu__init_system_early_generic(). Remove unnecessary checks forX86_FEATURE_FPUthat occur later in core x86 code.
Quoted 7 lines
Signed-off-by Eric Biggers <[email protected]>--- arch/x86/kernel/fpu/bugs.c | 4 ---- arch/x86/kernel/fpu/core.c | 2 +- arch/x86/kernel/fpu/init.c | 2 -- arch/x86/kernel/fpu/xstate.c | 5 ----- 4 files changed, 1 insertion(+), 12 deletions(-)
Sashiko might have a point here:
https://sashiko.dev/#/patchset/20260831185706.90103-1-ebiggers%40kernel.org
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 14 lines · Borislav Petkov
Quoted 5 lines · Eric Biggers
Since commit
ab05214025ee("x86/fpu: RemoveMATH_EMULATIONand related glue code"),X86_FEATURE_FPUis mandatory. If it's absent, the kernel halts execution infpu__init_system_early_generic(). Remove unnecessary checks forX86_FEATURE_FPUthat occur later in core x86 code.Quoted 7 lines
Signed-off-by Eric Biggers <[email protected]>--- arch/x86/kernel/fpu/bugs.c | 4 ---- arch/x86/kernel/fpu/core.c | 2 +- arch/x86/kernel/fpu/init.c | 2 -- arch/x86/kernel/fpu/xstate.c | 5 ----- 4 files changed, 1 insertion(+), 12 deletions(-)
Quoted 3 lines
Sashiko might have a point here:
https://sashiko.dev/#/patchset/20260831185706.90103-1-ebiggers%40kernel.org
Sure, there's more stuff that can be removed too. It will make for a large patch, but I'll try to get the rest in x86/fpu code.
- Eric