From: Ingo Molnar <mingo@kernel.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
linux-crypto@vger.kernel.org, linux-pm@vger.kernel.org,
Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
Ayush Jain <Ayush.Jain3@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH 3/3] x86/fpu: Don't support kernel-mode FPU when irqs_disabled()
Date: Sat, 17 May 2025 09:09:01 +0200 [thread overview]
Message-ID: <aCg2DSYp0nakwX3l@gmail.com> (raw)
In-Reply-To: <20250516231858.27899-4-ebiggers@kernel.org>
* Eric Biggers <ebiggers@kernel.org> wrote:
> From: Eric Biggers <ebiggers@google.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
next prev parent reply other threads:[~2025-05-17 7:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 23:18 [PATCH 0/3] x86: Don't support kernel-mode FPU with hardirqs disabled Eric Biggers
2025-05-16 23:18 ` [PATCH 1/3] x86/fpu: Add fpu_save_state() for __save_processor_state() Eric Biggers
2025-05-16 23:18 ` [PATCH 2/3] x86/pm: Use fpu_save_state() in __save_processor_state() Eric Biggers
2025-05-16 23:18 ` [PATCH 3/3] x86/fpu: Don't support kernel-mode FPU when irqs_disabled() Eric Biggers
2025-05-17 7:09 ` Ingo Molnar [this message]
2025-05-17 18:39 ` Eric Biggers
2025-05-18 6:34 ` Ingo Molnar
2025-05-18 13:18 ` Ard Biesheuvel
2025-05-18 20:01 ` Eric Biggers
2025-05-19 8:05 ` Ingo Molnar
2025-05-19 9:49 ` Ard Biesheuvel
2025-05-19 12:57 ` Ingo Molnar
2025-05-19 13:50 ` Ard Biesheuvel
2025-05-20 7:42 ` Ingo Molnar
2025-05-17 1:30 ` [PATCH 0/3] x86: Don't support kernel-mode FPU with hardirqs disabled Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aCg2DSYp0nakwX3l@gmail.com \
--to=mingo@kernel.org \
--cc=Ayush.Jain3@amd.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).