mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Gus Bourg <gus@bourg.net>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] arm64/efi: Do not call EFI runtime services preemptibly under SW PAN
Date: Tue, 11 Aug 2026 13:09:19 +0100	[thread overview]
Message-ID: <ansQ7xG51RddFmVu@willie-the-truck> (raw)
In-Reply-To: <CAKL=SEpvBqMjw2Ts4ODYHCJz0K1axwmtrUGKQEJeb_rvuAQk0A@mail.gmail.com>

On Mon, Aug 10, 2026 at 05:51:16PM -0700, Gus Bourg wrote:
> On Mon, Aug 10, 2026 at 4:04 AM Will Deacon <will@kernel.org> wrote:
> > On Fri, Aug 07, 2026 at 04:56:00PM +0300, Ard Biesheuvel wrote:
> > > On Fri, 7 Aug 2026, at 15:16, Will Deacon wrote:
> > > > On Wed, Aug 05, 2026 at 05:01:44PM -0700, gus bourg wrote:
> > > >> There is such a preemption point in arch_efi_call_virt_setup() itself,
> > > >> immediately after the TTBR0 install: __efi_fpsimd_begin() ->
> > > >> kernel_neon_begin() -> put_cpu_fpsimd_context() -> local_bh_enable() ->
> > > >> preempt_check_resched().
> > > >
> > > > Hmm, can we move the ttbr0 toggling until after __efi_fpsimd_begin() so
> > > > that this preemption point doesn't interfere?
> > > >
> > >
> > > Either that, or tweak the logic so that the switch is done eagerly in
> > > this particular case (untested):
> > >
> > > --- a/arch/arm64/mm/context.c
> > > +++ b/arch/arm64/mm/context.c
> > > @@ -266,7 +266,7 @@
> > >          * Defer TTBR0_EL1 setting for user threads to uaccess_enable() when
> > >          * emulating PAN.
> > >          */
> > > -       if (!system_uses_ttbr0_pan())
> > > +       if (!system_uses_ttbr0_pan() || mm_is_efi(mm))
> > >                 cpu_switch_mm(mm->pgd, mm);
> > >  }
> >
> > I think I'd prefer to avoid special-casing this, if we can. I was just
> > thinking of the diff below.
> 
> Tested the v2 approach (__efi_fpsimd_begin() before
> uaccess_ttbr0_enable()) on the board that originally reproduced the
> oops: Khadas VIM3, Amlogic A311D (4x Cortex-A73 + 2x Cortex-A53, no
> FEAT_PAN, so CONFIG_ARM64_SW_TTBR0_PAN is in use), EDK2-based UEFI
> firmware, v7.0.12 plus this change alone (my prior workaround removed).
> 
> Both firmware description modes were exercised (DeviceTree and ACPI
> boots of the same system):
> 
>   - 3,000,000 GetVariable calls (three concurrent readers) plus
>     200,000 GetTime calls per mode, under sustained CPU contention
>     (busy-loop load on half the cores to force scheduling in the call
>     window) - i.e. 6.4M calls total across the ACPI and DeviceTree
>     boots of the same system
>   - SetVariable create/write/delete round-trips in both modes
>   - ~15 reboots/power cycles (ResetSystem) and clean shutdowns across
>     the session
> 
> Zero efi_call_rts faults and zero "Unable to handle kernel access to
> user memory" events; efivars and the EFI RTC remained functional
> throughout, and poweroff/reboot stayed clean. Under the unpatched
> preemptible path the same board faulted within thousands of calls with
> comparable contention, so this comfortably clears the reproduction
> threshold.
> 
> Tested-by: gus bourg <gus@bourg.net>

Thanks for giving it a spin. I'll send it out as a proper patch.

Will

      reply	other threads:[~2026-08-11 12:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  0:01 gus bourg
2026-08-07 12:16 ` Will Deacon
2026-08-07 13:56   ` Ard Biesheuvel
2026-08-10 11:04     ` Will Deacon
2026-08-10 15:43       ` Ard Biesheuvel
2026-08-11  0:51       ` Gus Bourg
2026-08-11 12:09         ` Will Deacon [this message]

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=ansQ7xG51RddFmVu@willie-the-truck \
    --to=will@kernel.org \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=gus@bourg.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.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

all inboxes | Powered by JetHome®