hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/crypto/vmx/aes.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**
23 * AES routines supporting VMX instructions on the Power 8
34 *
45 * Copyright (C) 2015 International Business Machines Inc.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; version 2 only.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
186 *
197 * Author: Marcelo Henrique Cerri <mhcerri@br.ibm.com>
208 */
....@@ -23,9 +11,11 @@
2311 #include <linux/err.h>
2412 #include <linux/crypto.h>
2513 #include <linux/delay.h>
26
-#include <linux/hardirq.h>
14
+#include <asm/simd.h>
2715 #include <asm/switch_to.h>
2816 #include <crypto/aes.h>
17
+#include <crypto/internal/cipher.h>
18
+#include <crypto/internal/simd.h>
2919
3020 #include "aesp8-ppc.h"
3121
....@@ -78,20 +68,21 @@
7868 pagefault_disable();
7969 enable_kernel_vsx();
8070 ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key);
81
- ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key);
71
+ ret |= aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key);
8272 disable_kernel_vsx();
8373 pagefault_enable();
8474 preempt_enable();
8575
86
- ret += crypto_cipher_setkey(ctx->fallback, key, keylen);
87
- return ret;
76
+ ret |= crypto_cipher_setkey(ctx->fallback, key, keylen);
77
+
78
+ return ret ? -EINVAL : 0;
8879 }
8980
9081 static void p8_aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
9182 {
9283 struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
9384
94
- if (in_interrupt()) {
85
+ if (!crypto_simd_usable()) {
9586 crypto_cipher_encrypt_one(ctx->fallback, dst, src);
9687 } else {
9788 preempt_disable();
....@@ -108,7 +99,7 @@
10899 {
109100 struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm);
110101
111
- if (in_interrupt()) {
102
+ if (!crypto_simd_usable()) {
112103 crypto_cipher_decrypt_one(ctx->fallback, dst, src);
113104 } else {
114105 preempt_disable();