From: Ard Biesheuvel <ardb@kernel.org>
Kernel mode FP/SIMD no longer requires preemption to be disabled, so
only warn on uses of FP/SIMD from preemptible context if the fallback
path is taken for cases where kernel mode NEON would not be allowed
otherwise.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/kernel/fpsimd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index e3f8f51748bc..3d848c89604e 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1934,11 +1934,11 @@ void __efi_fpsimd_begin(void)
if (!system_supports_fpsimd())
return;
- WARN_ON(preemptible());
-
if (may_use_simd()) {
kernel_neon_begin();
} else {
+ WARN_ON(preemptible());
+
/*
* If !efi_sve_state, SVE can't be in use yet and doesn't need
* preserving:
--
2.51.0.869.ge66316f041-goog
On Wed, Oct 15, 2025 at 10:56:38PM +0200, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@kernel.org>
>
> Kernel mode FP/SIMD no longer requires preemption to be disabled, so
> only warn on uses of FP/SIMD from preemptible context if the fallback
> path is taken for cases where kernel mode NEON would not be allowed
> otherwise.
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/arm64/kernel/fpsimd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index e3f8f51748bc..3d848c89604e 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -1934,11 +1934,11 @@ void __efi_fpsimd_begin(void)
> if (!system_supports_fpsimd())
> return;
>
> - WARN_ON(preemptible());
> -
> if (may_use_simd()) {
> kernel_neon_begin();
> } else {
> + WARN_ON(preemptible());
> +
Given that may_use_simd() returns false on systems without support for
fpsimd, I wonder whether moving this WARN_ON() actually helps with
anything. That is, you probably shouldn't be calling __efi_fpsimd_begin()
from preemptible code regardless, no?
Will
On Tue, 4 Nov 2025 at 16:52, Will Deacon <will@kernel.org> wrote:
>
> On Wed, Oct 15, 2025 at 10:56:38PM +0200, Ard Biesheuvel wrote:
> > From: Ard Biesheuvel <ardb@kernel.org>
> >
> > Kernel mode FP/SIMD no longer requires preemption to be disabled, so
> > only warn on uses of FP/SIMD from preemptible context if the fallback
> > path is taken for cases where kernel mode NEON would not be allowed
> > otherwise.
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > ---
> > arch/arm64/kernel/fpsimd.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> > index e3f8f51748bc..3d848c89604e 100644
> > --- a/arch/arm64/kernel/fpsimd.c
> > +++ b/arch/arm64/kernel/fpsimd.c
> > @@ -1934,11 +1934,11 @@ void __efi_fpsimd_begin(void)
> > if (!system_supports_fpsimd())
> > return;
> >
> > - WARN_ON(preemptible());
> > -
> > if (may_use_simd()) {
> > kernel_neon_begin();
> > } else {
> > + WARN_ON(preemptible());
> > +
>
> Given that may_use_simd() returns false on systems without support for
> fpsimd, I wonder whether moving this WARN_ON() actually helps with
> anything.
This code is only reachable if system_supports_fpsimd() returns true,
so may_use_simd() will only return false here when running in
hardirq/NMI context.
> That is, you probably shouldn't be calling __efi_fpsimd_begin()
> from preemptible code regardless, no?
>
Not sure I follow you here: __efi_fpsimd_begin() is generally called
from preemptible code, and it is the EFI runtime wrappers themselves
that disable preemption - that is the whole point of this series.
On Tue, Nov 04, 2025 at 05:00:34PM +0100, Ard Biesheuvel wrote:
> On Tue, 4 Nov 2025 at 16:52, Will Deacon <will@kernel.org> wrote:
> >
> > On Wed, Oct 15, 2025 at 10:56:38PM +0200, Ard Biesheuvel wrote:
> > > From: Ard Biesheuvel <ardb@kernel.org>
> > >
> > > Kernel mode FP/SIMD no longer requires preemption to be disabled, so
> > > only warn on uses of FP/SIMD from preemptible context if the fallback
> > > path is taken for cases where kernel mode NEON would not be allowed
> > > otherwise.
> > >
> > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > > ---
> > > arch/arm64/kernel/fpsimd.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> > > index e3f8f51748bc..3d848c89604e 100644
> > > --- a/arch/arm64/kernel/fpsimd.c
> > > +++ b/arch/arm64/kernel/fpsimd.c
> > > @@ -1934,11 +1934,11 @@ void __efi_fpsimd_begin(void)
> > > if (!system_supports_fpsimd())
> > > return;
> > >
> > > - WARN_ON(preemptible());
> > > -
> > > if (may_use_simd()) {
> > > kernel_neon_begin();
> > > } else {
> > > + WARN_ON(preemptible());
> > > +
> >
> > Given that may_use_simd() returns false on systems without support for
> > fpsimd, I wonder whether moving this WARN_ON() actually helps with
> > anything.
>
> This code is only reachable if system_supports_fpsimd() returns true,
> so may_use_simd() will only return false here when running in
> hardirq/NMI context.
Sorry, I missed the check _right at the top of the hunk_!
>
> > That is, you probably shouldn't be calling __efi_fpsimd_begin()
> > from preemptible code regardless, no?
> >
>
> Not sure I follow you here: __efi_fpsimd_begin() is generally called
> from preemptible code, and it is the EFI runtime wrappers themselves
> that disable preemption - that is the whole point of this series.
Ignore me. I was reviewing this against the upstream
arch_efi_call_virt_setup/teardown() functions rather than in the context
of the changes made later in this series (specifically patch 5).
Will
© 2016 - 2025 Red Hat, Inc.