Commit c5b91a17 authored by Ard Biesheuvel's avatar Ard Biesheuvel
Browse files

arm64/simd: Add scoped guard API for kernel mode SIMD



Encapsulate kernel_neon_begin() and kernel_neon_end() using a 'ksimd'
cleanup guard. This hides the prototype of those functions, allowing
them to be changed for arm64 but not ARM, without breaking code that is
shared between those architectures (RAID6, AEGIS-128)

It probably makes sense to expose this API more widely across
architectures, as it affords more flexibility to the arch code to
plumb it in, while imposing more rigid rules regarding the start/end
bookends appearing in matched pairs.

Reviewed-by: default avatarKees Cook <kees@kernel.org>
Reviewed-by: default avatarMark Brown <broonie@kernel.org>
Reviewed-by: default avatarEric Biggers <ebiggers@kernel.org>
Reviewed-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 3a866087
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -6,12 +6,15 @@
#ifndef __ASM_SIMD_H
#define __ASM_SIMD_H

#include <linux/cleanup.h>
#include <linux/compiler.h>
#include <linux/irqflags.h>
#include <linux/percpu.h>
#include <linux/preempt.h>
#include <linux/types.h>

#include <asm/neon.h>

#ifdef CONFIG_KERNEL_MODE_NEON

/*
@@ -40,4 +43,8 @@ static __must_check inline bool may_use_simd(void) {

#endif /* ! CONFIG_KERNEL_MODE_NEON */

DEFINE_LOCK_GUARD_0(ksimd, kernel_neon_begin(), kernel_neon_end())

#define scoped_ksimd()	scoped_guard(ksimd)

#endif