diff options
author | Dave Martin <Dave.Martin@arm.com> | 2017-08-09 06:43:28 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2017-08-09 10:05:59 -0400 |
commit | 66c3ec5a712005625437474cf5a04148d7890350 (patch) | |
tree | 38274244ae2d7531ce45045cbfb2b64201dd69fb | |
parent | 11cefd5ac25f242349994140a3bce3a20db0c751 (diff) |
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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm64/include/asm/simd.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/simd.h b/arch/arm64/include/asm/simd.h index 5a1a927b74a2..fa8b3fe932e6 100644 --- a/arch/arm64/include/asm/simd.h +++ b/arch/arm64/include/asm/simd.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #define __ASM_SIMD_H | 10 | #define __ASM_SIMD_H |
11 | 11 | ||
12 | #include <linux/compiler.h> | 12 | #include <linux/compiler.h> |
13 | #include <linux/irqflags.h> | ||
13 | #include <linux/percpu.h> | 14 | #include <linux/percpu.h> |
14 | #include <linux/preempt.h> | 15 | #include <linux/preempt.h> |
15 | #include <linux/types.h> | 16 | #include <linux/types.h> |
@@ -40,7 +41,8 @@ static __must_check inline bool may_use_simd(void) | |||
40 | * can't migrate to another CPU and spuriously see it become | 41 | * can't migrate to another CPU and spuriously see it become |
41 | * false. | 42 | * false. |
42 | */ | 43 | */ |
43 | return !in_irq() && !in_nmi() && !raw_cpu_read(kernel_neon_busy); | 44 | return !in_irq() && !irqs_disabled() && !in_nmi() && |
45 | !raw_cpu_read(kernel_neon_busy); | ||
44 | } | 46 | } |
45 | 47 | ||
46 | #else /* ! CONFIG_KERNEL_MODE_NEON */ | 48 | #else /* ! CONFIG_KERNEL_MODE_NEON */ |