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

crypto/arm64: aes-ccm - Switch to 'ksimd' scoped guard API



Switch to the more abstract 'scoped_ksimd()' API, which will be modified
in a future patch to transparently allocate a kernel mode FP/SIMD state
buffer on the stack, so that kernel mode FP/SIMD code remains
preemptible in principe, but without the memory overhead that adds 528
bytes to the size of struct task_struct.

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 3142ec4a
Loading
Loading
Loading
Loading
+66 −69
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
 * Author: Ard Biesheuvel <ardb@kernel.org>
 */

#include <asm/neon.h>
#include <linux/unaligned.h>
#include <crypto/aes.h>
#include <crypto/scatterwalk.h>
@@ -16,6 +15,8 @@
#include <crypto/internal/skcipher.h>
#include <linux/module.h>

#include <asm/simd.h>

#include "aes-ce-setkey.h"

MODULE_IMPORT_NS("CRYPTO_INTERNAL");
@@ -184,8 +185,7 @@ static int ccm_encrypt(struct aead_request *req)
	if (unlikely(err))
		return err;

	kernel_neon_begin();

	scoped_ksimd() {
		if (req->assoclen)
			ccm_calculate_auth_mac(req, mac);

@@ -216,8 +216,7 @@ static int ccm_encrypt(struct aead_request *req)
				err = skcipher_walk_done(&walk, tail);
			}
		} while (walk.nbytes);

	kernel_neon_end();
	}

	if (unlikely(err))
		return err;
@@ -251,8 +250,7 @@ static int ccm_decrypt(struct aead_request *req)
	if (unlikely(err))
		return err;

	kernel_neon_begin();

	scoped_ksimd() {
		if (req->assoclen)
			ccm_calculate_auth_mac(req, mac);

@@ -283,8 +281,7 @@ static int ccm_decrypt(struct aead_request *req)
				err = skcipher_walk_done(&walk, tail);
			}
		} while (walk.nbytes);

	kernel_neon_end();
	}

	if (unlikely(err))
		return err;