From patchwork Mon Sep 17 15:09:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Manszewski X-Patchwork-Id: 10602893 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-2.web.codeaurora.org (Postfix) with ESMTP id B1554184E for ; Mon, 17 Sep 2018 15:10:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A31AC2998B for ; Mon, 17 Sep 2018 15:10:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 972732A089; Mon, 17 Sep 2018 15:10:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 2BF932998B for ; Mon, 17 Sep 2018 15:10:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729101AbeIQUhy (ORCPT ); Mon, 17 Sep 2018 16:37:54 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54812 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729233AbeIQUhx (ORCPT ); Mon, 17 Sep 2018 16:37:53 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180917151007euoutp0160fac89a2577bbf882c64ba3b2ff6da2~VOIi1Fg5t2428824288euoutp01h for ; Mon, 17 Sep 2018 15:10:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180917151007euoutp0160fac89a2577bbf882c64ba3b2ff6da2~VOIi1Fg5t2428824288euoutp01h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537197007; bh=g3RorNLxXU6pHJrFDZvhtON4nN0xcIymWtdQdIQNHtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxB7xrFaSswgXuHgRC4kjwkwA8uktgqTL5gbCLO+yt1TrTCmYSrks8edN0yV/t3IR y/gaEOModa9rd1KbqPYIU1QKWTLFtVlU9CxA83eL80DXO0aZUGYXrIYWAdUhszFMI0 LFYy8eAD2WnDsSNm3Dr0lI9jOmLDSg1DCZf+Cm6g= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180917151007eucas1p287db2d512a0af558d21176cce16a182b~VOIiQnvyT1112911129eucas1p2r; Mon, 17 Sep 2018 15:10:07 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 78.F7.04806.EC3CF9B5; Mon, 17 Sep 2018 16:10:06 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180917151006eucas1p2226806b94605b061bc1bc3e9b5a6c495~VOIhXssSK0729007290eucas1p25; Mon, 17 Sep 2018 15:10:06 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180917151005eusmtrp18cc33922795db87af587619b1d8acd70~VOIhFdGj03069130691eusmtrp1q; Mon, 17 Sep 2018 15:10:05 +0000 (GMT) X-AuditID: cbfec7f5-79db79c0000012c6-ba-5b9fc3ce4acc Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 41.48.04284.DC3CF9B5; Mon, 17 Sep 2018 16:10:05 +0100 (BST) Received: from AMDC2034.DIGITAL.local (unknown [106.120.51.41]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180917151005eusmtip2bd2888d07a6fb2b4fe73e5decabd865e~VOIglyGLT2368423684eusmtip29; Mon, 17 Sep 2018 15:10:05 +0000 (GMT) From: Christoph Manszewski To: linux-crypto@vger.kernel.org Cc: Christoph Manszewski , Krzysztof Kozlowski , Vladimir Zapolskiy , Kamil Konieczny , Herbert Xu , "David S. Miller" , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz Subject: [PATCH v2 1/4] crypto: s5p-sss: Fix race in error handling Date: Mon, 17 Sep 2018 17:09:27 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAKsWRmVeSWpSXmKPExsWy7djP87rnDs+PNrj4Uc1i44z1rBbHdy9l tJhzvoXFovuVjEXfvv+MFufPb2C3uH/vJ5PF5V1z2CxmnN/HZPH/VzOzA5fHlpU3mTy2HVD1 2LSqk83j38IpLB4H3+1h8ujbsorR4/MmuQD2KC6blNSczLLUIn27BK6Ml89mMRWcEa743fef pYFxlUAXIyeHhICJxL+uiaxdjFwcQgIrGCWmvf/LDuF8YZR42nuZBcL5zCixZsUsVpiWX7f2 MkEkljNKHN72gA2uZf+XpywgVWwCphK3734CSnBwiAgoSMz7qgMSZhZoYZb4tZoTJCws4Czx eb4jSJhFQFXi3fonjBDz5SRunutkBrE5BTwk3v+ZBXaRhEA/u0TL1VfsIAlegTKJvcvaWUDm SAi4SPz6LwLRKyzx6vgWdghbRuL05B4WiN5mRolbX66xQjgTGCUOru5igaiylth04xUTyCBm AU2J9bv0IWY6SlxproAw+SRuvBWEuJ5PYtK26cwQYV6JjjYhiBlqEq+3bGGD2fri81eoTzwk jp9oggbhbEaJdfOOsk9glJ+FsGsBI+MqRvHU0uLc9NRi47zUcr3ixNzi0rx0veT83E2MwHRy +t/xrzsY9/1JOsQowMGoxMO7YMH8aCHWxLLiytxDjBIczEoivMx8QCHelMTKqtSi/Pii0pzU 4kOM0hwsSuK8fFpp0UIC6YklqdmpqQWpRTBZJg5OqQZG12OC78K4KzK3rdqzNUZy1W+TfZIx q/9mdueIr7/tKTWHXeWI+f7mX9o26zzezfhqP+Ow56mUvj8t569Y373+bx4bp2F1ktX+9YkZ T5viZD4pTpZIYl28zsH+QtgNv5YE1spjd09crvMtLbfZsEPVVfBt9vfvvr+cRJMeGF7O/xMV d6VmtoSmEktxRqKhFnNRcSIAqr5h7CMDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsVy+t/xe7pnD8+PNji8WN1i44z1rBbHdy9l tJhzvoXFovuVjEXfvv+MFufPb2C3uH/vJ5PF5V1z2CxmnN/HZPH/VzOzA5fHlpU3mTy2HVD1 2LSqk83j38IpLB4H3+1h8ujbsorR4/MmuQD2KD2bovzSklSFjPziElulaEMLIz1DSws9IxNL PUNj81grI1MlfTublNSczLLUIn27BL2Ml89mMRWcEa743fefpYFxlUAXIyeHhICJxK9be5m6 GLk4hASWMkr82tLIDpGQkZh3to8NwhaW+HOtiw2i6BOjxOX+N8wgCTYBU4nbdz8BJTg4RAQU JOZ91QGpYRboYpaY8aQDLC4s4Czxeb4jSDmLgKrEu/VPGEFsXgF3iVn3e1kh5stJ3DzXCTaS U8BD4v2fWWA3CAHVbJk6g3ECI98CRoZVjCKppcW56bnFhnrFibnFpXnpesn5uZsYgQG+7djP zTsYL20MPsQowMGoxMO7YMH8aCHWxLLiytxDjBIczEoivMx8QCHelMTKqtSi/Pii0pzU4kOM pkBHTWSWEk3OB0ZfXkm8oamhuYWlobmxubGZhZI473mDyighgfTEktTs1NSC1CKYPiYOTqkG RkbZ3Vnf/+00ZVrgcGR6NkP6tZldizvcWV21/O6JHfv7ZcLP00bb/qcKiLTwml/3nHazq3XK V7usvorFrny/Otwkix55CEx4svakLs/MmYpRp+VybxwKPO+43Jr3kLpA3gOmmV8S+EzSO+Ud Flyaw1/9VsFz/VXND5kpyxIOb/F5bV6ntvSznBJLcUaioRZzUXEiAJz1/iaGAgAA Message-Id: <20180917151006eucas1p2226806b94605b061bc1bc3e9b5a6c495~VOIhXssSK0729007290eucas1p25@eucas1p2.samsung.com> X-CMS-MailID: 20180917151006eucas1p2226806b94605b061bc1bc3e9b5a6c495 X-Msg-Generator: CA X-RootMTR: 20180917151006eucas1p2226806b94605b061bc1bc3e9b5a6c495 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180917151006eucas1p2226806b94605b061bc1bc3e9b5a6c495 References: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> 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 Remove a race condition introduced by error path in functions: s5p_aes_interrupt and s5p_aes_crypt_start. Setting the busy field of struct s5p_aes_dev to false made it possible for s5p_tasklet_cb to change the req field, before s5p_aes_complete was called. Change the first parameter of s5p_aes_complete to struct ablkcipher_request. Before spin_unlock, make a copy of the currently handled request, to ensure s5p_aes_complete function call with the correct request. Signed-off-by: Christoph Manszewski Acked-by: Kamil Konieczny Reviewed-by: Krzysztof Kozlowski --- drivers/crypto/s5p-sss.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index faa282074e5a..9021ad9df0c4 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -475,9 +475,9 @@ static void s5p_sg_done(struct s5p_aes_dev *dev) } /* Calls the completion. Cannot be called with dev->lock hold. */ -static void s5p_aes_complete(struct s5p_aes_dev *dev, int err) +static void s5p_aes_complete(struct ablkcipher_request *req, int err) { - dev->req->base.complete(&dev->req->base, err); + req->base.complete(&req->base, err); } static void s5p_unset_outdata(struct s5p_aes_dev *dev) @@ -655,6 +655,7 @@ static irqreturn_t s5p_aes_interrupt(int irq, void *dev_id) { struct platform_device *pdev = dev_id; struct s5p_aes_dev *dev = platform_get_drvdata(pdev); + struct ablkcipher_request *req; int err_dma_tx = 0; int err_dma_rx = 0; int err_dma_hx = 0; @@ -727,7 +728,7 @@ static irqreturn_t s5p_aes_interrupt(int irq, void *dev_id) spin_unlock_irqrestore(&dev->lock, flags); - s5p_aes_complete(dev, 0); + s5p_aes_complete(dev->req, 0); /* Device is still busy */ tasklet_schedule(&dev->tasklet); } else { @@ -752,11 +753,12 @@ static irqreturn_t s5p_aes_interrupt(int irq, void *dev_id) error: s5p_sg_done(dev); dev->busy = false; + req = dev->req; if (err_dma_hx == 1) s5p_set_dma_hashdata(dev, dev->hash_sg_iter); spin_unlock_irqrestore(&dev->lock, flags); - s5p_aes_complete(dev, err); + s5p_aes_complete(req, err); hash_irq_end: /* @@ -1983,7 +1985,7 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) s5p_sg_done(dev); dev->busy = false; spin_unlock_irqrestore(&dev->lock, flags); - s5p_aes_complete(dev, err); + s5p_aes_complete(req, err); } static void s5p_tasklet_cb(unsigned long data) From patchwork Mon Sep 17 15:09:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Manszewski X-Patchwork-Id: 10602907 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-2.web.codeaurora.org (Postfix) with ESMTP id F379B112B for ; Mon, 17 Sep 2018 15:10:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5F422998B for ; Mon, 17 Sep 2018 15:10:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D87872A087; Mon, 17 Sep 2018 15:10:29 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 822D52998B for ; Mon, 17 Sep 2018 15:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729271AbeIQUhz (ORCPT ); Mon, 17 Sep 2018 16:37:55 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54830 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729272AbeIQUhz (ORCPT ); Mon, 17 Sep 2018 16:37:55 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180917151009euoutp017a810cc6d9ebe168689c720384e3c1fa~VOIkUadzk2530725307euoutp01M for ; Mon, 17 Sep 2018 15:10:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180917151009euoutp017a810cc6d9ebe168689c720384e3c1fa~VOIkUadzk2530725307euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537197009; bh=cY5FL3WC+eM3DcQ+/PpJo7RkBq4nR1ygXuBk+NVTqA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CSFkM+utx8lqhZgV1ryz1lCp9xzJtlCAtfvrhmAWxsHq96susRrtMuuNRnirl/lZD AdzcYFshYETxE1Lpt5vuHvLrLVzLdeyGbOM/k2BwsqvQvzAI7vHK0zi29yJyHB8+Ks Gzx/8ust4PPXtk4JmgoLvXx+R3wJaNv5rgIzf9b0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180917151008eucas1p16b9eb3e55838a61ab9189103e61fc49f~VOIj0tqCn0202502025eucas1p1B; Mon, 17 Sep 2018 15:10:08 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F6.7C.04441.0D3CF9B5; Mon, 17 Sep 2018 16:10:08 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180917151007eucas1p175be8c3c1119cff3189aa12722b21ca8~VOIi9Gjo-0057700577eucas1p1F; Mon, 17 Sep 2018 15:10:07 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180917151007eusmtrp1fff1b980948ca0b8b3a35d00aa2776f4~VOIirRn0r3069130691eusmtrp1r; Mon, 17 Sep 2018 15:10:07 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-09-5b9fc3d0917b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 82.48.04284.FC3CF9B5; Mon, 17 Sep 2018 16:10:07 +0100 (BST) Received: from AMDC2034.DIGITAL.local (unknown [106.120.51.41]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180917151006eusmtip2e95b823564f6593536dcfb7691a71258~VOIiMxK3q2417824178eusmtip2U; Mon, 17 Sep 2018 15:10:06 +0000 (GMT) From: Christoph Manszewski To: linux-crypto@vger.kernel.org Cc: Christoph Manszewski , Krzysztof Kozlowski , Vladimir Zapolskiy , Kamil Konieczny , Herbert Xu , "David S. Miller" , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz Subject: [PATCH v2 2/4] crypto: s5p-sss: Fix Fix argument list alignment Date: Mon, 17 Sep 2018 17:09:28 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIKsWRmVeSWpSXmKPExsWy7djPc7oXDs+PNvhxS9Ri44z1rBbHdy9l tJhzvoXFovuVjEXfvv+MFufPb2C3uH/vJ5PF5V1z2CxmnN/HZPH/VzOzA5fHlpU3mTy2HVD1 2LSqk83j38IpLB4H3+1h8ujbsorR4/MmuQD2KC6blNSczLLUIn27BK6MtskfGAtOs1f0P3nH 0sA4l62LkZNDQsBE4vqZ++wgtpDACkaJz+dSuxi5gOwvjBIt+/uZIJzPjBLLjl9lgum49Hs5 VGI5o8T2O4sY4VreNZ1hBaliEzCVuH33E9AODg4RAQWJeV91QMLMAi3MEr9Wc4LYwgIeEvtX fgVbzSKgKvHlzjqok+Qkbp7rZAaxOYFq3v+ZxQ4R72eX2LbeBcTmFSiTeDdvN9RBLhJHr22E qhGWeHV8C5QtI3F6cg8LyG0SAs2MEre+XGOFcCYwShxc3cUCUWUtsenGKyaQQ5kFNCXW79KH CDtK3L6ygRkkLCHAJ3HjrSDE/XwSk7ZNhwrzSnS0CUFUq0m83rKFDWbti89fGSFsD4m3c88x Q4JnNqPEm3MXWScwys9CWLaAkXEVo3hqaXFuemqxYV5quV5xYm5xaV66XnJ+7iZGYEI5/e/4 px2MXy8lHWIU4GBU4uFdsGB+tBBrYllxZe4hRgkOZiURXmY+oBBvSmJlVWpRfnxRaU5q8SFG aQ4WJXFePq20aCGB9MSS1OzU1ILUIpgsEwenVANjbUf9BcX6ryUxPktcFJd/O/Vi2fn22ZrT PmbM2XhvPvuHJWIKuzP+3GRfdEw3T+lAoKmO1494uVvRLxk++5/Snn7rltG9hx3zFPfX7e5R XLu25WVl2bZ/00y2KVSH/5thZiz+0pw79eV3vU1z5EstXsZeL+Ddeu5j3KbIssblbC8f9Zpd WXg3XomlOCPRUIu5qDgRALQbsYkkAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRmVeSWpSXmKPExsVy+t/xe7rnD8+PNvj8QcJi44z1rBbHdy9l tJhzvoXFovuVjEXfvv+MFufPb2C3uH/vJ5PF5V1z2CxmnN/HZPH/VzOzA5fHlpU3mTy2HVD1 2LSqk83j38IpLB4H3+1h8ujbsorR4/MmuQD2KD2bovzSklSFjPziElulaEMLIz1DSws9IxNL PUNj81grI1MlfTublNSczLLUIn27BL2MtskfGAtOs1f0P3nH0sA4l62LkZNDQsBE4tLv5Uxd jFwcQgJLGSXWrX3CCpGQkZh3tg+qSFjiz7UuNoiiT4wSM7ufMoMk2ARMJW7f/QSU4OAQEVCQ mPdVB6SGWaCLWWLGkw6wZmEBD4n9K7+yg9gsAqoSX+6sA4vzCrhLnLm2jxligZzEzXOdYDYn UP37P7PA6oWAarZMncE4gZFvASPDKkaR1NLi3PTcYkO94sTc4tK8dL3k/NxNjMAQ33bs5+Yd jJc2Bh9iFOBgVOLhXbBgfrQQa2JZcWXuIUYJDmYlEV5mPqAQb0piZVVqUX58UWlOavEhRlOg oyYyS4km5wPjL68k3tDU0NzC0tDc2NzYzEJJnPe8QWWUkEB6YklqdmpqQWoRTB8TB6dUA6Nk o/+MClGfJ4vniHVNeGTw+PgJPd697DqRCps7+e6efbfP8aeuRdaa7K/aMhkuH8QrGGLnlEZ2 7Ddnm8ApXvx73XnPX3vDm8RmlYZ0zL8bFPHhJnu114Pdr+XSpNMm2f20nVa2ieHIx1Pm92tv sAbP3KfjZjvtYnh82IxJGya6XHy70G6Z9nUlluKMREMt5qLiRAACB94ghwIAAA== Message-Id: <20180917151007eucas1p175be8c3c1119cff3189aa12722b21ca8~VOIi9Gjo-0057700577eucas1p1F@eucas1p1.samsung.com> X-CMS-MailID: 20180917151007eucas1p175be8c3c1119cff3189aa12722b21ca8 X-Msg-Generator: CA X-RootMTR: 20180917151007eucas1p175be8c3c1119cff3189aa12722b21ca8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180917151007eucas1p175be8c3c1119cff3189aa12722b21ca8 References: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> 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 Fix misalignment of continued argument list. Signed-off-by: Christoph Manszewski Reviewed-by: Krzysztof Kozlowski Acked-by: Kamil Konieczny --- drivers/crypto/s5p-sss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index 9021ad9df0c4..b7216935236f 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -491,7 +491,7 @@ static void s5p_unset_indata(struct s5p_aes_dev *dev) } static int s5p_make_sg_cpy(struct s5p_aes_dev *dev, struct scatterlist *src, - struct scatterlist **dst) + struct scatterlist **dst) { void *pages; int len; @@ -1889,7 +1889,7 @@ static int s5p_set_indata_start(struct s5p_aes_dev *dev, } static int s5p_set_outdata_start(struct s5p_aes_dev *dev, - struct ablkcipher_request *req) + struct ablkcipher_request *req) { struct scatterlist *sg; int err; From patchwork Mon Sep 17 15:09:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Manszewski X-Patchwork-Id: 10602899 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-2.web.codeaurora.org (Postfix) with ESMTP id 8C85A112B for ; Mon, 17 Sep 2018 15:10:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EFF42998B for ; Mon, 17 Sep 2018 15:10:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7348B2A087; Mon, 17 Sep 2018 15:10:14 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 141DB2A089 for ; Mon, 17 Sep 2018 15:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729312AbeIQUh5 (ORCPT ); Mon, 17 Sep 2018 16:37:57 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:59182 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729233AbeIQUh4 (ORCPT ); Mon, 17 Sep 2018 16:37:56 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180917151010euoutp02cc7c6612839a855f6e822e3bebc5d639~VOIl2IFUS1481614816euoutp02I for ; Mon, 17 Sep 2018 15:10:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180917151010euoutp02cc7c6612839a855f6e822e3bebc5d639~VOIl2IFUS1481614816euoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537197010; bh=T9jpYh7paRgEMj1xcfos8mLUbeOnMA+vBAv85Pt86X8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o3Tx5V8AM4mhStvjK2+MTQvuuB6BAVvdj0fpsqpZJrYekz0SZtajbkwZxE8VtJHl6 eTzOW1djPLUl6baZYYbBsb2B5bTJ1a1m1Wc+Z3C2vVOweKh010V5FE7RydDv7ZRHT+ 8fHyJtsWhn6JGPkV6kgBVsCsK0FNJWL77k+s68KU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180917151010eucas1p137a318378eaeabf8518fcb1f8e8a40c3~VOIlRcHs-0556505565eucas1p1v; Mon, 17 Sep 2018 15:10:10 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 6A.34.04294.1D3CF9B5; Mon, 17 Sep 2018 16:10:09 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180917151009eucas1p145fdde4a56241418a49a1da14c5bdb02~VOIkhD_S60202502025eucas1p1F; Mon, 17 Sep 2018 15:10:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180917151009eusmtrp229eece97d0623a272c92ec0f2378921b~VOIkPLJhD2674126741eusmtrp2v; Mon, 17 Sep 2018 15:10:09 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-c2-5b9fc3d1354c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 44.46.04128.1D3CF9B5; Mon, 17 Sep 2018 16:10:09 +0100 (BST) Received: from AMDC2034.DIGITAL.local (unknown [106.120.51.41]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180917151008eusmtip26c758608bc47011c811759e45550d48f~VOIj0tvfW2392923929eusmtip2b; Mon, 17 Sep 2018 15:10:08 +0000 (GMT) From: Christoph Manszewski To: linux-crypto@vger.kernel.org Cc: Christoph Manszewski , Krzysztof Kozlowski , Vladimir Zapolskiy , Kamil Konieczny , Herbert Xu , "David S. Miller" , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz Subject: [PATCH v2 3/4] crypto: s5p-sss: Minor code cleanup Date: Mon, 17 Sep 2018 17:09:29 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42LZduzned2Lh+dHGzy8YGmxccZ6Vovju5cy Wsw538Ji0f1KxqJv339Gi/PnN7Bb3L/3k8ni8q45bBYzzu9jsvj/q5nZgctjy8qbTB7bDqh6 bFrVyebxb+EUFo+D7/YwefRtWcXo8XmTXAB7FJdNSmpOZllqkb5dAlfGw5kzmAuaZSqmHLrD 2MA4V6yLkZNDQsBEYtqTz+xdjFwcQgIrGCU+Nv9khHC+MEps3rqaFcL5zCjx9+weoDIOsJZJ t2Mg4ssZJS5vXMgM19F4ZQEjyFw2AVOJ23c/sYE0iAgoSMz7qgMSZhZoYZb4tZoTxBYWsJZY 2zsbrJxFQFWi89ZzNoiT5CRunutkBrE5BTwk3v+ZxQ4Rn8wucbVRAsTmFSiTONYygxki7iKx 7tUUqF5hiVfHt0DVy0j83zmfCeQ2CYFmRolbX66xQjgTGCUOru5igaiylth04xUTyKHMApoS 63fpQzzpKDHzdCWEySdx460gxPl8EpO2TWeGCPNKdLQJQcxQk3i9ZQsbzNYXn78yQpR4SPzf EAEJnNmMEs1/prFPYJSfhbBqASPjKkbx1NLi3PTUYqO81HK94sTc4tK8dL3k/NxNjMBkcvrf 8S87GHf9STrEKMDBqMTDu2DB/Ggh1sSy4srcQ4wSHMxKIrzMfEAh3pTEyqrUovz4otKc1OJD jNIcLErivHxaadFCAumJJanZqakFqUUwWSYOTqkGRkUTA2avWUn2AdMY1CayNDBdkm6yUp2+ fi53zsaF5heXOLj/Nsv4zdf/vXdP0G+lsrYO/msKd42NGTWE3TbfVrx1qizw84OdObLX3ou8 nCPH0C1t9O9yqFUYk6SWxk0Xn1mZK6xf7Wdbsm6261m2xFtFVydrhq0tqes/4nL+2sEziuus 6zrWK7EUZyQaajEXFScCALrYY4YiAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsVy+t/xe7oXD8+PNljVxG6xccZ6Vovju5cy Wsw538Ji0f1KxqJv339Gi/PnN7Bb3L/3k8ni8q45bBYzzu9jsvj/q5nZgctjy8qbTB7bDqh6 bFrVyebxb+EUFo+D7/YwefRtWcXo8XmTXAB7lJ5NUX5pSapCRn5xia1StKGFkZ6hpYWekYml nqGxeayVkamSvp1NSmpOZllqkb5dgl7Gw5kzmAuaZSqmHLrD2MA4V6yLkYNDQsBEYtLtmC5G Lg4hgaWMEi86ljB3MXICxWUk5p3tY4OwhSX+XOtigyj6xCjx6N9xsASbgKnE7buf2EAGiQgo SMz7qgNSwyzQxSwx40kHWI2wgLXE2t7ZjCA2i4CqROet52BxXgF3iQPXPrBCLJCTuHmuE2wx p4CHxPs/s9hBbCGgmi1TZzBOYORbwMiwilEktbQ4Nz232EivODG3uDQvXS85P3cTIzDAtx37 uWUHY9e74EOMAhyMSjy8PxbNjxZiTSwrrsw9xCjBwawkwsvMBxTiTUmsrEotyo8vKs1JLT7E aAp01ERmKdHkfGD05ZXEG5oamltYGpobmxubWSiJ8543qIwSEkhPLEnNTk0tSC2C6WPi4JRq YLS8+KHuh3Hc6v/G0ltjfun/UbW9HGi/Jnmrw8fdIolF3see3d6iN2t30Tv7X+c4dY80tFfa cju92RPfND1/u+o5O///TckRC2+un5G8X7HGk/n/Jc8X99ZINAbr54tImEg8XGH2cPbaRg3B GE3zbBGFPfdMVi5k+7whPH3K1RP+tYpWr7LClimxFGckGmoxFxUnAgDkmwJBhgIAAA== Message-Id: <20180917151009eucas1p145fdde4a56241418a49a1da14c5bdb02~VOIkhD_S60202502025eucas1p1F@eucas1p1.samsung.com> X-CMS-MailID: 20180917151009eucas1p145fdde4a56241418a49a1da14c5bdb02 X-Msg-Generator: CA X-RootMTR: 20180917151009eucas1p145fdde4a56241418a49a1da14c5bdb02 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180917151009eucas1p145fdde4a56241418a49a1da14c5bdb02 References: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> 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 Modifications in s5p-sss.c: - remove unnecessary 'goto' statements (making code shorter), - change uint_8 and uint_32 to u8 and u32 types (for consistency in the driver and making code shorter), Signed-off-by: Christoph Manszewski Reviewed-by: Krzysztof Kozlowski Acked-by: Kamil Konieczny --- drivers/crypto/s5p-sss.c | 54 +++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index b7216935236f..ba8f2e2ea88f 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -249,8 +249,8 @@ struct s5p_aes_reqctx { struct s5p_aes_ctx { struct s5p_aes_dev *dev; - uint8_t aes_key[AES_MAX_KEY_SIZE]; - uint8_t nonce[CTR_RFC3686_NONCE_SIZE]; + u8 aes_key[AES_MAX_KEY_SIZE]; + u8 nonce[CTR_RFC3686_NONCE_SIZE]; int keylen; }; @@ -518,46 +518,28 @@ static int s5p_make_sg_cpy(struct s5p_aes_dev *dev, struct scatterlist *src, static int s5p_set_outdata(struct s5p_aes_dev *dev, struct scatterlist *sg) { - int err; - - if (!sg->length) { - err = -EINVAL; - goto exit; - } + if (!sg->length) + return -EINVAL; - err = dma_map_sg(dev->dev, sg, 1, DMA_FROM_DEVICE); - if (!err) { - err = -ENOMEM; - goto exit; - } + if (!dma_map_sg(dev->dev, sg, 1, DMA_FROM_DEVICE)) + return -ENOMEM; dev->sg_dst = sg; - err = 0; -exit: - return err; + return 0; } static int s5p_set_indata(struct s5p_aes_dev *dev, struct scatterlist *sg) { - int err; - - if (!sg->length) { - err = -EINVAL; - goto exit; - } + if (!sg->length) + return -EINVAL; - err = dma_map_sg(dev->dev, sg, 1, DMA_TO_DEVICE); - if (!err) { - err = -ENOMEM; - goto exit; - } + if (!dma_map_sg(dev->dev, sg, 1, DMA_TO_DEVICE)) + return -ENOMEM; dev->sg_src = sg; - err = 0; -exit: - return err; + return 0; } /* @@ -662,8 +644,7 @@ static irqreturn_t s5p_aes_interrupt(int irq, void *dev_id) bool tx_end = false; bool hx_end = false; unsigned long flags; - uint32_t status; - u32 st_bits; + u32 status, st_bits; int err; spin_lock_irqsave(&dev->lock, flags); @@ -1832,7 +1813,7 @@ static struct ahash_alg algs_sha1_md5_sha256[] = { }; static void s5p_set_aes(struct s5p_aes_dev *dev, - const uint8_t *key, const uint8_t *iv, + const u8 *key, const u8 *iv, unsigned int keylen) { void __iomem *keystart; @@ -1918,7 +1899,7 @@ static int s5p_set_outdata_start(struct s5p_aes_dev *dev, static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) { struct ablkcipher_request *req = dev->req; - uint32_t aes_control; + u32 aes_control; unsigned long flags; int err; u8 *iv; @@ -2026,7 +2007,7 @@ static int s5p_aes_handle_req(struct s5p_aes_dev *dev, err = ablkcipher_enqueue_request(&dev->queue, req); if (dev->busy) { spin_unlock_irqrestore(&dev->lock, flags); - goto exit; + return err; } dev->busy = true; @@ -2034,7 +2015,6 @@ static int s5p_aes_handle_req(struct s5p_aes_dev *dev, tasklet_schedule(&dev->tasklet); -exit: return err; } @@ -2056,7 +2036,7 @@ static int s5p_aes_crypt(struct ablkcipher_request *req, unsigned long mode) } static int s5p_aes_setkey(struct crypto_ablkcipher *cipher, - const uint8_t *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct s5p_aes_ctx *ctx = crypto_tfm_ctx(tfm); From patchwork Mon Sep 17 15:09:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Manszewski X-Patchwork-Id: 10602901 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-2.web.codeaurora.org (Postfix) with ESMTP id 385DC157B for ; Mon, 17 Sep 2018 15:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29C652998B for ; Mon, 17 Sep 2018 15:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DD052A089; Mon, 17 Sep 2018 15:10:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 86D952998B for ; Mon, 17 Sep 2018 15:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729326AbeIQUiA (ORCPT ); Mon, 17 Sep 2018 16:38:00 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54851 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729327AbeIQUh7 (ORCPT ); Mon, 17 Sep 2018 16:37:59 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180917151012euoutp01b75f346e75e7ce5d26f0b6a44c0dc53a~VOInw2m9f2435224352euoutp01T for ; Mon, 17 Sep 2018 15:10:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180917151012euoutp01b75f346e75e7ce5d26f0b6a44c0dc53a~VOInw2m9f2435224352euoutp01T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537197012; bh=lsWZ0ancngmtxX1n3Fse+Ouak7Qymqi/CgLF9OkT1/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AAQ5uCWk00cG85kVqA0GLLQFJ6+lEBV6fR2p1Sk0emekRc2nXmNE9wrn9CdbWkxaq JDcW/VFbjYKTAvlJsXhGI6Sa45DazC8x/eK89TteWKn0yrks1zXgA7AW0o06fbMEg6 xJYiPgAuRegnHLPxsXUbXR4QgG6+3f6aA6cw3ne4= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180917151012eucas1p115f7426d579c26f975eec3268d531fdd~VOInKw63A2050920509eucas1p1v; Mon, 17 Sep 2018 15:10:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id A9.7C.04441.3D3CF9B5; Mon, 17 Sep 2018 16:10:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180917151011eucas1p274a1407a02081b49aa03da85cc9aec4c~VOImIjh2C1107511075eucas1p2w; Mon, 17 Sep 2018 15:10:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180917151010eusmtrp1a5559102b1fa7f04b069f28e58da658f~VOIl2FFqs3069130691eusmtrp1u; Mon, 17 Sep 2018 15:10:10 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-13-5b9fc3d339aa Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 35.48.04284.2D3CF9B5; Mon, 17 Sep 2018 16:10:10 +0100 (BST) Received: from AMDC2034.DIGITAL.local (unknown [106.120.51.41]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180917151010eusmtip221a9e59f473c61164032fe2517f11788~VOIlbOU-F2369023690eusmtip2l; Mon, 17 Sep 2018 15:10:10 +0000 (GMT) From: Christoph Manszewski To: linux-crypto@vger.kernel.org Cc: Christoph Manszewski , Krzysztof Kozlowski , Vladimir Zapolskiy , Kamil Konieczny , Herbert Xu , "David S. Miller" , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz Subject: [PATCH v2 4/4] crypto: s5p-sss: Add aes-ctr support Date: Mon, 17 Sep 2018 17:09:30 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAKsWRmVeSWpSXmKPExsWy7djPc7qXD8+PNrjeaG2xccZ6Vovju5cy Wsw538Ji0f1KxqJv339Gi/PnN7Bb3L/3k8ni8q45bBYzzu9jsvj/q5nZgctjy8qbTB7bDqh6 bFrVyebxb+EUFo+D7/YwefRtWcXo8XmTXAB7FJdNSmpOZllqkb5dAlfGxbmzWArWqFQ0Ny1g amC8INvFyMkhIWAi8erXY/YuRi4OIYEVjBKLpi5hA0kICXxhlJjVyAKR+MwocWnrbWaYjntL PjBDJJYzSkw93MUO1/FrqiWIzSZgKnH77iegSRwcIgIKEvO+6oCEmQVamCV+reYEsYUFbCRu tr9kBLFZBFQlPp95zA4xX07i5rlOsF2cAh4S7//Mgop3s0v8fykOYvMKlEl8bWmCirtIPHp9 nQXCFpZ4dXwLVFxG4vTkHrAHJASaGSVufbnGCuFMYJQ4uLoLqsNaYtONV0wghzILaEqs36UP EXaUWNXUwQoSlhDgk7jxVhDifj6JSdumM0OEeSU62oQgqtUkXm/Zwgaz9sXnr4wQtofElSNH oUE1m1Fi7Y5NjBMY5WchLFvAyLiKUTy1tDg3PbXYMC+1XK84Mbe4NC9dLzk/dxMjMJ2c/nf8 0w7Gr5eSDjEKcDAq8fAuWDA/Wog1say4MvcQowQHs5IILzMfUIg3JbGyKrUoP76oNCe1+BCj NAeLkjgvn1ZatJBAemJJanZqakFqEUyWiYNTqoHRWW1+t5DB/NnqFifXfHBatmrribkxobfL lq0NOCqlOi3vlHV+ufHEDwafa50en9dL3j8/JS/79xyNjy7/N64yKlyXt3Ci5WvRSIsHT1mP 7v830WCCqLJQ6C6FWqaGjEux5/xYFmepn/gVd/1OW/hmN6N78y5+udWdv4OLw231qYWhNw5X LHgnq8RSnJFoqMVcVJwIAK9eeGojAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsVy+t/xe7qXDs+PNpj13Mhi44z1rBbHdy9l tJhzvoXFovuVjEXfvv+MFufPb2C3uH/vJ5PF5V1z2CxmnN/HZPH/VzOzA5fHlpU3mTy2HVD1 2LSqk83j38IpLB4H3+1h8ujbsorR4/MmuQD2KD2bovzSklSFjPziElulaEMLIz1DSws9IxNL PUNj81grI1MlfTublNSczLLUIn27BL2Mi3NnsRSsUaloblrA1MB4QbaLkZNDQsBE4t6SD8wg tpDAUkaJlZ28EHEZiXln+9ggbGGJP9e6gGwuoJpPjBLzl/0Ha2ATMJW4ffcTUIKDQ0RAQWLe Vx2QGmaBLmaJGU86wJqFBWwkbra/ZASxWQRUJT6fecwOYvMKuEtc+nKECWKBnMTNc51gMzkF PCTe/5nFDnGQu8SWqTMYJzDyLWBkWMUoklpanJueW2yoV5yYW1yal66XnJ+7iREY4NuO/dy8 g/HSxuBDjAIcjEo8vAsWzI8WYk0sK67MPcQowcGsJMLLzAcU4k1JrKxKLcqPLyrNSS0+xGgK dNREZinR5Hxg9OWVxBuaGppbWBqaG5sbm1koifOeN6iMEhJITyxJzU5NLUgtgulj4uCUamDU 01SQW3w1k3tvf8XRqM+3Dm+ou3mHyzHXL7hR1NBVOFTJs/nQ4lrLQJNn5oHKDrqBF43T7uep hX8sVNp1hKuUPYNx/zfl/fzM1s2ienrLWSW4L3ku19ipnnG3gGd/wDOfKrayWwLyjz5p8v1f rDrNTubdugk6f9dzcusvUTs83crhzUT3rUosxRmJhlrMRcWJANSOd1eGAgAA Message-Id: <20180917151011eucas1p274a1407a02081b49aa03da85cc9aec4c~VOImIjh2C1107511075eucas1p2w@eucas1p2.samsung.com> X-CMS-MailID: 20180917151011eucas1p274a1407a02081b49aa03da85cc9aec4c X-Msg-Generator: CA X-RootMTR: 20180917151011eucas1p274a1407a02081b49aa03da85cc9aec4c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180917151011eucas1p274a1407a02081b49aa03da85cc9aec4c References: <1537196970-5987-1-git-send-email-c.manszewski@samsung.com> 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 Add support for aes counter(ctr) block cipher mode of operation for Exynos Hardware. In contrast to ecb and cbc modes, aes-ctr allows encyption/decryption for request sizes not being a multiple of 16(bytes). Hardware requires block sizes being a multiple of 16(bytes). In order to achieve this, copy request source and destination memory, and align it's size to 16. That way hardware processes additional bytes, that are omitted when copying the result back to its original destination. Tested on Odroid-U3 with Exynos 4412 CPU, kernel 4.19-rc2 with crypto run-time self test testmgr. Signed-off-by: Christoph Manszewski Reviewed-by: Krzysztof Kozlowski Acked-by: Kamil Konieczny --- drivers/crypto/s5p-sss.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index ba8f2e2ea88f..0064be0e3941 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -1813,7 +1813,7 @@ static struct ahash_alg algs_sha1_md5_sha256[] = { }; static void s5p_set_aes(struct s5p_aes_dev *dev, - const u8 *key, const u8 *iv, + const u8 *key, const u8 *iv, const u8 *ctr, unsigned int keylen) { void __iomem *keystart; @@ -1821,6 +1821,9 @@ static void s5p_set_aes(struct s5p_aes_dev *dev, if (iv) memcpy_toio(dev->aes_ioaddr + SSS_REG_AES_IV_DATA(0), iv, 0x10); + if (ctr) + memcpy_toio(dev->aes_ioaddr + SSS_REG_AES_CNT_DATA(0), ctr, 0x10); + if (keylen == AES_KEYSIZE_256) keystart = dev->aes_ioaddr + SSS_REG_AES_KEY_DATA(0); else if (keylen == AES_KEYSIZE_192) @@ -1902,8 +1905,9 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) u32 aes_control; unsigned long flags; int err; - u8 *iv; + u8 *iv, *ctr; + /* This sets bit [13:12] to 00, which selects 128-bit counter */ aes_control = SSS_AES_KEY_CHANGE_MODE; if (mode & FLAGS_AES_DECRYPT) aes_control |= SSS_AES_MODE_DECRYPT; @@ -1911,11 +1915,14 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) { aes_control |= SSS_AES_CHAIN_MODE_CBC; iv = req->info; + ctr = NULL; } else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) { aes_control |= SSS_AES_CHAIN_MODE_CTR; - iv = req->info; + iv = NULL; + ctr = req->info; } else { iv = NULL; /* AES_ECB */ + ctr = NULL; } if (dev->ctx->keylen == AES_KEYSIZE_192) @@ -1947,7 +1954,7 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode) goto outdata_error; SSS_AES_WRITE(dev, AES_CONTROL, aes_control); - s5p_set_aes(dev, dev->ctx->aes_key, iv, dev->ctx->keylen); + s5p_set_aes(dev, dev->ctx->aes_key, iv, ctr, dev->ctx->keylen); s5p_set_dma_indata(dev, dev->sg_src); s5p_set_dma_outdata(dev, dev->sg_dst); @@ -2025,7 +2032,8 @@ static int s5p_aes_crypt(struct ablkcipher_request *req, unsigned long mode) struct s5p_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm); struct s5p_aes_dev *dev = ctx->dev; - if (!IS_ALIGNED(req->nbytes, AES_BLOCK_SIZE)) { + if (!IS_ALIGNED(req->nbytes, AES_BLOCK_SIZE) && + ((mode & FLAGS_AES_MODE_MASK) != FLAGS_AES_CTR)) { dev_err(dev->dev, "request size is not exact amount of AES blocks\n"); return -EINVAL; } @@ -2072,6 +2080,11 @@ static int s5p_aes_cbc_decrypt(struct ablkcipher_request *req) return s5p_aes_crypt(req, FLAGS_AES_DECRYPT | FLAGS_AES_CBC); } +static int s5p_aes_ctr_crypt(struct ablkcipher_request *req) +{ + return s5p_aes_crypt(req, FLAGS_AES_CTR); +} + static int s5p_aes_cra_init(struct crypto_tfm *tfm) { struct s5p_aes_ctx *ctx = crypto_tfm_ctx(tfm); @@ -2126,6 +2139,28 @@ static struct crypto_alg algs[] = { .decrypt = s5p_aes_cbc_decrypt, } }, + { + .cra_name = "ctr(aes)", + .cra_driver_name = "ctr-aes-s5p", + .cra_priority = 100, + .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | + CRYPTO_ALG_ASYNC | + CRYPTO_ALG_KERN_DRIVER_ONLY, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct s5p_aes_ctx), + .cra_alignmask = 0x0f, + .cra_type = &crypto_ablkcipher_type, + .cra_module = THIS_MODULE, + .cra_init = s5p_aes_cra_init, + .cra_u.ablkcipher = { + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .setkey = s5p_aes_setkey, + .encrypt = s5p_aes_ctr_crypt, + .decrypt = s5p_aes_ctr_crypt, + } + }, }; static int s5p_aes_probe(struct platform_device *pdev)