From patchwork Mon Jun 15 23:52:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6612521 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 994849F399 for ; Tue, 16 Jun 2015 00:07:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9ACAE2040F for ; Tue, 16 Jun 2015 00:07:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE358203FB for ; Tue, 16 Jun 2015 00:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751018AbbFPAHz (ORCPT ); Mon, 15 Jun 2015 20:07:55 -0400 Received: from mail-bn1bon0135.outbound.protection.outlook.com ([157.56.111.135]:51388 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750842AbbFPAHz (ORCPT ); Mon, 15 Jun 2015 20:07:55 -0400 X-Greylist: delayed 883 seconds by postgrey-1.27 at vger.kernel.org; Mon, 15 Jun 2015 20:07:54 EDT Received: from BLUPR0301MB1571.namprd03.prod.outlook.com (10.162.214.17) by BLUPR0301MB1652.namprd03.prod.outlook.com (10.162.214.146) with Microsoft SMTP Server (TLS) id 15.1.190.14; Mon, 15 Jun 2015 23:53:12 +0000 Received: from CH1PR03CA010.namprd03.prod.outlook.com (10.255.156.155) by BLUPR0301MB1571.namprd03.prod.outlook.com (10.162.214.17) with Microsoft SMTP Server (TLS) id 15.1.190.14; Mon, 15 Jun 2015 23:53:11 +0000 Received: from BN1BFFO11FD051.protection.gbl (10.255.156.132) by CH1PR03CA010.outlook.office365.com (10.255.156.155) with Microsoft SMTP Server (TLS) id 15.1.172.22 via Frontend Transport; Mon, 15 Jun 2015 23:53:11 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD051.mail.protection.outlook.com (10.58.145.6) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Mon, 15 Jun 2015 23:53:11 +0000 Received: from stc-hedley.am.freescale.net (stc-hedley.am.freescale.net [10.67.70.12]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t5FNr7p4003741; Mon, 15 Jun 2015 16:53:10 -0700 From: Victoria Milhoan To: CC: , , Subject: [PATCH RFC 09/11] crypto: caam - Fix incorrect size when DMA unmapping buffer Date: Mon, 15 Jun 2015 16:52:57 -0700 Message-ID: <1434412379-11623-10-git-send-email-vicki.milhoan@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434412379-11623-1-git-send-email-vicki.milhoan@freescale.com> References: <1434412379-11623-1-git-send-email-vicki.milhoan@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD051; 1:0N9j5shjByRZt5rnLKBKU6BEMYxRSU8DB7KUgXswng1zZUDEAnC+4mJnpxb2PJt5FDB1SZqEW4SRcga9hEaaDMKJBiRT33qo6bt+/ZP0pOfOXbvuluNgBpQTMMXJ6FBGBGtTEKiROtHtLvqQdci2LsZA1aoo3NLGvHyzNSflHV1gPPzRblExt1pex9dslLCPVopIDFnufNQoB8Ymax4I6pw/5ayicqitfRGjll9Up1w8bmxtNifNa4+COCqlOjMSk5JHM+JlwnT4AKwGwXIANAcvunPW/1p/WFTBRD07jN7Jv0tFIo2RokPM/sMBVKAINa7vcRe3RNnZVB3XC2C1W6IHp/QuaxUOdTb5orAyxzU= X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(199003)(189002)(19580405001)(50226001)(106466001)(105606002)(50986999)(50466002)(2351001)(76176999)(104016003)(92566002)(33646002)(19580395003)(46102003)(229853001)(86362001)(36756003)(6806004)(189998001)(87936001)(47776003)(107886002)(48376002)(110136002)(2950100001)(62966003)(77156002)(85426001)(5001920100001)(77096005)(5001960100002)(217873001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0301MB1571; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1571; 2:ABrNhDNX+EqOMhkE5mjP00pOFB6vCkuuIisWK7Dx+Y6eil+9VGG2MNeX2XUo6dcd; 2:pbMCw4SxEMLUQvvvRLvbhJGdwnZeYSTn+eiU4j/SHNHkX7SDHR9WY03vMNtw6jhS/MHQTJEhRavIAWEc6AAahl8sEYEECMjlZau1GugTUO2jZOEeuYgykLsOuHnhq75b3NCvB5q8CLJPjDaMsOGWhgmtQnRP50IvYYMNcb45WkvqB0c0DbAdkkup/sKojp1zqiVW8SOrqEIIEHDNeyUVVzJ0CMmsrbAQ9FRXDqXo8EU=; 6:meJQWQzII3rtIpP6FZ2apW4PnFMp5vTRuYos02p6YNC93maMyNpTx5K50oZXIqfY0wEkO76LzIpd3UHNuUvlgxWyhwrKlIxwH42p9rv0+E8kUUg6TJfl6Pwm43/RM6M2lycsD6ZBtRyngrs7gP0fgljeXkI/85J68WBHCxqtjYtCBhvYKOdHKSNxU6tzB5lVsjJgoMhVxVKw5wohOhILLMzrTPWg9mraGZHk3wcPeiebv1gx+KfQL24v43BZc4ADgm2QLJ23zIrvnYsVQ4TI2MFuz+U1VsSlCsEJzibqqc1NfIDCWdBG9UeuoLVbhthmkjRKBjlM+xAPIfp9ZmN1vQ== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1571; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1652; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520003)(3002001); SRVR:BLUPR0301MB1571; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1571; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1571; 3:fm4G+iMHR1hLc/xDM3QXG6XlYSVJOMubV0Ig7f8ljgkAZOz8a3K64aS92w4lVhr6q2sry/LPLzqdpcpVglh8upjNy14V7LokcvN1sO2g1AOyq+wlM8BmOYHU61WvYqlX8TzpupiJnYrM36z7vJKJwEfFY8SnRDDQUr1vwn/cK44O3r8G5FUkhKckbdEWo2AmsHcBxMZ1S2FUuLocdkCkWeMoBZ5X1LtVhDoy2lEtYSLfiuexe6GdXugrsRlyAEw+TYx4HxU6vTEBubdAZ50FisuYYJ3xhqsA47wni8i97Nb5vyvgaoZh3mfpD818v8Aq X-Forefront-PRVS: 0608DEDB67 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0301MB1571; 9:mXZ5+xhQGdNiGKLZDePn9z3g+9X8XrZ6w+ZGUu3z?= =?us-ascii?Q?JPj2yRCdnUSNGJ6tTxCIlXsf4Z80ztRP390MznVXD4qY8NJQlxCN1wkSBlJ3?= =?us-ascii?Q?yqURYutuiGBRnWtlYbiX+pWmEzJTAK2dHPaBoHWlxXXG/qjwwEqqZhuepElX?= =?us-ascii?Q?LRL5Ag7k9BvLWURHEjQxx9voPl8s+oso6pctXFzr6QOe+W+Efkq7t72Pi6nd?= =?us-ascii?Q?n+EJg9wRH9cX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Y+WFimqmz4AfWb3B6GOg4mb19z1Bs5/kmzzoSQ==; 10:vWOQON7a4jFxUmYGjMj4Mnx+lUf6o8KFeRg+7+Z4AYGeDP0wsPADqKzrPkgonmTAx4l1+iO7mZvNXsCJfi9y0/cGcn5Jdg42yceBrHJEzmk=; 6:2TV5dcYK/FOCs5zO665IK+Kz1ytqKf+mvOs6chMQKLAfId+1W81FEWvuZhcFQYnb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2015 23:53:11.0524 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB1571 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1652; 2:82kIHKWy9ecOo/QtJRbnX4zHc8CEruIRUSaTIxphayqYRvOPn12ENbzLs1urDCRt; 2:u+smQmlKAyqVDfnRcLaiDmiwa+BYTgDaoVIMbjbZULmdFK1LGCE1hkpqbFimRgHYrKQArdwE8wTusItRH8zhRNubvY4slcFvBhDCb+1PouFcpVTlZHo4vUwUVdbApET85GT0op1DYJiq1AV8t3ZbSqFAoHGeafy4f6KYNEpjTPivr4G5vCpNcp2kIDvt8lizCSeRuSqWo7IKzz6MczNxTE+4GSrD1xZugxX9KqYHJtg=; 9:PgxNWfHRx7+GQqtjsdHAf6Izh+LDrtih7etapj6v2cmECZ2KrG64NdRCaBTp0f2b0Yjhc3e8fALVCeovlIbfM2gc85YWhADcDOcX4JwxegrCFpOXCPS+1AkUHGsyi9UgCBfuRpCorjn1t5h6q8rPdA== X-OriginatorOrg: freescale.com Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The CAAM driver uses two data buffers to store data for a hashing operation, with one buffer defined as active. This change forces switching of the active buffer when executing a hashing operation to avoid a later DMA unmap using the length of the opposite buffer. Signed-off-by: Victoria Milhoan --- drivers/crypto/caam/caamhash.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index f2f1e87..6720332 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -843,17 +843,17 @@ static int ahash_update_ctx(struct ahash_request *req) src_map_to_sec4_sg(jrdev, req->src, src_nents, edesc->sec4_sg + sec4_sg_src_index, chained); - if (*next_buflen) { + if (*next_buflen) scatterwalk_map_and_copy(next_buf, req->src, to_hash - *buflen, *next_buflen, 0); - state->current_buf = !state->current_buf; - } } else { (edesc->sec4_sg + sec4_sg_src_index - 1)->len |= SEC4_SG_LEN_FIN; } + state->current_buf = !state->current_buf; + sh_len = desc_len(sh_desc); desc = edesc->hw_desc; init_job_desc_shared(desc, ptr, sh_len, HDR_SHARE_DEFER | @@ -1276,9 +1276,10 @@ static int ahash_update_no_ctx(struct ahash_request *req) scatterwalk_map_and_copy(next_buf, req->src, to_hash - *buflen, *next_buflen, 0); - state->current_buf = !state->current_buf; } + state->current_buf = !state->current_buf; + sh_len = desc_len(sh_desc); desc = edesc->hw_desc; init_job_desc_shared(desc, ptr, sh_len, HDR_SHARE_DEFER |