| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * AMD Cryptographic Coprocessor (CCP) driver |
|---|
| 3 | 4 | * |
|---|
| 4 | | - * Copyright (C) 2013,2017 Advanced Micro Devices, Inc. |
|---|
| 5 | + * Copyright (C) 2013-2019 Advanced Micro Devices, Inc. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Author: Tom Lendacky <thomas.lendacky@amd.com> |
|---|
| 7 | 8 | * 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. |
|---|
| 12 | 9 | */ |
|---|
| 13 | 10 | |
|---|
| 11 | +#include <linux/dma-mapping.h> |
|---|
| 14 | 12 | #include <linux/module.h> |
|---|
| 15 | 13 | #include <linux/kernel.h> |
|---|
| 16 | | -#include <linux/pci.h> |
|---|
| 17 | 14 | #include <linux/interrupt.h> |
|---|
| 18 | 15 | #include <crypto/scatterwalk.h> |
|---|
| 19 | 16 | #include <crypto/des.h> |
|---|
| .. | .. |
|---|
| 168 | 165 | if (len <= CCP_DMAPOOL_MAX_SIZE) { |
|---|
| 169 | 166 | wa->dma_pool = cmd_q->dma_pool; |
|---|
| 170 | 167 | |
|---|
| 171 | | - wa->address = dma_pool_alloc(wa->dma_pool, GFP_KERNEL, |
|---|
| 168 | + wa->address = dma_pool_zalloc(wa->dma_pool, GFP_KERNEL, |
|---|
| 172 | 169 | &wa->dma.address); |
|---|
| 173 | 170 | if (!wa->address) |
|---|
| 174 | 171 | return -ENOMEM; |
|---|
| 175 | 172 | |
|---|
| 176 | 173 | wa->dma.length = CCP_DMAPOOL_MAX_SIZE; |
|---|
| 177 | 174 | |
|---|
| 178 | | - memset(wa->address, 0, CCP_DMAPOOL_MAX_SIZE); |
|---|
| 179 | 175 | } else { |
|---|
| 180 | 176 | wa->address = kzalloc(len, GFP_KERNEL); |
|---|
| 181 | 177 | if (!wa->address) |
|---|
| .. | .. |
|---|
| 637 | 633 | struct ccp_data src, dst; |
|---|
| 638 | 634 | struct ccp_data aad; |
|---|
| 639 | 635 | struct ccp_op op; |
|---|
| 640 | | - |
|---|
| 641 | | - unsigned long long *final; |
|---|
| 642 | 636 | unsigned int dm_offset; |
|---|
| 643 | 637 | unsigned int authsize; |
|---|
| 644 | 638 | unsigned int jobid; |
|---|
| 645 | 639 | unsigned int ilen; |
|---|
| 646 | 640 | bool in_place = true; /* Default value */ |
|---|
| 641 | + __be64 *final; |
|---|
| 647 | 642 | int ret; |
|---|
| 648 | 643 | |
|---|
| 649 | 644 | struct scatterlist *p_inp, sg_inp[2]; |
|---|
| .. | .. |
|---|
| 845 | 840 | DMA_BIDIRECTIONAL); |
|---|
| 846 | 841 | if (ret) |
|---|
| 847 | 842 | goto e_dst; |
|---|
| 848 | | - final = (unsigned long long *) final_wa.address; |
|---|
| 843 | + final = (__be64 *)final_wa.address; |
|---|
| 849 | 844 | final[0] = cpu_to_be64(aes->aad_len * 8); |
|---|
| 850 | 845 | final[1] = cpu_to_be64(ilen * 8); |
|---|
| 851 | 846 | |
|---|
| .. | .. |
|---|
| 931 | 926 | return -EINVAL; |
|---|
| 932 | 927 | |
|---|
| 933 | 928 | 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)) && |
|---|
| 936 | 930 | (aes->src_len & (AES_BLOCK_SIZE - 1))) |
|---|
| 937 | 931 | return -EINVAL; |
|---|
| 938 | 932 | |
|---|
| .. | .. |
|---|
| 1331 | 1325 | return -EINVAL; |
|---|
| 1332 | 1326 | } |
|---|
| 1333 | 1327 | |
|---|
| 1334 | | - ret = -EIO; |
|---|
| 1335 | 1328 | /* Zero out all the fields of the command desc */ |
|---|
| 1336 | 1329 | memset(&op, 0, sizeof(op)); |
|---|
| 1337 | 1330 | |
|---|