public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Eric Biggers <ebiggers@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org, linux-pm@vger.kernel.org,
	Borislav Petkov <bp@alien8.de>, Ayush Jain <Ayush.Jain3@amd.com>,
	Ard Biesheuvel <ardb@kernel.org>, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] x86/fpu: Fix irq_fpu_usable() to return false during CPU onlining
Date: Mon, 26 May 2025 10:56:05 +0800	[thread overview]
Message-ID: <aDPYRUTYVGii2NYd@gondor.apana.org.au> (raw)
In-Reply-To: <87v7puq8g2.ffs@tglx>

On Wed, May 21, 2025 at 05:39:41PM +0200, Thomas Gleixner wrote:
> On Sun, May 18 2025 at 12:32, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> >
> > irq_fpu_usable() incorrectly returned true before the FPU is
> > initialized.  The x86 CPU onlining code can call sha256() to checksum
> > AMD microcode images, before the FPU is initialized.  Since sha256()
> > recently gained a kernel-mode FPU optimized code path, a crash occurred
> > in kernel_fpu_begin_mask() during hotplug CPU onlining.
> >
> > (The crash did not occur during boot-time CPU onlining, since the
> > optimized sha256() code is not enabled until subsys_initcalls run.)
> >
> > Fix this by making irq_fpu_usable() return false before fpu__init_cpu()
> > has run.  To do this without adding any additional overhead to
> > irq_fpu_usable(), replace the existing per-CPU bool in_kernel_fpu with
> > kernel_fpu_allowed which tracks both initialization and usage rather
> > than just usage.  The initial state is false; FPU initialization sets it
> > to true; kernel-mode FPU sections toggle it to false and then back to
> > true; and CPU offlining restores it to the initial state of false.
> >
> > Fixes: 11d7956d526f ("crypto: x86/sha256 - implement library instead of shash")
> > Reported-by: Ayush Jain <Ayush.Jain3@amd.com>
> > Closes: https://lore.kernel.org/r/20250516112217.GBaCcf6Yoc6LkIIryP@fat_crate.local
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> 
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Since this patch is holding up my pull request, I will be applying
it to cryptodev.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2025-05-26  2:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-18 19:32 [PATCH] x86/fpu: Fix irq_fpu_usable() to return false during CPU onlining Eric Biggers
2025-05-19  4:18 ` Jain, Ayush
2025-05-19  8:26 ` Ingo Molnar
2025-05-19  8:32   ` Ingo Molnar
2025-05-19 17:04     ` Eric Biggers
2025-05-20  9:33       ` Ingo Molnar
2025-05-21 15:39         ` Thomas Gleixner
2025-05-24  2:55           ` Eric Biggers
2025-05-21 15:39 ` Thomas Gleixner
2025-05-26  2:56   ` Herbert Xu [this message]

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=aDPYRUTYVGii2NYd@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=Ayush.Jain3@amd.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=ebiggers@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@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