From: David Laight <david.laight.linux@gmail.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: Dave Hansen <dave.hansen@intel.com>,
Eric Biggers <ebiggers@kernel.org>,
x86@kernel.org, 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>,
"Bae, Chang Seok" <chang.seok.bae@intel.com>
Subject: Re: [RFC PATCH v2] x86/fpu: make kernel-mode FPU reliably usable in softirqs
Date: Wed, 5 Mar 2025 21:22:55 +0000 [thread overview]
Message-ID: <20250305212255.4989a8ab@pumpkin> (raw)
In-Reply-To: <Z8iL1dY3o9OxQgBy@gmail.com>
On Wed, 5 Mar 2025 18:37:25 +0100
Ingo Molnar <mingo@kernel.org> wrote:
> * Dave Hansen <dave.hansen@intel.com> wrote:
>
> > On 3/5/25 01:07, Ingo Molnar wrote:>> Alternatives considered:
> > >> - Make kernel-mode FPU sections fully preemptible. This would require
> > >> growing task_struct by another struct fpstate which is more than 2K.
> > >
> > > So that's something that will probably happen once the kernel is built
> > > using APX anyway?
> >
> > I was expecting that building the kernel with APX would be very
> > different than a kernel_fpu_begin(). We don't just need *one* more
> > save area for APX registers: we need a stack, just like normal GPRs.
>
> Yes - but my point is: with any APX build we'd probably be saving
> FPU(-ish) registers at entry points, into a separate context area. If
> that includes FPU registers then we'd not have to do
> kernel_fpu_begin()/end().
Since the registers are caller saved (like the SSE onwards ones)
none of them really need to be saved on syscall entry
(just zeroed on return).
They do need saving on interrupt entry.
For some unknown reason the kernel saves the xyzmm ones on syscall entry.
For normal programs they won't be live - because of the asm syscall
wrapper is called from C.
So I think they can only be live if a system call is directly inlined
into the C function. Just marking them all 'clobbered' would have done.
But it now all too late to change.
David
>
> In other words, we'd be doing something close to 'growing task_struct
> by another struct fpstate', or so - regardless of whether it's in
> task_struct or some sort of extended pt_regs. The kernel would also be
> close to 'FPU-safe', i.e. there likely wouldn't be a need for
> kernel_fpu_begin()/end().
>
> Thanks,
>
> Ingo
>
next prev parent reply other threads:[~2025-03-05 21:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 20:49 [RFC PATCH v2] x86/fpu: make kernel-mode FPU reliably usable in softirqs Eric Biggers
2025-03-05 9:07 ` Ingo Molnar
2025-03-05 16:55 ` Dave Hansen
2025-03-05 17:37 ` Ingo Molnar
2025-03-05 18:04 ` Dave Hansen
2025-03-05 18:13 ` Ingo Molnar
2025-03-05 21:22 ` David Laight [this message]
2025-03-05 17:39 ` Eric Biggers
2025-03-05 18:09 ` Ingo Molnar
2025-03-05 20:30 ` Eric Biggers
2025-03-06 11:42 ` Ingo Molnar
2025-03-06 12:09 ` Peter Zijlstra
2025-03-06 12:00 ` [tip: x86/fpu] x86/fpu: Improve crypto performance by making " tip-bot2 for Eric Biggers
2025-03-06 17:54 ` 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=20250305212255.4989a8ab@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=ebiggers@kernel.org \
--cc=greearb@candelatech.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@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