[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCg2DSYp0nakwX3l@gmail.com>
Date: Sat, 17 May 2025 09:09:01 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Eric Biggers <ebiggers@...nel.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
linux-crypto@...r.kernel.org, linux-pm@...r.kernel.org,
Borislav Petkov <bp@...en8.de>,
Thomas Gleixner <tglx@...utronix.de>,
Ayush Jain <Ayush.Jain3@....com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Ard Biesheuvel <ardb@...nel.org>
Subject: Re: [PATCH 3/3] x86/fpu: Don't support kernel-mode FPU when
irqs_disabled()
* Eric Biggers <ebiggers@...nel.org> wrote:
> From: Eric Biggers <ebiggers@...gle.com>
>
> Make irq_fpu_usable() return false when irqs_disabled(). That makes the
> irqs_disabled() checks in kernel_fpu_begin_mask() and kernel_fpu_end()
> unnecessary, so also remove those.
>
> Rationale:
>
> - There's no known use case for kernel-mode FPU when irqs_disabled().
Except EFI?
> arm64 and riscv already disallow kernel-mode FPU when irqs_disabled().
> __save_processor_state() previously did expect kernel_fpu_begin() and
> kernel_fpu_end() to work when irqs_disabled(), but this was a
> different use case and not actual kernel-mode FPU use.
>
> - This is more efficient, since one call to irqs_disabled() replaces two
> irqs_disabled() and one in_hardirq().
This is noise compared to the overhead of saving/restoring vector CPU
context ...
> - This fixes irq_fpu_usable() to correctly return false during CPU
> initialization. Incorrectly returning true caused the SHA-256 library
> code, which is called when loading AMD microcode, to take a
> SIMD-optimized code path too early, causing a crash. By correctly
> returning false from irq_fpu_usable(), the generic SHA-256 code
> correctly gets used instead. (Note: SIMD-optimized SHA-256 doesn't
> get enabled until subsys_initcall, but CPU hotplug can happen later.)
Alternatively we could set in_kernel_fpu during CPU bootstrap, and
clear it once we know the FPU is usable? This is only a relatively
short early boot period, with no scheduling, right?
Thanks,
Ingo
Powered by blists - more mailing lists