Re: [PATCH RT v2] arm64: fpsimd: use a local_lock() in addition to local_bh_disable()

From: Dave Martin
Date: Tue Jul 24 2018 - 10:45:47 EST

On Wed, Jul 18, 2018 at 11:24:48AM +0200, Sebastian Andrzej Siewior wrote:
> On 2018-07-18 11:12:10 [+0200], To Dave Martin wrote:
> > > > - if (may_use_simd()) {
> > > > + if (!IS_ENABLED(CONFIG_PREEMPT_RT_BASE) && may_use_simd()) {
> > >
> > > I suspect this is wrong -- see comments on the commit message.
> I'm sorry, I pressed send too early, I was aiming for the draft folder.
> So yes, based on that EFI that might be interruptible, let me try to
> look at the initial issue again and maybe I get another idea how to deal
> with this.
> One question: If EFI is interruptible that means, we call into EFI - how
> do we get out? Does EFI enable interrupts and the kernel receives an
> interrupt and treats this EFI call like a regular context switch?

AFAIK the only safe way to get out permanently is for the call to
return. Note, I've not gone through the spec in fine detail myself.

The OS may handle interrupts occurring during the EFI call, but we
still have to return to EFI afterwards to finish off the call. From
the Linux perspective, I think this means that EFI calls are non-

Under RT, I'm pretty sure that we can't safely resume the interrupted
EFI call on a different cpu from the one it was interrupted on. Even
if it doesn't say this explicitly in the UEFI spec, I think it will be
assumed in implementations.

Certain EFI calls are not long-running and may need to be called from
interrupt context in Linux, which means that there may be live kernel-
mode NEON state. This is why there are separate FPSIMD/SVE percpu stash
buffers for EFI specifically.

Does this make sense? It's is probably not very clear, but I'm trying
to hide the fact that I haven't looked at the UEFI spec for ages...