.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /** |
---|
2 | 3 | * AES routines supporting VMX instructions on the Power 8 |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
18 | 6 | * |
---|
19 | 7 | * Author: Marcelo Henrique Cerri <mhcerri@br.ibm.com> |
---|
20 | 8 | */ |
---|
.. | .. |
---|
23 | 11 | #include <linux/err.h> |
---|
24 | 12 | #include <linux/crypto.h> |
---|
25 | 13 | #include <linux/delay.h> |
---|
26 | | -#include <linux/hardirq.h> |
---|
| 14 | +#include <asm/simd.h> |
---|
27 | 15 | #include <asm/switch_to.h> |
---|
28 | 16 | #include <crypto/aes.h> |
---|
| 17 | +#include <crypto/internal/cipher.h> |
---|
| 18 | +#include <crypto/internal/simd.h> |
---|
29 | 19 | |
---|
30 | 20 | #include "aesp8-ppc.h" |
---|
31 | 21 | |
---|
.. | .. |
---|
78 | 68 | pagefault_disable(); |
---|
79 | 69 | enable_kernel_vsx(); |
---|
80 | 70 | 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); |
---|
82 | 72 | disable_kernel_vsx(); |
---|
83 | 73 | pagefault_enable(); |
---|
84 | 74 | preempt_enable(); |
---|
85 | 75 | |
---|
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; |
---|
88 | 79 | } |
---|
89 | 80 | |
---|
90 | 81 | static void p8_aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) |
---|
91 | 82 | { |
---|
92 | 83 | struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
93 | 84 | |
---|
94 | | - if (in_interrupt()) { |
---|
| 85 | + if (!crypto_simd_usable()) { |
---|
95 | 86 | crypto_cipher_encrypt_one(ctx->fallback, dst, src); |
---|
96 | 87 | } else { |
---|
97 | 88 | preempt_disable(); |
---|
.. | .. |
---|
108 | 99 | { |
---|
109 | 100 | struct p8_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
110 | 101 | |
---|
111 | | - if (in_interrupt()) { |
---|
| 102 | + if (!crypto_simd_usable()) { |
---|
112 | 103 | crypto_cipher_decrypt_one(ctx->fallback, dst, src); |
---|
113 | 104 | } else { |
---|
114 | 105 | preempt_disable(); |
---|