Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4500136rwb; Tue, 6 Sep 2022 08:20:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6J4H9PNsMgJSTA9VW1qXObcFACsb1XrzA9Hj7jg+dpDtfrD1jCSugSsLu/wTLz67YVRz/G X-Received: by 2002:a17:90b:1e12:b0:1fe:5896:2e3d with SMTP id pg18-20020a17090b1e1200b001fe58962e3dmr24745256pjb.101.1662477631951; Tue, 06 Sep 2022 08:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477631; cv=none; d=google.com; s=arc-20160816; b=mv+nIThEqmuNu7IKPUnMHpux4kaz13y4rNALysRK7fdBRWcKdrwE6Z+Mw4h8mf0jw8 4qRkpV41TSoqQhAj7GkpeYZB1OslecP5kLpyTFxH2HU7BD8bwMbaq9obs3Q5luag4hWK g0bagcJ2YL6T+Iwr00makv5yZfgQMshukWHO1Ivy7C96uKDJ6KbBpYPXHgT9Xxd8DXve yadTEQk0+Y76kpUdR76H+ALWzWH3zezI6BSVTx5ToAGiP90yV5093v0Ebc4jxQYWCiYp v7w0SpNZ5vs8VqfhjsBVFOPLvsjXsR2U7tKnc7lm7n95yspArjUg3KTbL1ntDhgPa+AH zQrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:to:subject:from:cc:references :in-reply-to:content-transfer-encoding:mime-version:dkim-signature; bh=C/iCdAd7dch2IVzpvhY+Rj5l9VcvchivL67YvJCBxp0=; b=bXbrQU4NtxbKpQjjXskbVOqqMYdbyEDWztMm0MoI6UmYMJGQysO7Jhx4BQBe9Hj1Ni fpynaMmTHID8Ls1B63pn8JEGO1+PtxTQHskdX39pPcUkZbgvU4N24NNlOZFTbXqw5awo b2mkZ8GWa3vqZM8godByV2VZBpyBTfnQPG1dhKCXVfXqujcaGMbjZpoAqRwgpDM3vj2e t+mvA2s8xblW8TUagi8bZkAd2LFbSLJ7+6VHlf/4n+LT3PSaBLgIE4KyeVxS0mpixXkD zC9mpx7vOzVq0LWyFraWmeQkh4d9GDQRhiKKNWYtrdX4yuI/4SozUtnzsEM15+FyST/e RQSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iz9BYOJT; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a170902d3c100b00176985a80a4si7481662plb.466.2022.09.06.08.20.18; Tue, 06 Sep 2022 08:20:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iz9BYOJT; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbiIFPCY (ORCPT + 99 others); Tue, 6 Sep 2022 11:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233193AbiIFPCD (ORCPT ); Tue, 6 Sep 2022 11:02:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C1F1111 for ; Tue, 6 Sep 2022 07:16:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BFBB9B81636 for ; Tue, 6 Sep 2022 14:00:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39336C433D6; Tue, 6 Sep 2022 14:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662472856; bh=0n+iESD+GUNwlyuJIvTXBTASXtzx6TPBXDs0PV/nRls=; h=In-Reply-To:References:Cc:From:Subject:To:Date:From; b=iz9BYOJTujOFROlVYJNzkJ4OSxmkSOH7VfWYsX0KoK2M34U2xdgzznmvQtWYNlBGf MYEvg4N7mBDBBw1sn5WF+lWgYIqtQGJh+QVrChINMiZXrs2AcIi88rruYB0e1zDB/G WUTnxEAoUzVQJxwkcWCCWg5HM8vHdeyp3WI3Em+LYYCLQGc8JzyycBlMRUMB36t+t6 9N4X9IqqbMvEycJnfKQNFvKR9SXyeFqucaK0hqOc+JMhzlBIN+l7iqFT1D/IE9BibV EI6nLzaqEtydep704ldVoJaQyeDXlwUHE5adhDYv+jDidxo9k4kwgZAshgdwqzDGSe adLfPa1tQCU9w== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: Cc: linux-crypto@vger.kernel.org, linux-lgm-soc@maxlinear.com, Peter Harliman Liem From: Antoine Tenart Subject: Re: [PATCH v2 1/2] crypto: inside_secure - Avoid dma map if size is zero To: Peter Harliman Liem , herbert@gondor.apana.org.au Message-ID: <166247285388.3585.6290053542530090542@kwain> Date: Tue, 06 Sep 2022 16:00:53 +0200 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Quoting Peter Harliman Liem (2022-09-06 04:51:49) > From commit d03c54419274 ("dma-mapping: disallow .map_sg > operations from returning zero on error"), dma_map_sg() > produces warning if size is 0. This results in visible > warnings if crypto length is zero. > To avoid that, we avoid calling dma_map_sg if size is zero. >=20 > Fixes: d03c54419274 ("dma-mapping: disallow .map_sg operations from retur= ning zero on error") You can't reference the commit above, it's not introducing the issue but the warning itself. The actual commit introducing the below logic should be referenced. Alternatively since the warning was introduced latter than the logic and this is not a huge issue, you might resend it w/o the Fixes tag as well. > Signed-off-by: Peter Harliman Liem With the Fixes: tag fixed, Acked-by: Antoine Tenart Thanks! > --- > v2: > Add fixes tag >=20 > drivers/crypto/inside-secure/safexcel_cipher.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/cry= pto/inside-secure/safexcel_cipher.c > index d68ef16650d4..3775497775e0 100644 > --- a/drivers/crypto/inside-secure/safexcel_cipher.c > +++ b/drivers/crypto/inside-secure/safexcel_cipher.c > @@ -737,14 +737,17 @@ static int safexcel_send_req(struct crypto_async_re= quest *base, int ring, > max(totlen_src, totlen_dst)); > return -EINVAL; > } > - dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDIRECTIONA= L); > + if (sreq->nr_src > 0) > + dma_map_sg(priv->dev, src, sreq->nr_src, DMA_BIDI= RECTIONAL); > } else { > if (unlikely(totlen_src && (sreq->nr_src <=3D 0))) { > dev_err(priv->dev, "Source buffer not large enoug= h (need %d bytes)!", > totlen_src); > return -EINVAL; > } > - dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_DEVICE); > + > + if (sreq->nr_src > 0) > + dma_map_sg(priv->dev, src, sreq->nr_src, DMA_TO_D= EVICE); > =20 > if (unlikely(totlen_dst && (sreq->nr_dst <=3D 0))) { > dev_err(priv->dev, "Dest buffer not large enough = (need %d bytes)!", > @@ -753,7 +756,9 @@ static int safexcel_send_req(struct crypto_async_requ= est *base, int ring, > DMA_TO_DEVICE); > return -EINVAL; > } > - dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM_DEVICE); > + > + if (sreq->nr_dst > 0) > + dma_map_sg(priv->dev, dst, sreq->nr_dst, DMA_FROM= _DEVICE); > } > =20 > memcpy(ctx->base.ctxr->data, ctx->key, ctx->key_len); > --=20 > 2.17.1 >=20