Re: [PATCH] x86/fpu: Fix irq_fpu_usable() to return false during CPU onlining
From: Eric Biggers
Date: Mon May 19 2025 - 13:04:51 EST
On Mon, May 19, 2025 at 10:32:08AM +0200, Ingo Molnar wrote:
>
> > void fpu__init_cpu(void)
> > {
> > fpu__init_cpu_generic();
> > fpu__init_cpu_xstate();
> > +
> > + /* Start allowing kernel-mode FPU: */
> > + this_cpu_write(kernel_fpu_allowed, true);
> > }
>
> BTW., this is the chunk that fixes the crypto crash, right? If yes,
> then could you please split this from the main patch, with the main
> patch setting kernel_fpu_allowed very early, which should make the main
> patch an identity transformation with no (expected) change in behavior.
>
> Likewise, the cpu_disable_common change should similarly replicate the
> current code, and should only be changed in the second patch.
>
> Phasing it in like that should improve bisectability, for the off
> chance of some regression.
The line in fpu__init_cpu() is needed at the same time that the boolean is
inverted (when in_kernel_fpu is replaced with kernel_fpu_allowed), since
otherwise it never gets set to true and kernel-mode FPU is never allowed.
We could include the fpu__init_cpu() change in patch 1 and leave CPU hotplug
broken, and fix it in patch 2 by updating cpu_disable_common(). I think it
makes a lot more sense to keep them together though.
Or we could use DEFINE_PER_CPU() = true in patch 1, then revert that in patch 2
and replace it with the line in fpu__init_cpu(). But again I think the split
would be more likely to create problems than solve them.
- Eric