Received: by 10.223.148.5 with SMTP id 5csp7305363wrq; Thu, 18 Jan 2018 03:56:21 -0800 (PST) X-Google-Smtp-Source: ACJfBovTKvSkmsnBCOnCphtPKZ3x6J2sVlm6FoKeH9OCgQf7vHx3ByEpAitQ7hTvVy6D8cybeNdR X-Received: by 10.98.67.138 with SMTP id l10mr8326490pfi.72.1516276581721; Thu, 18 Jan 2018 03:56:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516276581; cv=none; d=google.com; s=arc-20160816; b=i0RYBIMJnc6T8R4VFxDG8nHxnqgrLNODBN7hROhwQCqBwf0dN1TBeWoKfKfLlUizYo 5vyKtKlHK3ZmQjo4jY6xtylZYL3V0f9dy5dtHW0z0BaMRy/AIt0FDvmmYE/racs5GXEq P5lFefXG4iNBxG/bin4zo/loE2daNHYtmOcaM8g0iHy3pYaPFJUv7s1hALlbPRVp4LXb JDVW8l28v2zVrp4dNiAgu0A0K28AAOGVjdFHWZDCbHJDtTuKgnht0bLXg3j5WGhhThGC qOIf+TRdTXDdUof7c6J95BrQfsSrrgLT7BQcZUud9buPoYkpriLd88M0FTyO81GOGWbT XE7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=TXmHDLYuIbgkegbwWGOegLgYSN/+fJuFzXWlV48vLeM=; b=FDlMbfnC8ylmJarl+46/K1EZgw04896CyC2+6IXaEn/O2/MqWnnC2WQnUVkOzLEudo +PqTxiy5gp/3G65OHGQuYG8pheXCKurKAHwwjaG4dhMy4LtbCN2oVsGlbbcJZagkihZt dv/IO8pZqOKT+aZDaCELFIf2fM6XXco0zUiTbm2CxXkbiWcPcRyNwN8abr5BQ4B03KHR UPWq8ejct6dRwc4VMLzgJ3SLeIM0lYV5a6E+WMtr+knc26F1eGOC84fuE60W1vYh0Rxe kW0/AWOw0RNyHwoK2G/FxeHXdChexpk43HchCHvTRKNHgF2Jx/8ZS9oRKMaLf2uXK93e EtEQ== 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 204si5825264pgf.94.2018.01.18.03.56.07; Thu, 18 Jan 2018 03:56:21 -0800 (PST) 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 S1755306AbeARLjX (ORCPT + 99 others); Thu, 18 Jan 2018 06:39:23 -0500 Received: from [128.1.224.119] ([128.1.224.119]:55278 "EHLO ringil.hmeau.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755098AbeARLjU (ORCPT ); Thu, 18 Jan 2018 06:39:20 -0500 Received: from gondolin.me.apana.org.au ([192.168.0.6] helo=gondolin.hengli.com.au) by norbury.hmeau.com with esmtp (Exim 4.80 #3 (Debian)) id 1ec8XN-0001W1-LQ; Thu, 18 Jan 2018 22:39:17 +1100 Received: from herbert by gondolin.hengli.com.au with local (Exim 4.80) (envelope-from ) id 1ec8XC-0005Ds-2E; Thu, 18 Jan 2018 22:39:06 +1100 Date: Thu, 18 Jan 2018 22:39:06 +1100 From: Herbert Xu To: Megha Dey Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, davem@davemloft.net, megha.dey@intel.com Subject: Re: [PATCH V8 1/5] crypto: Multi-buffer encryption infrastructure support Message-ID: <20180118113905.GA19904@gondor.apana.org.au> References: <1515542948-24041-1-git-send-email-megha.dey@linux.intel.com> <1515542948-24041-2-git-send-email-megha.dey@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1515542948-24041-2-git-send-email-megha.dey@linux.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 09, 2018 at 04:09:04PM -0800, Megha Dey wrote: > > +static void mcryptd_skcipher_encrypt(struct crypto_async_request *base, > + int err) > +{ > + struct skcipher_request *req = skcipher_request_cast(base); > + struct mcryptd_skcipher_request_ctx *rctx = skcipher_request_ctx(req); > + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); > + struct mcryptd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm); > + struct crypto_skcipher *child = ctx->child; > + struct skcipher_request subreq; > + > + if (unlikely(err == -EINPROGRESS)) > + goto out; > + > + /* set up the skcipher request to work on */ > + skcipher_request_set_tfm(&subreq, child); > + skcipher_request_set_callback(&subreq, > + CRYPTO_TFM_REQ_MAY_SLEEP, 0, 0); > + skcipher_request_set_crypt(&subreq, req->src, req->dst, > + req->cryptlen, req->iv); > + > + /* > + * pass addr of descriptor stored in the request context > + * so that the callee can get to the request context > + */ > + rctx->desc = subreq; > + err = crypto_skcipher_encrypt(&rctx->desc); > + > + if (err) { > + req->base.complete = rctx->complete; > + goto out; > + } > + return; > + > +out: > + mcryptd_skcipher_complete(req, err); > +} OK this looks better but it's still abusing the crypto API interface. In particular, you're sharing data with the underlying algorithm behind the crypto API's back. Also, the underlying algorithm does callback completion behind the API's back through the shared data context. It seems to me that the current mcryptd scheme is flawed. You want to batch multiple requests and yet this isn't actually being done by mcryptd at all. The actual batching happens at the very lowest level, i.e., in the crypto algorithm below mcryptd. For example, with your patch, the batching appears to happen in aes_cbc_job_mgr_submit. So the mcryptd template is in fact completely superfluous. You can remove it and just have all the main encrypt/decrypt functions invoke the underlying encrypt/decrypt function directly and achieve the same result. Am I missing something? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt