From patchwork Tue Nov 5 14:00:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 178504 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp709570ocf; Tue, 5 Nov 2019 06:01:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyeRL6InsXglLdJDtBkwjOUy98U83l/Uy0+xxlgPbvHkmi7MVFWs1Stw6NcJaA3xdavCg1n X-Received: by 2002:a17:906:6d82:: with SMTP id h2mr29572956ejt.127.1572962504773; Tue, 05 Nov 2019 06:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572962504; cv=none; d=google.com; s=arc-20160816; b=vu3RR3LcddBkcFLJHv1Gzoi4K/7MVZX0E7kccxW2shrnynD14GVwKl2/wxPYUHCUCR ppOW72HxwqqvSKX1GFbK+TtZ/SmZ7oeqBheFSYh+yiik4CjTCIE8hLQino/iK33DSJID 6iNZl2PXsGIlkxLVFU1PX7h55dArxM6XoN+ElovUEKwnhDz32hrg0pLpmsIZ/N9e+Tmi 0eHBjmsRpGD6dnfJ2LaXZkc2lyy5ThIZ/SnZR4VCtJOMBf57cntYaYrX51JOzWEqPDeV gCfzTuOYghusiUdIX1hge2K57D/CXuQWyfBISfdBhLznOaWku+FFUl+UfI19e4XfVvTS 28Pw== 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=gf7Wxfh77f7HHA3L8Iq0WB8JJs92egQOvoT79mDTzZI=; b=NTOb9Hp4zadfuidtIGpUcvr8hQGWDU0p4bMGBa8Sdhgwtakr0YJKbUTUST34fYSYWX f8WUrQkUjQOWTFsyNaqv4LJ1pXgK1cEOpJR+IlX1uay48TRyngR5pi4l6R8pmFOeBDIe VetSAnGE1Y4Ej8NI43gmrqJYm+X9+5liaxDVaJpxbMuMYp7HZ6CR4vusycFj6M27TYsZ NErLvhcmfXf/DG4n4XyUTgmKy2xHLsBP3RcyPJdug1KV2bNgOKjmA9V4SgsJ4MP/qjpF qXCVQXGwgeCozgbrVEEl4sr7zys4pTRUw9EyvF4/RYhold9KQ2e1xCRA7A6Q45n0wO3k hXdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PSUTMr5k; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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.44; Tue, 05 Nov 2019 06:01:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=PSUTMr5k; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 S2388605AbfKEOBm (ORCPT + 3 others); Tue, 5 Nov 2019 09:01:42 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:45256 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389368AbfKEOBm (ORCPT ); Tue, 5 Nov 2019 09:01:42 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA5E1Yp4101155; Tue, 5 Nov 2019 08:01:34 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572962494; bh=gf7Wxfh77f7HHA3L8Iq0WB8JJs92egQOvoT79mDTzZI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PSUTMr5k2hWcFS0rA9u1WNFHmhecrzz+6sfOyePpzRyWZo74oz/S1ggx79py6sucN haaUFjANx4koDqw/9ena01D2dT7f0JjrM8dOkW3Drk7wRH9i1kBepWw7ThOiJg225s jk5szRz+IJVAhrM68RPlCczDIflh9gRjSNv/epUc= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5E1YhP059697 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 08:01:34 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) 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; Tue, 5 Nov 2019 08:01:19 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE103.ent.ti.com (10.64.6.24) 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:19 -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 xA5E1FFj068289; Tue, 5 Nov 2019 08:01:32 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 06/22] crypto: omap-sham: fix buffer handling for split test cases Date: Tue, 5 Nov 2019 16:00:55 +0200 Message-ID: <20191105140111.20285-7-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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Current buffer handling logic fails in a case where the buffer contains existing data from previous update which is divisible by block size. This results in a block size of data to be left missing from the sg list going out to the hw accelerator, ending up in stalling the crypto accelerator driver (the last request never completes fully due to missing data.) Fix this by passing the total size of the data instead of the data size of current request, and also parsing the buffer contents within the prepare request handling. Signed-off-by: Tero Kristo --- drivers/crypto/omap-sham.c | 15 +++++++++++++-- 1 file changed, 13 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-sham.c b/drivers/crypto/omap-sham.c index 0bf07a7c060b..e71cd977b621 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -740,11 +740,12 @@ static int omap_sham_align_sgs(struct scatterlist *sg, struct scatterlist *sg_tmp = sg; int new_len; int offset = rctx->offset; + int bufcnt = rctx->bufcnt; if (!sg || !sg->length || !nbytes) return 0; - new_len = nbytes - offset; + new_len = nbytes; if (offset) list_ok = false; @@ -763,6 +764,16 @@ static int omap_sham_align_sgs(struct scatterlist *sg, while (nbytes > 0 && sg_tmp) { n++; + if (bufcnt) { + if (!IS_ALIGNED(bufcnt, bs)) { + aligned = false; + break; + } + nbytes -= bufcnt; + bufcnt = 0; + continue; + } + #ifdef CONFIG_ZONE_DMA if (page_zonenum(sg_page(sg_tmp)) != ZONE_DMA) { aligned = false; @@ -859,7 +870,7 @@ static int omap_sham_prepare_request(struct ahash_request *req, bool update) if (rctx->bufcnt) memcpy(rctx->dd->xmit_buf, rctx->buffer, rctx->bufcnt); - ret = omap_sham_align_sgs(req->src, nbytes, bs, final, rctx); + ret = omap_sham_align_sgs(req->src, rctx->total, bs, final, rctx); if (ret) return ret;