From patchwork Sun Jul 2 14:41:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106841 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8292174obb; Sun, 2 Jul 2017 07:43:15 -0700 (PDT) X-Received: by 10.84.208.236 with SMTP id c41mr5552611plj.95.1499006595213; Sun, 02 Jul 2017 07:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006595; cv=none; d=google.com; s=arc-20160816; b=ZA6scLKqQETxeSxTBnNXOj89LJLECpF1O0Y7LXueTmMixE1NzGqc+fhLHTLCjybc4X cMB7l9s9ZXyWJ/VnEfq/5T/n3JpyohqDkMAPjeu0B6eQWuECfh+/Mke3H8En1Nruf5Nd C/64wVHtJavQAFpVG2czh6vMpYO0Sl02VJYyvkCVMzwLS/vTo0SKuJKxWs8vXX5GNyd2 lEFLGFnGcRwFvvefIPc/mk8OKCXr/XheLuwTgArgvdHa3wpF6/k3O+LxF/pcsdiq866q k8XIMoDTWmVJSSi27aoxADv1BRSxNRhg3YBYWIJYeylaR0XNqQAHj0548rCTHaajgXG1 gbvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2wOXczyIvqVwRex8GDAhVMPa09Ve54NqKt44XJhI5oU=; b=FLxG2x4kWplIWI+v1x4nVC0VrirhtNIZ032P7ckKlrrw0abAwqveeQEAQ3MKTUMHH/ dWwS7Rcw/MI1hnTV0sZcpOpzEnNsk3s9rst1vJgNYvaCE/t0jT9D+zjy3PPKdZLpjplV Me8vZT8Ruh0/QrEIMXS0UHXeiQR3BXbpFZ5LdLIMa9EeS8VZmgj8H4QMkeOEVVDPwiOB XDM2jX+7AMApy9ie1Fy3ozBIhyGRDShVnxoqbN3A+WfOaGRG49W5XNtbTZfR/zYbZ3Ru B0mTL0Vu3uf1+dsSAzixG0S1sJ8CvoEZ00glR4rxNOvbzugZjL1lFSFcL/hhawPnmmAX 1V7A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g72si10235551pfa.464.2017.07.02.07.43.14; Sun, 02 Jul 2017 07:43:15 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752061AbdGBOmr (ORCPT + 1 other); Sun, 2 Jul 2017 10:42:47 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53430 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750818AbdGBOmn (ORCPT ); Sun, 2 Jul 2017 10:42:43 -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 0FE7015B2; Sun, 2 Jul 2017 07:42:43 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3678D3F578; Sun, 2 Jul 2017 07:42:35 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 01/28] crypto: change backlog return code to -EIOCBQUEUED Date: Sun, 2 Jul 2017 17:41:43 +0300 Message-Id: <1499006535-19760-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The crypto API was using the -EBUSY return value to indicate both a hard failure to submit a crypto operation into a transformation provider when the latter was busy and the backlog mechanism was not enabled as well as a notification that the operation was queued into the backlog when the backlog mechanism was enabled. Having the same return code indicate two very different conditions depending on a flag is both error prone and requires extra runtime check like the following to discern between the cases: if (err == -EINPROGRESS || (err == -EBUSY && (ahash_request_flags(req) & CRYPTO_TFM_REQ_MAY_BACKLOG))) This patch changes the return code used to indicate a crypto op was queued in the backlog to -EIOCBQUEUED, thus resolving both issues. Signed-off-by: Gilad Ben-Yossef --- crypto/af_alg.c | 2 +- crypto/ahash.c | 12 +++--------- crypto/algapi.c | 6 ++++-- crypto/asymmetric_keys/public_key.c | 2 +- crypto/chacha20poly1305.c | 2 +- crypto/cryptd.c | 4 +--- crypto/cts.c | 6 ++---- crypto/drbg.c | 2 +- crypto/gcm.c | 2 +- crypto/lrw.c | 8 ++------ crypto/rsa-pkcs1pad.c | 16 ++++------------ crypto/tcrypt.c | 6 +++--- crypto/testmgr.c | 12 ++++++------ crypto/xts.c | 8 ++------ 14 files changed, 32 insertions(+), 56 deletions(-) -- 2.1.4 diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 3556d8e..c67daba 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -484,7 +484,7 @@ int af_alg_wait_for_completion(int err, struct af_alg_completion *completion) { switch (err) { case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&completion->completion); reinit_completion(&completion->completion); err = completion->err; diff --git a/crypto/ahash.c b/crypto/ahash.c index 826cd7a..65d08db 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -334,9 +334,7 @@ static int ahash_op_unaligned(struct ahash_request *req, return err; err = op(req); - if (err == -EINPROGRESS || - (err == -EBUSY && (ahash_request_flags(req) & - CRYPTO_TFM_REQ_MAY_BACKLOG))) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return err; ahash_restore_req(req, err); @@ -394,9 +392,7 @@ static int ahash_def_finup_finish1(struct ahash_request *req, int err) req->base.complete = ahash_def_finup_done2; err = crypto_ahash_reqtfm(req)->final(req); - if (err == -EINPROGRESS || - (err == -EBUSY && (ahash_request_flags(req) & - CRYPTO_TFM_REQ_MAY_BACKLOG))) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return err; out: @@ -432,9 +428,7 @@ static int ahash_def_finup(struct ahash_request *req) return err; err = tfm->update(req); - if (err == -EINPROGRESS || - (err == -EBUSY && (ahash_request_flags(req) & - CRYPTO_TFM_REQ_MAY_BACKLOG))) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return err; return ahash_def_finup_finish1(req, err); diff --git a/crypto/algapi.c b/crypto/algapi.c index e4cc761..3bfd1fa 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -897,9 +897,11 @@ int crypto_enqueue_request(struct crypto_queue *queue, int err = -EINPROGRESS; if (unlikely(queue->qlen >= queue->max_qlen)) { - err = -EBUSY; - if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) { + err = -EBUSY; goto out; + } + err = -EIOCBQUEUED; if (queue->backlog == &queue->list) queue->backlog = &request->list; } diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index 3cd6e12..3fad1fd 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c @@ -141,7 +141,7 @@ int public_key_verify_signature(const struct public_key *pkey, * signature and returns that to us. */ ret = crypto_akcipher_verify(req); - if ((ret == -EINPROGRESS) || (ret == -EBUSY)) { + if ((ret == -EINPROGRESS) || (ret == -EIOCBQUEUED)) { wait_for_completion(&compl.completion); ret = compl.err; } diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c index db1bc31..e0e2785 100644 --- a/crypto/chacha20poly1305.c +++ b/crypto/chacha20poly1305.c @@ -79,7 +79,7 @@ static inline void async_done_continue(struct aead_request *req, int err, if (!err) err = cont(req); - if (err != -EINPROGRESS && err != -EBUSY) + if (err != -EINPROGRESS && err != -EIOCBQUEUED) aead_request_complete(req, err); } diff --git a/crypto/cryptd.c b/crypto/cryptd.c index 0508c48..5daca13 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c @@ -137,16 +137,14 @@ static int cryptd_enqueue_request(struct cryptd_queue *queue, int cpu, err; struct cryptd_cpu_queue *cpu_queue; atomic_t *refcnt; - bool may_backlog; cpu = get_cpu(); cpu_queue = this_cpu_ptr(queue->cpu_queue); err = crypto_enqueue_request(&cpu_queue->queue, request); refcnt = crypto_tfm_ctx(request->tfm); - may_backlog = request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG; - if (err == -EBUSY && !may_backlog) + if (err == -EBUSY) goto out_put_cpu; queue_work_on(cpu, kcrypto_wq, &cpu_queue->work); diff --git a/crypto/cts.c b/crypto/cts.c index 243f591..e2068dc 100644 --- a/crypto/cts.c +++ b/crypto/cts.c @@ -136,8 +136,7 @@ static void crypto_cts_encrypt_done(struct crypto_async_request *areq, int err) goto out; err = cts_cbc_encrypt(req); - if (err == -EINPROGRESS || - (err == -EBUSY && req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return; out: @@ -229,8 +228,7 @@ static void crypto_cts_decrypt_done(struct crypto_async_request *areq, int err) goto out; err = cts_cbc_decrypt(req); - if (err == -EINPROGRESS || - (err == -EBUSY && req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return; out: diff --git a/crypto/drbg.c b/crypto/drbg.c index 633a88e..850b451 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1767,7 +1767,7 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg, case 0: break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&drbg->ctr_completion); if (!drbg->ctr_async_err) { reinit_completion(&drbg->ctr_completion); diff --git a/crypto/gcm.c b/crypto/gcm.c index 3841b5e..ffac821 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -151,7 +151,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, sizeof(data->hash), data->iv); err = crypto_skcipher_encrypt(&data->req); - if (err == -EINPROGRESS || err == -EBUSY) { + if (err == -EINPROGRESS || err == -EIOCBQUEUED) { wait_for_completion(&data->result.completion); err = data->result.err; } diff --git a/crypto/lrw.c b/crypto/lrw.c index a8bfae4..e2b1378 100644 --- a/crypto/lrw.c +++ b/crypto/lrw.c @@ -328,9 +328,7 @@ static int do_encrypt(struct skcipher_request *req, int err) crypto_skcipher_encrypt(subreq) ?: post_crypt(req); - if (err == -EINPROGRESS || - (err == -EBUSY && - req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return err; } @@ -380,9 +378,7 @@ static int do_decrypt(struct skcipher_request *req, int err) crypto_skcipher_decrypt(subreq) ?: post_crypt(req); - if (err == -EINPROGRESS || - (err == -EBUSY && - req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return err; } diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 407c64b..3c82542 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c @@ -279,9 +279,7 @@ static int pkcs1pad_encrypt(struct akcipher_request *req) req->dst, ctx->key_size - 1, req->dst_len); err = crypto_akcipher_encrypt(&req_ctx->child_req); - if (err != -EINPROGRESS && - (err != -EBUSY || - !(req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG))) + if (err != -EINPROGRESS && err != -EIOCBQUEUED) return pkcs1pad_encrypt_sign_complete(req, err); return err; @@ -383,9 +381,7 @@ static int pkcs1pad_decrypt(struct akcipher_request *req) ctx->key_size); err = crypto_akcipher_decrypt(&req_ctx->child_req); - if (err != -EINPROGRESS && - (err != -EBUSY || - !(req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG))) + if (err != -EINPROGRESS && err != -EIOCBQUEUED) return pkcs1pad_decrypt_complete(req, err); return err; @@ -440,9 +436,7 @@ static int pkcs1pad_sign(struct akcipher_request *req) req->dst, ctx->key_size - 1, req->dst_len); err = crypto_akcipher_sign(&req_ctx->child_req); - if (err != -EINPROGRESS && - (err != -EBUSY || - !(req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG))) + if (err != -EINPROGRESS && err != -EIOCBQUEUED) return pkcs1pad_encrypt_sign_complete(req, err); return err; @@ -561,9 +555,7 @@ static int pkcs1pad_verify(struct akcipher_request *req) ctx->key_size); err = crypto_akcipher_verify(&req_ctx->child_req); - if (err != -EINPROGRESS && - (err != -EBUSY || - !(req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG))) + if (err != -EINPROGRESS && err != -EIOCBQUEUED) return pkcs1pad_verify_complete(req, err); return err; diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 0dd6a43..57f7ac4 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -97,7 +97,7 @@ static void tcrypt_complete(struct crypto_async_request *req, int err) static inline int do_one_aead_op(struct aead_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EBUSY) { + if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { struct tcrypt_result *tr = req->base.data; ret = wait_for_completion_interruptible(&tr->completion); @@ -397,7 +397,7 @@ static void test_hash_sg_init(struct scatterlist *sg) static inline int do_one_ahash_op(struct ahash_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EBUSY) { + if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { struct tcrypt_result *tr = req->base.data; wait_for_completion(&tr->completion); @@ -765,7 +765,7 @@ static void test_hash_speed(const char *algo, unsigned int secs, static inline int do_one_acipher_op(struct skcipher_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EBUSY) { + if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { struct tcrypt_result *tr = req->base.data; wait_for_completion(&tr->completion); diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 7125ba3..fb5418f 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -195,7 +195,7 @@ static void testmgr_free_buf(char *buf[XBUFSIZE]) static int wait_async_op(struct tcrypt_result *tr, int ret) { - if (ret == -EINPROGRESS || ret == -EBUSY) { + if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { wait_for_completion(&tr->completion); reinit_completion(&tr->completion); ret = tr->err; @@ -425,7 +425,7 @@ static int __test_hash(struct crypto_ahash *tfm, case 0: break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&tresult.completion); reinit_completion(&tresult.completion); ret = tresult.err; @@ -723,7 +723,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, } break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&result.completion); reinit_completion(&result.completion); ret = result.err; @@ -880,7 +880,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, } break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&result.completion); reinit_completion(&result.completion); ret = result.err; @@ -1171,7 +1171,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, case 0: break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&result.completion); reinit_completion(&result.completion); ret = result.err; @@ -1279,7 +1279,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, case 0: break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&result.completion); reinit_completion(&result.completion); ret = result.err; diff --git a/crypto/xts.c b/crypto/xts.c index d86c11a..b4b90cc 100644 --- a/crypto/xts.c +++ b/crypto/xts.c @@ -269,9 +269,7 @@ static int do_encrypt(struct skcipher_request *req, int err) crypto_skcipher_encrypt(subreq) ?: post_crypt(req); - if (err == -EINPROGRESS || - (err == -EBUSY && - req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return err; } @@ -321,9 +319,7 @@ static int do_decrypt(struct skcipher_request *req, int err) crypto_skcipher_decrypt(subreq) ?: post_crypt(req); - if (err == -EINPROGRESS || - (err == -EBUSY && - req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) + if (err == -EINPROGRESS || err == -EIOCBQUEUED) return err; } From patchwork Sun Jul 2 14:41:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106843 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8292734obb; Sun, 2 Jul 2017 07:43:58 -0700 (PDT) X-Received: by 10.99.49.20 with SMTP id x20mr5541063pgx.181.1499006638009; Sun, 02 Jul 2017 07:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006638; cv=none; d=google.com; s=arc-20160816; b=ldkf4ZeQ/Vjex4iy9XqHTHLPML+5zNMU5jjPiAb8FFejrAkmfeRsGhJbEVpI8tjYSS w1eMW4qVebIc/mY6Ryt6q9hBIDCGOeZz3A27Y5CqG4y9dna5e9/dW7o6vS43VlSQTH4/ QtTXeWaUuFTXIZgO0pdPjL0wzo5rViGSUBYsK7SSB0FFVRdv8WnD/2SCBukz1bjbrKX7 +vjz7CL2wIf2zrbV73XItlSDOp39IyAgv5Zjfv/bLHa87sc5pQhljvqpEW0lsNEBISpN crfQ8DNKMUjEEC1fgDmFuFBv5XHqI5xCpG9Qepn7dZXbATQ3n1SOjsiEDtOcBGTNzF/3 OyLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ZKvkf+MCOIK8f8xSWZnuT1SPOpefoHn4zrHuOPgaHgg=; b=LGnsW3srbM+2RJRoBcOaVNBNn0PJYqHR8v3It8ctsChQI7pbLruCdGzjsqFsmNrHs+ 4MRg0G5ETghHPtg4034nSjlCnM94PwrLqiSe/nglkcRNk5DdP90yJ70IEdpkoVKCyHdb cNT0vHyY4G+AaBrBtd4ziL4rf3foYsfnC+hovYTriJpkN0jinohbnD4iZ1qoPte4jKzc ENvz2b3WQLOXpIRbCSpGiYCDvQWnnjto7aRcLkhTWtrf5nsoUHtEisk61y/T/8FdT6l1 QJY8ep2YPT3cxVNZ6SalNmM+Z8tJONe4RTDYTkByQuhcYQGwoapNStTKP0tx1GKXTPuN dhnQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g16si10183773pfe.261.2017.07.02.07.43.57; Sun, 02 Jul 2017 07:43:57 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211AbdGBOn0 (ORCPT + 1 other); Sun, 2 Jul 2017 10:43:26 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53518 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751780AbdGBOnY (ORCPT ); Sun, 2 Jul 2017 10:43:24 -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 0902815B2; Sun, 2 Jul 2017 07:43:09 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 299953F578; Sun, 2 Jul 2017 07:43:00 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 03/28] crypto: ccm: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:45 +0300 Message-Id: <1499006535-19760-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/crypto/ccp/ccp-crypto-main.c | 10 +++++----- drivers/crypto/ccp/ccp-dev.c | 8 +++++--- drivers/crypto/ccp/ccp-dmaengine.c | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c index 8dccbdd..dff1998 100644 --- a/drivers/crypto/ccp/ccp-crypto-main.c +++ b/drivers/crypto/ccp/ccp-crypto-main.c @@ -84,7 +84,7 @@ struct ccp_crypto_cpu { static inline bool ccp_crypto_success(int err) { - if (err && (err != -EINPROGRESS) && (err != -EBUSY)) + if (err && (err != -EINPROGRESS) && (err != -EIOCBQUEUED)) return false; return true; @@ -148,7 +148,7 @@ static void ccp_crypto_complete(void *data, int err) if (err == -EINPROGRESS) { /* Only propagate the -EINPROGRESS if necessary */ - if (crypto_cmd->ret == -EBUSY) { + if (crypto_cmd->ret == -EIOCBQUEUED) { crypto_cmd->ret = -EINPROGRESS; req->complete(req, -EINPROGRESS); } @@ -166,8 +166,8 @@ static void ccp_crypto_complete(void *data, int err) backlog->req->complete(backlog->req, -EINPROGRESS); } - /* Transition the state from -EBUSY to -EINPROGRESS first */ - if (crypto_cmd->ret == -EBUSY) + /* Transition the state from -EIOCBQUEUED to -EINPROGRESS first */ + if (crypto_cmd->ret == -EIOCBQUEUED) req->complete(req, -EINPROGRESS); /* Completion callbacks */ @@ -243,7 +243,7 @@ static int ccp_crypto_enqueue_cmd(struct ccp_crypto_cmd *crypto_cmd) } if (req_queue.cmd_count >= CCP_CRYPTO_MAX_QLEN) { - ret = -EBUSY; + ret = -EIOCBQUEUED; if (req_queue.backlog == &req_queue.cmds) req_queue.backlog = &crypto_cmd->entry; } diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index 2506b50..b7006d7 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -269,7 +269,7 @@ EXPORT_SYMBOL_GPL(ccp_version); * Queue a cmd to be processed by the CCP. If queueing the cmd * would exceed the defined length of the cmd queue the cmd will * only be queued if the CCP_CMD_MAY_BACKLOG flag is set and will - * result in a return code of -EBUSY. + * result in a return code of -EIOCBQUEUED; * * The callback routine specified in the ccp_cmd struct will be * called to notify the caller of completion (if the cmd was not @@ -280,7 +280,7 @@ EXPORT_SYMBOL_GPL(ccp_version); * * The cmd has been successfully queued if: * the return code is -EINPROGRESS or - * the return code is -EBUSY and CCP_CMD_MAY_BACKLOG flag is set + * the return code is -EIOCBQUEUED */ int ccp_enqueue_cmd(struct ccp_cmd *cmd) { @@ -307,8 +307,10 @@ int ccp_enqueue_cmd(struct ccp_cmd *cmd) if (ccp->cmd_count >= MAX_CMD_QLEN) { ret = -EBUSY; - if (cmd->flags & CCP_CMD_MAY_BACKLOG) + if (cmd->flags & CCP_CMD_MAY_BACKLOG) { list_add_tail(&cmd->entry, &ccp->backlog); + ret = -EIOCBQUEUED; + } } else { ret = -EINPROGRESS; ccp->cmd_count++; diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c index e00be01..ab67304 100644 --- a/drivers/crypto/ccp/ccp-dmaengine.c +++ b/drivers/crypto/ccp/ccp-dmaengine.c @@ -146,7 +146,7 @@ static int ccp_issue_next_cmd(struct ccp_dma_desc *desc) desc->tx_desc.cookie, cmd); ret = ccp_enqueue_cmd(&cmd->ccp_cmd); - if (!ret || (ret == -EINPROGRESS) || (ret == -EBUSY)) + if (!ret || (ret == -EINPROGRESS) || (ret == -EIOCBQUEUED)) return 0; dev_dbg(desc->ccp->dev, "%s - error: ret=%d, tx %d, cmd=%p\n", __func__, From patchwork Sun Jul 2 14:41:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106846 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293047obb; Sun, 2 Jul 2017 07:44:21 -0700 (PDT) X-Received: by 10.84.128.102 with SMTP id 93mr5606405pla.21.1499006661066; Sun, 02 Jul 2017 07:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006661; cv=none; d=google.com; s=arc-20160816; b=ZjOVIl7ah77baTbw6iDxFSSHw55H1+F1me1uy+XfzAV3hiCq1PONNYVInvpX4uld49 4lTQKy5J2XOAj2jv5J/RGK0l25+qg25vQFhoWO9vnshOzkzcepO8lHB+TjE1sINz3YGJ jB+cW2xT2jFPpLUJrReQA4hCgfE23pMe2G2X7yenwR951RvZ8RaQGXcvUzCmVfIntSwd IBqk03+hWx+fZvhGxf0/eT6mgMzAs4JRCfrTT8myx/qhR6BAWvXZlxUFGFP1wgIZHl8N BC3+ohQKVMWXA6mCHjVJ0rKv8GRY3hM3a4lk45/8vK8L/gF8NCap9pXiw4YUsQvd7PyD vdpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ctFlAVM/rZxssevNrVNeLfvj9XmZ43ZmiYCMNdO3hiY=; b=SPXN/c7aJjUcwO+9X+zwrLDMHU7uWngfK/cZeuio7Y8rcaPkMPLfj8+Co8sDNPhLDB DBZqIhNS2+B0hkAlBfo+VrMHMN+X1NC5vrno9WGBLPX9oEZ3R1Q2rD9Gx6pN/pwSd1hK 9NUDTxEODGvWJoOdnttmyz6E3fn3N1BCjVjZPEz+JCYJVrbgFT01Ps/DWh/vOG6p3zhQ t4b0sg058yq8VvimeDVanYAGtBrDwzvGhHOTgoUXbVLR58bMH+PM+yzwno3icnKEiOha wGpOi34ujgh01eWm6DqGmTG1ZLzjJPOpAn5DnwuGL/7ROvqC/fm4LSuPJdBRm+DSnRvt pnPg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w125si10188980pfb.449.2017.07.02.07.44.20; Sun, 02 Jul 2017 07:44:21 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752404AbdGBOoD (ORCPT + 1 other); Sun, 2 Jul 2017 10:44:03 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53710 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752390AbdGBOn6 (ORCPT ); Sun, 2 Jul 2017 10:43:58 -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 DD041344; Sun, 2 Jul 2017 07:43:47 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E14C3F578; Sun, 2 Jul 2017 07:43:39 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 06/28] crypto: omap: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:48 +0300 Message-Id: <1499006535-19760-7-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/crypto/omap-sham.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index 9ad9d39..dfac821 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c @@ -1279,7 +1279,7 @@ static int omap_sham_finup(struct ahash_request *req) ctx->flags |= BIT(FLAGS_FINUP); err1 = omap_sham_update(req); - if (err1 == -EINPROGRESS || err1 == -EBUSY) + if (err1 == -EINPROGRESS || err1 == -EIOCBQUEUED) return err1; /* * final() has to be always called to cleanup resources From patchwork Sun Jul 2 14:41:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106847 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293052obb; Sun, 2 Jul 2017 07:44:21 -0700 (PDT) X-Received: by 10.84.211.136 with SMTP id c8mr5543365pli.96.1499006661417; Sun, 02 Jul 2017 07:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006661; cv=none; d=google.com; s=arc-20160816; b=DaQMvFYh6LKJfCT4JgKTrtfJxpgw7hNjMoZk8XyKfhODGY/9Eirs/kHd74fKC3ShUh noYN0L11Ycu4KaUoXtCiR9GOEoRtEnLiexiuaOUJS96jOepRLchwZ1oq2l3KzVKBLUZT GvSk3Odil77GQgLDQshCWTU71c4sK14R2P0ukx+jycNJrhlfvSxHlRel/3NtJezWZVlg IhduqsxhGWiJbwqLVxxuX+MGLOnU5rBIBK+pTWUXwYdvb+eEqB/BZvg0CrjvzzQTxuM0 ESJLetM8EgZc7zGWAOHCGPaGl75+9DkXeNQhDxWgO3zx0BjmX+a2jZaXw1QZeBsmUnFg p0sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=BBScG0KPSqUJY54N+RHRn+7/RMcqDXA9RpOSCHFFQqU=; b=o5CZl+iMCP3gOF8zjZ78fP84mc8BxuPN89L0Xn9zr5MkEKifeYuehroQTuHkwJ/z2l qP5JNqmUj9spFjGnPPy8qC+u1IyZd/NYNVLjeocfMtDzml7tE1r6Kfy6JT0KW3Ft9rj+ r0Bg2gv0FsfmVIxnnv42PZAGCA1yEcbXQYvktz6IqG+9a4brql0t1l13/dtvSEoG3eaU nDzIjaOV6tvxQ3AnZ95QLWMU8on4Hcq6elbdM/qe/nB7r5/A52HvBllHMPXbje3JCZ/b kkGWhaKkcYnMA+xjh7N7vD2n6N3tAjnuaJ/XTvPxh3YIhaG9YGYaX3okfUID7A+Rr1Db FN0g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w125si10188980pfb.449.2017.07.02.07.44.21; Sun, 02 Jul 2017 07:44:21 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752040AbdGBOoF (ORCPT + 1 other); Sun, 2 Jul 2017 10:44:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53758 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbdGBOoB (ORCPT ); Sun, 2 Jul 2017 10:44:01 -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 DCE9015B2; Sun, 2 Jul 2017 07:44:00 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 10B523F578; Sun, 2 Jul 2017 07:43:52 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 07/28] crypto: qce: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:49 +0300 Message-Id: <1499006535-19760-8-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/crypto/qce/sha.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 47e114a..a21d2a1c 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -421,7 +421,7 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, ahash_request_set_crypt(req, &sg, ctx->authkey, keylen); ret = crypto_ahash_digest(req); - if (ret == -EINPROGRESS || ret == -EBUSY) { + if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { ret = wait_for_completion_interruptible(&result.completion); if (!ret) ret = result.error; From patchwork Sun Jul 2 14:41:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106849 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293576obb; Sun, 2 Jul 2017 07:45:06 -0700 (PDT) X-Received: by 10.99.114.19 with SMTP id n19mr5571921pgc.81.1499006706329; Sun, 02 Jul 2017 07:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006706; cv=none; d=google.com; s=arc-20160816; b=zymx5XxAjjfrUCnwZ0CeLXb7OHL4Fu6BsfgaWE8wr5UBkoAW/cCsgMizju8rg0YsSq fsusBnbHm1XcbR7GU+a0iw6zd2w+RWSS5FoxpZ2YWqvmGr7W7VqqKi/cqSXc0NzxPOX+ nAqHo+8WQONLQz0r2XzDVhVV3LWLNl7eO+xcWRLOfIc75qY2stwaYr7SBUsfGizXc8ph WHIYDjUZcpyjHRDKg2BR9NzFowBL6Lhb3sgCWizrxXW3p2J1CqqCN7pxmwVSVvc56cPf umNZHT2PLqowVAQKCbIVnSQSPJ/ypPoss4sc3wp9CAc1Phy/OZovPfE4udVTNp6oAitf 1fiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rVBxj84DG5JK0J4YDQyxU3k8wsvoodOXpa6TgP//XW8=; b=WagwZl9R9SFsGuEJjxSymln8Ua8jwvZg8i2b/zXUo2CsNqKKdzgMG6L9P5jm2K6MFE PY5sV1KLoS+f1DZvwcpH1Y57Aev/C7OaMJSHNgxdiR018OF/InFgqo5tXvl5IqMqF4Go 8B6/ueogFFvl1Wm8X+t54p6xgNN7ZID9UXPHUfzYzfYjGN2zWlbCQ4pyUv4ZIrb+JLeO +wu8WCCYr/YpNMdfRUrNYjwBQCrekl3aQXdjNZ5ztGQGBhWqxX2Lorp4uQHtT9o+laNd eb+xgpVnqljNtLuq9GjN6m22VwkOMiikSpp2PWx94o7CBfMW9e+IqrFpQgIKis5s55yI eVJA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si2341484pfb.183.2017.07.02.07.45.06; Sun, 02 Jul 2017 07:45:06 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbdGBOou (ORCPT + 1 other); Sun, 2 Jul 2017 10:44:50 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53798 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbdGBOoa (ORCPT ); Sun, 2 Jul 2017 10:44:30 -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 685BA344; Sun, 2 Jul 2017 07:44:14 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8DB913F578; Sun, 2 Jul 2017 07:44:06 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 08/28] crypto: talitos: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:50 +0300 Message-Id: <1499006535-19760-9-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/crypto/talitos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 79791c6..0ab3c4d 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -2082,7 +2082,7 @@ static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, case 0: break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: ret = wait_for_completion_interruptible( &hresult.completion); if (!ret) From patchwork Sun Jul 2 14:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106848 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293197obb; Sun, 2 Jul 2017 07:44:32 -0700 (PDT) X-Received: by 10.99.142.202 with SMTP id k193mr5630078pge.86.1499006672875; Sun, 02 Jul 2017 07:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006672; cv=none; d=google.com; s=arc-20160816; b=mPEe1F0/1uKteBc7Kp6EIaTRA4PNiDp7hWfzRLzQBmgnr6d5G8SNMfFn/IogAqKRIB /9VQQGrKR/40kqcgpcxaIIPpBmWwwTd+34L2WiXtZLm4slX8yT2rJBjmQRGGjQZUBfxR e0pvezuz5YF5vyRVhOijU46cb2+3QkfqFAOSc+LBDAXOMCYCdhNQYl78iT5h0CqoETqQ o1D6c4V5S0klKfr2NhjK0dvvPDe660BuEaQOPGsCZTX0j6LmlNyVZz1C0Jv0Hr8hcrTo zA8y4eWkEfvLDDDkKi2wyzGBtZ8X8yI9RlCB9Dg4DliOjgIFoxK4+vtONJ4qotg3DRxA vgHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=idsu0cjfwq27booneepQ0ngshojpmNOoHTiKRHufSTU=; b=k7Dva+PNrLhX+BarivEGqB1+bNmOTpNqKNscBYE2GE4o8OOah+rtECE3c96A0PBVdj lTrenRAaTHBst8mf67UuxlNStfxoqLWkxfz7BEvrhab/TAornh0OCok1VyeImqPfdhST 6RcS5KvK3D/q3Sdg/nNQNpK19etsM42xbfu89k6fZYhrBCkKJnt1SuPML/3/x79KFxUy xYxox2rZZ4Omzq21Lz++hUieawSxV7dp4bFEQu+jUhbpipEEpHmgtaKwPnDUO5eVrfhX 2ZKB6nLHQcAMaR0mUvVp5ZfrHispfoYFZBs8g7eR+FZ4iIFC8h/6LcSPSEkFYK1xozS5 ePRA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w125si10188980pfb.449.2017.07.02.07.44.32; Sun, 02 Jul 2017 07:44:32 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752002AbdGBOoa (ORCPT + 1 other); Sun, 2 Jul 2017 10:44:30 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53850 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbdGBOo2 (ORCPT ); Sun, 2 Jul 2017 10:44:28 -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 A413B15B2; Sun, 2 Jul 2017 07:44:27 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C7CCF3F578; Sun, 2 Jul 2017 07:44:19 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 09/28] dm: verity: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:51 +0300 Message-Id: <1499006535-19760-10-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. drivers/md/dm-verity-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index b46705e..4fe7d18 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -116,7 +116,7 @@ static inline int verity_complete_op(struct verity_result *res, int ret) break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: ret = wait_for_completion_interruptible(&res->completion); if (!ret) ret = res->err; From patchwork Sun Jul 2 14:41:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106850 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293598obb; Sun, 2 Jul 2017 07:45:08 -0700 (PDT) X-Received: by 10.99.228.69 with SMTP id i5mr5486862pgk.192.1499006707998; Sun, 02 Jul 2017 07:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006707; cv=none; d=google.com; s=arc-20160816; b=pEfYmXc7tt5Pkf6KSz7lFUcMX/37Nk9szaj8ecjoyY3M29bd0Lq65Cl6wms+CybzKW e+pGXSLoCSpdjJYqplOvzhScud1NmJAKDYDaawCplqzWYni/6dtn+yg3O9TCG3qY6xCN DatNx2XYXGOGqufqfpxF69B2bgjIigeKDBIaPV1R0l6a20RLxBgN5mNYCoKllgSOe9uc L06FuYLJhN1lGJdc0BUld09K+pLM8FtbS9xPBAQqWc0C2g1epnVEMNsH+aysybK9DXgV zr6uwygefMuEgYkB+4PI0Gqk2oSAj4S4V8U6q/8j1nQqGMAaX+7+a4z5Wr4QbsLUmDa/ /N6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=IlzlfFQaEd2K5fNpzTP7A6BHcyqQkP/oI2LwUlvJwLs=; b=GKKmFkntg8qXRRNFAVN/INhBTXs977ptK/MJQY/1eF07xMT6N19emrFhJP5VkjSEK+ G8vUQv4UUotzePkbI0fY8VMyAC9FAtBG602Qq8DLNcSrSGQwZcdOiU0enZuT2I+98AJp gjUWMODPxowju4nwjyAOsxnLOMPsB9IbIsOxGFO5a4Ap3+pfA+E7n5G9ts9+t6ewi0jU 399Pl7bhBAT/BcCYJBlEWm606OysV1IeDv8TJ1eODIxkR8uo2KbCshZuE1jg/VZrpBpC GjZAgnXfpxlhOMGz86V2ZfIuNPHMRF4K3EmwvQbxsoCdRHkU9kueOfUAPif4CSFcvgaK GfZA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si2341484pfb.183.2017.07.02.07.45.07; Sun, 02 Jul 2017 07:45:07 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752532AbdGBOo6 (ORCPT + 1 other); Sun, 2 Jul 2017 10:44:58 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752510AbdGBOoz (ORCPT ); Sun, 2 Jul 2017 10:44:55 -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 1191D15B2; Sun, 2 Jul 2017 07:44:54 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2CFF53F578; Sun, 2 Jul 2017 07:44:45 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 11/28] cifs: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:53 +0300 Message-Id: <1499006535-19760-12-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. fs/cifs/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 941c40b..00b1143 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1934,7 +1934,7 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) rc = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); - if (rc == -EINPROGRESS || rc == -EBUSY) { + if (rc == -EINPROGRESS || rc == -EIOCBQUEUED) { wait_for_completion(&result.completion); rc = result.err; } From patchwork Sun Jul 2 14:41:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106852 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293991obb; Sun, 2 Jul 2017 07:45:38 -0700 (PDT) X-Received: by 10.98.69.219 with SMTP id n88mr5436085pfi.192.1499006738866; Sun, 02 Jul 2017 07:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006738; cv=none; d=google.com; s=arc-20160816; b=ylOaUxNrWdcYKD04znsP2vlCek7xQBsf3bbMnaWkBH7ORRJ+fSf236dCpjN2hQ/mLe hOcgzhq4DN0B8kBifvlI0YYMN4ODCaqLpp8+eY6ryiAfNj96dEq+kRU7Gf7tcgFXfuql G9lQgyRY50R+D35Y2KIDEaMjKOwAdBu0oSiTJEz92/I2kMxTwXFt1msVqd6ISIdyb7c5 YAanqCIt3pNmMJkgH2bJYBzKGM+vw2J+DTuZ8vwE5iz5ji4na8l7dDo+aebvbfVPecry JPW5qmaTAENEGCwCZRcZ/ublH+aIqJZEPY6M7HLvQfeutrFHG48/PUnF3GsMZWOUhGz0 zf2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KXKopzAbFVkafc0ewV0eh9vcAEbwuOiOW9EHlvGwon0=; b=komKp2HTI7UCwil+8xFjL5KvjCgZyFW03D+RQ3AjYaN2vSRsMgq6I6ZPRtp4d92DYu ttyoOvAH5MgNXvE5EAThtCvBtjzly5xtkOSPyfjs+e/SrF5HxNfB1bdbr2J4unXHI3Fz jI3wu60+cwh2CyPh8zPcqwNzVTIBSIAswca7WS16krlxjdCPIgAKSuegv+bisGK20LeB zdJVH9mt1w+lESkzYsA8JDDrtz0uxyR+LR6mjenm9H6p35GHAVUMTcVHGujIJ/noAm/W EdnBcTiI9wREIUtU5bwgm+R1tVxKGBP1yvVUEkmmi5zBaakGXwQF1ovxYoGPfJr8t1oH tAxg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si11118323pli.557.2017.07.02.07.45.38; Sun, 02 Jul 2017 07:45:38 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbdGBOpR (ORCPT + 1 other); Sun, 2 Jul 2017 10:45:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54008 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752228AbdGBOpN (ORCPT ); Sun, 2 Jul 2017 10:45:13 -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 72F4F344; Sun, 2 Jul 2017 07:45:07 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 998D13F578; Sun, 2 Jul 2017 07:44:59 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 12/28] ima: use -EIOCBQUEUED for backlog indication Date: Sun, 2 Jul 2017 17:41:54 +0300 Message-Id: <1499006535-19760-13-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. security/integrity/ima/ima_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c index 802d5d2..226dd88 100644 --- a/security/integrity/ima/ima_crypto.c +++ b/security/integrity/ima/ima_crypto.c @@ -212,7 +212,7 @@ static int ahash_wait(int err, struct ahash_completion *res) case 0: break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: wait_for_completion(&res->completion); reinit_completion(&res->completion); err = res->err; From patchwork Sun Jul 2 14:41:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106853 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8293994obb; Sun, 2 Jul 2017 07:45:39 -0700 (PDT) X-Received: by 10.98.133.211 with SMTP id m80mr5411002pfk.164.1499006739180; Sun, 02 Jul 2017 07:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006739; cv=none; d=google.com; s=arc-20160816; b=PnTBhHEqM4pA0TRkUjSbwjMKhUDXwx8RJkKe67r+BE7DrCR7Nc4lNUDk/ws9SCq1TN PJqwaSzkSJd3jw9SuirCU0wXPaQ8DClxAHIrN0wm+/REJNTRPyzAKVmINbVtwgT3fu5i bMeyNpi1KMX+aHl+VrYhxIjA5vABLHq4WMTH6ZrAZruA6mqwxmz3j+sgtvzp+n2Fx2nB 2olcw1ecXRM7rhWsBYpp17Y8+/O4j/CVJk0qN+oUuN8RL9/ZvCGAEiYbXFFa8I58gRO7 qHHtmyn/t/5h2MYbCreuBpeENCNBBpwl3TMOA6BPH+z0K1SM7/baZx0bfuwhWPzARHn7 bNzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8SERSYDba/ci+vJ63j1m588uTGoj9iOtcPglZrg1rM0=; b=TRq0TDVvF0Ts6crpeL+LOXHUsKJD/uICSlfDMmwd44Fc1ivYmV+ZFaSB4Mfxr1/fUd Pkq0NCS53goeZ2jY8hroL1Qz8z8ZaG28mMKkymv9raXY12o0V1tysFHUFQRPPG+IJILJ qRLiIElTAd+6AolvC5xL/BwxP9/NBYoa2V9Hi3DSt7fjm3/e+/yCsvqx6qyWYjNRHGxg cX114t1p0ADjnIvD4pF/yK1rVDZCoQoym9tFqCTPSXRkP5S+ISG9WwcTcTe4ymi0ay+G lwCL8/eVss84YwNce3aGoOsUo4C0zzCFPSVZVqrXRswEmDxeVGNgnK5mV5WZBO1LsqAA 56zQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si11118323pli.557.2017.07.02.07.45.38; Sun, 02 Jul 2017 07:45:39 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752256AbdGBOpZ (ORCPT + 1 other); Sun, 2 Jul 2017 10:45:25 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54066 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752609AbdGBOpV (ORCPT ); Sun, 2 Jul 2017 10:45:21 -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 6A00D15B2; Sun, 2 Jul 2017 07:45:20 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8EB893F578; Sun, 2 Jul 2017 07:45:12 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 13/28] crypto: adapt api sample to -EIOCBQUEUED as backlog indication Date: Sun, 2 Jul 2017 17:41:55 +0300 Message-Id: <1499006535-19760-14-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Replace -EBUSY with -EIOCBQUEUED for backlog queueing indication as part of new API. Signed-off-by: Gilad Ben-Yossef --- This patch should be squashed with the first patch in the series when applied. Documentation/crypto/api-samples.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.1.4 diff --git a/Documentation/crypto/api-samples.rst b/Documentation/crypto/api-samples.rst index 2531948..c6aa4ba 100644 --- a/Documentation/crypto/api-samples.rst +++ b/Documentation/crypto/api-samples.rst @@ -47,7 +47,7 @@ Code Example For Symmetric Key Cipher Operation case 0: break; case -EINPROGRESS: - case -EBUSY: + case -EIOCBQUEUED: rc = wait_for_completion_interruptible( &sk->result.completion); if (!rc && !sk->result.err) { From patchwork Sun Jul 2 14:41:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106854 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8294071obb; Sun, 2 Jul 2017 07:45:46 -0700 (PDT) X-Received: by 10.98.163.203 with SMTP id q72mr5280258pfl.97.1499006746760; Sun, 02 Jul 2017 07:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006746; cv=none; d=google.com; s=arc-20160816; b=o1GTqQoz8PQARIXvvZjwL/I4hRr7avTrOyJCNOB4uvxkQjM7ylUqT9iccGlNqfnOZB A4ApjIYKUd0TGMweygXHYqbsK7706U3yftOS6Qi9+FwOqycZdddkp0OaNenvTZWvIclB Oej8JjKPilvo18BgsoFxdZuFKgx6+FYZcilfGUe8jSg9gsjh9f8iH6UFNo3dE0AHhcJB P+t0Oi+Lk4iRx6y73GZN8fOS5Xtsu+GMwHq5EjuvDKfy1pXGIa644Tm+yNVaOo4377z5 f9I/hZQXYMEn7p9JZ41XKBeJOC2g0Gr8WvoTkcSatNUN5hGf5Y5yXKX+AQ3lZXPAz8J7 NLzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8yGWbKKEOdzYXLhBpYrs90p4S6mZKVD/hPBAgNOytcE=; b=YNY8uZdX8xFz/ezIGoKjB/UJF30JKHjr6fW/HJyi9R9Ov7/uvdV4hFPP89oAopj/O0 Kz4cFYR7r5LD/U4oayeWuZAtHDhKbEw6G6OmK1w9ZJbXJOXZivRGMj//MXvpyaw9VDvn tWE33pwoHb/t+L444VwiserTSY1IZhzwLyid3Qi6uFfp1dkOiCNZr9Q1jH0SzmTbpBIF QU1rvqgq6KLuYrClV8O7SAA4X0RaB7xM3atagFYh7xIbKwDgwopdpiYp0p6aHowZzwtJ jWSjWKJXn0odaVZfFuiT4EI/DOU5hKvDcWVyEy6JDCAG2xayO7bfBXgyy5A+9x1lJJgu MTAw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si11118323pli.557.2017.07.02.07.45.46; Sun, 02 Jul 2017 07:45:46 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752282AbdGBOpn (ORCPT + 1 other); Sun, 2 Jul 2017 10:45:43 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54124 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751934AbdGBOpj (ORCPT ); Sun, 2 Jul 2017 10:45:39 -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 9F1CF344; Sun, 2 Jul 2017 07:45:33 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F1103F578; Sun, 2 Jul 2017 07:45:25 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang , Eric Biggers Subject: [PATCH v3 14/28] crypto: introduce crypto wait for async op Date: Sun, 2 Jul 2017 17:41:56 +0300 Message-Id: <1499006535-19760-15-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Invoking a possibly async. crypto op and waiting for completion while correctly handling backlog processing is a common task in the crypto API implementation and outside users of it. This patch adds a generic implementation for doing so in preparation for using it across the board instead of hand rolled versions. Signed-off-by: Gilad Ben-Yossef CC: Eric Biggers --- crypto/api.c | 13 +++++++++++++ include/linux/crypto.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) -- 2.1.4 diff --git a/crypto/api.c b/crypto/api.c index 941cd4c..2a2479d 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "internal.h" LIST_HEAD(crypto_alg_list); @@ -595,5 +596,17 @@ int crypto_has_alg(const char *name, u32 type, u32 mask) } EXPORT_SYMBOL_GPL(crypto_has_alg); +void crypto_req_done(struct crypto_async_request *req, int err) +{ + struct crypto_wait *wait = req->data; + + if (err == -EINPROGRESS) + return; + + wait->err = err; + complete(&wait->completion); +} +EXPORT_SYMBOL_GPL(crypto_req_done); + MODULE_DESCRIPTION("Cryptographic core API"); MODULE_LICENSE("GPL"); diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 84da997..47e884a 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -24,6 +24,7 @@ #include #include #include +#include /* * Autoloaded crypto modules should only use a prefixed name to avoid allowing @@ -468,6 +469,45 @@ struct crypto_alg { } CRYPTO_MINALIGN_ATTR; /* + * A helper struct for waiting for completion of async crypto ops + */ +struct crypto_wait { + struct completion completion; + int err; +}; + +/* + * Macro for declaring a crypto op async wait object on stack + */ +#define DECLARE_CRYPTO_WAIT(_wait) \ + struct crypto_wait _wait = { \ + COMPLETION_INITIALIZER_ONSTACK((_wait).completion), 0 } + +/* + * Async ops completion helper functioons + */ +void crypto_req_done(struct crypto_async_request *req, int err); + +static inline int crypto_wait_req(int err, struct crypto_wait *wait) +{ + switch (err) { + case -EINPROGRESS: + case -EIOCBQUEUED: + wait_for_completion(&wait->completion); + reinit_completion(&wait->completion); + err = wait->err; + break; + }; + + return err; +} + +static inline void crypto_init_wait(struct crypto_wait *wait) +{ + init_completion(&wait->completion); +} + +/* * Algorithm registration interface. */ int crypto_register_alg(struct crypto_alg *alg); From patchwork Sun Jul 2 14:41:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106857 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8294732obb; Sun, 2 Jul 2017 07:46:37 -0700 (PDT) X-Received: by 10.98.62.131 with SMTP id y3mr5318198pfj.49.1499006797285; Sun, 02 Jul 2017 07:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006797; cv=none; d=google.com; s=arc-20160816; b=psqH/juL6zq/hH70i4HxmNvhwtzNgq4hY2Ih5gUYKRFbE4L47CdVETrQiP+xNIQkGz Fi1egfna2zPRRLeYb/HDilD+kAoEojlsRtkPZblU2ADtG3BKfICfptO633cjH456cSXO uXQCWi82zrHlnMlK8LQb2gONBbnBk3B4qgODr/6DqfC2CBqS5A23/ooJ33YCVhDJzVM3 EOrDPZPx3Pf686taITmNmtP1rQ1feREEHb+zS4UHGkGIGDSaPWmIRdHbgdiv4cBHqW5G 6RUMxMmV867xD5DBEnyIzROozltl6rj9m4qvtWNqx6Xtugyb3eBmwdHwFqrc5uPS7KDu KDdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Q/mQUOZ2I/IDsPdwViUV0gX6y/zy6Us2KsWAvNRyyxI=; b=s1ocJJuzHFjvAuzd7riteY9EFDqxEvz+EBFHDfcpQRTNfCUYH1DjRwvBW5alAjxvNt HT6fQox7Eqn5K1v3zOTmUauB9iaV0Foak1YIJiKeeJhpPEpUVkWXx4OvEbczZ9wp7FK+ o3bVH6Zh1kjcVlqCnMaD4zDtshJ4GCFOtt5K560DUn9elyJY7NXrc6Eamxe6Ddb/bMZz xYsTEOwszMYdXSzfzTCWXPCqtPcoGk3McGuzQsUBkr8J63pY+bJQA0zOmbg5U7wfLB2f 8wuHEIiXM7Hjhor/CmKC/Vf75NEjAfBcStWWvb4GM1l53GthholPWKiXQsMi9E3VYeQ0 Wu5A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y69si10330627pfb.190.2017.07.02.07.46.37; Sun, 02 Jul 2017 07:46:37 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752488AbdGBOq1 (ORCPT + 1 other); Sun, 2 Jul 2017 10:46:27 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54298 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbdGBOqY (ORCPT ); Sun, 2 Jul 2017 10:46:24 -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 DA8FD164F; Sun, 2 Jul 2017 07:46:13 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 09DA93F578; Sun, 2 Jul 2017 07:46:05 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 17/28] crypto: move drbg to generic async completion Date: Sun, 2 Jul 2017 17:41:59 +0300 Message-Id: <1499006535-19760-18-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org DRBG is starting an async. crypto op and waiting for it complete. Move it over to generic code doing the same. The code now also passes CRYPTO_TFM_REQ_MAY_SLEEP flag indicating crypto request memory allocation may use GFP_KERNEL which should be perfectly fine as the code is obviously sleeping for the completion of the request any way. Signed-off-by: Gilad Ben-Yossef Acked-by: Stephan Muller --- crypto/drbg.c | 36 +++++++++--------------------------- include/crypto/drbg.h | 3 +-- 2 files changed, 10 insertions(+), 29 deletions(-) -- 2.1.4 diff --git a/crypto/drbg.c b/crypto/drbg.c index 850b451..c522251 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1651,16 +1651,6 @@ static int drbg_fini_sym_kernel(struct drbg_state *drbg) return 0; } -static void drbg_skcipher_cb(struct crypto_async_request *req, int error) -{ - struct drbg_state *drbg = req->data; - - if (error == -EINPROGRESS) - return; - drbg->ctr_async_err = error; - complete(&drbg->ctr_completion); -} - static int drbg_init_sym_kernel(struct drbg_state *drbg) { struct crypto_cipher *tfm; @@ -1691,7 +1681,7 @@ static int drbg_init_sym_kernel(struct drbg_state *drbg) return PTR_ERR(sk_tfm); } drbg->ctr_handle = sk_tfm; - init_completion(&drbg->ctr_completion); + crypto_init_wait(&drbg->ctr_wait); req = skcipher_request_alloc(sk_tfm, GFP_KERNEL); if (!req) { @@ -1700,8 +1690,9 @@ static int drbg_init_sym_kernel(struct drbg_state *drbg) return -ENOMEM; } drbg->ctr_req = req; - skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - drbg_skcipher_cb, drbg); + skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | + CRYPTO_TFM_REQ_MAY_SLEEP, + crypto_req_done, &drbg->ctr_wait); alignmask = crypto_skcipher_alignmask(sk_tfm); drbg->ctr_null_value_buf = kzalloc(DRBG_CTR_NULL_LEN + alignmask, @@ -1762,21 +1753,12 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg, /* Output buffer may not be valid for SGL, use scratchpad */ skcipher_request_set_crypt(drbg->ctr_req, &sg_in, &sg_out, cryptlen, drbg->V); - ret = crypto_skcipher_encrypt(drbg->ctr_req); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&drbg->ctr_completion); - if (!drbg->ctr_async_err) { - reinit_completion(&drbg->ctr_completion); - break; - } - default: + ret = crypto_wait_req(crypto_skcipher_encrypt(drbg->ctr_req), + &drbg->ctr_wait); + if (ret) goto out; - } - init_completion(&drbg->ctr_completion); + + crypto_init_wait(&drbg->ctr_wait); memcpy(outbuf, drbg->outscratchpad, cryptlen); diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h index 22f884c..8f94110 100644 --- a/include/crypto/drbg.h +++ b/include/crypto/drbg.h @@ -126,8 +126,7 @@ struct drbg_state { __u8 *ctr_null_value; /* CTR mode aligned zero buf */ __u8 *outscratchpadbuf; /* CTR mode output scratchpad */ __u8 *outscratchpad; /* CTR mode aligned outbuf */ - struct completion ctr_completion; /* CTR mode async handler */ - int ctr_async_err; /* CTR mode async error */ + struct crypto_wait ctr_wait; /* CTR mode async wait obj */ bool seeded; /* DRBG fully seeded? */ bool pr; /* Prediction resistance enabled? */ From patchwork Sun Jul 2 14:42:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106868 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8297486obb; Sun, 2 Jul 2017 07:50:05 -0700 (PDT) X-Received: by 10.98.85.196 with SMTP id j187mr5330981pfb.19.1499007005143; Sun, 02 Jul 2017 07:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499007005; cv=none; d=google.com; s=arc-20160816; b=ldHw692/SaZ+vb5Yct6itnYKrXKOa4p7Thbdo+vXZXO22HA9bwe8VUUTf1ARsJ1Rd5 w3tkMavtG2zfEhYcCEpWBTsaXPO9s9sCQDpg3cxwM4kEgHLP7NCl4ylnT+/Npk4hUDJu VaNDjp/7kalDtIUMx6j5jJHKJred+dG0wkY6TgOyT5D3CUv634GCp7G0Y8dU/68q/+wn HxrOS/jqb3ucKJuSSjRqBBCHacdI4wvEWaDCjNCfDMtvaG6N9KOGhdcAaAAh11nJa8sE RROHN/tFPwxvG0wnIIWhYS+LhgzXph03vIPl0a0occejcp1PKh9Qmv3k5SUHXo7SrIHg h+yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=IpO9WY3n0iy6qRhnC7gV9XsZJQSs0iNF6ZSgh3S2UOU=; b=z3aPtWlAq+knZDjbhLX2b+x0qOJeYiDRd8Fmu0evVyOcD0epHUEqETGHcpuKV4DLAT g+mTRah7/a7Mhn3TCnY8cUCIxBHufIiXo2J51gQbB36VlbDSgz6du1E1a18ExQNQEXmo HLYgMA3UYf5Y5mizKQFoapht9rCkfZ9VKujKEeZeEYhQXGyaYiM4XWgkeMqj5KOr5Fl9 xvMdrVRHwiZiYbbPAyj4nJjo63m1DxKHOdnOnCP9OqAap0pn6WR/88DUhMp4GDHH4K2D H+0fdqLwLvRBwgFz+dDajah+/UsTJ/LQc8QhLybbXj9NdgBLZIctY3znxSxo359kBxKq mN/Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i127si10301592pgc.170.2017.07.02.07.50.04; Sun, 02 Jul 2017 07:50:05 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbdGBOtx (ORCPT + 1 other); Sun, 2 Jul 2017 10:49:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54350 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752421AbdGBOqn (ORCPT ); Sun, 2 Jul 2017 10:46:43 -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 D22DA344; Sun, 2 Jul 2017 07:46:26 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 393E33F578; Sun, 2 Jul 2017 07:46:19 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 18/28] crypto: move gcm to generic async completion Date: Sun, 2 Jul 2017 17:42:00 +0300 Message-Id: <1499006535-19760-19-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org gcm is starting an async. crypto op and waiting for it complete. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- crypto/gcm.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/crypto/gcm.c b/crypto/gcm.c index ffac821..fb923a5 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -16,7 +16,6 @@ #include #include #include "internal.h" -#include #include #include #include @@ -78,11 +77,6 @@ struct crypto_gcm_req_priv_ctx { } u; }; -struct crypto_gcm_setkey_result { - int err; - struct completion completion; -}; - static struct { u8 buf[16]; struct scatterlist sg; @@ -98,17 +92,6 @@ static inline struct crypto_gcm_req_priv_ctx *crypto_gcm_reqctx( return (void *)PTR_ALIGN((u8 *)aead_request_ctx(req), align + 1); } -static void crypto_gcm_setkey_done(struct crypto_async_request *req, int err) -{ - struct crypto_gcm_setkey_result *result = req->data; - - if (err == -EINPROGRESS) - return; - - result->err = err; - complete(&result->completion); -} - static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, unsigned int keylen) { @@ -119,7 +102,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, be128 hash; u8 iv[16]; - struct crypto_gcm_setkey_result result; + struct crypto_wait wait; struct scatterlist sg[1]; struct skcipher_request req; @@ -140,21 +123,18 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, if (!data) return -ENOMEM; - init_completion(&data->result.completion); + crypto_init_wait(&data->wait); sg_init_one(data->sg, &data->hash, sizeof(data->hash)); skcipher_request_set_tfm(&data->req, ctr); skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - crypto_gcm_setkey_done, - &data->result); + crypto_req_done, + &data->wait); skcipher_request_set_crypt(&data->req, data->sg, data->sg, sizeof(data->hash), data->iv); - err = crypto_skcipher_encrypt(&data->req); - if (err == -EINPROGRESS || err == -EIOCBQUEUED) { - wait_for_completion(&data->result.completion); - err = data->result.err; - } + err = crypto_wait_req(crypto_skcipher_encrypt(&data->req), + &data->wait); if (err) goto out; From patchwork Sun Jul 2 14:42:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106858 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8294983obb; Sun, 2 Jul 2017 07:46:58 -0700 (PDT) X-Received: by 10.98.110.132 with SMTP id j126mr5451779pfc.115.1499006818321; Sun, 02 Jul 2017 07:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006818; cv=none; d=google.com; s=arc-20160816; b=JapPLR9xpfgQP2JsoBQ+twaDUa/7Qj8njimiLAH3t3cXJFVlUhmtb/kLRxEGmtSB2C MJ+LSUXSLQ+Lpg7Ljd0yx50uKoBvW++ZyOwgh0jwx4iOzIGGkMkEeuhXf+C79h/dXcis cF4s5dmqOPr6VCCdj6zHL3bfRrgYK3hpIZPlwXU5sXj7egKouPFBs1dNKUUVEpJZvuf4 1jlvM9AyDJaiGUM7vQT1SCn3w9dHosuQStymeJGS0flk8iowzS5gbxUtK/+BzZLAEKFx YiKinBLy5KNfxesSzcurdc6cWy8oQHTC5CpwBYeMeZxXwMlxJSp4dP2FINqCOPw3wRGc jOrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=sFtILIfhDFgDsluzj5kIuBvGwatd3hNwG45yyXi5uqE=; b=EMTKgz0dyjMeMaMxkoNN0k2mJ0WYN9e7XXiLfpmik9Hzr+um874n7zfhWYvd6XIv7s Ep0S/ujv8RPh1uuQ5JAKfjrNVTy5Okc8VEGLqhqBOdS2qQ6MooJzjfrUxjkVwg6bxbpU WYtvdxrUQfBALh/PAc8APNN9Ekqtr9DnfIfykForGNtfjWR//FShorT2VeeMIIDSm112 vfaDqoHSGOTL+3CK4elZEkxXKomnYfUAUp7xRzBjVocJ+EHnO+jBQ6jKHgDsDVRTil8L GVh6U8oefF9O7mcFq0k5r453sXGDLcJXUlCWo1q7tdyeBkcs+QZXAqm3h8QOI1hzCnNM 1kTw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i185si9998376pge.481.2017.07.02.07.46.58; Sun, 02 Jul 2017 07:46:58 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752511AbdGBOqo (ORCPT + 1 other); Sun, 2 Jul 2017 10:46:44 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54418 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752244AbdGBOqk (ORCPT ); Sun, 2 Jul 2017 10:46:40 -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 F3ABA15B2; Sun, 2 Jul 2017 07:46:39 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2751D3F578; Sun, 2 Jul 2017 07:46:31 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 19/28] crypto: move testmgr to generic async completion Date: Sun, 2 Jul 2017 17:42:01 +0300 Message-Id: <1499006535-19760-20-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org testmgr is starting async. crypto ops and waiting for them to complete. Move it over to generic code doing the same. This also provides a test of the generic crypto async. wait code. Signed-off-by: Gilad Ben-Yossef --- crypto/testmgr.c | 204 ++++++++++++++++++------------------------------------- 1 file changed, 66 insertions(+), 138 deletions(-) -- 2.1.4 diff --git a/crypto/testmgr.c b/crypto/testmgr.c index fb5418f..c998b85 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -76,11 +76,6 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) #define ENCRYPT 1 #define DECRYPT 0 -struct tcrypt_result { - struct completion completion; - int err; -}; - struct aead_test_suite { struct { const struct aead_testvec *vecs; @@ -155,17 +150,6 @@ static void hexdump(unsigned char *buf, unsigned int len) buf, len, false); } -static void tcrypt_complete(struct crypto_async_request *req, int err) -{ - struct tcrypt_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int testmgr_alloc_buf(char *buf[XBUFSIZE]) { int i; @@ -193,20 +177,10 @@ static void testmgr_free_buf(char *buf[XBUFSIZE]) free_page((unsigned long)buf[i]); } -static int wait_async_op(struct tcrypt_result *tr, int ret) -{ - if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { - wait_for_completion(&tr->completion); - reinit_completion(&tr->completion); - ret = tr->err; - } - return ret; -} - static int ahash_partial_update(struct ahash_request **preq, struct crypto_ahash *tfm, const struct hash_testvec *template, void *hash_buff, int k, int temp, struct scatterlist *sg, - const char *algo, char *result, struct tcrypt_result *tresult) + const char *algo, char *result, struct crypto_wait *wait) { char *state; struct ahash_request *req; @@ -236,7 +210,7 @@ static int ahash_partial_update(struct ahash_request **preq, } ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, tresult); + crypto_req_done, wait); memcpy(hash_buff, template->plaintext + temp, template->tap[k]); @@ -247,7 +221,7 @@ static int ahash_partial_update(struct ahash_request **preq, pr_err("alg: hash: Failed to import() for %s\n", algo); goto out; } - ret = wait_async_op(tresult, crypto_ahash_update(req)); + ret = crypto_wait_req(crypto_ahash_update(req), wait); if (ret) goto out; *preq = req; @@ -272,7 +246,7 @@ static int __test_hash(struct crypto_ahash *tfm, char *result; char *key; struct ahash_request *req; - struct tcrypt_result tresult; + struct crypto_wait wait; void *hash_buff; char *xbuf[XBUFSIZE]; int ret = -ENOMEM; @@ -286,7 +260,7 @@ static int __test_hash(struct crypto_ahash *tfm, if (testmgr_alloc_buf(xbuf)) goto out_nobuf; - init_completion(&tresult.completion); + crypto_init_wait(&wait); req = ahash_request_alloc(tfm, GFP_KERNEL); if (!req) { @@ -295,7 +269,7 @@ static int __test_hash(struct crypto_ahash *tfm, goto out_noreq; } ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &tresult); + crypto_req_done, &wait); j = 0; for (i = 0; i < tcount; i++) { @@ -335,26 +309,26 @@ static int __test_hash(struct crypto_ahash *tfm, ahash_request_set_crypt(req, sg, result, template[i].psize); if (use_digest) { - ret = wait_async_op(&tresult, crypto_ahash_digest(req)); + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); if (ret) { pr_err("alg: hash: digest failed on test %d " "for %s: ret=%d\n", j, algo, -ret); goto out; } } else { - ret = wait_async_op(&tresult, crypto_ahash_init(req)); + ret = crypto_wait_req(crypto_ahash_init(req), &wait); if (ret) { pr_err("alg: hash: init failed on test %d " "for %s: ret=%d\n", j, algo, -ret); goto out; } - ret = wait_async_op(&tresult, crypto_ahash_update(req)); + ret = crypto_wait_req(crypto_ahash_update(req), &wait); if (ret) { pr_err("alg: hash: update failed on test %d " "for %s: ret=%d\n", j, algo, -ret); goto out; } - ret = wait_async_op(&tresult, crypto_ahash_final(req)); + ret = crypto_wait_req(crypto_ahash_final(req), &wait); if (ret) { pr_err("alg: hash: final failed on test %d " "for %s: ret=%d\n", j, algo, -ret); @@ -420,22 +394,10 @@ static int __test_hash(struct crypto_ahash *tfm, } ahash_request_set_crypt(req, sg, result, template[i].psize); - ret = crypto_ahash_digest(req); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&tresult.completion); - reinit_completion(&tresult.completion); - ret = tresult.err; - if (!ret) - break; - /* fall through */ - default: - printk(KERN_ERR "alg: hash: digest failed " - "on chunking test %d for %s: " - "ret=%d\n", j, algo, -ret); + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); + if (ret) { + pr_err("alg: hash: digest failed on chunking test %d for %s: ret=%d\n", + j, algo, -ret); goto out; } @@ -486,13 +448,13 @@ static int __test_hash(struct crypto_ahash *tfm, } ahash_request_set_crypt(req, sg, result, template[i].tap[0]); - ret = wait_async_op(&tresult, crypto_ahash_init(req)); + ret = crypto_wait_req(crypto_ahash_init(req), &wait); if (ret) { pr_err("alg: hash: init failed on test %d for %s: ret=%d\n", j, algo, -ret); goto out; } - ret = wait_async_op(&tresult, crypto_ahash_update(req)); + ret = crypto_wait_req(crypto_ahash_update(req), &wait); if (ret) { pr_err("alg: hash: update failed on test %d for %s: ret=%d\n", j, algo, -ret); @@ -503,7 +465,7 @@ static int __test_hash(struct crypto_ahash *tfm, for (k = 1; k < template[i].np; k++) { ret = ahash_partial_update(&req, tfm, &template[i], hash_buff, k, temp, &sg[0], algo, result, - &tresult); + &wait); if (ret) { pr_err("alg: hash: partial update failed on test %d for %s: ret=%d\n", j, algo, -ret); @@ -511,7 +473,7 @@ static int __test_hash(struct crypto_ahash *tfm, } temp += template[i].tap[k]; } - ret = wait_async_op(&tresult, crypto_ahash_final(req)); + ret = crypto_wait_req(crypto_ahash_final(req), &wait); if (ret) { pr_err("alg: hash: final failed on test %d for %s: ret=%d\n", j, algo, -ret); @@ -580,7 +542,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, struct scatterlist *sg; struct scatterlist *sgout; const char *e, *d; - struct tcrypt_result result; + struct crypto_wait wait; unsigned int authsize, iv_len; void *input; void *output; @@ -619,7 +581,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, else e = "decryption"; - init_completion(&result.completion); + crypto_init_wait(&wait); req = aead_request_alloc(tfm, GFP_KERNEL); if (!req) { @@ -629,7 +591,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, } aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); iv_len = crypto_aead_ivsize(tfm); @@ -709,7 +671,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc, aead_request_set_ad(req, template[i].alen); - ret = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); + ret = crypto_wait_req(enc ? crypto_aead_encrypt(req) + : crypto_aead_decrypt(req), &wait); switch (ret) { case 0: @@ -722,13 +685,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, goto out; } break; - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; case -EBADMSG: if (template[i].novrfy) /* verification failure was expected */ @@ -866,7 +822,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc, aead_request_set_ad(req, template[i].alen); - ret = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); + ret = crypto_wait_req(enc ? crypto_aead_encrypt(req) + : crypto_aead_decrypt(req), &wait); switch (ret) { case 0: @@ -879,13 +836,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, goto out; } break; - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; case -EBADMSG: if (template[i].novrfy) /* verification failure was expected */ @@ -1083,7 +1033,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, struct scatterlist sg[8]; struct scatterlist sgout[8]; const char *e, *d; - struct tcrypt_result result; + struct crypto_wait wait; void *data; char iv[MAX_IVLEN]; char *xbuf[XBUFSIZE]; @@ -1107,7 +1057,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, else e = "decryption"; - init_completion(&result.completion); + crypto_init_wait(&wait); req = skcipher_request_alloc(tfm, GFP_KERNEL); if (!req) { @@ -1117,7 +1067,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); j = 0; for (i = 0; i < tcount; i++) { @@ -1164,21 +1114,10 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, template[i].ilen, iv); - ret = enc ? crypto_skcipher_encrypt(req) : - crypto_skcipher_decrypt(req); + ret = crypto_wait_req(enc ? crypto_skcipher_encrypt(req) : + crypto_skcipher_decrypt(req), &wait); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; - /* fall through */ - default: + if (ret) { pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n", d, e, j, algo, -ret); goto out; @@ -1272,21 +1211,10 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, template[i].ilen, iv); - ret = enc ? crypto_skcipher_encrypt(req) : - crypto_skcipher_decrypt(req); + ret = crypto_wait_req(enc ? crypto_skcipher_encrypt(req) : + crypto_skcipher_decrypt(req), &wait); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EIOCBQUEUED: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; - /* fall through */ - default: + if (ret) { pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n", d, e, j, algo, -ret); goto out; @@ -1462,7 +1390,7 @@ static int test_acomp(struct crypto_acomp *tfm, int ret; struct scatterlist src, dst; struct acomp_req *req; - struct tcrypt_result result; + struct crypto_wait wait; output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); if (!output) @@ -1486,7 +1414,7 @@ static int test_acomp(struct crypto_acomp *tfm, } memset(output, 0, dlen); - init_completion(&result.completion); + crypto_init_wait(&wait); sg_init_one(&src, input_vec, ilen); sg_init_one(&dst, output, dlen); @@ -1501,9 +1429,9 @@ static int test_acomp(struct crypto_acomp *tfm, acomp_request_set_params(req, &src, &dst, ilen, dlen); acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); - ret = wait_async_op(&result, crypto_acomp_compress(req)); + ret = crypto_wait_req(crypto_acomp_compress(req), &wait); if (ret) { pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); @@ -1516,10 +1444,10 @@ static int test_acomp(struct crypto_acomp *tfm, dlen = COMP_BUF_SIZE; sg_init_one(&src, output, ilen); sg_init_one(&dst, decomp_out, dlen); - init_completion(&result.completion); + crypto_init_wait(&wait); acomp_request_set_params(req, &src, &dst, ilen, dlen); - ret = wait_async_op(&result, crypto_acomp_decompress(req)); + ret = crypto_wait_req(crypto_acomp_decompress(req), &wait); if (ret) { pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); @@ -1563,7 +1491,7 @@ static int test_acomp(struct crypto_acomp *tfm, } memset(output, 0, dlen); - init_completion(&result.completion); + crypto_init_wait(&wait); sg_init_one(&src, input_vec, ilen); sg_init_one(&dst, output, dlen); @@ -1578,9 +1506,9 @@ static int test_acomp(struct crypto_acomp *tfm, acomp_request_set_params(req, &src, &dst, ilen, dlen); acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); - ret = wait_async_op(&result, crypto_acomp_decompress(req)); + ret = crypto_wait_req(crypto_acomp_decompress(req), &wait); if (ret) { pr_err("alg: acomp: decompression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); @@ -2000,7 +1928,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, void *a_public = NULL; void *a_ss = NULL; void *shared_secret = NULL; - struct tcrypt_result result; + struct crypto_wait wait; unsigned int out_len_max; int err = -ENOMEM; struct scatterlist src, dst; @@ -2009,7 +1937,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, if (!req) return err; - init_completion(&result.completion); + crypto_init_wait(&wait); err = crypto_kpp_set_secret(tfm, vec->secret, vec->secret_size); if (err < 0) @@ -2027,10 +1955,10 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, sg_init_one(&dst, output_buf, out_len_max); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); /* Compute party A's public key */ - err = wait_async_op(&result, crypto_kpp_generate_public_key(req)); + err = crypto_wait_req(crypto_kpp_generate_public_key(req), &wait); if (err) { pr_err("alg: %s: Party A: generate public key test failed. err %d\n", alg, err); @@ -2069,8 +1997,8 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, kpp_request_set_input(req, &src, vec->b_public_size); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); - err = wait_async_op(&result, crypto_kpp_compute_shared_secret(req)); + crypto_req_done, &wait); + err = crypto_wait_req(crypto_kpp_compute_shared_secret(req), &wait); if (err) { pr_err("alg: %s: Party A: compute shared secret test failed. err %d\n", alg, err); @@ -2100,9 +2028,9 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, kpp_request_set_input(req, &src, vec->expected_a_public_size); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); - err = wait_async_op(&result, - crypto_kpp_compute_shared_secret(req)); + crypto_req_done, &wait); + err = crypto_wait_req(crypto_kpp_compute_shared_secret(req), + &wait); if (err) { pr_err("alg: %s: Party B: compute shared secret failed. err %d\n", alg, err); @@ -2179,7 +2107,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, struct akcipher_request *req; void *outbuf_enc = NULL; void *outbuf_dec = NULL; - struct tcrypt_result result; + struct crypto_wait wait; unsigned int out_len_max, out_len = 0; int err = -ENOMEM; struct scatterlist src, dst, src_tab[2]; @@ -2191,7 +2119,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, if (!req) goto free_xbuf; - init_completion(&result.completion); + crypto_init_wait(&wait); if (vecs->public_key_vec) err = crypto_akcipher_set_pub_key(tfm, vecs->key, @@ -2220,13 +2148,13 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, akcipher_request_set_crypt(req, src_tab, &dst, vecs->m_size, out_len_max); akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); - err = wait_async_op(&result, vecs->siggen_sigver_test ? - /* Run asymmetric signature generation */ - crypto_akcipher_sign(req) : - /* Run asymmetric encrypt */ - crypto_akcipher_encrypt(req)); + err = crypto_wait_req(vecs->siggen_sigver_test ? + /* Run asymmetric signature generation */ + crypto_akcipher_sign(req) : + /* Run asymmetric encrypt */ + crypto_akcipher_encrypt(req), &wait); if (err) { pr_err("alg: akcipher: encrypt test failed. err %d\n", err); goto free_all; @@ -2261,14 +2189,14 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, sg_init_one(&src, xbuf[0], vecs->c_size); sg_init_one(&dst, outbuf_dec, out_len_max); - init_completion(&result.completion); + crypto_init_wait(&wait); akcipher_request_set_crypt(req, &src, &dst, vecs->c_size, out_len_max); - err = wait_async_op(&result, vecs->siggen_sigver_test ? - /* Run asymmetric signature verification */ - crypto_akcipher_verify(req) : - /* Run asymmetric decrypt */ - crypto_akcipher_decrypt(req)); + err = crypto_wait_req(vecs->siggen_sigver_test ? + /* Run asymmetric signature verification */ + crypto_akcipher_verify(req) : + /* Run asymmetric decrypt */ + crypto_akcipher_decrypt(req), &wait); if (err) { pr_err("alg: akcipher: decrypt test failed. err %d\n", err); goto free_all; From patchwork Sun Jul 2 14:42:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106860 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8295465obb; Sun, 2 Jul 2017 07:47:34 -0700 (PDT) X-Received: by 10.84.171.197 with SMTP id l63mr5639126plb.167.1499006854034; Sun, 02 Jul 2017 07:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006854; cv=none; d=google.com; s=arc-20160816; b=ICVkPvS4vmUiAZWmYKJx3v/E+LxLsEmksoxgAbhDlGKHB3TEsMETR2ne5rc0u1ebVh M7pUKzdiO+aAivVaVaYs0dlO3Zc3R7E6awnXv/UH3DnVbSvbd8y4ubK9n6spPgaAdRlP iWYs7eP20b/PzE5E6IaQvRc4Ffm1dXeM2PImuV2AovXgj9lIcQDelJ/dirOvYKwMVhlB QTzSuOnEvnVWLzkcjPN4QCM5Kdd71pPWl/hAHJ6PyMRI0urh2PAB4zmbei23YkMZuO4L Hd1g5NgCnlTiL7qKGCxcW+QR67q7pYBnVNVvAqzmu7OGYZFcDmcPG7jhbz8Q2Xo56Glv uufA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=PiRLqgCfP615gISZieNKTunTQ13PBzmAU/iIenX+V9o=; b=PnZ84T9B1mpX4bQQZ5MJ2jZLhYdiztzjtdwgeVr7LsGNP9ntaSji04mxMRcgfGAsAv WY/MheI82rdCTbs3ss34w7oDRG3Q1phTW3pv/1JBF/NczJm27bhyJ05XfH2ItDY3PbdV izFypbJ/hiAu4XFe+mlakupBWRbKpdp8KJkWbFmr4Qoh678M6D2rxWy4tBuieH/h3cgz 0kmfDvRvjYf3JD9kCVDk3XzZ+vX+dYwlePu7D8OqQruR5ieulLT/P6L0aqQjV3bR+yay WGTEU8SwPX4ThYAYZLXW736z6fbKVaPK96OxKIvTHLyoZHZYQJUNm+mcHUtTuQ4KpbJS KWuA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si11127819pli.90.2017.07.02.07.47.33; Sun, 02 Jul 2017 07:47:34 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752233AbdGBOrR (ORCPT + 1 other); Sun, 2 Jul 2017 10:47:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54498 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751875AbdGBOrM (ORCPT ); Sun, 2 Jul 2017 10:47:12 -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 37F1415B2; Sun, 2 Jul 2017 07:47:06 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F3DD3F578; Sun, 2 Jul 2017 07:46:58 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 21/28] fscrypt: move to generic async completion Date: Sun, 2 Jul 2017 17:42:03 +0300 Message-Id: <1499006535-19760-22-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org fscrypt starts several async. crypto ops and waiting for them to complete. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- fs/crypto/crypto.c | 29 +++++------------------------ fs/crypto/fname.c | 36 ++++++------------------------------ fs/crypto/fscrypt_private.h | 10 ---------- fs/crypto/keyinfo.c | 21 +++------------------ 4 files changed, 14 insertions(+), 82 deletions(-) -- 2.1.4 diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index c5c89ed..4e8740f 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -126,21 +126,6 @@ struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode, gfp_t gfp_flags) } EXPORT_SYMBOL(fscrypt_get_ctx); -/** - * page_crypt_complete() - completion callback for page crypto - * @req: The asynchronous cipher request context - * @res: The result of the cipher operation - */ -static void page_crypt_complete(struct crypto_async_request *req, int res) -{ - struct fscrypt_completion_result *ecr = req->data; - - if (res == -EINPROGRESS) - return; - ecr->res = res; - complete(&ecr->completion); -} - int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw, u64 lblk_num, struct page *src_page, struct page *dest_page, unsigned int len, @@ -151,7 +136,7 @@ int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw, u8 padding[FS_IV_SIZE - sizeof(__le64)]; } iv; struct skcipher_request *req = NULL; - DECLARE_FS_COMPLETION_RESULT(ecr); + DECLARE_CRYPTO_WAIT(wait); struct scatterlist dst, src; struct fscrypt_info *ci = inode->i_crypt_info; struct crypto_skcipher *tfm = ci->ci_ctfm; @@ -179,7 +164,7 @@ int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw, skcipher_request_set_callback( req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - page_crypt_complete, &ecr); + crypto_req_done, &wait); sg_init_table(&dst, 1); sg_set_page(&dst, dest_page, len, offs); @@ -187,14 +172,10 @@ int fscrypt_do_page_crypto(const struct inode *inode, fscrypt_direction_t rw, sg_set_page(&src, src_page, len, offs); skcipher_request_set_crypt(req, &src, &dst, len, &iv); if (rw == FS_DECRYPT) - res = crypto_skcipher_decrypt(req); + res = crypto_wait_req(crypto_skcipher_decrypt(req), &wait); else - res = crypto_skcipher_encrypt(req); - if (res == -EINPROGRESS || res == -EIOCBQUEUED) { - BUG_ON(req->base.data != &ecr); - wait_for_completion(&ecr.completion); - res = ecr.res; - } + res = crypto_wait_req(crypto_skcipher_encrypt(req), &wait); + skcipher_request_free(req); if (res) { printk_ratelimited(KERN_ERR diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index ad9f814..a80a0d3 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -15,21 +15,6 @@ #include "fscrypt_private.h" /** - * fname_crypt_complete() - completion callback for filename crypto - * @req: The asynchronous cipher request context - * @res: The result of the cipher operation - */ -static void fname_crypt_complete(struct crypto_async_request *req, int res) -{ - struct fscrypt_completion_result *ecr = req->data; - - if (res == -EINPROGRESS) - return; - ecr->res = res; - complete(&ecr->completion); -} - -/** * fname_encrypt() - encrypt a filename * * The caller must have allocated sufficient memory for the @oname string. @@ -40,7 +25,7 @@ static int fname_encrypt(struct inode *inode, const struct qstr *iname, struct fscrypt_str *oname) { struct skcipher_request *req = NULL; - DECLARE_FS_COMPLETION_RESULT(ecr); + DECLARE_CRYPTO_WAIT(wait); struct fscrypt_info *ci = inode->i_crypt_info; struct crypto_skcipher *tfm = ci->ci_ctfm; int res = 0; @@ -76,17 +61,12 @@ static int fname_encrypt(struct inode *inode, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - fname_crypt_complete, &ecr); + crypto_req_done, &wait); sg_init_one(&sg, oname->name, cryptlen); skcipher_request_set_crypt(req, &sg, &sg, cryptlen, iv); /* Do the encryption */ - res = crypto_skcipher_encrypt(req); - if (res == -EINPROGRESS || res == -EBUSY) { - /* Request is being completed asynchronously; wait for it */ - wait_for_completion(&ecr.completion); - res = ecr.res; - } + res = crypto_wait_req(crypto_skcipher_encrypt(req), &wait); skcipher_request_free(req); if (res < 0) { printk_ratelimited(KERN_ERR @@ -110,7 +90,7 @@ static int fname_decrypt(struct inode *inode, struct fscrypt_str *oname) { struct skcipher_request *req = NULL; - DECLARE_FS_COMPLETION_RESULT(ecr); + DECLARE_CRYPTO_WAIT(wait); struct scatterlist src_sg, dst_sg; struct fscrypt_info *ci = inode->i_crypt_info; struct crypto_skcipher *tfm = ci->ci_ctfm; @@ -131,7 +111,7 @@ static int fname_decrypt(struct inode *inode, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - fname_crypt_complete, &ecr); + crypto_req_done, &wait); /* Initialize IV */ memset(iv, 0, FS_CRYPTO_BLOCK_SIZE); @@ -140,11 +120,7 @@ static int fname_decrypt(struct inode *inode, sg_init_one(&src_sg, iname->name, iname->len); sg_init_one(&dst_sg, oname->name, oname->len); skcipher_request_set_crypt(req, &src_sg, &dst_sg, iname->len, iv); - res = crypto_skcipher_decrypt(req); - if (res == -EINPROGRESS || res == -EBUSY) { - wait_for_completion(&ecr.completion); - res = ecr.res; - } + res = crypto_wait_req(crypto_skcipher_decrypt(req), &wait); skcipher_request_free(req); if (res < 0) { printk_ratelimited(KERN_ERR diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index a1d5021..c0f1881 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -69,16 +69,6 @@ typedef enum { #define FS_CTX_REQUIRES_FREE_ENCRYPT_FL 0x00000001 #define FS_CTX_HAS_BOUNCE_BUFFER_FL 0x00000002 -struct fscrypt_completion_result { - struct completion completion; - int res; -}; - -#define DECLARE_FS_COMPLETION_RESULT(ecr) \ - struct fscrypt_completion_result ecr = { \ - COMPLETION_INITIALIZER_ONSTACK((ecr).completion), 0 } - - /* crypto.c */ extern int fscrypt_initialize(unsigned int cop_flags); extern struct workqueue_struct *fscrypt_read_workqueue; diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 018c588..3c84cac 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -17,17 +17,6 @@ static struct crypto_shash *essiv_hash_tfm; -static void derive_crypt_complete(struct crypto_async_request *req, int rc) -{ - struct fscrypt_completion_result *ecr = req->data; - - if (rc == -EINPROGRESS) - return; - - ecr->res = rc; - complete(&ecr->completion); -} - /** * derive_key_aes() - Derive a key using AES-128-ECB * @deriving_key: Encryption key used for derivation. @@ -42,7 +31,7 @@ static int derive_key_aes(u8 deriving_key[FS_AES_128_ECB_KEY_SIZE], { int res = 0; struct skcipher_request *req = NULL; - DECLARE_FS_COMPLETION_RESULT(ecr); + DECLARE_CRYPTO_WAIT(wait); struct scatterlist src_sg, dst_sg; struct crypto_skcipher *tfm = crypto_alloc_skcipher("ecb(aes)", 0, 0); @@ -59,7 +48,7 @@ static int derive_key_aes(u8 deriving_key[FS_AES_128_ECB_KEY_SIZE], } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - derive_crypt_complete, &ecr); + crypto_req_done, &wait); res = crypto_skcipher_setkey(tfm, deriving_key, FS_AES_128_ECB_KEY_SIZE); if (res < 0) @@ -69,11 +58,7 @@ static int derive_key_aes(u8 deriving_key[FS_AES_128_ECB_KEY_SIZE], sg_init_one(&dst_sg, derived_raw_key, source_key->size); skcipher_request_set_crypt(req, &src_sg, &dst_sg, source_key->size, NULL); - res = crypto_skcipher_encrypt(req); - if (res == -EINPROGRESS || res == -EBUSY) { - wait_for_completion(&ecr.completion); - res = ecr.res; - } + res = crypto_wait_req(crypto_skcipher_encrypt(req), &wait); out: skcipher_request_free(req); crypto_free_skcipher(tfm); From patchwork Sun Jul 2 14:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106861 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8295504obb; Sun, 2 Jul 2017 07:47:37 -0700 (PDT) X-Received: by 10.84.128.14 with SMTP id 14mr5777458pla.285.1499006857389; Sun, 02 Jul 2017 07:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006857; cv=none; d=google.com; s=arc-20160816; b=i3GjBpHwo68O5FADGbs11DmsIHHAS+L27yZ5zIuYgocjErS9tVtDPfcb7YUOUM8KLv JMM8B+G0mmu6KPTGFzP2GyrhqyBLcXzOEx+eAqrCq9AFuh6NsHLSxMFdSdcqB+aDEAGR 7SMqhmxm0NmcFnALGJbfTe7HiKqHvF8JQHLtvGfR08W1DBLt4ea9SX364VH31oHhSvUa iWiovtIUc553zP5HGYY7aDqu3GAVTBeaNUP+xqGYL88mDY7qkE0mgTnKJtFVj+mTof01 mRpI/G2HuglGqlmdjEdqhl4uKJebLradraCIYErEK3zZhvklNKQrv7WmMAc9GOuGojtJ 9LTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=+9UYqrNtfXheaFFtShApRws/5GiiNFcfxJCyinCxixc=; b=OgSqb3zgZOC6qlqRlargZ3BHDTlhi1jBzUZO2GlZC7g+mod0NaOPNMmQySmRmmWAGd eJhTqvPLkZWEcdQ4puUDnbnrKoVZi2gkWVM4nyITGWiLc32MpbW31VnKazUSHFgcrQ+Q mRi3DLw3ECjG5dEXc8MWDD601qrIYWwoPxMsXrU1WOFBukU/zp0wF5rtf+Y82EofY2Qo KA/csF/OhXyrIPChX4hCQsxbHs3xO42famMf7AR9aPqMqRI4wuFfQ7RicLpEVLINnJXX Nqwh5xPnRCrTqjj4uaNSON742fWtg2kjE1F7fUJXw7Kj3HW70RlH6orSSYjBMfvQczDT TNHQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si11127819pli.90.2017.07.02.07.47.37; Sun, 02 Jul 2017 07:47:37 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752405AbdGBOre (ORCPT + 1 other); Sun, 2 Jul 2017 10:47:34 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54554 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752426AbdGBOrU (ORCPT ); Sun, 2 Jul 2017 10:47:20 -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 446FF344; Sun, 2 Jul 2017 07:47:19 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 69B993F578; Sun, 2 Jul 2017 07:47:11 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 22/28] cifs: move to generic async completion Date: Sun, 2 Jul 2017 17:42:04 +0300 Message-Id: <1499006535-19760-23-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org cifs starts an async. crypto op and waits for their completion. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef Acked-by: Pavel Shilovsky --- fs/cifs/smb2ops.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 00b1143..46abe62 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1809,22 +1809,6 @@ init_sg(struct smb_rqst *rqst, u8 *sign) return sg; } -struct cifs_crypt_result { - int err; - struct completion completion; -}; - -static void cifs_crypt_complete(struct crypto_async_request *req, int err) -{ - struct cifs_crypt_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int smb2_get_enc_key(struct TCP_Server_Info *server, __u64 ses_id, int enc, u8 *key) { @@ -1865,12 +1849,10 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) struct aead_request *req; char *iv; unsigned int iv_len; - struct cifs_crypt_result result = {0, }; + DECLARE_CRYPTO_WAIT(wait); struct crypto_aead *tfm; unsigned int crypt_len = le32_to_cpu(tr_hdr->OriginalMessageSize); - init_completion(&result.completion); - rc = smb2_get_enc_key(server, tr_hdr->SessionId, enc, key); if (rc) { cifs_dbg(VFS, "%s: Could not get %scryption key\n", __func__, @@ -1930,14 +1912,10 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) aead_request_set_ad(req, assoc_data_len); aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - cifs_crypt_complete, &result); + crypto_req_done, &wait); - rc = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); - - if (rc == -EINPROGRESS || rc == -EIOCBQUEUED) { - wait_for_completion(&result.completion); - rc = result.err; - } + rc = crypto_wait_req(enc ? crypto_aead_encrypt(req) + : crypto_aead_decrypt(req), &wait); if (!rc && enc) memcpy(&tr_hdr->Signature, sign, SMB2_SIGNATURE_SIZE); From patchwork Sun Jul 2 14:42:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106863 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8295979obb; Sun, 2 Jul 2017 07:48:12 -0700 (PDT) X-Received: by 10.99.64.197 with SMTP id n188mr5719920pga.281.1499006892026; Sun, 02 Jul 2017 07:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006892; cv=none; d=google.com; s=arc-20160816; b=mzDV27m+pYaWetzCkl7fnxuQ5/3uiak85uGR8V8xQ8xC/EM6s5tLvVl2VMjlw5uEnS HizgwWQ28upvtWnBLMCIkDxvr/u9vzTYSMJ26cQ/twKxHbwC7mCHvjB/V2pB/cYyF9Ka CTZL9XIVkVl52OsCOlx24t4BXyPveB8gw4mzj/TjpQFXDbGZTlf058WBHeWV2M7+8qjC AWKt0UaSWCDK0HDLLINHdO+7J26g4Qy/9OLN6mr65NcmraZ4VGKH+mCDaIqTD6qc8bkr jjip6cS8INXcgqH8/OcIj601k13fRhzGpIfKVEPO+AGdQDAA+hDIjYoGO1PypriyPIpm FCzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7efp7xaubi4g9BdQMQ2FDbdahbz4gzqQ5N8pBHwynn4=; b=cHxhT0Uxn9IAnoZXxxNiW5089LsUCql4Sog6CGSVIR88c8EF06D3LGFetzkYqGrLRw lSpYEUMj93lUkaukI0imVepp9lhkhMU454vR5QRvh1BuE//IcaKPu5xyEQ5OtCv18XBy z24beiMlkPGlAeGqO94Pp6jBh3MbWlYz2D0chymeVWmtAgu+0O2jXcgryLLpBuMp4exq 7Pam/vXD+kJZE7AjjLARRy1qyuJNhvLgeBdbZEX2m9mLmgxGE/RnXaITrXQ9g0AReZBF 4m3BhdVWMps2M62Kq9a79WMsyRiywcqYmP/Xqszwwny6eUNA8YdQ2x27wKx3DEYRi1ea WXaQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12si1289000pfg.407.2017.07.02.07.48.11; Sun, 02 Jul 2017 07:48:12 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752377AbdGBOr7 (ORCPT + 1 other); Sun, 2 Jul 2017 10:47:59 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54672 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbdGBOrz (ORCPT ); Sun, 2 Jul 2017 10:47:55 -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 190B3344; Sun, 2 Jul 2017 07:47:50 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 415953F578; Sun, 2 Jul 2017 07:47:42 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 24/28] crypto: tcrypt: move to generic async completion Date: Sun, 2 Jul 2017 17:42:06 +0300 Message-Id: <1499006535-19760-25-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org tcrypt starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- crypto/tcrypt.c | 84 +++++++++++++++++---------------------------------------- 1 file changed, 25 insertions(+), 59 deletions(-) -- 2.1.4 diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 57f7ac4..0278a39 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -79,34 +79,11 @@ static char *check[] = { NULL }; -struct tcrypt_result { - struct completion completion; - int err; -}; - -static void tcrypt_complete(struct crypto_async_request *req, int err) -{ - struct tcrypt_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static inline int do_one_aead_op(struct aead_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { - struct tcrypt_result *tr = req->base.data; + struct crypto_wait *wait = req->base.data; - ret = wait_for_completion_interruptible(&tr->completion); - if (!ret) - ret = tr->err; - reinit_completion(&tr->completion); - } - - return ret; + return crypto_wait_req(ret, wait); } static int test_aead_jiffies(struct aead_request *req, int enc, @@ -248,7 +225,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, char *axbuf[XBUFSIZE]; unsigned int *b_size; unsigned int iv_len; - struct tcrypt_result result; + struct crypto_wait wait; iv = kzalloc(MAX_IVLEN, GFP_KERNEL); if (!iv) @@ -284,7 +261,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, goto out_notfm; } - init_completion(&result.completion); + crypto_init_wait(&wait); printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, get_driver_name(crypto_aead, tfm), e); @@ -296,7 +273,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, } aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); i = 0; do { @@ -397,21 +374,16 @@ static void test_hash_sg_init(struct scatterlist *sg) static inline int do_one_ahash_op(struct ahash_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { - struct tcrypt_result *tr = req->base.data; + struct crypto_wait *wait = req->base.data; - wait_for_completion(&tr->completion); - reinit_completion(&tr->completion); - ret = tr->err; - } - return ret; + return crypto_wait_req(ret, wait); } struct test_mb_ahash_data { struct scatterlist sg[TVMEMSIZE]; char result[64]; struct ahash_request *req; - struct tcrypt_result tresult; + struct crypto_wait wait; char *xbuf[XBUFSIZE]; }; @@ -440,7 +412,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, if (testmgr_alloc_buf(data[i].xbuf)) goto out; - init_completion(&data[i].tresult.completion); + crypto_init_wait(&data[i].wait); data[i].req = ahash_request_alloc(tfm, GFP_KERNEL); if (!data[i].req) { @@ -449,8 +421,8 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, goto out; } - ahash_request_set_callback(data[i].req, 0, - tcrypt_complete, &data[i].tresult); + ahash_request_set_callback(data[i].req, 0, crypto_req_done, + &data[i].wait); test_hash_sg_init(data[i].sg); } @@ -492,16 +464,16 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, if (ret) break; - complete(&data[k].tresult.completion); - data[k].tresult.err = 0; + crypto_req_done(&data[k].req->base, 0); } for (j = 0; j < k; j++) { - struct tcrypt_result *tr = &data[j].tresult; + struct crypto_wait *wait = &data[j].wait; + int wait_ret; - wait_for_completion(&tr->completion); - if (tr->err) - ret = tr->err; + wait_ret = crypto_wait_req(-EINPROGRESS, wait); + if (wait_ret) + ret = wait_ret; } end = get_cycles(); @@ -679,7 +651,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, struct hash_speed *speed, unsigned mask) { struct scatterlist sg[TVMEMSIZE]; - struct tcrypt_result tresult; + struct crypto_wait wait; struct ahash_request *req; struct crypto_ahash *tfm; char *output; @@ -708,9 +680,9 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, goto out; } - init_completion(&tresult.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &tresult); + crypto_req_done, &wait); output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL); if (!output) @@ -765,15 +737,9 @@ static void test_hash_speed(const char *algo, unsigned int secs, static inline int do_one_acipher_op(struct skcipher_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { - struct tcrypt_result *tr = req->base.data; - - wait_for_completion(&tr->completion); - reinit_completion(&tr->completion); - ret = tr->err; - } + struct crypto_wait *wait = req->base.data; - return ret; + return crypto_wait_req(ret, wait); } static int test_acipher_jiffies(struct skcipher_request *req, int enc, @@ -853,7 +819,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, unsigned int tcount, u8 *keysize, bool async) { unsigned int ret, i, j, k, iv_len; - struct tcrypt_result tresult; + struct crypto_wait wait; const char *key; char iv[128]; struct skcipher_request *req; @@ -866,7 +832,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, else e = "decryption"; - init_completion(&tresult.completion); + crypto_init_wait(&wait); tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC); @@ -887,7 +853,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &tresult); + crypto_req_done, &wait); i = 0; do { From patchwork Sun Jul 2 14:42:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106864 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8296298obb; Sun, 2 Jul 2017 07:48:36 -0700 (PDT) X-Received: by 10.98.72.194 with SMTP id q63mr5501011pfi.23.1499006916149; Sun, 02 Jul 2017 07:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006916; cv=none; d=google.com; s=arc-20160816; b=GLq6ZN0lZVLbSbLEg4y8qReYngPz9nVmll/3p8rFYFDjkxLcQPwdGsw1GBitP6S4d6 h1MRy//QDAIhzDaWCSXeAgvUDks/PxgUqDOpM/ncTJsFS2aSLfLOEKD5p4qW48kdKJ+V E40E80gXyzcpaUHf+iu4wAvAb653KqReKUwzhF8v8QGB1ujJ1DQcxONyH1EzjLQDjI78 xvFfsRxx/fcyKHzUrNTPMKxLgJrPQao5cgknzZwT2BwCNpJr1sSNhM996XxNTxSWTSs/ NG0W3AMk50YhDh2nAWgqSqxhuSTdU5M/YMvGsBAbEoorU5l39Vh0Yv9ZbcOczP69Zecb lNww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OT/TNElTP1m27nipjV74NgcmxauSxLzDpZ2KR3V3zno=; b=q/oGqWMLMbwsOuFzfdRyH8oVAtACBu4ZdszttLA52toQnQbKd9ZT08DjnK1wkgCi86 IfWERe73ARB6czLuGhNd5qRqWt8pqBP6lKhYQAVlZAi1UXCMe/edEXXgLDwHheEBAeJJ OIrPoYzj4CueymtvxgXNPHfkxAWSBy6HnnNIoWodx9/F3JjK9AHV7mOvXoLD+fNsy18o 2K+LV1IJLE5LbtI+kAmAjno3q8EpA6UaFT9l4BsPdjeVt7pS/KcjF5jU4UV4wIvxKxxV d5neFtjATjjsmYCW4oYyuiQjxsT1HlKazJm/hO//+IMJTcXMYZZXSJbXNQa5scG0JNe3 0Y9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15si10835723plj.408.2017.07.02.07.48.35; Sun, 02 Jul 2017 07:48:36 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbdGBOsN (ORCPT + 1 other); Sun, 2 Jul 2017 10:48:13 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54720 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbdGBOsJ (ORCPT ); Sun, 2 Jul 2017 10:48:09 -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 807E815B2; Sun, 2 Jul 2017 07:48:03 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB1FD3F578; Sun, 2 Jul 2017 07:47:55 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 25/28] crypto: talitos: move to generic async completion Date: Sun, 2 Jul 2017 17:42:07 +0300 Message-Id: <1499006535-19760-26-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The talitos driver starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/talitos.c | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 0ab3c4d..bf80d3b 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -2037,22 +2037,6 @@ static int ahash_import(struct ahash_request *areq, const void *in) return 0; } -struct keyhash_result { - struct completion completion; - int err; -}; - -static void keyhash_complete(struct crypto_async_request *req, int err) -{ - struct keyhash_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, u8 *hash) { @@ -2060,10 +2044,10 @@ static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, struct scatterlist sg[1]; struct ahash_request *req; - struct keyhash_result hresult; + struct crypto_wait wait; int ret; - init_completion(&hresult.completion); + crypto_init_wait(&wait); req = ahash_request_alloc(tfm, GFP_KERNEL); if (!req) @@ -2072,25 +2056,12 @@ static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, /* Keep tfm keylen == 0 during hash of the long key */ ctx->keylen = 0; ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - keyhash_complete, &hresult); + crypto_req_done, &wait); sg_init_one(&sg[0], key, keylen); - ahash_request_set_crypt(req, sg, hash, keylen); - ret = crypto_ahash_digest(req); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EIOCBQUEUED: - ret = wait_for_completion_interruptible( - &hresult.completion); - if (!ret) - ret = hresult.err; - break; - default: - break; - } + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); + ahash_request_free(req); return ret; From patchwork Sun Jul 2 14:42:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106865 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8296310obb; Sun, 2 Jul 2017 07:48:37 -0700 (PDT) X-Received: by 10.98.27.73 with SMTP id b70mr5371860pfb.42.1499006917191; Sun, 02 Jul 2017 07:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006917; cv=none; d=google.com; s=arc-20160816; b=UDbNxM2nml4O5Rd9IWZSYAbOxaRXWBh6WuqR2n6H9oGpsh7fq28MkekHo0xnCO7xiv ww8wV00LXCB+bs6e5kMdBDusuwvlrHDnDCjljbuqmI+bQmvbfIk2GSlJ+1qX3N8xiCCq FGFROtfJKszvvnlNJkqygEm2BQj0riogwRnWUN/VqZv4z6Zbi47Bg62nDSJuEnCwg5yT OuBxdBnuHdy+6gl0Dx9VG+uaM7/+XGd3McUM1cKWQ+pryAap8wxCLtZe5O6ZkYYVmjCW E/t+u6N+tEvJuaan6hbpmqcmesuo6psIS0CKCwoE04zJMNJaUCjdyBClv/bQ48qTtVqI CTvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=R86U9TgpLobjdd/CR7n3vSr01rD4PyrnS7Hc3BfkGoI=; b=Ex2OQE8o7kwhEilxlAzjQWY0ocEhNY8J6zCYk3S8kutkDx9O47zLy71RnBOgiFQGq2 wrSD9Aup5D90GuHIeMaG6Q8SVjKs7l2wZ6CFzfR/5GvBM8xSoTUJvSZ1rLL2OxqSWq0U thtrdTDTVeTnY2HpPetWi2DNlgTL49KEV4LiIO5I/v4j+nNiN+Cr9B8XvlmOgmyxm5O5 PUzqxdkyLmJgz/7giB74vjS9M+TU7P3nQugSKkMXkCzIWwadglNXQDfKkY7Q4wfMRF2S 0zOcJ7sWryIzho4XBahwhXqa4TB3JZnE/B7XtrNF2MfmPSQ5oSA53uVDFv+YsajI8Eil sfwA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15si10835723plj.408.2017.07.02.07.48.36; Sun, 02 Jul 2017 07:48:37 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752623AbdGBOs1 (ORCPT + 1 other); Sun, 2 Jul 2017 10:48:27 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54776 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbdGBOsW (ORCPT ); Sun, 2 Jul 2017 10:48:22 -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 D0112344; Sun, 2 Jul 2017 07:48:16 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0685E3F578; Sun, 2 Jul 2017 07:48:08 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 26/28] crypto: qce: move to generic async completion Date: Sun, 2 Jul 2017 17:42:08 +0300 Message-Id: <1499006535-19760-27-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The qce driver starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/qce/sha.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) -- 2.1.4 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index a21d2a1c..53227d7 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -349,28 +349,12 @@ static int qce_ahash_digest(struct ahash_request *req) return qce->async_req_enqueue(tmpl->qce, &req->base); } -struct qce_ahash_result { - struct completion completion; - int error; -}; - -static void qce_digest_complete(struct crypto_async_request *req, int error) -{ - struct qce_ahash_result *result = req->data; - - if (error == -EINPROGRESS) - return; - - result->error = error; - complete(&result->completion); -} - static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen) { unsigned int digestsize = crypto_ahash_digestsize(tfm); struct qce_sha_ctx *ctx = crypto_tfm_ctx(&tfm->base); - struct qce_ahash_result result; + struct crypto_wait wait; struct ahash_request *req; struct scatterlist sg; unsigned int blocksize; @@ -405,9 +389,9 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, goto err_free_ahash; } - init_completion(&result.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - qce_digest_complete, &result); + crypto_req_done, &wait); crypto_ahash_clear_flags(ahash_tfm, ~0); buf = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, GFP_KERNEL); @@ -420,13 +404,7 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, sg_init_one(&sg, buf, keylen); ahash_request_set_crypt(req, &sg, ctx->authkey, keylen); - ret = crypto_ahash_digest(req); - if (ret == -EINPROGRESS || ret == -EIOCBQUEUED) { - ret = wait_for_completion_interruptible(&result.completion); - if (!ret) - ret = result.error; - } - + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); if (ret) crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); From patchwork Sun Jul 2 14:42:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 106867 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8296581obb; Sun, 2 Jul 2017 07:49:00 -0700 (PDT) X-Received: by 10.99.65.196 with SMTP id o187mr5625105pga.193.1499006940651; Sun, 02 Jul 2017 07:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006940; cv=none; d=google.com; s=arc-20160816; b=hhrAeyTBdXooZFoY9z8A7ncLdGA4pa8l5xU3/4bBd2ErwTp9yzc8wj/6G9SaZ08sfx 5qHYsldrAWn9vaP+TaxRcT2vXuLrH2Cb81eyl7XzySvsTslm4hu+x1oNKB/a50HUA3TS lQ1CWls79ogWw0NMPj0T5A+RbcU8J5TDGHe4Ezi5T6PkcFMP5fzymCjtgrAiFT3X2j8Y hrlX8LcpRpViF2L9wvhqnbJS0VHNschZapHNjgiFGZ3S4umMLDFNTIaNesvweCqp7xtp OOLGB+lYHgEuGOgYS1dHLCTTMSxiYzE1yrrIpqewChaseMW2GSmErH22AQ26Ngb1TIr+ EbrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7C1aAJSgYY01SDIvfXS6Jxsz2JTGLabAgoM2YxxlpuA=; b=oNPgxxRbCPp/EP5ZNeR69Q0zfdTKYKyuMN8/FPEK6Yi8co6xpBmPbVVWeNBT+8pakn F5pj2OQFrwwZvwNQd8X+0rDGwbTF6mGI7y1NhGeiP5K++Qgv87fCNdCI7wL5MpV5jZ3u SMXEk0C/pLKN5vwv2twaNIi9pHVR6vsVOWmsoFHtEQfkjQEV//T7emu5kkLadH8PlqiC CU+ED0roERm925FIPW/zmhOutCh7D9NXfOUaZWNhzn0Tcp3BnrqX2THxeBG1AeSG41wZ jDI0lAkEvBxME3Qt8yI7ksXHeczJk3D93ZNTnVRf9Zmz7kGpmxgKqWtj/+nVIZTAbnyo HJaw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si10208060pfg.45.2017.07.02.07.49.00; Sun, 02 Jul 2017 07:49:00 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752463AbdGBOs6 (ORCPT + 1 other); Sun, 2 Jul 2017 10:48:58 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54890 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752638AbdGBOsz (ORCPT ); Sun, 2 Jul 2017 10:48:55 -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 5168115B2; Sun, 2 Jul 2017 07:48:44 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 781043F578; Sun, 2 Jul 2017 07:48:36 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 28/28] crypto: adapt api sample to use async. op wait Date: Sun, 2 Jul 2017 17:42:10 +0300 Message-Id: <1499006535-19760-29-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The code sample is waiting for an async. crypto op completion. Adapt sample to use the new generic infrastructure to do the same. This also fixes a possible data coruption bug created by the use of wait_for_completion_interruptible() without dealing correctly with an interrupt aborting the wait prior to the async op finishing. Signed-off-by: Gilad Ben-Yossef --- Documentation/crypto/api-samples.rst | 52 +++++++----------------------------- 1 file changed, 10 insertions(+), 42 deletions(-) -- 2.1.4 diff --git a/Documentation/crypto/api-samples.rst b/Documentation/crypto/api-samples.rst index c6aa4ba..006827e 100644 --- a/Documentation/crypto/api-samples.rst +++ b/Documentation/crypto/api-samples.rst @@ -7,59 +7,27 @@ Code Example For Symmetric Key Cipher Operation :: - struct tcrypt_result { - struct completion completion; - int err; - }; - /* tie all data structures together */ struct skcipher_def { struct scatterlist sg; struct crypto_skcipher *tfm; struct skcipher_request *req; - struct tcrypt_result result; + struct crypto_wait wait; }; - /* Callback function */ - static void test_skcipher_cb(struct crypto_async_request *req, int error) - { - struct tcrypt_result *result = req->data; - - if (error == -EINPROGRESS) - return; - result->err = error; - complete(&result->completion); - pr_info("Encryption finished successfully\n"); - } - /* Perform cipher operation */ static unsigned int test_skcipher_encdec(struct skcipher_def *sk, int enc) { - int rc = 0; + int rc; if (enc) - rc = crypto_skcipher_encrypt(sk->req); + rc = crypto_wait_req(crypto_skcipher_encrypt(sk->req), &sk->wait); else - rc = crypto_skcipher_decrypt(sk->req); - - switch (rc) { - case 0: - break; - case -EINPROGRESS: - case -EIOCBQUEUED: - rc = wait_for_completion_interruptible( - &sk->result.completion); - if (!rc && !sk->result.err) { - reinit_completion(&sk->result.completion); - break; - } - default: - pr_info("skcipher encrypt returned with %d result %d\n", - rc, sk->result.err); - break; - } - init_completion(&sk->result.completion); + rc = crypto_wait_req(crypto_skcipher_decrypt(sk->req), &sk->wait); + + if (rc) + pr_info("skcipher encrypt returned with result %d\n", rc); return rc; } @@ -89,8 +57,8 @@ Code Example For Symmetric Key Cipher Operation } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - test_skcipher_cb, - &sk.result); + crypto_req_done, + &sk.wait); /* AES 256 with random key */ get_random_bytes(&key, 32); @@ -122,7 +90,7 @@ Code Example For Symmetric Key Cipher Operation /* We encrypt one block */ sg_init_one(&sk.sg, scratchpad, 16); skcipher_request_set_crypt(req, &sk.sg, &sk.sg, 16, ivdata); - init_completion(&sk.result.completion); + crypto_init_wait(&sk.wait); /* encrypt data */ ret = test_skcipher_encdec(&sk, 1);