diff options
| author | Ard Biesheuvel <ardb@kernel.org> | 2025-10-01 12:20:32 +0200 |
|---|---|---|
| committer | Ard Biesheuvel <ardb@kernel.org> | 2025-11-12 09:22:39 +0100 |
| commit | 814f5415d3e3084eeb0550acdee5eca8b4966055 (patch) | |
| tree | be5cebe0324116a0dfd9db65dc97d9b0ceb064be | |
| parent | c5b91a17cc72e37fd830bca008369db12e7b9d2d (diff) | |
ARM/simd: Add scoped guard API for kernel mode SIMD
Implement the ksimd scoped guard API so that it can be used by code that
supports both ARM and arm64.
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
| -rw-r--r-- | arch/arm/include/asm/simd.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/arm/include/asm/simd.h b/arch/arm/include/asm/simd.h index be08a8da046f..8549fa8b7253 100644 --- a/arch/arm/include/asm/simd.h +++ b/arch/arm/include/asm/simd.h @@ -2,14 +2,21 @@ #ifndef _ASM_SIMD_H #define _ASM_SIMD_H +#include <linux/cleanup.h> #include <linux/compiler_attributes.h> #include <linux/preempt.h> #include <linux/types.h> +#include <asm/neon.h> + static __must_check inline bool may_use_simd(void) { return IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && !in_hardirq() && !irqs_disabled(); } +DEFINE_LOCK_GUARD_0(ksimd, kernel_neon_begin(), kernel_neon_end()) + +#define scoped_ksimd() scoped_guard(ksimd) + #endif /* _ASM_SIMD_H */ |
