From patchwork Mon May 20 11:50:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 164599 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp184082ili; Mon, 20 May 2019 04:50:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLGzvTazRr1JfzkX7TRHjMgWdwnAGVxXYD1MCbJ0og5CmkTAPeAyIh7uyGa8DoxDQdIi60 X-Received: by 2002:aa7:9afc:: with SMTP id y28mr80038931pfp.101.1558353040277; Mon, 20 May 2019 04:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558353040; cv=none; d=google.com; s=arc-20160816; b=plZeVbDkeoP9S3jDXhwtWaq2n0+vLQcdIGxa7rzWHW2liNTOx2vqDtrzZbXWHOXJLA qgr+oXzEzU2h1YIQHZg1iQnvTrpecHxa92OoA/aIpxqoXW0Z3HS+JQdo5xONJUF14CNh HQ5AM/pAKP+mX2LAAN7vdAAv4hISit92ifPrTpTgzLRXdtFDnjUbbXjGzFW2HWh35PP8 k6q/mhCt5a71DFSO7PBqkCyNElkDB/Vg2Wo0ipAhqrPGlktTraPTgF7MJuS39JUeAfwH fgSe7ux4Kp/vL8Edx9LNDMv1qXTLCM342kjrf1h1J7KNM4p5F2uxiv3eXxzVhZgXHCr2 jNRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jBa/4lfxlhySIR6mrJWQlih1J8FM1zKWUV9zS3y3E/E=; b=tBcvHorTHBAzRAYm8zdxLzfAxYjiho04q1kDr7C5hNMZV3dFAWKFxv0Rsv9HZSnasW D9qhaegbpBgHlz3vWhz6TjM/rHwbP9lBf1Il3u/mo50ydOv+ACtoyk2F1FzpfBYxxtA0 drAZanjYpkVhc5a5ncWLLWDX2jRk275ElsYyi5fGS/tHsyHb00IE1tCeLw1j/FxeLrPb XCu+MSwzt1TYMawbOiyro7Ek1CZ4hSTvlsgLoYRyCjObV7GOSpRiZIBdmwugJIK7lREQ JPKMQlnrM/Ns2HTLawac3jqynqoGUn9uhkL2UZAUTvtwwNZUs/n1HdmEzhxN1vP4IZO5 Us8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f90si18377478plb.25.2019.05.20.04.50.39; Mon, 20 May 2019 04:50:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731770AbfETLuj (ORCPT + 30 others); Mon, 20 May 2019 07:50:39 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43982 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730606AbfETLui (ORCPT ); Mon, 20 May 2019 07:50:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8030015AB; Mon, 20 May 2019 04:50:37 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (unknown [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7BE13F5AF; Mon, 20 May 2019 04:50:35 -0700 (PDT) From: Gilad Ben-Yossef To: gregkh@linuxfoundation.org, Herbert Xu , "David S. Miller" Cc: stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [STABLE PATCH 1/2] crypto: ccree: zap entire sg on aead request unmap Date: Mon, 20 May 2019 14:50:23 +0300 Message-Id: <20190520115025.16457-2-gilad@benyossef.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115025.16457-1-gilad@benyossef.com> References: <20190520115025.16457-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We were trying to be clever zapping out of the cache only the required length out of scatter list on AEAD request completion and getting it wrong. As Knuth said: "when in douby, use brute force". Zap the whole length of the scatter list. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_buffer_mgr.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) -- 2.21.0 diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index 0ee1c52da0a4..0774bf54fcab 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -568,11 +568,7 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); unsigned int hw_iv_size = areq_ctx->hw_iv_size; - struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct cc_drvdata *drvdata = dev_get_drvdata(dev); - u32 dummy; - bool chained; - u32 size_to_unmap = 0; if (areq_ctx->mac_buf_dma_addr) { dma_unmap_single(dev, areq_ctx->mac_buf_dma_addr, @@ -629,22 +625,12 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) dev_dbg(dev, "Unmapping src sgl: req->src=%pK areq_ctx->src.nents=%u areq_ctx->assoc.nents=%u assoclen:%u cryptlen=%u\n", sg_virt(req->src), areq_ctx->src.nents, areq_ctx->assoc.nents, req->assoclen, req->cryptlen); - size_to_unmap = req->assoclen + req->cryptlen; - if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) - size_to_unmap += areq_ctx->req_authsize; - if (areq_ctx->is_gcm4543) - size_to_unmap += crypto_aead_ivsize(tfm); - dma_unmap_sg(dev, req->src, - cc_get_sgl_nents(dev, req->src, size_to_unmap, - &dummy, &chained), - DMA_BIDIRECTIONAL); + dma_unmap_sg(dev, req->src, sg_nents(req->src), DMA_BIDIRECTIONAL); if (req->src != req->dst) { dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", sg_virt(req->dst)); - dma_unmap_sg(dev, req->dst, - cc_get_sgl_nents(dev, req->dst, size_to_unmap, - &dummy, &chained), + dma_unmap_sg(dev, req->dst, sg_nents(req->dst), DMA_BIDIRECTIONAL); } if (drvdata->coherent &&