linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: x86@kernel.org
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ard Biesheuvel <ardb@kernel.org>,
	Ben Greear <greearb@candelatech.com>,
	Xiao Liang <shaw.leon@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	"Jason A . Donenfeld" <Jason@zx2c4.com>
Subject: Re: [RFC PATCH 1/2] x86/fpu: make kernel-mode FPU reliably usable in softirqs
Date: Thu, 27 Feb 2025 19:59:24 -0800	[thread overview]
Message-ID: <20250228035924.GC5588@sol.localdomain> (raw)
In-Reply-To: <20250220051325.340691-2-ebiggers@kernel.org>

On Wed, Feb 19, 2025 at 09:13:24PM -0800, Eric Biggers wrote:
> To comply with the requirements of local_bh_disable and local_bh_enable,
> this change also removes support for kernel-mode FPU in hardirq context
> or with hardirqs disabled.  This should not be a problem, though.  There
> does not appear to be any use case for kernel-mode FPU in such contexts,
> and notably arm64 and riscv already have these same conditions.

I found a problem with this assumption: the system suspend and resume code calls
kernel_fpu_begin() and kernel_fpu_end() with hardirqs disabled.  See
__save_processor_state() and __restore_processor_state() in
arch/x86/power/cpu.c.  That triggers the WARN_ON_FPU(!irq_fpu_usable()).

I think there are two directions we could go with this: either choose a solution
that keeps kernel_fpu_begin() usable with hardirqs disabled; or change
__save_processor_state() and __restore_processor_state() to save/restore the FPU
registers directly, e.g. via save_fpregs_to_fpstate() and
restore_fpregs_from_fpstate().  (Kernel-mode FPU isn't actually being used in
this case, so a more direct save/restore might make sense here.)

- Eric

  parent reply	other threads:[~2025-02-28  3:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20  5:13 [RFC PATCH 0/2] Eliminate the no-SIMD en/decryption fallbacks on x86 Eric Biggers
2025-02-20  5:13 ` [RFC PATCH 1/2] x86/fpu: make kernel-mode FPU reliably usable in softirqs Eric Biggers
2025-02-21  7:38   ` Xiao Liang
2025-02-21 19:31     ` Eric Biggers
2025-02-25 22:21       ` David Laight
2025-02-25 22:59         ` Eric Biggers
2025-02-26 17:09           ` Dave Hansen
2025-02-28  3:59   ` Eric Biggers [this message]
2025-02-28 12:39     ` Ard Biesheuvel
2025-02-20  5:13 ` [RFC PATCH 2/2] crypto: x86 - stop using the SIMD helper Eric Biggers
2025-02-21  3:53 ` [RFC PATCH 0/2] Eliminate the no-SIMD en/decryption fallbacks on x86 Herbert Xu
2025-02-24 18:57 ` 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=20250228035924.GC5588@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=greearb@candelatech.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=shaw.leon@gmail.com \
    --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).