[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXHzFiQsjUH90J56ds2fgge-MUXmFMBWKtmb0LF=UjbJcg@mail.gmail.com>
Date: Mon, 19 May 2025 15:50:55 +0200
From: Ard Biesheuvel <ardb@...nel.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: Eric Biggers <ebiggers@...nel.org>, x86@...nel.org, linux-kernel@...r.kernel.org,
linux-crypto@...r.kernel.org, linux-pm@...r.kernel.org,
Borislav Petkov <bp@...en8.de>, Thomas Gleixner <tglx@...utronix.de>, Ayush Jain <Ayush.Jain3@....com>,
Herbert Xu <herbert@...dor.apana.org.au>
Subject: Re: [PATCH 3/3] x86/fpu: Don't support kernel-mode FPU when irqs_disabled()
On Mon, 19 May 2025 at 14:57, Ingo Molnar <mingo@...nel.org> wrote:
>
>
> * Ard Biesheuvel <ardb@...nel.org> wrote:
>
> > On Mon, 19 May 2025 at 10:06, Ingo Molnar <mingo@...nel.org> wrote:
> > >
> > >
> > > * Eric Biggers <ebiggers@...nel.org> wrote:
> > >
> > > > > # echo PANIC > /sys/kernel/debug/provoke-crash/DIRECT
> > > > >
> > > > > Another case that likely executes with IRQs disabled (but I haven't
> > > > > double checked) is reset_system(), which may return with an error, or
> > > > > reboot/poweroff the machine and never return.
> > > >
> > > > That makes sense to me. preempt_disable() and preempt_enable() are already
> > > > allowed when IRQs are disabled, and I'm not sure why local_bh_disable() and
> > > > local_bh_enable() are different.
> > >
> > > Because local_bh_enable() may run softirq handlers immediately if
> > > there's pending softirqs, which shouldn't be done in hardirq context.
> > >
> >
> > Sure, but why is that mandatory?
> >
> >
> > preempt_disable() has preempt_enable() and preempt_enable_no_resched()
> > counterparts.
>
> > [...] Could we have a local_bh_enable_no_xxx() version that
> > re-enables async softirq processing on the current CPU but does not
> > kick off a synchronous processing run?
>
> Yes, that's what __local_bh_enable() does, but if used it for
> kernel_fpu_end() we'd be introducing random softirq processing
> latencies. The softirq execution model is for softirqs to be
> immediately executed after local_bh_enable(), and various networking
> code is tuned to that behavior.
>
All of that only applies when re-enabling softirqs with IRQs enabled.
> You can try talking the networking folks into an asynchronous
> local_bh_enable() executed on the next IRQ or the next scheduler tick
> or so, but it's a non-trivial behavioral change. It would probably also
> need user-return callback activation.
>
> I'm pretty sure that the naive implementation would increase LAN ping
> latencies by +4 msecs on a typical distro kernel.
>
I don't see why we'd need all of that.
Conceptually, kernel_fpu_end() would do
if (irqs_disabled())
local_bh_enable_no_xxx();
else
local_bh_enable();
which cannot affect any existing use cases, given that the former case
is forbidden atm.
Powered by blists - more mailing lists