From: Thomas Gleixner <tglx@linutronix.de>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Borislav Petkov <bp@alien8.de>,
LKML <linux-kernel@vger.kernel.org>,
x86@kernel.org, Filipe Manana <fdmanana@suse.com>,
linux-crypto@vger.kernel.org
Subject: Re: [patch 3/3] x86/fpu: Make FPU protection more robust
Date: Wed, 04 May 2022 18:45:45 +0200 [thread overview]
Message-ID: <87czgtjlfq.ffs@tglx> (raw)
In-Reply-To: <YnKh96isoB7jiFrv@zx2c4.com>
Jason,
On Wed, May 04 2022 at 17:55, Jason A. Donenfeld wrote:
> On Wed, May 04, 2022 at 05:36:38PM +0200, Thomas Gleixner wrote:
>> But the only use case which utilizes FPU from hard interrupt context is
>> the random generator via add_randomness_...().
>>
>> I did a benchmark of these functions, which invoke blake2s_update()
>> three times in a row, on a SKL-X and a ZEN3. The generic code and the
>> FPU accelerated code are pretty much on par vs. execution time of the
>> algorithm itself plus/minus noise.
>>
>> IOW, using the FPU blindly for this kind of computations is not
>> necessarily a good plan. I have no idea how these things are analyzed
>> and evaluated if at all. Maybe the crypto people can shed some light on
>> this.
>
> drivers/net/wireguard/{noise,cookie}.c makes pretty heavy use of BLAKE2s
> in hot paths where the FPU is already being used for other algorithms,
> and so there the save/restore is worth it (assuming restore finally
> works lazily). In benchmarks, the SIMD code made a real difference.
I'm sure there are very valid use cases, but just the two things I
looked at turned out to be questionable at least.
> But this presumably regards mix_pool_bytes() in the RNG. If it turns out
> that supporting the FPU in hard IRQ context is a major PITA, and the
> RNG
Supporting FPU in hard interrupt context is possible if required and the
preexisting bug which survived 10+ years has been fixed.
x
I just started to look into this because of that bug and due to the
inconsistency between the FPU protections we have. The inconsistency
comes from the hardirq requirement.
> is the only thing making use of it, then sure, drop hard IRQ context
> support for it. However... This may be unearthing a larger bug.
> Sebastian and I put in a decent amount of work during 5.18 to remove all
> calls to mix_pool_bytes() (and hence to blake2s_compress()) from
> add_interrupt_randomness(). Have a look:
I know.
> It now accumulates in some per-CPU buffer, and then every 64 interrupts
> a worker runs that does the actual mix_pool_bytes() from kthread
> context.
That's add_interrupt_randomness() and not affected by this.
> So the question is: what is still hitting mix_pool_bytes() from hard IRQ
> context? I'll investigate a bit and see.
add_disk_randomness() on !RT kernels. That's what made me look into this
in the first place as it unearthed the long standing FPU protection
bug. See the first patch in this thread.
Possibly add_device_randomness() too, but I haven't seen evidence so far.
Thanks,
tglx
next prev parent reply other threads:[~2022-05-04 16:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220501192740.203963477@linutronix.de>
[not found] ` <20220501193102.704267030@linutronix.de>
[not found] ` <Ym/sHqKqmLOJubgE@zn.tnic>
[not found] ` <87k0b4lydr.ffs@tglx>
[not found] ` <YnDwjjdiSQ5Yml6E@hirez.programming.kicks-ass.net>
2022-05-04 15:36 ` [patch 3/3] x86/fpu: Make FPU protection more robust Thomas Gleixner
2022-05-04 15:55 ` Jason A. Donenfeld
2022-05-04 16:45 ` Thomas Gleixner [this message]
2022-05-04 19:05 ` Jason A. Donenfeld
2022-05-04 21:04 ` Thomas Gleixner
2022-05-04 23:52 ` Jason A. Donenfeld
2022-05-05 0:55 ` Thomas Gleixner
2022-05-05 1:11 ` Jason A. Donenfeld
2022-05-05 1:21 ` Thomas Gleixner
2022-05-05 11:02 ` Jason A. Donenfeld
2022-05-05 11:34 ` David Laight
2022-05-05 11:35 ` Jason A. Donenfeld
2022-05-05 11:53 ` David Laight
2022-05-06 22:34 ` Jason A. Donenfeld
2022-05-07 13:50 ` David Laight
2022-05-05 13:48 ` Jason A. Donenfeld
2022-05-06 22:15 ` Jason A. Donenfeld
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=87czgtjlfq.ffs@tglx \
--to=tglx@linutronix.de \
--cc=Jason@zx2c4.com \
--cc=bp@alien8.de \
--cc=fdmanana@suse.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--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).