ccp-ops.c (9938b04472d5c59f8bd8152a548533a8599596a2) | ccp-ops.c (58ea8abf490415c390e0cc671e875510c9b66318) |
---|---|
1/* 2 * AMD Cryptographic Coprocessor (CCP) driver 3 * 4 * Copyright (C) 2013,2016 Advanced Micro Devices, Inc. 5 * 6 * Author: Tom Lendacky <thomas.lendacky@amd.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 1413 unchanged lines hidden (view full) --- 1422 1423e_mask: 1424 if (pt->bit_mod != CCP_PASSTHRU_BITWISE_NOOP) 1425 ccp_dm_free(&mask); 1426 1427 return ret; 1428} 1429 | 1/* 2 * AMD Cryptographic Coprocessor (CCP) driver 3 * 4 * Copyright (C) 2013,2016 Advanced Micro Devices, Inc. 5 * 6 * Author: Tom Lendacky <thomas.lendacky@amd.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 1413 unchanged lines hidden (view full) --- 1422 1423e_mask: 1424 if (pt->bit_mod != CCP_PASSTHRU_BITWISE_NOOP) 1425 ccp_dm_free(&mask); 1426 1427 return ret; 1428} 1429 |
1430static int ccp_run_passthru_nomap_cmd(struct ccp_cmd_queue *cmd_q, 1431 struct ccp_cmd *cmd) 1432{ 1433 struct ccp_passthru_nomap_engine *pt = &cmd->u.passthru_nomap; 1434 struct ccp_dm_workarea mask; 1435 struct ccp_op op; 1436 int ret; 1437 1438 if (!pt->final && (pt->src_len & (CCP_PASSTHRU_BLOCKSIZE - 1))) 1439 return -EINVAL; 1440 1441 if (!pt->src_dma || !pt->dst_dma) 1442 return -EINVAL; 1443 1444 if (pt->bit_mod != CCP_PASSTHRU_BITWISE_NOOP) { 1445 if (pt->mask_len != CCP_PASSTHRU_MASKSIZE) 1446 return -EINVAL; 1447 if (!pt->mask) 1448 return -EINVAL; 1449 } 1450 1451 BUILD_BUG_ON(CCP_PASSTHRU_KSB_COUNT != 1); 1452 1453 memset(&op, 0, sizeof(op)); 1454 op.cmd_q = cmd_q; 1455 op.jobid = ccp_gen_jobid(cmd_q->ccp); 1456 1457 if (pt->bit_mod != CCP_PASSTHRU_BITWISE_NOOP) { 1458 /* Load the mask */ 1459 op.ksb_key = cmd_q->ksb_key; 1460 1461 mask.length = pt->mask_len; 1462 mask.dma.address = pt->mask; 1463 mask.dma.length = pt->mask_len; 1464 1465 ret = ccp_copy_to_ksb(cmd_q, &mask, op.jobid, op.ksb_key, 1466 CCP_PASSTHRU_BYTESWAP_NOOP); 1467 if (ret) { 1468 cmd->engine_error = cmd_q->cmd_error; 1469 return ret; 1470 } 1471 } 1472 1473 /* Send data to the CCP Passthru engine */ 1474 op.eom = 1; 1475 op.soc = 1; 1476 1477 op.src.type = CCP_MEMTYPE_SYSTEM; 1478 op.src.u.dma.address = pt->src_dma; 1479 op.src.u.dma.offset = 0; 1480 op.src.u.dma.length = pt->src_len; 1481 1482 op.dst.type = CCP_MEMTYPE_SYSTEM; 1483 op.dst.u.dma.address = pt->dst_dma; 1484 op.dst.u.dma.offset = 0; 1485 op.dst.u.dma.length = pt->src_len; 1486 1487 ret = cmd_q->ccp->vdata->perform->perform_passthru(&op); 1488 if (ret) 1489 cmd->engine_error = cmd_q->cmd_error; 1490 1491 return ret; 1492} 1493 |
|
1430static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) 1431{ 1432 struct ccp_ecc_engine *ecc = &cmd->u.ecc; 1433 struct ccp_dm_workarea src, dst; 1434 struct ccp_op op; 1435 int ret; 1436 u8 *save; 1437 --- 319 unchanged lines hidden (view full) --- 1757 break; 1758 case CCP_ENGINE_SHA: 1759 ret = ccp_run_sha_cmd(cmd_q, cmd); 1760 break; 1761 case CCP_ENGINE_RSA: 1762 ret = ccp_run_rsa_cmd(cmd_q, cmd); 1763 break; 1764 case CCP_ENGINE_PASSTHRU: | 1494static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) 1495{ 1496 struct ccp_ecc_engine *ecc = &cmd->u.ecc; 1497 struct ccp_dm_workarea src, dst; 1498 struct ccp_op op; 1499 int ret; 1500 u8 *save; 1501 --- 319 unchanged lines hidden (view full) --- 1821 break; 1822 case CCP_ENGINE_SHA: 1823 ret = ccp_run_sha_cmd(cmd_q, cmd); 1824 break; 1825 case CCP_ENGINE_RSA: 1826 ret = ccp_run_rsa_cmd(cmd_q, cmd); 1827 break; 1828 case CCP_ENGINE_PASSTHRU: |
1765 ret = ccp_run_passthru_cmd(cmd_q, cmd); | 1829 if (cmd->flags & CCP_CMD_PASSTHRU_NO_DMA_MAP) 1830 ret = ccp_run_passthru_nomap_cmd(cmd_q, cmd); 1831 else 1832 ret = ccp_run_passthru_cmd(cmd_q, cmd); |
1766 break; 1767 case CCP_ENGINE_ECC: 1768 ret = ccp_run_ecc_cmd(cmd_q, cmd); 1769 break; 1770 default: 1771 ret = -EINVAL; 1772 } 1773 1774 return ret; 1775} | 1833 break; 1834 case CCP_ENGINE_ECC: 1835 ret = ccp_run_ecc_cmd(cmd_q, cmd); 1836 break; 1837 default: 1838 ret = -EINVAL; 1839 } 1840 1841 return ret; 1842} |