* [PATCH] x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU
@ 2026-08-31 18:57 Eric Biggers
2026-08-31 19:59 ` H. Peter Anvin
2026-09-23 21:14 ` Borislav Petkov
0 siblings, 2 replies; 4+ messages in thread
From: Eric Biggers @ 2026-08-31 18:57 UTC (permalink / raw)
To: x86, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen
Cc: linux-kernel, H . Peter Anvin, Arnd Bergmann, Eric Biggers
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.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
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(-)
diff --git a/arch/x86/kernel/fpu/bugs.c b/arch/x86/kernel/fpu/bugs.c
index edbafc5940e3..4b84cd0a9d24 100644
--- a/arch/x86/kernel/fpu/bugs.c
+++ b/arch/x86/kernel/fpu/bugs.c
@@ -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();
/*
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index d1aeecd57f5e..100bfe7336dd 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -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))
asm volatile ("fninit");
}
EXPORT_SYMBOL_GPL(kernel_fpu_begin_mask);
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 0d33c217b71c..8804ef0295dc 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -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: */
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index a7b6524a9dea..029a9b896997 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -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
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU
2026-08-31 18:57 [PATCH] x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU Eric Biggers
@ 2026-08-31 19:59 ` H. Peter Anvin
2026-09-23 21:14 ` Borislav Petkov
1 sibling, 0 replies; 4+ messages in thread
From: H. Peter Anvin @ 2026-08-31 19:59 UTC (permalink / raw)
To: Eric Biggers, x86, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen
Cc: linux-kernel, Arnd Bergmann
On 2026-08-31 11:57, Eric Biggers wrote:
> 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.
>
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: H. Peter Anvin <hpa@zytor.com>
-hpa
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU
2026-08-31 18:57 [PATCH] x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU Eric Biggers
2026-08-31 19:59 ` H. Peter Anvin
@ 2026-09-23 21:14 ` Borislav Petkov
2026-09-24 3:24 ` Eric Biggers
1 sibling, 1 reply; 4+ messages in thread
From: Borislav Petkov @ 2026-09-23 21:14 UTC (permalink / raw)
To: Eric Biggers
Cc: x86, Thomas Gleixner, Ingo Molnar, Dave Hansen, linux-kernel,
H . Peter Anvin, Arnd Bergmann
On Mon, Aug 31, 2026 at 11:57:06AM -0700, Eric Biggers wrote:
> 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.
>
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
> 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.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU
2026-09-23 21:14 ` Borislav Petkov
@ 2026-09-24 3:24 ` Eric Biggers
0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2026-09-24 3:24 UTC (permalink / raw)
To: Borislav Petkov
Cc: x86, Thomas Gleixner, Ingo Molnar, Dave Hansen, linux-kernel,
H . Peter Anvin, Arnd Bergmann
On Wed, Sep 23, 2026 at 02:14:50PM -0700, Borislav Petkov wrote:
> On Mon, Aug 31, 2026 at 11:57:06AM -0700, Eric Biggers wrote:
> > 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.
> >
> > Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> > ---
> > 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
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-24 3:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-31 18:57 [PATCH] x86/fpu: Remove unnecessary checks for X86_FEATURE_FPU Eric Biggers
2026-08-31 19:59 ` H. Peter Anvin
2026-09-23 21:14 ` Borislav Petkov
2026-09-24 3:24 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®