From patchwork Tue Nov 5 12:37: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: 178489 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp698773ilf; Tue, 5 Nov 2019 04:38:20 -0800 (PST) X-Google-Smtp-Source: APXvYqw1ujcu/b0wmLsBxP57wQIGX33qFxsOj2rGUthtXlOWwnZyzTadU07iMBUUK2xoLtgJn4n3 X-Received: by 2002:a17:906:1f09:: with SMTP id w9mr29670666ejj.35.1572957500190; Tue, 05 Nov 2019 04:38:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572957500; cv=none; d=google.com; s=arc-20160816; b=qQAGMpWpIVpo0vStodxVcZ7heRB87C26+4QDHjoPYfUG57elcwlXhpquhSGgphbRnN Cy8g/tX5ZR9KhcjumQSZpZoRxrEsDyRDqJe/mvGz6aBjaBMTzsA0/EHTQwcztW5jKvmQ aa5NQ18MK1Ws7GL2o+jjqjprr/+Wjj85yDYcvsV4514fpXDaKFQ9Lq9jyA2IWsHskC+s yS6yCmDVy0zF+2097vN7Qprm/gseNpWszt6CwypRtQlZ2mdo+9Gtj5DtnV/Wtwh2X14q tkmatQLcivl9Jyjlf1LqNfXTBErXVVD9iXAbFe0Wgamc1rfMQTzYptNtAZGRrJWu88bo XD4g== 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=L9J0BXJblFUZbSioOx+kBANafT74E3zu97Z+az3LWPv634vzvQtrSqEv/IEMGFv64F MiWciiiX8sFBrlfThaB/e7RUbMX3svJHG8RGtyJSXKbViK1+PEWaIMRA9hWLnjq3iaze vVs96XPbAFfkp0IVag7rqfH3UuPauztALgbhT3TdO9C9BzIb/U5svRgXPrckwcOb0knc YOZllxpwTcY+UmNqKy+v1DISbBUf9NkTVagAV9QlbxILmnNhH0Z8eowA3NXd4rcCXIiG sf8ixkVFkWcSEO2a4BI2okBx+jYRuxhQXa3w0dgrJGXmvVluiqnqVuHYtLRn0wDx36jK V1LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=zDFvrPRq; 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 l3si4323152ejr.86.2019.11.05.04.38.20; Tue, 05 Nov 2019 04:38:20 -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=zDFvrPRq; 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 S2388681AbfKEMiT (ORCPT + 3 others); Tue, 5 Nov 2019 07:38:19 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:53530 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388551AbfKEMiT (ORCPT ); Tue, 5 Nov 2019 07:38:19 -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 xA5CcD1A016852; Tue, 5 Nov 2019 06:38:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572957493; bh=+AmfYZzlDSB4ydg8jhXUTAd0sR8HN8hG6r1nfOurSMs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=zDFvrPRqT0LK+p1n3Nz8y+n5anm2OQMYD7/U2ESXrsm/wlreNncKEDo/9Nr3KNhqk W5GfrQUYanjQTlxUNE4sm4HmwojyZBIjnPWpwVs6KlTq0JQaU0bmWpzGgRUBK145J5 5V38PizJeIfGnkOtNzgZzRiQFUcAwmYINA/juqK4= Received: from DLEE110.ent.ti.com (dlee110.ent.ti.com [157.170.170.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xA5CcD4Y087593 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Nov 2019 06:38:13 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) 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; Tue, 5 Nov 2019 06:37:56 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) 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 via Frontend Transport; Tue, 5 Nov 2019 06:38:11 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA5Cc6cx117093; Tue, 5 Nov 2019 06:38:10 -0600 From: Tero Kristo To: , , CC: , Subject: [PATCH 2/6] crypto: omap-sham: fix unaligned sg list handling Date: Tue, 5 Nov 2019 14:37:55 +0200 Message-ID: <20191105123759.25053-3-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191105123759.25053-1-t-kristo@ti.com> References: <20191105123759.25053-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 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; }