From patchwork Thu Oct 13 14:53:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 9375151 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5944960839 for ; Thu, 13 Oct 2016 15:27:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47EE12A122 for ; Thu, 13 Oct 2016 15:27:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BD092A132; Thu, 13 Oct 2016 15:27:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54EFB2A122 for ; Thu, 13 Oct 2016 15:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754611AbcJMP14 (ORCPT ); Thu, 13 Oct 2016 11:27:56 -0400 Received: from mail-by2nam03on0072.outbound.protection.outlook.com ([104.47.42.72]:52172 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754424AbcJMP1z (ORCPT ); Thu, 13 Oct 2016 11:27:55 -0400 X-Greylist: delayed 2045 seconds by postgrey-1.27 at vger.kernel.org; Thu, 13 Oct 2016 11:27:54 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=88FXCLKNdms4IiP+27WXelnnIGH4nUM4KYUT/dRmJAY=; b=bPwapmFuiiFI8K1Nj/KtQW/VqGUGgQ/jDI0o1MADi0F1TGaagqI6MKwRGbWCfn0JaMMDlUPC2jHA0GOg+eyONSSXUDS0fqDaDucJ09wlIrOBAfHlD8uaeJiaQMqhOXxiAE0gyi/kUiaLHX2CbJxw6Q7U/c3LlQl8nGkKRAS3Kkw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [10.236.19.42] (165.204.77.1) by DM5PR12MB1401.namprd12.prod.outlook.com (10.168.238.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Thu, 13 Oct 2016 14:53:05 +0000 Subject: [PATCH 2/6] crypto: ccp - Remove unneeded sign-extension support From: Gary R Hook To: CC: , , Date: Thu, 13 Oct 2016 09:53:00 -0500 Message-ID: <20161013145300.19759.14061.stgit@taos> In-Reply-To: <20161013144542.19759.6924.stgit@taos> References: <20161013144542.19759.6924.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR0401CA0011.namprd04.prod.outlook.com (10.162.114.149) To DM5PR12MB1401.namprd12.prod.outlook.com (10.168.238.140) X-MS-Office365-Filtering-Correlation-Id: 8e2b9e74-b39e-4a02-0ac4-08d3f378a3c8 X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1401; 2:JeLTTtpgx+BSPYRlfqyyhiWrcN5iQQC76R1zMWOg9DBbXLfPqCfUEz0MsIhzSzt8iLzoYzcPZBMFo/Q2BFf4jcGnMtkzOsk4WUzYXHlK/MWPhpF2japM7fsRGQwhhtTCSTv/n/KHNr1Mgvf1bA4BfuXC+qdyihDWzbJzdQ0MGGcILtRUlE2Vp3vLc0vfwaWf; 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lVMWdilJmWN/e8y1fsGI7og+t xo+fqhIxXNwuc2XI/IeTWltxhR X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:DM5PR12MB1401; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1401; X-Forefront-PRVS: 0094E3478A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(199003)(189002)(586003)(2351001)(81156014)(81166006)(42186005)(106356001)(105586002)(110136003)(189998001)(4001350100001)(97746001)(101416001)(23676002)(229853001)(305945005)(2950100002)(6916009)(97736004)(103116003)(6666003)(8676002)(5660300001)(19580395003)(19580405001)(54356999)(7736002)(7846002)(86362001)(4326007)(76176999)(50466002)(50986999)(77096005)(33646002)(83506001)(68736007)(47776003)(33716001)(6116002)(230700001)(66066001)(2906002)(3846002)(92566002)(9686002)(1076002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1401; H:[10.236.19.42]; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjEyTUIxNDAxOzIzOnloNE93VDVTZ29qcTJxY2kySlVVRitFL2hF?= =?utf-8?B?d2JpQjJ4UEUrYTZlM0RwQzh0NUU5Umk0Mi9mdzR3ZjJEZlE3M1RqUUxuSXVu?= =?utf-8?B?Y2dsNC9CQjAzSnc1SkNXc0tSTHh5dUFYY1pSSU5uamVScW1xVW5nTXdURVA1?= =?utf-8?B?cWJWS2hnMjk2cGFOTUE2ZDRjcG1RbzAvRFNwbXYyR1pCUEZOd3VMR0lSbnY3?= =?utf-8?B?RE9paGplV0JkQTF2UVZzeFdBTkRoMllRbVdyMDVhdDZaemhtNU5SaH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hBz9YLiAJo2diu7+3tJ7qYtWTQxdfFvbA3HhLxPyANjbnxeF7ImM+LsVxP/hEyNl24dNw4JHrE/Y4x8nwKfIeUZHyoszQ+Ad5xmZDwk0tP3g==; 24:veDEdBmwDkgz9cFk3t8KWZmTrjwaM3B/vxB7Bkeu2AfROyYKGRErvOX6HXneIbO4rbJGN3S/IusXpp5Y4wIhvpJPWLixhGVoEBLFO9RjFYo=; 7:ELGDEPyLNcOuZxS666qrC6JH+z3LMXDNmvjEWNcxs7fh70BK90aXU083ix5gnHAtvXjbd31jrxsqzfTT1jVOoSnHRXBz6RCrCd6nEk2R2ztMBSqwQBpX0Tm2qGDP1WtechyFi7A7p/5DQi2jmst1j2g7uEQ8fiv9uZTB4VuWRGecq3bhCVhtp1cNumAc/TOPRO6DHnE3l+3gi4N3STmXVf3MdzK0bVbzzK0aT69zZw0m+mcY3RqLLYvfjTyzysw+RlXNgK5PqSLtZN+AcWfPsBPZoOp4MiSwcco03c6ldDhkpb6s5Hd1vHVMh3+AHR2S3q9H VAtwBI2pGI4ThuOxmA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1401; 20:WPEMc1R6385bqB342BqMEbtk0rsdxsG5Sj/r3zPzbSSVXRPmBphS1Y8yVsLG2bqOiukiQkHWhlGDUavGtqVWhzulcJyAyzgs3RwdbVn62wnaBLSDDz2kLJ8i4AvYFsOBPO4GPUcZpLfkrpnHB68vcfG/mpmeSrJEM1r0DhrsfrReyEUGnjdlAqB4QgmyR3k2Fy07WXoL0ZoHO4ukduL3vKyPPhowdwpiEQFdNukMF6HAymfG8i07cNw7x3nVR3bI X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2016 14:53:05.4289 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1401 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The reverse-get/set functions can be simplified by eliminating unused code. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-ops.c | 145 +++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 86 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index 8fedb14..82cc637 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -198,62 +198,46 @@ static void ccp_get_dm_area(struct ccp_dm_workarea *wa, unsigned int wa_offset, } static int ccp_reverse_set_dm_area(struct ccp_dm_workarea *wa, + unsigned int wa_offset, struct scatterlist *sg, - unsigned int len, unsigned int se_len, - bool sign_extend) + unsigned int sg_offset, + unsigned int len) { - unsigned int nbytes, sg_offset, dm_offset, sb_len, i; - u8 buffer[CCP_REVERSE_BUF_SIZE]; - - if (WARN_ON(se_len > sizeof(buffer))) - return -EINVAL; - - sg_offset = len; - dm_offset = 0; - nbytes = len; - while (nbytes) { - sb_len = min_t(unsigned int, nbytes, se_len); - sg_offset -= sb_len; - - scatterwalk_map_and_copy(buffer, sg, sg_offset, sb_len, 0); - for (i = 0; i < sb_len; i++) - wa->address[dm_offset + i] = buffer[sb_len - i - 1]; - - dm_offset += sb_len; - nbytes -= sb_len; - - if ((sb_len != se_len) && sign_extend) { - /* Must sign-extend to nearest sign-extend length */ - if (wa->address[dm_offset - 1] & 0x80) - memset(wa->address + dm_offset, 0xff, - se_len - sb_len); - } + u8 *p, *q; + + ccp_set_dm_area(wa, wa_offset, sg, sg_offset, len); + + p = wa->address + wa_offset; + q = p + len - 1; + while (p < q) { + *p = *p ^ *q; + *q = *p ^ *q; + *p = *p ^ *q; + p++; + q--; } - return 0; } static void ccp_reverse_get_dm_area(struct ccp_dm_workarea *wa, + unsigned int wa_offset, struct scatterlist *sg, + unsigned int sg_offset, unsigned int len) { - unsigned int nbytes, sg_offset, dm_offset, sb_len, i; - u8 buffer[CCP_REVERSE_BUF_SIZE]; - - sg_offset = 0; - dm_offset = len; - nbytes = len; - while (nbytes) { - sb_len = min_t(unsigned int, nbytes, sizeof(buffer)); - dm_offset -= sb_len; - - for (i = 0; i < sb_len; i++) - buffer[sb_len - i - 1] = wa->address[dm_offset + i]; - scatterwalk_map_and_copy(buffer, sg, sg_offset, sb_len, 1); - - sg_offset += sb_len; - nbytes -= sb_len; + u8 *p, *q; + + p = wa->address + wa_offset; + q = p + len - 1; + while (p < q) { + *p = *p ^ *q; + *q = *p ^ *q; + *p = *p ^ *q; + p++; + q--; } + + ccp_get_dm_area(wa, wa_offset, sg, sg_offset, len); } static void ccp_free_data(struct ccp_data *data, struct ccp_cmd_queue *cmd_q) @@ -1294,7 +1278,9 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) struct ccp_data dst; struct ccp_op op; unsigned int sb_count, i_len, o_len; - int ret; + unsigned int dm_offset; + int i = 0; + int ret = 0; if (rsa->key_size > CCP_RSA_MAX_WIDTH) return -EINVAL; @@ -1331,8 +1317,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) if (ret) goto e_sb; - ret = ccp_reverse_set_dm_area(&exp, rsa->exp, rsa->exp_len, - CCP_SB_BYTES, false); + ret = ccp_reverse_set_dm_area(&exp, 0, rsa->exp, 0, rsa->exp_len); if (ret) goto e_exp; ret = ccp_copy_to_sb(cmd_q, &exp, op.jobid, op.sb_key, @@ -1350,13 +1335,10 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) if (ret) goto e_exp; - ret = ccp_reverse_set_dm_area(&src, rsa->mod, rsa->mod_len, - CCP_SB_BYTES, false); + ret = ccp_reverse_set_dm_area(&src, 0, rsa->mod, 0, rsa->mod_len); if (ret) goto e_src; - src.address += o_len; /* Adjust the address for the copy operation */ - ret = ccp_reverse_set_dm_area(&src, rsa->src, rsa->src_len, - CCP_SB_BYTES, false); + ret = ccp_reverse_set_dm_area(&src, o_len, rsa->mod, 0, rsa->mod_len); if (ret) goto e_src; src.address -= o_len; /* Reset the address to original value */ @@ -1384,7 +1366,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) goto e_dst; } - ccp_reverse_get_dm_area(&dst.dm_wa, rsa->dst, rsa->mod_len); + ccp_reverse_get_dm_area(&dst.dm_wa, 0, rsa->dst, 0, rsa->mod_len); e_dst: ccp_free_data(&dst, cmd_q); @@ -1636,25 +1618,22 @@ static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) save = src.address; /* Copy the ECC modulus */ - ret = ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->mod, 0, ecc->mod_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; /* Copy the first operand */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_1, - ecc->u.mm.operand_1_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.mm.operand_1, 0, + ecc->u.mm.operand_1_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; if (ecc->function != CCP_ECC_FUNCTION_MINV_384BIT) { /* Copy the second operand */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_2, - ecc->u.mm.operand_2_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.mm.operand_2, 0, + ecc->u.mm.operand_2_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1693,7 +1672,8 @@ static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) } /* Save the ECC result */ - ccp_reverse_get_dm_area(&dst, ecc->u.mm.result, CCP_ECC_MODULUS_BYTES); + ccp_reverse_get_dm_area(&dst, 0, ecc->u.mm.result, 0, + CCP_ECC_MODULUS_BYTES); e_dst: ccp_dm_free(&dst); @@ -1761,22 +1741,19 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) save = src.address; /* Copy the ECC modulus */ - ret = ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->mod, 0, ecc->mod_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; /* Copy the first point X and Y coordinate */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.x, - ecc->u.pm.point_1.x_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_1.x, 0, + ecc->u.pm.point_1.x_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.y, - ecc->u.pm.point_1.y_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_1.y, 0, + ecc->u.pm.point_1.y_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1787,15 +1764,13 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) if (ecc->function == CCP_ECC_FUNCTION_PADD_384BIT) { /* Copy the second point X and Y coordinate */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.x, - ecc->u.pm.point_2.x_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_2.x, 0, + ecc->u.pm.point_2.x_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.y, - ecc->u.pm.point_2.y_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_2.y, 0, + ecc->u.pm.point_2.y_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1805,19 +1780,17 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) src.address += CCP_ECC_OPERAND_SIZE; } else { /* Copy the Domain "a" parameter */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.domain_a, - ecc->u.pm.domain_a_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.domain_a, 0, + ecc->u.pm.domain_a_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; if (ecc->function == CCP_ECC_FUNCTION_PMUL_384BIT) { /* Copy the scalar value */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.scalar, - ecc->u.pm.scalar_len, - CCP_ECC_OPERAND_SIZE, - false); + ret = ccp_reverse_set_dm_area(&src, 0, + ecc->u.pm.scalar, 0, + ecc->u.pm.scalar_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1862,10 +1835,10 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) save = dst.address; /* Save the ECC result X and Y coordinates */ - ccp_reverse_get_dm_area(&dst, ecc->u.pm.result.x, + ccp_reverse_get_dm_area(&dst, 0, ecc->u.pm.result.x, 0, CCP_ECC_MODULUS_BYTES); dst.address += CCP_ECC_OUTPUT_SIZE; - ccp_reverse_get_dm_area(&dst, ecc->u.pm.result.y, + ccp_reverse_get_dm_area(&dst, 0, ecc->u.pm.result.y, 0, CCP_ECC_MODULUS_BYTES); dst.address += CCP_ECC_OUTPUT_SIZE;