Commit 66c3ec5a authored by Dave Martin's avatar Dave Martin Committed by Catalin Marinas

arm64: neon: Forbid when irqs are disabled

Currently, may_use_simd() can return true if IRQs are disabled.  If
the caller goes ahead and calls kernel_neon_begin(), this can
result in use of local_bh_enable() in an unsafe context.

In particular, __efi_fpsimd_begin() may do this when calling EFI as
part of system shutdown.

This patch ensures that callers don't think they can use
kernel_neon_begin() in such a context.
Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 11cefd5a
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define __ASM_SIMD_H #define __ASM_SIMD_H
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/irqflags.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/preempt.h> #include <linux/preempt.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -40,7 +41,8 @@ static __must_check inline bool may_use_simd(void) ...@@ -40,7 +41,8 @@ static __must_check inline bool may_use_simd(void)
* can't migrate to another CPU and spuriously see it become * can't migrate to another CPU and spuriously see it become
* false. * false.
*/ */
return !in_irq() && !in_nmi() && !raw_cpu_read(kernel_neon_busy); return !in_irq() && !irqs_disabled() && !in_nmi() &&
!raw_cpu_read(kernel_neon_busy);
} }
#else /* ! CONFIG_KERNEL_MODE_NEON */ #else /* ! CONFIG_KERNEL_MODE_NEON */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment