From patchwork Fri Nov 4 16:03:53 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: 9412767 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 714C76022E for ; Fri, 4 Nov 2016 16:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F81C2B189 for ; Fri, 4 Nov 2016 16:04:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51E012B1BC; Fri, 4 Nov 2016 16:04:03 +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 539B02B189 for ; Fri, 4 Nov 2016 16:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936113AbcKDQEB (ORCPT ); Fri, 4 Nov 2016 12:04:01 -0400 Received: from mail-by2nam01on0047.outbound.protection.outlook.com ([104.47.34.47]:47271 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935059AbcKDQEA (ORCPT ); Fri, 4 Nov 2016 12:04:00 -0400 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=ONlmV3y3ZK1gXL/g4+FDucSHraV7ag+w2kZg1tY8cEnhAo74gdzzdHGXAEm03KR+ygWz7WUdAt97MaapEPNkmumJSssu5uUmvFunsiwyRW8YsGe0l4YSnQYWQKMRhKE5PdN9+InRsZSnU9/7hhDUI+/sjDTv4YEJ/5YVQXmdhoM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [10.236.19.42] (165.204.77.1) by DM5PR12MB1402.namprd12.prod.outlook.com (10.168.238.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12; Fri, 4 Nov 2016 16:03:58 +0000 Subject: [PATCH V2 3/9] crypto: ccp - Simplify some buffer management routines From: Gary R Hook To: CC: , , Date: Fri, 4 Nov 2016 11:03:53 -0500 Message-ID: <20161104160353.18155.83076.stgit@taos> In-Reply-To: <20161104160140.18155.75618.stgit@taos> References: <20161104160140.18155.75618.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR18CA0035.namprd18.prod.outlook.com (10.173.208.21) To DM5PR12MB1402.namprd12.prod.outlook.com (10.168.238.141) X-MS-Office365-Filtering-Correlation-Id: c70fd320-f850-47bd-bd76-08d404cc2fef X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1402; 2:xw1kdIRKhm3bf2NPpISRounuUrrrRbZu3JPtKCjbv856rI2p90fR5+AjaKnDty/4cBqzZEookchO17/ZwHSQymDSJ7hx5D8r/l39LTG80tJ3G+Aun6FSCw4nOZef7ybaf5/kSmnC0aOUHjDHG4nPLKlc4K8KjHx4YHeddJjSt1oz1IRUCYpbmoPi60QPrjMLZCL5QP9S19wxCXvd3j1v6Q==; 3:GwOR0+59MmrwYIn0xZnw0ksjSmHAovU4plm+7EX2yLNcsInmnzvYErgP3lPymwQuwhNS983rcD1nnn4AMfrz+74s+zdmPWPokz1gxye+qq6yD5DZBIBVl76clspPIY3RqezhM9bds080EhwrlkugLw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR12MB1402; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1402; 25:HJiNdRYgQJ/yjZIlK0ZkBaOxgltF+BL4UEhHRkeKKDFB5NgN/QJJWwMX6juIaJ+4wS1LN283+eFmk/lZgsHNH5KReGfkmpx995Koer1eKdq8M9Ai4Vaxj7SseN6vCCf/4AVJC2QAdRn55DnH5AX5QQE8H/nb/8DUn4QR7Yw5d/fzELHekZ7H2+luyZXFPmpxInMrdZLcXiNioux3bWcdgzM7SVPwmkGKv7RgnM9Gy2byBIGdQOECnYKCC4xWcy2siBwrVEwirt9KzNzJODsQNW+lgQBcO9sH1fBjgO/pO7mNVJ9Mj9CwfvZmPzqOJMSDkRik57EpUjk1tkFAsNqB/av9fhKw6tlLwyN6Y+8Jz9WvpEPBGABDprqiUqPZHJS9kRwAOXna1G7yIbWRksFPkOCp1Sn0c5hzw8DJvNfehwlr5x/uL3Pg/JubgfZIP87rlqmRlP0+V6KfzwdgdUBECEJKJqP6Yk0g6n5z/s16I9cjh+N3YfucMw+VFuDaETFwxTHPBtsjfznT4HmcfUchhWgIAskLcQpHsr22u1SXDraoILEPlS+X3vV4MKWkbLUSH6sN38kpxcKK45terPtIXk1NIyNiihx4gCoIGi00JolnPw1DHAKuNcPY1SYgkm+1b/c4yuo7npYJybc8S84I5Bl4zstQtKE9/S7oQitpBM0I6t/a9FzfR+ssdTnsot3WHF7MqG+E+pFdRtwXQFJgCyebixJmB6mVHUe3tBWLBqU= X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1402; 31:gujAMquWlouNWYokQVUPnMA5Ujgjx1oZ1xmvIEs3030YS+rnMB8UXiGBnjJJYFB8vKu6gPxmhtNPEMFghCvLkl5JKdfBFdSJmCBVmPmDg8CqEXCEv/P32CsNRYTG53hzqmXPRdNnjmovaczCCVPFD1Wb1HbatgcyvDSPlOh1g3D/HoQNA/ocPbKkj2N3fhg1Bj9BV0Aago84U/FKpVCGa1fBimW5MZZg+4qYwyFGZ0AsiPseoEbZpbvwv/gGk1tzRjHbiBwmKynEnbYj3ijZEg==; 20:y8BYLMuXwKFqLB+Dqo9FZBoas0CWJ5ezERV9IaLg1jtilxIWOUPtBspeWq5wqqzeA7bWMi2RStROZIVmYoiin8dbaz356I4TuoP7fC46IePsL/YQAhXO8q3U0O+YpwbbpxVvAx+WjazSrQ2gxilHmM3HjHRd6KvRe0Z8wxsoYLojvk2ug0zgI+69clqWW0bElTaKsYZqNKF+Ad9ewCeWNgShVxMbUCNsec0o6Y4aLDXUuAb+jm7nlPTiV5zmTqoedaxkofPSCIr6SYtrQwGDD4NDoKuCp4IvAuGj0DwttptmsvmIIjRWVoo0wZg2knMutbnwYYzuiwu9zavV6iOKWkrkv1g5ENN/9rl/m0z4QvyRZAciVRPDHvSSPKau0kHIQDbdb8qXH9nXtub38ixZHLIrga12DMGWn1gQckGzmw3PQWe0lMvGVhp5nLfsEc1Hy6xA4M+fdTvTDAMTNapGsMZ2TohPADPT22ZpghAN2w0YWg6hkvRv+cVaTrTA30qY 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)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:DM5PR12MB1402; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1402; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1402; 4:I0K1LPhRD5MCYiSdgyWk7d0W7nVOlTegGwzfSlXST9WqY2NeNnChwKN0CxyVD+AxWPce+IEWhsf+7nWC05imLjvMP1U/OoHBfCIgo/GCT3HvIwyCdCQ9fxiMY5qkY4nZM4e7zUnSD5aPhemhjAYuEFM5fwPzeilZdZ1WlhbfGXn4YWUxxZzDqvPXCcfJqSNoVq6bc/3YmQHlQ7n4fQkihEgte7c+7P/lfzgFE80odctYnONiD7/HYMON6N44HZxr9wtZyua0JDBVBTFDkWkXKSizs9wal0dtCEzWjbdO2LMrhM0OMCvCPVOwnijM5HWw9FstFmNJcoO5L5r+dfTonahfyZ4pF2w6dbnsUrocdT17CYVVm7yE091eEOyCgPWnL4PxT83eQ0sVq/+QHnW/oqnWOO7inl+cHD0OK/kw30FGB949Xcodp10kNy3kH0L3a1CwNOEWYxTDUk51WwFVBQ== X-Forefront-PRVS: 01165471DB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(199003)(189002)(81156014)(97736004)(6116002)(77096005)(86362001)(6666003)(4001350100001)(97746001)(586003)(92566002)(8676002)(54356999)(68736007)(33646002)(66066001)(76176999)(3846002)(50986999)(50466002)(81166006)(101416001)(19580395003)(2906002)(1076002)(7846002)(106356001)(6916009)(7736002)(229853001)(189998001)(305945005)(103116003)(42186005)(105586002)(33716001)(83506001)(9686002)(110136003)(2950100002)(2351001)(23676002)(47776003)(5660300001)(230700001)(4326007)(19580405001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1402; 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?MTtETTVQUjEyTUIxNDAyOzIzOm0rQnE3N2xGRXZEV2t2cm1yR0ovTlJua2Q4?= =?utf-8?B?aGtCZkFhRUdkNXF6RkZLWDd1dXNaUnVWVEFMbldTcnY4c0UzMHVjYlFMZ2hz?= =?utf-8?B?Z3hqZTZWd3RkT2NIdWVaOE85Vit1MG8rMktsTDcwdWlkUHJyUUY3eTNqK2Fh?= =?utf-8?B?Q0F2Q2NrM0xvcWxkNEFkZ0x3ckJUUDQ4b3NRVDZWa1NwYnduZ01MeHIxd0JV?= =?utf-8?B?T05t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6qMyPDt0/HK4hDMD5pJRLYoJgFiECcOipho=; 5:RcKSRu9Pxo47ijaMtoB/kVduNou6IKXi9PXHbzCy4fhNJ6BNPxPJn2qLLPCALzF5gKyAm+FddL5wUkCysuHeGJ+rC0MDkReNyZsW5MILsqIf22uwN7vKgg9LaZH/Wvfzqxi9cNfQI+oADH7KJG27zTXSDUeAxKjzVnInmHI/0Kc=; 24:MmY9wkvlsy2T1HpSjSYiw6dr7aC8roTCE8sJISEaaEvZPKmmFPLAxaQgX8S6DRUEU0igcj4woaLsiiSSu6mksrZppwzPYAME3z3JTkaUxWE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1402; 7:66/2Xu+2HAKZI/WwnHc46jXQRjJYSzD8gJPRJgTMpJd9rjWY2wSPQ38pJ4bNhHsrdYONfUCLQS3aBmPDREBJAwbFxUHoNRwxb0yhTdGZheFNqd+b/zLfGP53sA/RjamH3GNN9QNzQLXPblCJmSlHqkTmB7HHWFq/6zKKEDGa2vlGPFq994dlmV5qJN6fQDM03HmIX4Lk8AUMBjqCR/h0X6z99Cl7Wo7e/Gn5neNjsjBdbPNSuhOn/jyo3G95Rcq8Y1QMuJGAA1O3NAmvTGC+nfYjQhUqvWfOgHrbcwo1RLut7gpoLWuIrlpDqGHuqi/lwsnc03N07c+7dnumyJcdDrKEKn0i58/KMCYOhbhGnKs=; 20:2YIRvuXv1y3A5lutaeYXrjCBgb7H6SeHAbr3/uBBLoJnmFsPU8aV858/oyN1jH2qwowuJ5cgMiGdvQWy20RJug1vWrtng90qXcBqhCnXHSUv1qCZGfaO1piAhVuED/kGL7CE9QI/5HoT4beovIS4iMFjpNt9u9ykn7IqmxmC26HNYSWgMcd0CMmXJd7jpbWzDvT9yaV3FwzIWRRoqicVyPZ9jud1YyWHyMh4iTPLQT9NFhh643pkopOCvdwdB8P2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2016 16:03:58.8571 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1402 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(-) -- 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 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;