From patchwork Tue Nov 5 14:00:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178498 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709140ocf; Tue, 5 Nov 2019 06:01:29 -0800 (PST) X-Google-Smtp-Source: APXvYqw164Tib1EJEnGZMjHsASBCqiWZHCgSW3Nts+4tV83VbaCzX/lJo+QYH0vihMbQdkASEfN+ X-Received: by 2002:a17:906:ecad:: with SMTP id qh13mr7483533ejb.25.1572962489092; Tue, 05 Nov 2019 06:01:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962489; cv=none; d=google.com; s=arc-20160816; b=zKSu4CxzaD0BC2c9YT2rNfUWAjfXVn/RHKmWUuwFfle69XRf/9IoX1JIrdyxK3bKm1 asE4vCLwNKSwa8kGwYRNB5Y4v4J9NacG9AGIdO70MJLr5JmYcSjShqJL6Gr/+LOfycXx 70dl7wehgN2dcQNkU7SWhmJPnwWvm0X4JeLrgCpiCzU3rZvtikzKRHRG2kfNx7uOq0b8 P7b3l38/K0QXGKvnsNnqbbeEcMZDdfH/iFoTJcz5jqvyTQcH+4wKaWgbP+bKrvlF2myS 3F6CohcQp793vBQai11aZewbQh20PqVOMpfjPHz5LAN7ZJh8/qryB7Vu6X3mRikuZrJU oLog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5LuvH1G1CxJXjnQPeRbfhDmv2ndruQP/Xg9DUfak+xk=; b=e6rUpSjGyCFqFHZD2Cqh5qZdF0t+LGYHNgBJtzm1Y/uVB/xOUnD7mE0eaGJ4na/Qs4 rP4lYodGVjxgYyqI9i1BqFu8NTJBcPZ3g+tpdaG8tKAfvW8dyTQT0BDf1DK9oS/7a2o1 lbylysQUGYGLcDHGMP+ko6xJRajKN/61jB0+fZFNjZgwPyghiY7zY4vf/GqpDaD55veO rxiqnLHEkjh2P3XRJL63I+SR3Xz1pdSQARTmqqOCDlqWxJ3kYqHSNlOIV4BxKX5qdPvC OuDsNENV4yY58gG1OWI3JtBwzmPmf/KDpByFSKcOAAc2RZeHv3MUPXpP8Nh7pyTarrW2 +AAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=niojAQcb; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.28; Tue, 05 Nov 2019 06:01:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=niojAQcb; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389294AbfKEOB2 (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:28 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44666 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389290AbfKEOB2 (ORCPT ); Tue, 5 Nov 2019 09:01:28 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1JmZ043337; Tue, 5 Nov 2019 08:01:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962479; bh=5LuvH1G1CxJXjnQPeRbfhDmv2ndruQP/Xg9DUfak+xk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=niojAQcbK7t1Ye8eAGH6QDDfvEMsfaPK8HqWSrDMoYjRPgfw2svW1CBTWMfHqdRuw iP6i0mzD3dOK5DzCnRVRBRnNUF8nBqCrVZfU/v09NB0hFCfzr1HfqgxaIgchsURMgP wAYWstDhWpN1df2uk2op+VVq95PP8MauFSQ7l3Pg= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1JP2007694 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:19 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 5 Nov 2019 08:01:04 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 5 Nov 2019 08:01:04 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFe068289; Tue, 5 Nov 2019 08:01:17 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 01/22] crypto: omap-sham: split up data to multiple sg elements with huge data Date: Tue, 5 Nov 2019 16:00:50 +0200 Message-ID: <20191105140111.20285-2-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org When using huge data amount, allocating free pages fails as the kernel isn't able to process get_free_page requests larger than MAX_ORDER. Also, the DMA subsystem has an inherent limitation that data size larger than some 2MB can't be handled properly. In these cases, split up the data instead to smaller requests so that the kernel can allocate the data, and also so that the DMA driver can handle the separate SG elements. Signed-off-by: Tero Kristo Tested-by: Bin Liu --- drivers/crypto/omap-sham.c | 81 ++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 17 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index ac80bc6af093..2e9435577cea 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -112,6 +112,8 @@ #define FLAGS_BE32_SHA1 8 #define FLAGS_SGS_COPIED 9 #define FLAGS_SGS_ALLOCED 10 +#define FLAGS_HUGE 11 + /* context flags */ #define FLAGS_FINUP 16 @@ -136,6 +138,8 @@ #define BUFLEN SHA512_BLOCK_SIZE #define OMAP_SHA_DMA_THRESHOLD 256 +#define OMAP_SHA_MAX_DMA_LEN (1024 * 2048) + struct omap_sham_dev; struct omap_sham_reqctx { @@ -689,21 +693,20 @@ static int omap_sham_copy_sg_lists(struct omap_sham_reqctx *ctx, set_bit(FLAGS_SGS_ALLOCED, &ctx->dd->flags); + ctx->offset += new_len - ctx->bufcnt; ctx->bufcnt = 0; return 0; } static int omap_sham_copy_sgs(struct omap_sham_reqctx *ctx, - struct scatterlist *sg, int bs, int new_len) + struct scatterlist *sg, int bs, + unsigned int new_len) { int pages; void *buf; - int len; - - len = new_len + ctx->bufcnt; - pages = get_order(ctx->total); + pages = get_order(new_len); buf = (void *)__get_free_pages(GFP_ATOMIC, pages); if (!buf) { @@ -715,14 +718,14 @@ static int omap_sham_copy_sgs(struct omap_sham_reqctx *ctx, memcpy(buf, ctx->dd->xmit_buf, ctx->bufcnt); scatterwalk_map_and_copy(buf + ctx->bufcnt, sg, ctx->offset, - ctx->total - ctx->bufcnt, 0); + min(new_len, ctx->total) - ctx->bufcnt, 0); sg_init_table(ctx->sgl, 1); - sg_set_buf(ctx->sgl, buf, len); + sg_set_buf(ctx->sgl, buf, new_len); ctx->sg = ctx->sgl; set_bit(FLAGS_SGS_COPIED, &ctx->dd->flags); ctx->sg_len = 1; + ctx->offset += new_len - ctx->bufcnt; ctx->bufcnt = 0; - ctx->offset = 0; return 0; } @@ -741,7 +744,7 @@ static int omap_sham_align_sgs(struct scatterlist *sg, if (!sg || !sg->length || !nbytes) return 0; - new_len = nbytes; + new_len = nbytes - offset; if (offset) list_ok = false; @@ -751,6 +754,9 @@ static int omap_sham_align_sgs(struct scatterlist *sg, else new_len = (new_len - 1) / bs * bs; + if (!new_len) + return 0; + if (nbytes != new_len) list_ok = false; @@ -794,10 +800,17 @@ static int omap_sham_align_sgs(struct scatterlist *sg, } } + if (new_len > OMAP_SHA_MAX_DMA_LEN) { + new_len = OMAP_SHA_MAX_DMA_LEN; + aligned = false; + } + if (!aligned) return omap_sham_copy_sgs(rctx, sg, bs, new_len); else if (!list_ok) return omap_sham_copy_sg_lists(rctx, sg, bs, new_len); + else + rctx->offset += new_len; rctx->sg_len = n; rctx->sg = sg; @@ -821,7 +834,12 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) else nbytes = 0; - rctx->total = nbytes + rctx->bufcnt; + rctx->total = nbytes + rctx->bufcnt - rctx->offset; + + dev_dbg(rctx->dd->dev, + "%s: nbytes=%d, bs=%d, total=%d, offset=%d, bufcnt=%d\n", + __func__, nbytes, bs, rctx->total, rctx->offset, + rctx->bufcnt); if (!rctx->total) return 0; @@ -847,12 +865,15 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) xmit_len = rctx->total; + if (xmit_len > OMAP_SHA_MAX_DMA_LEN) + xmit_len = OMAP_SHA_MAX_DMA_LEN; + if (!IS_ALIGNED(xmit_len, bs)) { if (final) xmit_len = DIV_ROUND_UP(xmit_len, bs) * bs; else xmit_len = xmit_len / bs * bs; - } else if (!final) { + } else if (!final && rctx->total == xmit_len) { xmit_len -= bs; } @@ -880,7 +901,7 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) rctx->sg_len = 1; } - if (hash_later) { + if (hash_later && hash_later <= rctx->buflen) { int offset = 0; if (hash_later > req->nbytes) { @@ -901,6 +922,9 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) rctx->bufcnt = 0; } + if (hash_later > rctx->buflen) + set_bit(FLAGS_HUGE, &rctx->dd->flags); + if (!final) rctx->total = xmit_len; @@ -998,10 +1022,11 @@ static int omap_sham_update_req(struct omap_sham_dev *dd) struct ahash_request *req = dd->req; struct omap_sham_reqctx *ctx = ahash_request_ctx(req); int err; - bool final = ctx->flags & BIT(FLAGS_FINUP); + bool final = (ctx->flags & BIT(FLAGS_FINUP)) && + !(dd->flags & BIT(FLAGS_HUGE)); - dev_dbg(dd->dev, "update_req: total: %u, digcnt: %d, finup: %d\n", - ctx->total, ctx->digcnt, (ctx->flags & BIT(FLAGS_FINUP)) != 0); + dev_dbg(dd->dev, "update_req: total: %u, digcnt: %d, final: %d", + ctx->total, ctx->digcnt, final); if (ctx->total < get_block_size(ctx) || ctx->total < dd->fallback_sz) @@ -1024,6 +1049,9 @@ static int omap_sham_final_req(struct omap_sham_dev *dd) struct omap_sham_reqctx *ctx = ahash_request_ctx(req); int err = 0, use_dma = 1; + if (dd->flags & BIT(FLAGS_HUGE)) + return 0; + if ((ctx->total <= get_block_size(ctx)) || dd->polling_mode) /* * faster to handle last block with cpu or @@ -1083,7 +1111,7 @@ static void omap_sham_finish_req(struct ahash_request *req, int err) if (test_bit(FLAGS_SGS_COPIED, &dd->flags)) free_pages((unsigned long)sg_virt(ctx->sg), - get_order(ctx->sg->length + ctx->bufcnt)); + get_order(ctx->sg->length)); if (test_bit(FLAGS_SGS_ALLOCED, &dd->flags)) kfree(ctx->sg); @@ -1092,6 +1120,21 @@ static void omap_sham_finish_req(struct ahash_request *req, int err) dd->flags &= ~(BIT(FLAGS_SGS_ALLOCED) | BIT(FLAGS_SGS_COPIED)); + if (dd->flags & BIT(FLAGS_HUGE)) { + dd->flags &= ~(BIT(FLAGS_CPU) | BIT(FLAGS_DMA_READY) | + BIT(FLAGS_OUTPUT_READY) | BIT(FLAGS_HUGE)); + omap_sham_prepare_request(req, ctx->op == OP_UPDATE); + if (ctx->op == OP_UPDATE || (dd->flags & BIT(FLAGS_HUGE))) { + err = omap_sham_update_req(dd); + if (err != -EINPROGRESS && + (ctx->flags & BIT(FLAGS_FINUP))) + err = omap_sham_final_req(dd); + } else if (ctx->op == OP_FINAL) { + omap_sham_final_req(dd); + } + return; + } + if (!err) { dd->pdata->copy_hash(req, 1); if (test_bit(FLAGS_FINAL, &dd->flags)) @@ -1107,6 +1150,8 @@ static void omap_sham_finish_req(struct ahash_request *req, int err) pm_runtime_mark_last_busy(dd->dev); pm_runtime_put_autosuspend(dd->dev); + ctx->offset = 0; + if (req->base.complete) req->base.complete(&req->base, err); } @@ -1158,7 +1203,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd, /* request has changed - restore hash */ dd->pdata->copy_hash(req, 0); - if (ctx->op == OP_UPDATE) { + if (ctx->op == OP_UPDATE || (dd->flags & BIT(FLAGS_HUGE))) { err = omap_sham_update_req(dd); if (err != -EINPROGRESS && (ctx->flags & BIT(FLAGS_FINUP))) /* no final() after finup() */ @@ -1730,6 +1775,8 @@ static void omap_sham_done_task(unsigned long data) struct omap_sham_dev *dd = (struct omap_sham_dev *)data; int err = 0; + dev_dbg(dd->dev, "%s: flags=%lx\n", __func__, dd->flags); + if (!test_bit(FLAGS_BUSY, &dd->flags)) { omap_sham_handle_queue(dd, NULL); return; From patchwork Tue Nov 5 14:00:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178499 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709170ocf; Tue, 5 Nov 2019 06:01:30 -0800 (PST) X-Google-Smtp-Source: APXvYqy0M83QT7+a0iD2x5l2IpH+Mx4yYQ/eBWmVJnvfbSLeNTxa8LwNWpEoECS6rZ7bP6xc1zAE X-Received: by 2002:a50:cc43:: with SMTP id n3mr36442823edi.287.1572962490177; Tue, 05 Nov 2019 06:01:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962490; cv=none; d=google.com; s=arc-20160816; b=s+AyH9U4aSWFunAoTbclYTRA5KtPZI7jnXNKRK2cediMcQ8rX5rLd72PltdPkxdy1k 7OIQwrsP9MAKYK+hIAebMvFp5mscy3Jo3F7ysM4I4LwlgYMU0B62lX8OAOZCZEfW9XEL wRGA7xEVULWwl7X6hWPdM/AxyQFTCEZK3waUzKYeUJwMsbr3OQRap1Alx2xYDMJDhp8m BIzCVVoVbfsGAUo5E89KC32L3sBJ//SK0yGRjyauKbN8WqAIbNRFFIksuwzrYLuqVpXm hAInk4Q6t9UqCTop9PkVPzkXW9ZkXlPJM5SPnHhKRqIaZhRoGEHjpYKRyXLh7UckHfS/ 70Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=DlKZU2pnO04HoutMJq1MepcXwIlqftahdOsUH2+lg9Q=; b=z2Ehl9yM8ld/PpfiGCl/FV4jAAiBOMBjoWrWG5Ta1/9Q1FMR8c2GP2TA/FKGEosMtL QXZ1Q8pQ5Hpzud2NSoTqCoZTxB3rIK8/f7W57HQRlnnTO9dk/4KRQlqW/pKrYwpYQg2S +y0+hJXkZI67KJSgKV2oJWM3SKZ/lDohax3l5GzMzzohP5fqsIkf85bmucYm7jSecmlL l1JseiaklRS4zFYuES/3aZVok3n0d5L9kSQlkBOyF9lakKKAhzuJkzVshunPT740RcRw Idze5EQOfpTd4lTnzL2x9ogDlLHQbnyBgl1/NMs/930FyBFWhZaUAX/3s8/w7p0aDZJc Nfvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YSLy33ni; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.30; Tue, 05 Nov 2019 06:01:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YSLy33ni; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389325AbfKEOB3 (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:29 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44690 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389300AbfKEOB3 (ORCPT ); Tue, 5 Nov 2019 09:01:29 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1NEL043354; Tue, 5 Nov 2019 08:01:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962483; bh=DlKZU2pnO04HoutMJq1MepcXwIlqftahdOsUH2+lg9Q=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YSLy33ninCGUHbjzm8f/GKFxgqgZqrVeuWf0TKaET7HX1MfyZ88q7l2eyK2wSWwFU 73tGEiQcvHhF4+7NWn0xxrGimL0txljGSKQYdBQbgA72FTuBHqwuz0/Cxf30b/1dT5 U1JztIU7T0cCE/V0EVCsQVMy8VbsasfIz7lqsWqk= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1N5m059512 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:23 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 5 Nov 2019 08:01:23 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:08 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFg068289; Tue, 5 Nov 2019 08:01:21 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 03/22] crypto: omap-aes: remove the sysfs group during driver removal Date: Tue, 5 Nov 2019 16:00:52 +0200 Message-ID: <20191105140111.20285-4-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The driver removal should also cleanup the created sysfs group. If not, the driver fails the subsequent probe as the files exist already. Also, drop a completely unnecessary pointer assignment from the removal function at the same time. Signed-off-by: Tero Kristo --- drivers/crypto/omap-aes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index a1fc03ed01f3..38c750e83dbe 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -1296,7 +1296,8 @@ static int omap_aes_remove(struct platform_device *pdev) tasklet_kill(&dd->done_task); omap_aes_dma_cleanup(dd); pm_runtime_disable(dd->dev); - dd = NULL; + + sysfs_remove_group(&dd->dev->kobj, &omap_aes_attr_group); return 0; } From patchwork Tue Nov 5 14:00:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178501 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709261ocf; Tue, 5 Nov 2019 06:01:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxUdbvBWASKd/FfrdfYnwOqnvfSr77gptE1XqPq3OFE4KtXhBBJ8j8s3K7lTf08C0oM3fl3 X-Received: by 2002:a50:b626:: with SMTP id b35mr31766361ede.183.1572962493995; Tue, 05 Nov 2019 06:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962493; cv=none; d=google.com; s=arc-20160816; b=S6199QE4P5cw0Bui212Ig7i8RF2fSA8TCBCmiiJ/Jg1EurK1e1lInehW1frPt3dQc1 8x0TFfcLnCulVHMepPt8CXA5wHr51c1K81G1uYyfSU07I8J386FXhZZ+F+QUuul3eZsA VQzfdner4G3QRYzN08Ruyj7138X8Dx3kUS0HedaB3In0fxoRbxo4ipzoEn0rHEJn5EaC O8P8MzWa5RxcO0PPe1AyftMgommVHxpwQ4x8xH5x7RFTfB0hvs3KoA4AuaxDuVQjGIQd 1+siAZJGtQUqZsvkq2MRqVIEp1nIXOqS3pTZSfZB9Ddp8Oz+tpWEt+FkSrhzNrOUYaW6 ehng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1EkNmS89YfDgM2jgb2vd+QfDT3W+cE8tMZjNL9+5Avw=; b=CJGAEWPnXEd052tiVxqLP/wV0RyJKp+B9myBJaaWeAMJxP6f0UimS1QNqdhrlOfMeX xl8tUHbyEqHwoOz9A6xrxRX3Wn0oz2J4qSIh22uczisG8kPxVrIGe4+linunBHFlMjFJ 2HP/popfW/nSvYt6JMkRDD9cO1Own/v0zsa0zxBitGom7eMEs4BHAYS3+ZafhkJ2W/m3 pow4ER68y/4aOQTIuw+qVzFrFOzeU8NAzh4fREoAJlfmxepnCyUisquqVK/JxyqRB1/3 pH5CK0oNNPjpk1082oJfCdlVfP084W03qC6xGC9t5N2WJmVoJFqjZ88jxFVsXe3YVyPR KPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=IxpLht6V; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.33; Tue, 05 Nov 2019 06:01:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=IxpLht6V; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389332AbfKEOBd (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:33 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44710 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389290AbfKEOBd (ORCPT ); Tue, 5 Nov 2019 09:01:33 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1RNG043448; Tue, 5 Nov 2019 08:01:27 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962488; bh=1EkNmS89YfDgM2jgb2vd+QfDT3W+cE8tMZjNL9+5Avw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=IxpLht6VPuPpoO77CL9p07NTcLbRMWWlTHB6DV1AiRO9lLtYPmZ6KVChC0Dlweg1c Grw8n3qoI0+nzgOtzR3JxLLeFk3oECVMMCzHyjT8lLhggYLAuYZqTbz0euLvSXNO28 V291Q3H0eCPjdg2iFRQrh0UzjGA6ZuGZjLqSwCbc= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1RLb084461; Tue, 5 Nov 2019 08:01:27 -0600 Received: from DFLE104.ent.ti.com (10.64.6.25) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 5 Nov 2019 08:01:11 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:11 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFh068289; Tue, 5 Nov 2019 08:01:23 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 04/22] crypto: omap-des: add IV output handling Date: Tue, 5 Nov 2019 16:00:53 +0200 Message-ID: <20191105140111.20285-5-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Currently omap-des driver does not copy end result IV out at all. This is evident with the additional checks done at the crypto test manager. Fix by copying out the IV values from HW. Signed-off-by: Tero Kristo --- drivers/crypto/omap-des.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 4c4dbc2b377e..2e3ecb860e27 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -597,6 +597,7 @@ static int omap_des_crypt_req(struct crypto_engine *engine, static void omap_des_done_task(unsigned long data) { struct omap_des_dev *dd = (struct omap_des_dev *)data; + int i; pr_debug("enter done_task\n"); @@ -615,6 +616,11 @@ static void omap_des_done_task(unsigned long data) omap_crypto_cleanup(&dd->out_sgl, dd->orig_out, 0, dd->total_save, FLAGS_OUT_DATA_ST_SHIFT, dd->flags); + if ((dd->flags & FLAGS_CBC) && dd->req->iv) + for (i = 0; i < 2; i++) + ((u32 *)dd->req->iv)[i] = + omap_des_read(dd, DES_REG_IV(dd, i)); + omap_des_finish_req(dd, 0); pr_debug("exit\n"); From patchwork Tue Nov 5 14:00:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178502 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709514ocf; Tue, 5 Nov 2019 06:01:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyeR4fNTLd2oP8EO7oqOLMdPaWTDdEZa2ChknpsTzOU8eRMZaQ6xj2V27RTcGdd6lYHzTUN X-Received: by 2002:a50:c408:: with SMTP id v8mr35685147edf.140.1572962502539; Tue, 05 Nov 2019 06:01:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962502; cv=none; d=google.com; s=arc-20160816; b=pt2MWU0Rwt7u4WJnxn3AjkJEHt77gYSWGZBbNTRSi6efBP+WHa6LykUMXJyKggqUX/ O8rjJvklFFHIMRXdyC9Bhnvie2kKL8d+5TztoyjGuJzQZbfzn14uvkgUr/SdU2E26gnf v9dO3cYmo3c66uF7nX/ztBr/mY00B14j/9aE+xkkSkqfzZ9Eja8NbYgqyGQbj3QNO89J BjqwH0Wntii2v/TQ0OouwJcr2EcEAgVpj2gi0LnohG16h7VQwcmlL7lYrOPJbYJcv54S a5BRAsYjk4IAhCS4+cdfoKciTZH7iDPauoLSGBJCS+BabqblVDPPnKEimP/gFJcRyv4h cB9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=/548IYlsZzVpGFlUyLpuldMg6WhApejqtJF4qdDLFY8=; b=Kd/PmVQGUDPPvMFabbskw2eIpXbmIOA+4IcFneS+Rna/6oyLxGnuH8wr8foK+qJG7Z 5Ecvm0AcVNBAQYEqzuC24AemvEJUkc7ZO7h/Z/jz8CENPqOrLidNdRWzdTBjWzxvNmPP dd5G5Yj2owdlqIPz/jXxPjxeUsvH1KrRDdr/89csBnP1Hg2kPhooG96pza5Jc0Pr7z5F LfjZ7c6cdXsiYhsQS37tDREWyiq1D0Ee7cbeM2nMQKZqY6pGB6Yx79WW7Eyt6DU4aYCE zdpkK5nIjL7mz7lNtQpvIF/d919Xczwzi2+Os0ia1ubM+/qcuSUetWyTYVT8tjZv1muC XHuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xnNecQu0; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.42; Tue, 05 Nov 2019 06:01:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xnNecQu0; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389369AbfKEOBl (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:41 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35128 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389290AbfKEOBl (ORCPT ); Tue, 5 Nov 2019 09:01:41 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1aPm038169; Tue, 5 Nov 2019 08:01:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962496; bh=/548IYlsZzVpGFlUyLpuldMg6WhApejqtJF4qdDLFY8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xnNecQu0ByEXRygUFD4eTHRu4VpwDaHeJSu2V1Cb3iI5G1S8tJeCIyF/Y/vPy0z8/ O9nJyYgVcxnBSOW2z3+EAG0edxyoegvy7P4E6cYt/awKIT1fQxX5f/weiOV5zM5AY2 ecP3Dt4H+BFUgPDDDCC5pVuN9zKFzwkRZBCXKNXI= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1aEB087706 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:36 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 5 Nov 2019 08:01:36 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 5 Nov 2019 08:01:36 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFk068289; Tue, 5 Nov 2019 08:01:34 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 07/22] crypto: omap-aes-gcm: fix corner case with only auth data Date: Tue, 5 Nov 2019 16:00:56 +0200 Message-ID: <20191105140111.20285-8-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Fix a corner case where only authdata is generated, without any provided assocdata / cryptdata. Passing the empty scatterlists to OMAP AES core driver in this case would confuse it, failing to map DMAs. Signed-off-by: Tero Kristo --- drivers/crypto/omap-aes-gcm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index 9bbedbccfadf..dfd4d1cac421 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -148,12 +148,14 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, if (req->src == req->dst || dd->out_sg == sg_arr) flags |= OMAP_CRYPTO_FORCE_COPY; - ret = omap_crypto_align_sg(&dd->out_sg, cryptlen, - AES_BLOCK_SIZE, &dd->out_sgl, - flags, - FLAGS_OUT_DATA_ST_SHIFT, &dd->flags); - if (ret) - return ret; + if (cryptlen) { + ret = omap_crypto_align_sg(&dd->out_sg, cryptlen, + AES_BLOCK_SIZE, &dd->out_sgl, + flags, + FLAGS_OUT_DATA_ST_SHIFT, &dd->flags); + if (ret) + return ret; + } dd->in_sg_len = sg_nents_for_len(dd->in_sg, alen + clen); dd->out_sg_len = sg_nents_for_len(dd->out_sg, clen); @@ -287,8 +289,12 @@ static int omap_aes_gcm_handle_queue(struct omap_aes_dev *dd, return err; err = omap_aes_write_ctrl(dd); - if (!err) - err = omap_aes_crypt_dma_start(dd); + if (!err) { + if (dd->in_sg_len && dd->out_sg_len) + err = omap_aes_crypt_dma_start(dd); + else + omap_aes_gcm_dma_out_callback(dd); + } if (err) { omap_aes_gcm_finish_req(dd, err); From patchwork Tue Nov 5 14:00:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178507 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709772ocf; Tue, 5 Nov 2019 06:01:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxYcUA+p/nCBAGkEMZ/1DIb73JrmnGL0vVB+lZs6Jt4gSJjdnNCmEvcuNIOlGDf3xdpvepj X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr22034453ejg.315.1572962511550; Tue, 05 Nov 2019 06:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962511; cv=none; d=google.com; s=arc-20160816; b=damwOBN95LLenIi2JHvd1uiFUJpbhsSnOX7oBYhIOmyy7URF1Ti52ij53L2F9B+ROQ fKIRqvdaHBwe2Fv6ShCRvYms+2K49CWC06LfxbDkrV0oZ0lLqm21pkWvixleCL5mTooN 8gLVy19YYbqtrIv1XgPZcWInQkIYkIRyAIHvk6ZvyuS8vLz8FvSKhGv2klVPqeWQ/sKV hOpnM1vVvIlHUYg6CB93yG236jsk+OIy+iHe0rjU2nZih0TOqMHR5ii5duoqI3PlGpQe oNww2RF9QyOVQ4LTE0Aobt91XImWh58e+T6zmU+3YfR1TuE0uc4ZHOD5IZ/kxSVGU8zu 9oOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=DytK5ZfNQDTyFQ9kvyYcuDXQB7MIOphvtCQ9eA53fOk=; b=ldwW6k9DyUlze6RY0sn3rBRQySC82yrkqPPZHFEPg4wk/c3o3rt9fOS4/12Mjj8yNM dWthPsqfe4i7AC6Hqioi+6eL20yq0pJx4zAXQ9Livng5ywLym9th8S7cKSOID3NIjZeX C47tHbG5pRzE1oUYG3Plqu5dm9ihrrg0y4yVtYdo98koKtFlNhoR0t7bMdPhtymv4Ys/ q3TV6ktGnqdNWXC5w/3QTEYLrd6gYmhXQkrks3km3TOJcczhd5iRrJsDDH8Gc9Snl9Jk q+kSwz3JM/G8khUExqhEqdvxZf/EeXdeHwTxWhIzCtuh1Jp8Yn6TMUm2aYCwu1A7m3wY 42Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=yrgeKv7a; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.51; Tue, 05 Nov 2019 06:01:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=yrgeKv7a; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389414AbfKEOBr (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:47 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35154 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389377AbfKEOBr (ORCPT ); Tue, 5 Nov 2019 09:01:47 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1f5R038178; Tue, 5 Nov 2019 08:01:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962501; bh=DytK5ZfNQDTyFQ9kvyYcuDXQB7MIOphvtCQ9eA53fOk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yrgeKv7aDdjQaAbIiyW8ZERkZDAo1pKPFIrMLGV92vBUrNiYOg6LCq3Amz7+UOUfJ JNVGwegQfqS2J77wNpRalEJ2cSk7pzjyR0caFiESwx2BTAH66kry0ZUdckMM7MduGs gT/okgs4mqXvWX2t7zEV3hirByAdVHbvtm5tEHa0= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1fpn008046 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:41 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 5 Nov 2019 08:01:24 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:24 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFm068289; Tue, 5 Nov 2019 08:01:38 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 09/22] crypto: add timeout to crypto_wait_req Date: Tue, 5 Nov 2019 16:00:58 +0200 Message-ID: <20191105140111.20285-10-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Currently crypto_wait_req waits indefinitely for an async crypto request to complete. This is bad as it can cause for example the crypto test manager to hang without any notification as to why it has happened. Instead of waiting indefinitely, add a 1 second timeout to the call, and provide a warning print if a timeout happens. Signed-off-by: Tero Kristo --- include/linux/crypto.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 19ea3a371d7b..41279eeecb21 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -682,8 +682,15 @@ static inline int crypto_wait_req(int err, struct crypto_wait *wait) switch (err) { case -EINPROGRESS: case -EBUSY: - wait_for_completion(&wait->completion); + err = wait_for_completion_timeout(&wait->completion, + msecs_to_jiffies(1000)); reinit_completion(&wait->completion); + if (!err) { + pr_err("%s: timeout for %p\n", __func__, wait); + err = -ETIMEDOUT; + break; + } + err = wait->err; break; }; From patchwork Tue Nov 5 14:00:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178506 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709756ocf; Tue, 5 Nov 2019 06:01:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyPbh5aO3cpg/dWMm7gtQssUhJ1do/hjr0drlZit0ytOQSIsniAql6VfWm3ntB5O+Dkg1WA X-Received: by 2002:ac2:46c9:: with SMTP id p9mr19226502lfo.166.1572962510817; Tue, 05 Nov 2019 06:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962510; cv=none; d=google.com; s=arc-20160816; b=QdWb6KvZYujOOjDsIG+ahtbH1JaghsH35WBq6eIfNecy2qByP0F6iot2cp/ETE5wt5 M+Ihe5DJfaK+alp/DL86SwB87Bo6S2XsBQ3JD1bZWw/AHh+K7zr5CCl0ELW+ffotLJOb f796WBJPhA7gNboHIuqcvhdEBNtBysbOueqtk+GOHbQHo35pqn/mhNjPYWpmfsS1JYox 79RzJtiXhg+YcwBwcGDJ8mbVAN7jjhiXmTH76FkH6swWJmwLZCqH9tZNzokcubiqHnou 4aWyzDkm1u+GFir7+CTVMldxGjcmAARM6COIKbSQjfCFAsb9YDM2DrDH0ANbcYKkI8BJ eMDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8Qb0rbFmtCeLFsP63eWPse1DK88m1awgJzuGanBPJcY=; b=QjF/9TBz21aUkkCjKYIcePPCDKUN8IfFDqajGytnOoaSep28t9PBOCqSIesR8G1U9O P/ghenWl+fD4kYpoR281Hv7jEEZVKtunJ7zgc8vvRZ7uMn6TdOpFn0uWTv/N9gfk0mrU JM/oeCQy70OpjeorladfkF+sJB9HiKF8ZEaBp1V/rA2P8iaa421QK55W7TyKpEocIBnw ENI1X7MiTI3KsdLxJjHhR6/qoZbuo0xLgVJoCFuWwBeSsa6qceOuDTnA6+EdrJKiy2QD LAB3SiYki/ifQeTLWhqwyT1zkcXwQs5AHAGORBKjOGWLjX3x2I62PD1k+neys/PJGlWD dULw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=RAuv6iax; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.50; Tue, 05 Nov 2019 06:01:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=RAuv6iax; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389413AbfKEOBq (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:46 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:43976 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389377AbfKEOBq (ORCPT ); Tue, 5 Nov 2019 09:01:46 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1fvU071574; Tue, 5 Nov 2019 08:01:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962501; bh=8Qb0rbFmtCeLFsP63eWPse1DK88m1awgJzuGanBPJcY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RAuv6iaxRCpWAWs0mwbfhmUmlh7KyyKi+PPtwwaBU1xpKi2iTFUDHMKQHLlUfB+aR CCArs4q6OToe/zgSWaN7l+6nhM/PxaJ09ikL17pE6OIVaiFl5amdr/l81a8ojr2jQ3 9GyGLyhyLu+2MMVHXyUEKG+fl+C9/fUHBa8oYBOA= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1fBZ087778 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:41 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 5 Nov 2019 08:01:41 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:26 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFn068289; Tue, 5 Nov 2019 08:01:39 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 10/22] crypto: omap-aes: fixup aligned data cleanup Date: Tue, 5 Nov 2019 16:00:59 +0200 Message-ID: <20191105140111.20285-11-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Aligned data cleanup is using wrong pointers in the cleanup calls. Most of the time these are right, but can cause mysterious problems in some cases. Fix to use the same pointers that were used with the align call. Signed-off-by: Tero Kristo --- drivers/crypto/omap-aes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index e3f2ed0184f8..de05b35283bf 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -502,10 +502,10 @@ static void omap_aes_done_task(unsigned long data) omap_aes_crypt_dma_stop(dd); } - omap_crypto_cleanup(dd->in_sgl, NULL, 0, dd->total_save, + omap_crypto_cleanup(dd->in_sg, NULL, 0, dd->total_save, FLAGS_IN_DATA_ST_SHIFT, dd->flags); - omap_crypto_cleanup(&dd->out_sgl, dd->orig_out, 0, dd->total_save, + omap_crypto_cleanup(dd->out_sg, dd->orig_out, 0, dd->total_save, FLAGS_OUT_DATA_ST_SHIFT, dd->flags); /* Update IV output */ From patchwork Tue Nov 5 14:01:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178510 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709843ocf; Tue, 5 Nov 2019 06:01:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyBfn8dIdACQ6rieTFFcQqpMjm6gmI2nOGXzLB4rWBGw5cMCQEYiSwnCmDpmb09wy3YD+7L X-Received: by 2002:a17:906:945:: with SMTP id j5mr22882093ejd.211.1572962514869; Tue, 05 Nov 2019 06:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962514; cv=none; d=google.com; s=arc-20160816; b=0xtoDdRWQIt35pHMtp6D7HsPtvrHKOXSA3/zOs7Sy1AAejh3kQUXVh3IdrFWn4dZu/ RpYLS5Iwb12uz+QywxDShbG1ONj/m10AMBjov6JWxT1UkjEthIY6dhcRNWkuTYo0cth+ Sgd3h1Ri3t1lW31duLDHM97Wk3xDCncHyFppvJwEsD+K7DFqagxrwa96S3wRGhPh8EfD Wto4zfcmqhsFYY8eTFkUJ4//6fDtO9IssN2O//6592DGe21AiliPBw+iOpB720WQpj2p DxTGKLh9bp+1gaopZVX5mh+KrK+pDhxNXrPeY9GdC0FDDD+umyh6SqpCslqLZQusCoO+ Assw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vdMLW9KPI1Tz8cqZnds9ghnwG28mTN9081e17+WfrQk=; b=KmJ/qUhkq0OqVdaUV2rZ1vBSErzSKUTDcF0Lmvi5l11NHAZpbgtnYjpx7HvENpNfKT DekkgksCQlj+Ot+8gLFVL5zQEFpdhHzDlS766tjhwz1G+TBzvPa4EqGw2xnd0a8mwgf6 jNWjgbe2Yfgndyy8425tQ2AFXfM9qu1L5erW2ESxjubBd0+1UhZoR02kq2rAswYBtlYe LJY0h6UZ6Va4hH8yCRUIBFfJrIl8+sS215RBQEzoCewjmJUJQX5Z065ogihl6nYplp8r UwoH4CQYsTLmWXhAiGc7KaRDF8MazdHD8EgW5gO2huAnrNAsuy7Z2oK1/jIkDB6FGXvN MI9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=U8xXW9V5; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.01.54; Tue, 05 Nov 2019 06:01:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=U8xXW9V5; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389377AbfKEOBy (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:54 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35180 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389421AbfKEOBx (ORCPT ); Tue, 5 Nov 2019 09:01:53 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1laI038217; Tue, 5 Nov 2019 08:01:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962507; bh=vdMLW9KPI1Tz8cqZnds9ghnwG28mTN9081e17+WfrQk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=U8xXW9V5C7jq0ddpEG5JMslTxWiNePP6bI+sWud6CR8mSm67PZ2pBqyQ/4MA9pO+7 bhwqVaVTR+My3eJSq9AA4/3FdUPuSPOrquBkTZ4OEEuvas9h02zfs7ehtHVDVVucuC 0GU8EoRIASe1jXyi3cm7xEAdkqvw6wZ2jmA6Hy0c= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1lRo087823 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:47 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 5 Nov 2019 08:01:32 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 5 Nov 2019 08:01:32 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFq068289; Tue, 5 Nov 2019 08:01:45 -0600 From: Tero Kristo To: , , CC: , , Ard Biesheuvel Subject: [PATCHv2 13/22] crypto: omap-aes-gcm - deal with memory allocation failure Date: Tue, 5 Nov 2019 16:01:02 +0200 Message-ID: <20191105140111.20285-14-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Ard Biesheuvel The OMAP gcm(aes) driver invokes omap_crypto_align_sg() without dealing with the errors it may return, resulting in a crash if the routine fails in a __get_free_pages(GFP_ATOMIC) call. So bail and return the error rather than limping on if one occurs. Signed-off-by: Ard Biesheuvel Reviewed-by: Tero Kristo Tested-by: Tero Kristo --- drivers/crypto/omap-aes-gcm.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index dfd4d1cac421..05d2fe78b105 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -120,6 +120,8 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, OMAP_CRYPTO_FORCE_SINGLE_ENTRY, FLAGS_ASSOC_DATA_ST_SHIFT, &dd->flags); + if (ret) + return ret; } if (cryptlen) { @@ -132,6 +134,8 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, OMAP_CRYPTO_FORCE_SINGLE_ENTRY, FLAGS_IN_DATA_ST_SHIFT, &dd->flags); + if (ret) + return ret; } dd->in_sg = dd->in_sgl; From patchwork Tue Nov 5 14:01:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178512 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp710024ocf; Tue, 5 Nov 2019 06:02:00 -0800 (PST) X-Google-Smtp-Source: APXvYqwqPgCnU3AsQcHPh+YmdheKqLC5A15VHK1pNJbHmNL4D5ARwJpPGgWDD8qbxAILMzbJnLeZ X-Received: by 2002:a17:906:b74c:: with SMTP id fx12mr21299443ejb.324.1572962520414; Tue, 05 Nov 2019 06:02:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962520; cv=none; d=google.com; s=arc-20160816; b=Yn7SVnGYLfuUzp14Y2Ghwse3szrCC9DPo6MKe8aXK1iyvk/FFfeuZOkxCwSS6pCGBE esNvUajFTnUeT28fWxiKBHYP21DJt9ACtwuVMyjL3F0qL5S+PKZEHCoheBKcnzq1pTwe w4VLgEHWT48whfu9xFlHEObpjtPy6lpZJE5fKe0jK5qg2wr+iyxX/D8MoYfstnRqIkjc UXvpEXQRnoQIouU3Qdx95nhyuceELmRkFDuDJaSG9LdybCBXQxbxnVKE0Ghiz091WsFv nf3KNStTGDWDqk5F4dSu4khArImGnAV6tDYFgAflCRTcGXMVGwnGTn77MHbkghIl7bJ1 jVwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Fy9RhC6tUOYLCrTUDsYzuh5bXy3NK5kpC2mGjoRFUPE=; b=RJsKWfMdK3PfTAvObNGtsCLQltMoiQndMXLBqjUpSI8hDsXZppBt3y5+WavCvqy824 8qGo3j4XmPhJ5VPEJ/yhvTUqTAdLVpkp9adX+BYIIWQSSlNxhncEJn+69xxnm3WwxWNK 46RzMdhks+2hoqnSiC519JkZ7jeKWQFXuULkft/dpyw3Kr4aAGUHOQKDFmpYloz9JKQq zmqeB1BI25UNWQp6sCoT0K8V+lkXIwj8G2Nwjqprd4Il6Al3S9XikJR2+2Qs4Z2ZzzF1 bsergBUqs6vqUQug9NTshx6AevJVHRXTt33h2MPmkLt1XesMPDYUg9uWI5w5NXCfD/SU a3pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UNqbLGfv; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.02.00; Tue, 05 Nov 2019 06:02:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=UNqbLGfv; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389430AbfKEOB7 (ORCPT + 5 others); Tue, 5 Nov 2019 09:01:59 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35218 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389429AbfKEOB7 (ORCPT ); Tue, 5 Nov 2019 09:01:59 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1p61038233; Tue, 5 Nov 2019 08:01:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962511; bh=Fy9RhC6tUOYLCrTUDsYzuh5bXy3NK5kpC2mGjoRFUPE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UNqbLGfv9bGDddhm5a4GJv8q80u7GytwMr0iExRzM9KlBZo0iiVQFiHtRDHCrP4uH Vv72P50cbKn6kgxj87MkEy3X3w19lQZRwSPW7uCJj5mpAsscKPtw+FlduXvhreXL82 mV1z4IAELVUNcguLboAslizdSvf/jZR594yyDY3k= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1pol059894 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:51 -0600 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 5 Nov 2019 08:01:34 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:34 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFr068289; Tue, 5 Nov 2019 08:01:47 -0600 From: Tero Kristo To: , , CC: , , Ard Biesheuvel Subject: [PATCHv2 14/22] crypto: omap-aes-gcm - add missing .setauthsize hooks Date: Tue, 5 Nov 2019 16:01:03 +0200 Message-ID: <20191105140111.20285-15-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Ard Biesheuvel GCM only permits certain tag lengths, so populate the .setauthsize hooks which ensure that only permitted sizes are accepted by the implementation. Signed-off-by: Ard Biesheuvel Reviewed-by: Tero Kristo Tested-by: Tero Kristo --- drivers/crypto/omap-aes-gcm.c | 11 +++++++++++ drivers/crypto/omap-aes.c | 2 ++ drivers/crypto/omap-aes.h | 3 +++ 3 files changed, 16 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index 05d2fe78b105..70398fbd669d 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -413,3 +413,14 @@ int omap_aes_4106gcm_setkey(struct crypto_aead *tfm, const u8 *key, return 0; } + +int omap_aes_gcm_setauthsize(struct crypto_aead *tfm, unsigned int authsize) +{ + return crypto_gcm_check_authsize(authsize); +} + +int omap_aes_4106gcm_setauthsize(struct crypto_aead *parent, + unsigned int authsize) +{ + return crypto_rfc4106_check_authsize(authsize); +} diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index 33cba7a2d6df..161af3bf667c 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -787,6 +787,7 @@ static struct aead_alg algs_aead_gcm[] = { .ivsize = GCM_AES_IV_SIZE, .maxauthsize = AES_BLOCK_SIZE, .setkey = omap_aes_gcm_setkey, + .setauthsize = omap_aes_gcm_setauthsize, .encrypt = omap_aes_gcm_encrypt, .decrypt = omap_aes_gcm_decrypt, }, @@ -807,6 +808,7 @@ static struct aead_alg algs_aead_gcm[] = { .maxauthsize = AES_BLOCK_SIZE, .ivsize = GCM_RFC4106_IV_SIZE, .setkey = omap_aes_4106gcm_setkey, + .setauthsize = omap_aes_4106gcm_setauthsize, .encrypt = omap_aes_4106gcm_encrypt, .decrypt = omap_aes_4106gcm_decrypt, }, diff --git a/drivers/crypto/omap-aes.h b/drivers/crypto/omap-aes.h index 2d3575231e31..1bcca7957e92 100644 --- a/drivers/crypto/omap-aes.h +++ b/drivers/crypto/omap-aes.h @@ -202,8 +202,11 @@ int omap_aes_4106gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen); int omap_aes_gcm_encrypt(struct aead_request *req); int omap_aes_gcm_decrypt(struct aead_request *req); +int omap_aes_gcm_setauthsize(struct crypto_aead *tfm, unsigned int authsize); int omap_aes_4106gcm_encrypt(struct aead_request *req); int omap_aes_4106gcm_decrypt(struct aead_request *req); +int omap_aes_4106gcm_setauthsize(struct crypto_aead *parent, + unsigned int authsize); int omap_aes_write_ctrl(struct omap_aes_dev *dd); int omap_aes_crypt_dma_start(struct omap_aes_dev *dd); int omap_aes_crypt_dma_stop(struct omap_aes_dev *dd); From patchwork Tue Nov 5 14:01:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178514 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp710139ocf; Tue, 5 Nov 2019 06:02:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzh2Tuu94Si9v8KJCWM9AYHLX25jlbQkk6fqarHKeP2lJbFJIH+E1X8kUpbzqUDOXg7gqqd X-Received: by 2002:aa7:d552:: with SMTP id u18mr36227251edr.86.1572962524032; Tue, 05 Nov 2019 06:02:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962524; cv=none; d=google.com; s=arc-20160816; b=RhXKtX75zIiKd+MXdsT+iHGfSxH0A21ZPC2TZ1xW6qEXf21ik6kAB29IInJhp3JMJE IwNeXU0fR8g03C0Qx0tg8XCQetL8b4tH+IlvNb93sStMw1rKXJePS8rnKcZRmdujRF5j BMiXTxQmeJwU8vzzJTAuvB0ttGcycDFzrU4Yy5M/zScAvYwnJ0EIyivlq/mEQ+WdiunV j0YIz0p9jB/1Z7pcYr+uksifAsqrXR4/bQpS+yr3ZekCnjjDwYNiPz2pnGeLaOc9EMXB MYPTVnXhWZqEmmFolj4rHuXD6xTHzkhhL1U7JI5qU4N6VxnnajXM1T18cWp0sn2OtRac diAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+AmfYZzlDSB4ydg8jhXUTAd0sR8HN8hG6r1nfOurSMs=; b=vQzc0gvvk59uiLDKISFZ679FKZbKgk29r+6U09MWbWI3Kz96ZHYIm0npUdz1dzJZkg ZHBgRzMLpjoeoERpm0vC+Uh5rWWPuBU5O/GwBGDaMd4xPr3SI2YWIph3zH+Nvu1jIfKd LguK6e3Cjc15eaKuUuEVfThZ+dms751/Bppwsa3EAehrA/btX8SiMdktc7g3jAibpRPe yJ5ofm++PQWEd6hg/GJvY85K4nBvxmH7jmUi/QDhMDmVUgri2R6w7xgFV8ECrkPe5XsA 8oU5gwl7nKp28oTUk0cF54hFsbUQw80Gr/9LxMWoF9zBIpHA6c4rOB/mCsE2i3JwXm5G GrMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=baEzSgE3; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.02.03; Tue, 05 Nov 2019 06:02:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=baEzSgE3; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389440AbfKEOCC (ORCPT + 5 others); Tue, 5 Nov 2019 09:02:02 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:44058 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389435AbfKEOCB (ORCPT ); Tue, 5 Nov 2019 09:02:01 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1udg071641; Tue, 5 Nov 2019 08:01:56 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962516; bh=+AmfYZzlDSB4ydg8jhXUTAd0sR8HN8hG6r1nfOurSMs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=baEzSgE3Vrmx+S/C4RCByCuJrZQaV95bwVHtG+mKvFtcEojqODy+jRpJAV8QoqYLX qqhBAnpCukV5SPEDlfXGkSLl5OmvjrBNfB/NqJ0D/yorwehSyY12SfBk8YJ0QSxACh 9ACHThxk07LixVF753otT46YsiozAa8TKDuk7LX0= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1ujX059973 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:56 -0600 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 5 Nov 2019 08:01:41 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:41 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFv068289; Tue, 5 Nov 2019 08:01:55 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 18/22] crypto: omap-sham: fix unaligned sg list handling Date: Tue, 5 Nov 2019 16:01:07 +0200 Message-ID: <20191105140111.20285-19-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Currently the offset for unaligned sg lists is not handled properly leading into wrong results with certain testmgr self tests. Fix the handling to account for proper offset within the current sg list. Signed-off-by: Tero Kristo --- drivers/crypto/omap-sham.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index 33a58ebf652c..4f915a4ef5b0 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -673,10 +673,10 @@ static int omap_sham_copy_sg_lists(struct omap_sham_reqctx *ctx, while (sg && new_len) { int len = sg->length - offset; - if (offset) { + if (len <= 0) { offset -= sg->length; - if (offset < 0) - offset = 0; + sg = sg_next(sg); + continue; } if (new_len < len) @@ -684,7 +684,9 @@ static int omap_sham_copy_sg_lists(struct omap_sham_reqctx *ctx, if (len > 0) { new_len -= len; - sg_set_page(tmp, sg_page(sg), len, sg->offset); + sg_set_page(tmp, sg_page(sg), len, sg->offset + offset); + offset = 0; + ctx->offset = 0; ctx->sg_len++; if (new_len <= 0) break; @@ -834,7 +836,14 @@ static int omap_sham_align_sgs(struct scatterlist *sg, rctx->total = new_len; rctx->offset += new_len; rctx->sg_len = n; - rctx->sg = sg; + if (rctx->bufcnt) { + sg_init_table(rctx->sgl, 2); + sg_set_buf(rctx->sgl, rctx->dd->xmit_buf, rctx->bufcnt); + sg_chain(rctx->sgl, 2, sg); + rctx->sg = rctx->sgl; + } else { + rctx->sg = sg; + } return 0; } From patchwork Tue Nov 5 14:01:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178515 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp710171ocf; Tue, 5 Nov 2019 06:02:05 -0800 (PST) X-Google-Smtp-Source: APXvYqxCmXbEqvoe+mG1TobM3lCJOlOKcKgmJRIfnjmx5k2Db1OvZnVIeKewtP14Rm2BxU5NuR1O X-Received: by 2002:ac2:5328:: with SMTP id f8mr20961494lfh.128.1572962525401; Tue, 05 Nov 2019 06:02:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962525; cv=none; d=google.com; s=arc-20160816; b=gtWtcEU5TC7+3A5L6M0TbcrLpCttQPYQchvCxtY1RsmB6Gz48fzODyI+Xd8BMRl8Hp 8dKncNBELDXdqIvn5kfheA/2vpt9s09U4o+vz5BirtC3Ju41Ia6ABt4aJdzX6+HT0AlE ++lNd2Rskt04qyQz9yWQfJ9EZcPDCQW8eU5DcgYi8HTGpuhiZ0Zy+jiWDW0Rg+trfXA8 ZKSG8ppmHcoCrwt1skLG6j8oETsZHeXrRsaaPv5BloPHYl8FqhTdPiA/9JmNabzON2UP Tv/+rPqEBlc+NKn5DFiWfhxbNHxWwmaA2aanIvKxqYu1J49k7E9s0/+JEs1Nawr7rbZ0 vZYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=t3VIb0F0Yu7RigcFIoRIYL9QulN0D+VeUxrnCGq/nrE=; b=De+9/hJ3ZORxBKNZDRPU4OdHwxrw6F9PebuSSK1Jb81d/Lz+LRlaG9FgqfmbPQJPp5 fGzErriysKebRr+7EB/ScXS0oWYmSY8+NAKgzt/MdgSiTQtPe00vWqDLA6TWA7bIbWJ9 5KdQszVwPhd4RjULoK97k8CfN1NS6iWLgiedZ0Reh/TJHxz7TY2yG5lS96UvNaU1l3ms 3u7/wAi3mjfGsSHhkcJ/SyFvB2aW5f/h4maupZeVUq9MhrPFXUnBHwNXuMw+mTvDzZtP ww42Fv6ysSZIlZkKoWiNjAIZoW5bjwTGmzMav9j4w9R/jER36hXeSic8A5TZDp2syaza oAEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bHCWgrJb; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.02.04; Tue, 05 Nov 2019 06:02:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bHCWgrJb; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389445AbfKEOCE (ORCPT + 5 others); Tue, 5 Nov 2019 09:02:04 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35242 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389435AbfKEOCE (ORCPT ); Tue, 5 Nov 2019 09:02:04 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1wBq038266; Tue, 5 Nov 2019 08:01:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962518; bh=t3VIb0F0Yu7RigcFIoRIYL9QulN0D+VeUxrnCGq/nrE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=bHCWgrJb0xcc5yjLReD/v3pNsJFMYg+JkPEGv7k4a45sn3i4hmq4qaRKUVUKncMN8 pKLlS8tVVHUTOC56PwS40ihG2qMvaVbqIKI61h/nNYTWMiS0krzJaFkkDcdzhA9Qjb VFJWLz/W8I0PDVcbg2+vlSWyEGK6Cqk9QNsj2LV8= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1w36008332 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:58 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 5 Nov 2019 08:01:43 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 5 Nov 2019 08:01:43 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFw068289; Tue, 5 Nov 2019 08:01:56 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 19/22] crypto: omap-aes-gcm: convert to use crypto engine Date: Tue, 5 Nov 2019 16:01:08 +0200 Message-ID: <20191105140111.20285-20-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Currently omap-aes-gcm algorithms are using local implementation for crypto request queuing logic. Instead, implement this via usage of crypto engine which is used already for rest of the omap aes algorithms. This avoids some random conflicts / crashes also which can happen if both aes and aes-gcm are attempted to be used simultaneously. Signed-off-by: Tero Kristo --- drivers/crypto/omap-aes-gcm.c | 98 +++++++++++++++++++---------------- drivers/crypto/omap-aes.c | 23 -------- drivers/crypto/omap-aes.h | 2 +- 3 files changed, 55 insertions(+), 68 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index e92000846f16..32dc00dc570b 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -29,11 +30,13 @@ static void omap_aes_gcm_finish_req(struct omap_aes_dev *dd, int ret) { struct aead_request *req = dd->aead_req; - dd->flags &= ~FLAGS_BUSY; dd->in_sg = NULL; dd->out_sg = NULL; - req->base.complete(&req->base, ret); + crypto_finalize_aead_request(dd->engine, req, ret); + + pm_runtime_mark_last_busy(dd->dev); + pm_runtime_put_autosuspend(dd->dev); } static void omap_aes_gcm_done_task(struct omap_aes_dev *dd) @@ -81,7 +84,6 @@ static void omap_aes_gcm_done_task(struct omap_aes_dev *dd) } omap_aes_gcm_finish_req(dd, ret); - omap_aes_gcm_handle_queue(dd, NULL); } static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, @@ -127,6 +129,9 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, if (cryptlen) { tmp = scatterwalk_ffwd(sg_arr, req->src, req->assoclen); + if (nsg) + sg_unmark_end(dd->in_sgl); + ret = omap_crypto_align_sg(&tmp, cryptlen, AES_BLOCK_SIZE, &dd->in_sgl[nsg], OMAP_CRYPTO_COPY_DATA | @@ -146,7 +151,7 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, dd->out_sg = req->dst; dd->orig_out = req->dst; - dd->out_sg = scatterwalk_ffwd(sg_arr, req->dst, assoclen); + dd->out_sg = scatterwalk_ffwd(sg_arr, req->dst, req->assoclen); flags = 0; if (req->src == req->dst || dd->out_sg == sg_arr) @@ -202,37 +207,21 @@ void omap_aes_gcm_dma_out_callback(void *data) static int omap_aes_gcm_handle_queue(struct omap_aes_dev *dd, struct aead_request *req) { - struct omap_aes_gcm_ctx *ctx; - struct aead_request *backlog; - struct omap_aes_reqctx *rctx; - unsigned long flags; - int err, ret = 0; - - spin_lock_irqsave(&dd->lock, flags); - if (req) - ret = aead_enqueue_request(&dd->aead_queue, req); - if (dd->flags & FLAGS_BUSY) { - spin_unlock_irqrestore(&dd->lock, flags); - return ret; - } - - backlog = aead_get_backlog(&dd->aead_queue); - req = aead_dequeue_request(&dd->aead_queue); if (req) - dd->flags |= FLAGS_BUSY; - spin_unlock_irqrestore(&dd->lock, flags); - - if (!req) - return ret; + return crypto_transfer_aead_request_to_engine(dd->engine, req); - if (backlog) - backlog->base.complete(&backlog->base, -EINPROGRESS); + return 0; +} - ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); - rctx = aead_request_ctx(req); +static int omap_aes_gcm_prepare_req(struct crypto_engine *engine, void *areq) +{ + struct aead_request *req = container_of(areq, struct aead_request, + base); + struct omap_aes_reqctx *rctx = aead_request_ctx(req); + struct omap_aes_dev *dd = rctx->dd; + struct omap_aes_gcm_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); + int err; - dd->ctx = &ctx->octx; - rctx->dd = dd; dd->aead_req = req; rctx->mode &= FLAGS_MODE_MASK; @@ -242,20 +231,9 @@ static int omap_aes_gcm_handle_queue(struct omap_aes_dev *dd, if (err) return err; - err = omap_aes_write_ctrl(dd); - if (!err) { - if (dd->in_sg_len) - err = omap_aes_crypt_dma_start(dd); - else - omap_aes_gcm_dma_out_callback(dd); - } - - if (err) { - omap_aes_gcm_finish_req(dd, err); - omap_aes_gcm_handle_queue(dd, NULL); - } + dd->ctx = &ctx->octx; - return ret; + return omap_aes_write_ctrl(dd); } static int omap_aes_gcm_crypt(struct aead_request *req, unsigned long mode) @@ -378,3 +356,35 @@ int omap_aes_4106gcm_setauthsize(struct crypto_aead *parent, { return crypto_rfc4106_check_authsize(authsize); } + +static int omap_aes_gcm_crypt_req(struct crypto_engine *engine, void *areq) +{ + struct aead_request *req = container_of(areq, struct aead_request, + base); + struct omap_aes_reqctx *rctx = aead_request_ctx(req); + struct omap_aes_dev *dd = rctx->dd; + int ret = 0; + + if (!dd) + return -ENODEV; + + if (dd->in_sg_len) + ret = omap_aes_crypt_dma_start(dd); + else + omap_aes_gcm_dma_out_callback(dd); + + return ret; +} + +int omap_aes_gcm_cra_init(struct crypto_aead *tfm) +{ + struct omap_aes_ctx *ctx = crypto_aead_ctx(tfm); + + ctx->enginectx.op.prepare_request = omap_aes_gcm_prepare_req; + ctx->enginectx.op.unprepare_request = NULL; + ctx->enginectx.op.do_one_request = omap_aes_gcm_crypt_req; + + crypto_aead_set_reqsize(tfm, sizeof(struct omap_aes_reqctx)); + + return 0; +} diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index 758c93908fa5..824ddf2a66ff 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -657,29 +657,6 @@ static int omap_aes_init_tfm(struct crypto_skcipher *tfm) return 0; } -static int omap_aes_gcm_cra_init(struct crypto_aead *tfm) -{ - struct omap_aes_dev *dd = NULL; - int err; - - /* Find AES device, currently picks the first device */ - spin_lock_bh(&list_lock); - list_for_each_entry(dd, &dev_list, list) { - break; - } - spin_unlock_bh(&list_lock); - - err = pm_runtime_get_sync(dd->dev); - if (err < 0) { - dev_err(dd->dev, "%s: failed to get_sync(%d)\n", - __func__, err); - return err; - } - - tfm->reqsize = sizeof(struct omap_aes_reqctx); - return 0; -} - static void omap_aes_exit_tfm(struct crypto_skcipher *tfm) { struct omap_aes_ctx *ctx = crypto_skcipher_ctx(tfm); diff --git a/drivers/crypto/omap-aes.h b/drivers/crypto/omap-aes.h index b89d2e673699..2d111bf906e1 100644 --- a/drivers/crypto/omap-aes.h +++ b/drivers/crypto/omap-aes.h @@ -80,7 +80,6 @@ #define FLAGS_INIT BIT(5) #define FLAGS_FAST BIT(6) -#define FLAGS_BUSY BIT(7) #define FLAGS_IN_DATA_ST_SHIFT 8 #define FLAGS_OUT_DATA_ST_SHIFT 10 @@ -212,6 +211,7 @@ int omap_aes_4106gcm_encrypt(struct aead_request *req); int omap_aes_4106gcm_decrypt(struct aead_request *req); int omap_aes_4106gcm_setauthsize(struct crypto_aead *parent, unsigned int authsize); +int omap_aes_gcm_cra_init(struct crypto_aead *tfm); int omap_aes_write_ctrl(struct omap_aes_dev *dd); int omap_aes_crypt_dma_start(struct omap_aes_dev *dd); int omap_aes_crypt_dma_stop(struct omap_aes_dev *dd); From patchwork Tue Nov 5 14:01:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178516 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp710228ocf; Tue, 5 Nov 2019 06:02:07 -0800 (PST) X-Google-Smtp-Source: APXvYqzgKkW7CfGwvHxJvW3iV3Rga0FbeyAa3B9fNggxZG6KkNplp2m3BEFf0ma3Sc/AwncVh9H/ X-Received: by 2002:aa7:d908:: with SMTP id a8mr17335107edr.173.1572962526913; Tue, 05 Nov 2019 06:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962526; cv=none; d=google.com; s=arc-20160816; b=pN1ABDmA5+WZJzDwYDKj1NS52gSqSTP4ZwUKvXgHvfePjORjzbvVPG8BAlTA57GVMp PMqKiSgx0AFKDgJ8Hc26EFh68FYpKtsSMUdDGn1oLNAkEhRDY9hPbqwQqVSi2Ho0puNN eX4W6KxDqX7s0h4HsR7OxrFfVX0LBoL0hXiolMCCflVCz+GIawyRyFPVnx14llVP0fv3 UuiThiF6X9Zi3Id2x7NlbH5zWzCRPD/a+GwCCzKbldqDHn23jGHyY6BZ8fgQspKTZPHT YzJgItSU2olU4j573By9r4B8bgJOVqBs4ZypdwpWiCbFko9VBHGiDAoqJ/vPiM1teivd Gvdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=iACfiWeWKd/Z5WO9/BaeMkYTLRwpjoLt0A1bTfApxq4=; b=pIVDxLXkp8/56jI2dkWhvYqS+wrR/+VdPYc3yYNg3zI0zHhX5orX1lRVCyMyGywmpi PLqsgxZkQnkmVmbsxChPGQ54cD9Tvk49btYn99H3nDVHGOfaqIvBxyYc15p7s9uoM977 3qyYJJ+fAiU3SKSSM2VikMyWp8OBN25GbqtgYGLvF62S9Zo9fznDG+BgbSm4OoV92ldk qFx3MYC5XUXKv0I4DMKqwSCRz5r+5p6/0Xi5eSrzraBWvKtlks1qFfklCUM/Hg0QED0e R4PA3xNPZBGKf8OOW4jUJA35sKREznz3PZZRQ7NjxpXvxuUM2TSnzmUtihGKwoVUyBmN cQPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Br18sfkx; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.02.06; Tue, 05 Nov 2019 06:02:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Br18sfkx; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389446AbfKEOCF (ORCPT + 5 others); Tue, 5 Nov 2019 09:02:05 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:45336 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389441AbfKEOCE (ORCPT ); Tue, 5 Nov 2019 09:02:04 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E20lW101234; Tue, 5 Nov 2019 08:02:00 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962520; bh=iACfiWeWKd/Z5WO9/BaeMkYTLRwpjoLt0A1bTfApxq4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Br18sfkx4J8seB05ET0j/EfpwxVInHNRCznznjYj2zC954v+5wp4jQmS+uMw5QJjc fpThW/z4CV13vPk4LlaPQjx/lPgS6MlX9vcYg8DIr8vG5p/VhFC/vdNcD65Fm+inH6 8x4GCc6lxd7uUcaP6AF5MaQzfz8KzVKbtBaUOe7E= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E20AM008358 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:02:00 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 5 Nov 2019 08:01:45 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:45 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FFx068289; Tue, 5 Nov 2019 08:01:58 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 20/22] crypto: omap-des: avoid unnecessary spam with bad cryptlen Date: Tue, 5 Nov 2019 16:01:09 +0200 Message-ID: <20191105140111.20285-21-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Remove the error print in this case, and just return the error. Signed-off-by: Tero Kristo --- drivers/crypto/omap-des.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 2e3ecb860e27..31fc9300b990 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -637,10 +637,8 @@ static int omap_des_crypt(struct skcipher_request *req, unsigned long mode) !!(mode & FLAGS_ENCRYPT), !!(mode & FLAGS_CBC)); - if (!IS_ALIGNED(req->cryptlen, DES_BLOCK_SIZE)) { - pr_err("request size is not exact amount of DES blocks\n"); + if (!IS_ALIGNED(req->cryptlen, DES_BLOCK_SIZE)) return -EINVAL; - } dd = omap_des_find_dev(ctx); if (!dd) From patchwork Tue Nov 5 14:01:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178517 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp710259ocf; Tue, 5 Nov 2019 06:02:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxAMK4V+3xgb94PPEZH7oNSY28sBauYZv6j+amIi7tlhfL2zOgCfw7Tt2lMLs45FF3Vug3b X-Received: by 2002:a50:9353:: with SMTP id n19mr36004622eda.258.1572962528550; Tue, 05 Nov 2019 06:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962528; cv=none; d=google.com; s=arc-20160816; b=h5ZhfSKSJLlJJNba+WS4RdRqrSTLCO4dLnOAl4/d9Jm0ATYXfE9+lVIO2gr4S/h7IW pUfsryaNmgHx5bGZRG5eT35mwZUij/NH1yH2iJv2AEActttnclyFeVsbU3gFVL4/0ZZZ LvHOGEHD3TzkBt9ws94y7Pc0QInopKXwMLAHshCBx5DxdQsuvoKFEe05gG2rAKV8KAZv sIcHEH+hgZ6GcZue6Ts9F2ZMpAcpJhCGVNwDuwfKybqPkmZlNmvw/W2D4nijgRa08uvU qO74PihfHTXZkr6KUUBrFNp1l4nqJhWG361n7x0E0ynKS4OEbQL5FA0zNvLDecxwrhs9 e6CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qiitmBl9jjvBguTATL7zDt4nRfxz/HTB3erTJxZqwpQ=; b=r5PwydpqvPMDPD7eJ7K+jxvvn+QqcgJkoSK7JYh3T0pTyDhR6YJmY0DliK5lmEQgIo BFvEic8UR6/DMZCBHlQ4IgCZ5LuoHbu3Ft5YSe8qh0ud/w19lMTk29O5BMWxa0jcNWE8 P4ZXKE8V0uQM3H1bc9ra4FIWhy9sERfZ3XV3+fImpfsC2Lt2m1IiotLq+OIaGjJyjuFF P7IkrMPnmOLhFJnkOg6YOqbOulB0f4MFEx3u0OMMxDTquPLPm9upjviypjc0wrNmskox Q7rP0w5daIOGZVa8x5FbA/Jv4b6LaGhVFb+hV9Dp1Bm0qjY9blGdYTQdsRVqMLSPwI1H 7wWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rJmfgkun; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.02.08; Tue, 05 Nov 2019 06:02:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rJmfgkun; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389441AbfKEOCH (ORCPT + 5 others); Tue, 5 Nov 2019 09:02:07 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:45360 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389342AbfKEOCH (ORCPT ); Tue, 5 Nov 2019 09:02:07 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E22bO101246; Tue, 5 Nov 2019 08:02:02 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962522; bh=qiitmBl9jjvBguTATL7zDt4nRfxz/HTB3erTJxZqwpQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rJmfgkunIDUrTE/pNxAn6HWIkA5GvQ/1RvZnrG44UdHYwA7RJxujmPO9QoQczxoMZ NWDm2kBWDBDJs79V6JudfkcT2nVI20xe+R3PMLHUF85usQ9hEYfPIeBCSvLV1L17hE D+BxKKw7LNAnnkJS3O7grZ6VCvBN4BGf6rJSyfDc= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E21FI088066 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:02:01 -0600 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 5 Nov 2019 08:01:46 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:01:46 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FG0068289; Tue, 5 Nov 2019 08:02:00 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 21/22] crypto: omap-des: handle NULL cipher request Date: Tue, 5 Nov 2019 16:01:10 +0200 Message-ID: <20191105140111.20285-22-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org If no data is provided for DES request, just return immediately. No processing is needed in this case. Signed-off-by: Tero Kristo --- drivers/crypto/omap-des.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 31fc9300b990..8eda43319204 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -637,6 +637,9 @@ static int omap_des_crypt(struct skcipher_request *req, unsigned long mode) !!(mode & FLAGS_ENCRYPT), !!(mode & FLAGS_CBC)); + if (!req->cryptlen) + return 0; + if (!IS_ALIGNED(req->cryptlen, DES_BLOCK_SIZE)) return -EINVAL; From patchwork Tue Nov 5 14:01:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178518 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp710308ocf; Tue, 5 Nov 2019 06:02:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzDlZmvJqqPHoL02NsU3S9Sx8IgUlmOxwbSANsQm7dvjiSI5e2Rc2Nb9Qa+oJRc5mC82T8f X-Received: by 2002:a05:6402:158d:: with SMTP id c13mr19690115edv.62.1572962530316; Tue, 05 Nov 2019 06:02:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962530; cv=none; d=google.com; s=arc-20160816; b=k9qL77VJA7vkhy0ZBbDn1E4/Xz+wIrF6nzFzQV/76uNXg+QX1db7U+XJVCLaPft8bd IkK6w3FUEI2gZsJ+pCck0Ko6HmIGnxs9NXvhEk7eFKXthQl5pWDon++9M6ZtKDbh/snZ 3OBOITJKzGzznOC1JGl2/J23x9LgTAfSIFA2jk2Z22icGEvN7AYo8Owz1SmEVUKR2XKb JbQAo6w1eq9+DRnScumaGOG97WTHHLnf29MSA2r89Phi43vFjKXDtvAFRpYPbrTMg7Lf 4yFWvmo1CqF4qrfjDIl8da+3fo9byXWf7Tj3myaQjrqGRLIfxoF05yXHUiwaHfwEms5Z lrOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9fJAHIVAgIN3PPmEYUALLZCyp9Oxs8DgQg19svNGF8c=; b=js6ZZjmY9uSLytMfQgRanKpF4C83gpp4ICwyaDMCt637NcWboidb8+5HF4fs8WSgAI LhQrzouJME2mTgj23dPcOtnzkaDtpxObnfmXDokYNreJAGrddbjPv3UcRQi7y3bWhv4V iFY3fGm4sZ1omeRhFyC0Szl0ndR3D9ECFpzyQWwQEJdjAAoNEz1Ra7pShbGrClm6LuYi Xyx7SrIMNBfaZLdiI9qqTf+rFfHSDNqLTlLm9yuOSZadb6KSbF4pBpJ0kbgZm8JTIbQI At+W2ZasxpCmLvU/BMmUIHAXABOWtkdWLe33KK+awNZLxS2ekKtK7PLRKIQg71a5k3n9 pjrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HbLRw8kg; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk11si13340421ejb.97.2019.11.05.06.02.10; Tue, 05 Nov 2019 06:02:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HbLRw8kg; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389449AbfKEOCJ (ORCPT + 5 others); Tue, 5 Nov 2019 09:02:09 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:35274 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389342AbfKEOCJ (ORCPT ); Tue, 5 Nov 2019 09:02:09 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E24h4038298; Tue, 5 Nov 2019 08:02:04 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962524; bh=9fJAHIVAgIN3PPmEYUALLZCyp9Oxs8DgQg19svNGF8c=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HbLRw8kgswNEXHxEe2P87lvRkRS3yxuXfOAO8ILecB6xsNbpf7qQuIcWRaguB4xwo HgqnEMOTJgCoTdbDwzDzLFg+NzS33ufa4GqNpT5KNslDGkIt0bOw1HOqAn5u88cv2d cQNxQNj/pPlJqbn7i+wnjn0SfiOXzxnF1JAfH2sk= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E23Rm085039; Tue, 5 Nov 2019 08:02:03 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 5 Nov 2019 08:02:03 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 5 Nov 2019 08:02:03 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1FG1068289; Tue, 5 Nov 2019 08:02:01 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 22/22] crypto: omap-crypto: copy the temporary data to output buffer properly Date: Tue, 5 Nov 2019 16:01:11 +0200 Message-ID: <20191105140111.20285-23-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105140111.20285-1-t-kristo@ti.com> References: <20191105140111.20285-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Both source and destination are scatterlists that can contain multiple entries under the omap crypto cleanup handling. Current code only copies data from the first source scatterlist entry to the target scatterlist, potentially omitting any sg entries following the first one. Instead, implement a new routine that walks through both source and target and copies the data over once it goes. Signed-off-by: Tero Kristo --- drivers/crypto/omap-crypto.c | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-crypto.c b/drivers/crypto/omap-crypto.c index 7d592d93bb1c..cc88b7362bc2 100644 --- a/drivers/crypto/omap-crypto.c +++ b/drivers/crypto/omap-crypto.c @@ -154,6 +154,41 @@ int omap_crypto_align_sg(struct scatterlist **sg, int total, int bs, } EXPORT_SYMBOL_GPL(omap_crypto_align_sg); +static void omap_crypto_copy_data(struct scatterlist *src, + struct scatterlist *dst, + int offset, int len) +{ + int amt; + void *srcb, *dstb; + int srco = 0, dsto = offset; + + while (src && dst && len) { + if (srco >= src->length) { + srco -= src->length; + src = sg_next(src); + continue; + } + + if (dsto >= dst->length) { + dsto -= dst->length; + dst = sg_next(dst); + continue; + } + + amt = min(src->length - srco, dst->length - dsto); + amt = min(len, amt); + + srcb = sg_virt(src) + srco; + dstb = sg_virt(dst) + dsto; + + memcpy(dstb, srcb, amt); + + srco += amt; + dsto += amt; + len -= amt; + } +} + void omap_crypto_cleanup(struct scatterlist *sg, struct scatterlist *orig, int offset, int len, u8 flags_shift, unsigned long flags) @@ -171,7 +206,7 @@ void omap_crypto_cleanup(struct scatterlist *sg, struct scatterlist *orig, pages = get_order(len); if (orig && (flags & OMAP_CRYPTO_COPY_MASK)) - scatterwalk_map_and_copy(buf, orig, offset, len, 1); + omap_crypto_copy_data(sg, orig, offset, len); if (flags & OMAP_CRYPTO_DATA_COPIED) free_pages((unsigned long)buf, pages);