hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/crypto/ccp/ccp-ops.c
....@@ -1,19 +1,16 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * AMD Cryptographic Coprocessor (CCP) driver
34 *
4
- * Copyright (C) 2013,2017 Advanced Micro Devices, Inc.
5
+ * Copyright (C) 2013-2019 Advanced Micro Devices, Inc.
56 *
67 * Author: Tom Lendacky <thomas.lendacky@amd.com>
78 * Author: Gary R Hook <gary.hook@amd.com>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
129 */
1310
11
+#include <linux/dma-mapping.h>
1412 #include <linux/module.h>
1513 #include <linux/kernel.h>
16
-#include <linux/pci.h>
1714 #include <linux/interrupt.h>
1815 #include <crypto/scatterwalk.h>
1916 #include <crypto/des.h>
....@@ -168,14 +165,13 @@
168165 if (len <= CCP_DMAPOOL_MAX_SIZE) {
169166 wa->dma_pool = cmd_q->dma_pool;
170167
171
- wa->address = dma_pool_alloc(wa->dma_pool, GFP_KERNEL,
168
+ wa->address = dma_pool_zalloc(wa->dma_pool, GFP_KERNEL,
172169 &wa->dma.address);
173170 if (!wa->address)
174171 return -ENOMEM;
175172
176173 wa->dma.length = CCP_DMAPOOL_MAX_SIZE;
177174
178
- memset(wa->address, 0, CCP_DMAPOOL_MAX_SIZE);
179175 } else {
180176 wa->address = kzalloc(len, GFP_KERNEL);
181177 if (!wa->address)
....@@ -637,13 +633,12 @@
637633 struct ccp_data src, dst;
638634 struct ccp_data aad;
639635 struct ccp_op op;
640
-
641
- unsigned long long *final;
642636 unsigned int dm_offset;
643637 unsigned int authsize;
644638 unsigned int jobid;
645639 unsigned int ilen;
646640 bool in_place = true; /* Default value */
641
+ __be64 *final;
647642 int ret;
648643
649644 struct scatterlist *p_inp, sg_inp[2];
....@@ -845,7 +840,7 @@
845840 DMA_BIDIRECTIONAL);
846841 if (ret)
847842 goto e_dst;
848
- final = (unsigned long long *) final_wa.address;
843
+ final = (__be64 *)final_wa.address;
849844 final[0] = cpu_to_be64(aes->aad_len * 8);
850845 final[1] = cpu_to_be64(ilen * 8);
851846
....@@ -931,8 +926,7 @@
931926 return -EINVAL;
932927
933928 if (((aes->mode == CCP_AES_MODE_ECB) ||
934
- (aes->mode == CCP_AES_MODE_CBC) ||
935
- (aes->mode == CCP_AES_MODE_CFB)) &&
929
+ (aes->mode == CCP_AES_MODE_CBC)) &&
936930 (aes->src_len & (AES_BLOCK_SIZE - 1)))
937931 return -EINVAL;
938932
....@@ -1331,7 +1325,6 @@
13311325 return -EINVAL;
13321326 }
13331327
1334
- ret = -EIO;
13351328 /* Zero out all the fields of the command desc */
13361329 memset(&op, 0, sizeof(op));
13371330