* [PATCH] arm64: neon: Forbid when irqs are disabled
@ 2017-08-09 10:43 Dave Martin
2017-08-09 13:57 ` Ard Biesheuvel
2017-08-09 14:31 ` Catalin Marinas
0 siblings, 2 replies; 3+ messages in thread
From: Dave Martin @ 2017-08-09 10:43 UTC (permalink / raw)
To: linux-arm-kernel
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.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
---
arch/arm64/include/asm/simd.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/simd.h b/arch/arm64/include/asm/simd.h
index 5a1a927..fa8b3fe 100644
--- a/arch/arm64/include/asm/simd.h
+++ b/arch/arm64/include/asm/simd.h
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] arm64: neon: Forbid when irqs are disabled
2017-08-09 10:43 [PATCH] arm64: neon: Forbid when irqs are disabled Dave Martin
@ 2017-08-09 13:57 ` Ard Biesheuvel
2017-08-09 14:31 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2017-08-09 13:57 UTC (permalink / raw)
To: linux-arm-kernel
On 9 August 2017 at 11:43, Dave Martin <Dave.Martin@arm.com> wrote:
> 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.
>
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> arch/arm64/include/asm/simd.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/simd.h b/arch/arm64/include/asm/simd.h
> index 5a1a927..fa8b3fe 100644
> --- a/arch/arm64/include/asm/simd.h
> +++ b/arch/arm64/include/asm/simd.h
> @@ -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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] arm64: neon: Forbid when irqs are disabled
2017-08-09 10:43 [PATCH] arm64: neon: Forbid when irqs are disabled Dave Martin
2017-08-09 13:57 ` Ard Biesheuvel
@ 2017-08-09 14:31 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2017-08-09 14:31 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Aug 09, 2017 at 11:43:28AM +0100, Dave P Martin wrote:
> 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.
>
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Thanks. I pushed it out to the for-next/kernel-mode-neon branch.
--
Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-09 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-09 10:43 [PATCH] arm64: neon: Forbid when irqs are disabled Dave Martin
2017-08-09 13:57 ` Ard Biesheuvel
2017-08-09 14:31 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).