Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp890663pxm; Thu, 3 Mar 2022 06:36:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNojZv/JUYDySZSnJ5Kt2bZMinuShkKho71lVoMmgWPnnPGreR2lTOZ2aLm+Y0IOF8+xXe X-Received: by 2002:a17:90a:aa83:b0:1b9:7c62:61e5 with SMTP id l3-20020a17090aaa8300b001b97c6261e5mr5692146pjq.118.1646318213702; Thu, 03 Mar 2022 06:36:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646318213; cv=none; d=google.com; s=arc-20160816; b=Dhpv/NhC1Aq8R3qlg/5UycRP4PYiYDLaszL4BEj4t3Bn7y/QoqMNj7W4fn0y1P9EAO 01L5DCbQfX6+Jqg8geXlSU8+U0cogVJyep5jQ8ElqLJvOKswsVkfkop7x+AfPrTd1hxe DnMBXNrNl0fLMcKSgioF0bjPLIoDFGd6G6OMStmDVDIfli6XCQLs431/cHtaM/1sVdh7 5IWSriZt/OlH2iRiphIQaKsak9rE3Jyd5I8Tt5mSIYQfntnxF/irf6jaW1l6uZPlJ2zE AvGbiDWI+aas2gEoiAul5ZObPDNWoY7dvjMj/Kgt86zGhuQv8hbA4uuxmX6W+BlEynSf Qd3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qjeRQXDRHJDEOFaM/bFhRf+N+QLbWVSGAMDaOy7ZtIw=; b=kHF3aYV7XF7g8gKGCtNe2khOP9nz2IbUGAbUWqCXxfMRlkMAyH/gzS2gHn0yAVOpEW C1tygY5AdaFcs12ptb1h6NvGw28/BegCUMFiZRLV9fZNSnCFKztttMRf6l0z4+ilhSjr o+y4r7+BmertYQuwqCGHXR6X8Xn8RUiOMtc22ZK3QpZpKvy+ntVjwiyFpEkLWEY9+aOo zlfcYMzKPyQQ9jO+trwb1sqSJI0HhrNooU48sfigZhqpoftFGZaqqNY3mbBgqvKRhcoT EAZUWMlzLWNXMJ4kiARgfWzC4L9fwzi73wntELlHwcC62fcKcMyf+1FkceUsMb0ecL6V BTXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@metanate.com header.s=stronger header.b=Rvpp48c8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090a77c700b001bd5f71ff51si8171948pjs.21.2022.03.03.06.36.34; Thu, 03 Mar 2022 06:36:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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 (test mode) header.i=@metanate.com header.s=stronger header.b=Rvpp48c8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=metanate.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234028AbiCCOWl (ORCPT + 99 others); Thu, 3 Mar 2022 09:22:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234034AbiCCOWj (ORCPT ); Thu, 3 Mar 2022 09:22:39 -0500 Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 462C118E3E6; Thu, 3 Mar 2022 06:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=In-Reply-To:Content-Type:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=qjeRQXDRHJDEOFaM/bFhRf+N+QLbWVSGAMDaOy7ZtIw=; b=Rvpp4 8c8iAHDqTdLm8OD88p2G1kMMZO1W9Qi8uaYRy6VtgwIne1WnNP5cFq+1yHtWWbJKgAzkyrTZ2OD/t 1GAjcpLSaQ2q1Z/zbJhwn+ZgShs+EEoJtL4NtYR7Lr4tJBrTiRgJjUiYtedY05KN3wsNw56tzeXd5 xYsbHbNtEHBnddcHxE2yKCNmG24T3XqK0lcyH9rwZlwmW76WtWKTAsk6ZiB2mxqelhLwKG/iIkfPH Q4t4f9pYMq0gttOHOmdDFCcchJpb1xwWOAz2XvzIyq0SEQiHiymNXyNpwu9qTLXc/GpjeaUg474I2 zs2suSeUxZ4I2VTyRjKIDlr7YdiWQ==; Received: from [81.174.171.191] (helo=donbot) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nPmKo-0005yL-KP; Thu, 03 Mar 2022 14:21:38 +0000 Date: Thu, 3 Mar 2022 14:21:37 +0000 From: John Keeping To: Corentin Labbe Cc: heiko@sntech.de, herbert@gondor.apana.org.au, robh+dt@kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: Re: [PATCH v2 06/18] crypto: rockchip: add fallback for cipher Message-ID: References: <20220302211113.4003816-1-clabbe@baylibre.com> <20220302211113.4003816-7-clabbe@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220302211113.4003816-7-clabbe@baylibre.com> X-Authenticated: YES X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org On Wed, Mar 02, 2022 at 09:11:01PM +0000, Corentin Labbe wrote: > The hardware does not handle 0 size length request, let's add a > fallback. > Furthermore fallback will be used for all unaligned case the hardware > cannot handle. > > Fixes: ce0183cb6464b ("crypto: rockchip - switch to skcipher API") > Signed-off-by: Corentin Labbe > --- > drivers/crypto/rockchip/rk3288_crypto.h | 2 + > .../crypto/rockchip/rk3288_crypto_skcipher.c | 97 ++++++++++++++++--- > 2 files changed, 86 insertions(+), 13 deletions(-) > > diff --git a/drivers/crypto/rockchip/rk3288_crypto.h b/drivers/crypto/rockchip/rk3288_crypto.h > index c919d9a43a08..8b1e15d8ddc6 100644 > --- a/drivers/crypto/rockchip/rk3288_crypto.h > +++ b/drivers/crypto/rockchip/rk3288_crypto.h > @@ -246,10 +246,12 @@ struct rk_cipher_ctx { > struct rk_crypto_info *dev; > unsigned int keylen; > u8 iv[AES_BLOCK_SIZE]; > + struct crypto_skcipher *fallback_tfm; > }; > > struct rk_cipher_rctx { > u32 mode; > + struct skcipher_request fallback_req; // keep at the end > }; > > enum alg_type { > diff --git a/drivers/crypto/rockchip/rk3288_crypto_skcipher.c b/drivers/crypto/rockchip/rk3288_crypto_skcipher.c > index bbd0bf52bf07..bf9d398cc54c 100644 > --- a/drivers/crypto/rockchip/rk3288_crypto_skcipher.c > +++ b/drivers/crypto/rockchip/rk3288_crypto_skcipher.c > @@ -13,6 +13,63 @@ > > #define RK_CRYPTO_DEC BIT(0) > > +static int rk_cipher_need_fallback(struct skcipher_request *req) > +{ > + struct scatterlist *sgs, *sgd; > + > + if (!req->cryptlen) > + return true; > + > + sgs = req->src; > + while (sgs) { > + if (!IS_ALIGNED(sgs->offset, sizeof(u32))) { > + return true; > + } > + if (sgs->length % 16) { Can this be relaxed to check for alignment to 4 rather than 16? That's the requirement for programming the registers. But I think this check is wrong in general as it doesn't account for cryptlen; with fscrypt I'm seeing sgs->length == 255 but cryptlen == 16 so the hardware can be used but at the moment the fallback path is triggered.