From patchwork Thu Feb 9 21:50:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 9565545 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 B3038601C3 for ; Thu, 9 Feb 2017 21:51:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A43FC2854A for ; Thu, 9 Feb 2017 21:51:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 991A32855D; Thu, 9 Feb 2017 21:51:30 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 E0FC32854A for ; Thu, 9 Feb 2017 21:51:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752986AbdBIVvZ (ORCPT ); Thu, 9 Feb 2017 16:51:25 -0500 Received: from mail-dm3nam03on0055.outbound.protection.outlook.com ([104.47.41.55]:36192 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753032AbdBIVvK (ORCPT ); Thu, 9 Feb 2017 16:51:10 -0500 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=WWmpjJ5L2m/GJJnTwSwzjwcQEwPuxhcPR/RyUUSggOI=; b=xgcvNEudO3RscHqkPt3t2a6Ps7qHC/+oakpc6EVdC5Y3WEe6hM45qhGft7VeRjj6bDvkjAbrOJuNpGyXKvlwjV0it+f+NmTiIkbJ5/GKGHtA6CawEjf+AtiD67MdfSFYIYb2byGbv13r+09qV3697vEzUN6LK2ZF/gw6ru1DYF0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [10.236.19.42] (165.204.77.1) by MWHPR12MB1405.namprd12.prod.outlook.com (10.169.206.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Thu, 9 Feb 2017 21:50:14 +0000 Subject: [PATCH v2 3/3] crypto: ccp - Simplify some buffer management routines From: Gary R Hook To: CC: , , Date: Thu, 9 Feb 2017 15:50:08 -0600 Message-ID: <20170209215008.11781.28483.stgit@taos> In-Reply-To: <20170209214704.11781.28640.stgit@taos> References: <20170209214704.11781.28640.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR18CA0034.namprd18.prod.outlook.com (10.173.208.20) To MWHPR12MB1405.namprd12.prod.outlook.com (10.169.206.16) X-MS-Office365-Filtering-Correlation-Id: e065cb4f-93fa-4893-f4b1-08d45135a142 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:MWHPR12MB1405; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1405; 3:GEVE9LbSBjzccKX8V11w61VkjAAnbHt6miIJLaleRszgCniLI1j7pHZ4tpK3ChrIclQlUEao5UL5yrBdPhkhNimpPhdXnCuXtOyfvzjYJKIdr50lr2AbD0w4SFIi3Pum+SA2KH/Vb0tXHuo/HyccvEc9iXlbQrr93/pufd+xxrZPbPSbBoCoVhhIRaYfQ0jU2w0v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tctSxA18RPPbhsSSoLwZKrORowLBUOdJAdKOF//f5oay0E1kB+7N37gnE35eBv2N9KfPRczdFrBUQQbXr0QFV3YjJ+NRuoy8CSaHxcvWEwVt20+pwg+UaBQh3uusqfqTAYVjtZR+Tj7maVsl8/4PKQ1lN9+egZvbTSIUirdZ54AKOC5jY2IL5rBVH3CObQmyPM3tea+EN10TYK2fYfaIC3oFfVQLy2v0dPAKDueoS37eNfdQBCY0cgZ1zpjj/HQELnZgUkZBZp6cg7NYguhtTzKK0ayoThrQcsL/Sa+TS6qOx2/k60LDLyttMosgGJZjkkLD X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123564025)(20161123560025)(20161123558025)(20161123562025)(6072148); SRVR:MWHPR12MB1405; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1405; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1405; 4:jLLaz+KcwF7Qqhaxgme5OWfL7bueEEWA0d/ZuWnLqlvWv6MbefFVlNTFwSEUQH105vl+NAzew9HUByIiDUYs4YV2FXmjm7JhAS12rrWA8D+ufHlTTHmy3Jl1hqEWpPRVSjRXrzrT96QRHCSdRTF9weemSn5kNNwZVMG0zukiN/DIVJQZK+Ozu8RZ509sZzeRGHpgz6FCcsQBfTv/eLEUWexDWlBsRZfiGdg0kdUD4V5SJHRz7wsKkmWkwngGzLkNsEYF/h/iRsm+bjCU0hzJGfGeleZrQzm3zfD1D7mmhlQYtnsJ25NNG76efft5X/SgCbkURATjJbb4UUeWGPJLmE8QcfTJbbn9S6WBu/6GmF9jH2yb3Tz0F0NtvVPyVlxrtZtcTsSr+O0x20t39LOXPj86qUh6UpuDvb2MAa9vwIjZzqw8zdvaCJlNkWMnWk6ZNKyHbf6dZLBZ/4RZy/rXcRnEbt0rIBnzeVtl41LDut7scdLHNSPlYuxsSL5DuubcgmHoXyk6cWp51LDrl8fh8iBDQyNe0TkwR9NMU4qd/Me8lyoazxI2FYM25g3raDFqwHEaflUthRgSj1sQIHr9xpeqWkETYnYuCfCGK9WNEK4S0Yl76tViDTgxdFPJjbx2jNB2c3A4cJtWy+Hpvw3QosJ3UAq6bsP+yt8Lvc/l7CE= X-Forefront-PRVS: 02135EB356 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(39860400002)(39850400002)(39840400002)(39410400002)(39450400003)(199003)(189002)(105586002)(86362001)(103116003)(106356001)(23676002)(230700001)(6666003)(1076002)(2950100002)(7736002)(53936002)(4326007)(50986999)(2906002)(83506001)(54356999)(76176999)(97736004)(81166006)(81156014)(4001350100001)(189998001)(2351001)(3846002)(68736007)(6116002)(92566002)(8676002)(66066001)(47776003)(33646002)(97746001)(305945005)(50466002)(33716001)(101416001)(6916009)(6486002)(77096006)(90366009)(110136004)(38730400002)(42186005)(54906002)(25786008)(5660300001)(9686003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1405; 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?MTtNV0hQUjEyTUIxNDA1OzIzOjFTd0c4VC9rUkN0R3RRWWcvc2Z2dEhlZ0lp?= =?utf-8?B?RWRGWXVJN0NRNmVGUVpSaWZtdmZ6cnBhNlkxZklOdXh1UHhoQnlzRlhmV2xH?= =?utf-8?B?cGtJNXRoTzNGdHZrS2ZTVDlZSEt3clRSSm1xSTJrYnBuL1Y5NDBESG96c0Zj?= =?utf-8?B?OWZlc0x2OTJPM0VpS1d1Tnh3NzNManJsZGlvckF5elIwT2RQd0hqbytZRTRN?= =?utf-8?B?NWp4c3NDdXNFQS9maG43N1VlS0hVY0x5cCt2TSs5V0o0e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M9bZRANG7bKYbx/MP2DedjHnvz5VX3EiVw9JaDYgFrU4rNCeb9K5HKFrLEhoBq5kRXrcefmBAqLgk60uRw5eN7KnxD7TwMHw4Tg==; 20:lnqr5Y+xTXLKo0arkmgDSk4++hFCaJbMmqDKvayTLrBwqYX2hYQXFe3XFRy/ln658kSd/K/pVpieUKX8FRDfcspD2NuZSAlHnJqxN6omd0A8MHI76J9WNCxJlP+qxphcwV0sY897/xShhGquw+J9p6hBTuH7k3DAoT4AeEbYVQuuM6ldRZtaFPPTm7WHXbNo6QA5APRLdjxsDmnH/cRyc7oPfLRfhj3HUC58smEju0fhwyG2ItiF1D0P6GmMRj+o X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2017 21:50:14.3256 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1405 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 | 142 +++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 86 deletions(-) diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index 50fae44..efac3d5 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -184,62 +184,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) @@ -1261,8 +1245,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, @@ -1280,16 +1263,12 @@ 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->src, 0, rsa->src_len); if (ret) goto e_src; - src.address -= o_len; /* Reset the address to original value */ /* Prepare the output area for the operation */ ret = ccp_init_data(&dst, cmd_q, rsa->dst, rsa->mod_len, @@ -1314,7 +1293,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); @@ -1566,25 +1545,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; @@ -1623,7 +1599,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); @@ -1691,22 +1668,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; @@ -1717,15 +1691,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; @@ -1735,19 +1707,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; @@ -1792,10 +1762,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;