arm64: neon: Forbid when irqs are disabled
PATCH 1/1 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.
--- arch/arm64/include/asm/simd.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/include/asm/simd.h +3 -1
@@ -10,6 +10,7 @@#define __ASM_SIMD_H#include <linux/compiler.h> +#include <linux/irqflags.h> #include <linux/percpu.h> #include <linux/preempt.h> #include <linux/types.h>
@@ -40,7 +41,8 @@ static __must_check inline bool may_use_simd(void)* can't migrate to another CPU and spuriously see it become * 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 */
Signature · 1 line
2.1.4
PATCH 1/1 arm64: neon: Forbid when irqs are disabled
Quoted 11 lines · Dave Martin
Currently,
may_use_simd()can return true if IRQs are disabled. If the caller goes ahead and callskernel_neon_begin(), this can result in use oflocal_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.Signed-off-by Dave Martin <[email protected]>
Quoted 29 lines
--- arch/arm64/include/asm/simd.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm64/include/asm/simd.h +3
-2@@ -10,6 +10,7 @@#define __ASM_SIMD_H#include <linux/compiler.h> +#include <linux/irqflags.h> #include <linux/percpu.h> #include <linux/preempt.h> #include <linux/types.h> @@ -40,7 +41,8 @@ static __must_check inline bool may_use_simd(void)* can't migrate to another CPU and spuriously see it become * 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 */ --2.1.4
Catalin Marinas
maintainerPATCH 1/1 arm64: neon: Forbid when irqs are disabled
In reply to Dave MartinQuoted 11 lines · Dave P Martin
Currently,
may_use_simd()can return true if IRQs are disabled. If the caller goes ahead and callskernel_neon_begin(), this can result in use oflocal_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.Signed-off-by Dave Martin <[email protected]>
Thanks. I pushed it out to the for-next/kernel-mode-neon branch.
Signature · 1 line
Catalin