Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3797757imm; Mon, 11 Jun 2018 01:49:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIJDT6GwQgfKz0VbbiAZvdPHB4ptkhDjq4eBKMp+98BDDIzgPXIAnyT3xN/AmB0Hpf+UfIX X-Received: by 2002:a17:902:ab95:: with SMTP id f21-v6mr10397468plr.264.1528706942359; Mon, 11 Jun 2018 01:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528706942; cv=none; d=google.com; s=arc-20160816; b=Zgqeod2O1V7tBGOVVulyqtAC3ogeSOYhXg+LQE6IPXZ97opXzNPYPoPQpHZZjDn100 7vEBtTGQKIDE4NgVpgIVvbioZ/aiH+TwMfqFbMJtabLLF0ZbQm3DGXCheE7Ifh1RqCv7 X2q0OGHAnKWuF7tVApw71+g5OBRNULfWY167ExHgVjrH9rpV89UQ0OOkeTm7oQ0CIwKe qfb/StGBb4luoKUknNFmrYaBoxn//rEpWr08ZjPKCkC80Z+XxpKvmGYu0wqnJenQL6+4 55UDapUOJ/7f8EJcl6ElFIAORzG/YNymYIXiFAmY8YGiHsnTPk5GwidXWFw2BKq3KV3X lhRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=Q9QrUplDzsDm3UwOBVubkr9Xf+JAPTTcUgMQv8UxONA=; b=HsVN0qh1yNq65mPh1OT0cPpxjnWm3IKvs27D8PL299EG8NLa9h+BlMuygYfTj0q+BV UF+3KIhfekgtCynpudaKGdMKjfdwDGRWn7xxDqKr9oIQLEyMAxjTEm36Ehp7IGO7HbVy T5I5GHSYNIRSvXK03SS6V1GHCJzBrxOaYW/zIHqizcNpkkx+KeIic3CovIYIvBpZB8F1 yPtSZ7fRgR0WsMAWa5/DNPKifKEWeV9DygdBjDzpUcNeg2enftYj2TVADPIDlq22ctZ/ sOIDOLyqZ+k8JopaIxax82GvU3KVD7a3hQOFK9nIiqV1vX+26X3zEe2VlO6y3bKTh9Ky pxlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p187-v6si4646790pfp.125.2018.06.11.01.48.48; Mon, 11 Jun 2018 01:49:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754157AbeFKIsS convert rfc822-to-8bit (ORCPT + 99 others); Mon, 11 Jun 2018 04:48:18 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:38403 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754024AbeFKIsR (ORCPT ); Mon, 11 Jun 2018 04:48:17 -0400 Received: from DGGEML404-HUB.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id 1EA03431565E8; Mon, 11 Jun 2018 16:48:14 +0800 (CST) Received: from DGGEML511-MBX.china.huawei.com ([169.254.1.61]) by DGGEML404-HUB.china.huawei.com ([fe80::b177:a243:7a69:5ab8%31]) with mapi id 14.03.0382.000; Mon, 11 Jun 2018 16:48:08 +0800 From: "Gonglei (Arei)" To: Farhan Ali , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" CC: "mst@redhat.com" , "qemu-devel@nongnu.org" , longpeng , "pasic@linux.ibm.com" , "frankja@linux.ibm.com" , "borntraeger@de.ibm.com" Subject: RE: [RFC v1 2/2] crypto/virtio-crypto: Register an algo only if it's supported Thread-Topic: [RFC v1 2/2] crypto/virtio-crypto: Register an algo only if it's supported Thread-Index: AQHT/1w9irxqESt7g0CZ2KZ6/sbWPKRawPbg Date: Mon, 11 Jun 2018 08:48:07 +0000 Message-ID: <33183CC9F5247A488A2544077AF19020DB015ABF@dggeml511-mbx.china.huawei.com> References: In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.18.62] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Farhan Ali [mailto:alifm@linux.ibm.com] > Sent: Saturday, June 09, 2018 3:09 AM > To: linux-kernel@vger.kernel.org; kvm@vger.kernel.org > Cc: mst@redhat.com; qemu-devel@nongnu.org; Gonglei (Arei) > ; longpeng ; > pasic@linux.ibm.com; frankja@linux.ibm.com; borntraeger@de.ibm.com; > alifm@linux.ibm.com > Subject: [RFC v1 2/2] crypto/virtio-crypto: Register an algo only if it's supported > > From: Farhan Ali > > Register a crypto algo with the Linux crypto layer only if > the algorithm is supported by the backend virtio-crypto > device. > > Also route crypto requests to a virtio-crypto > device, only if it can support the requested service and > algorithm. > > Signed-off-by: Farhan Ali > --- > drivers/crypto/virtio/virtio_crypto_algs.c | 110 > ++++++++++++++++++--------- > drivers/crypto/virtio/virtio_crypto_common.h | 11 ++- > drivers/crypto/virtio/virtio_crypto_mgr.c | 81 ++++++++++++++++++-- > 3 files changed, 158 insertions(+), 44 deletions(-) > > diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c > b/drivers/crypto/virtio/virtio_crypto_algs.c > index ba190cf..fef112a 100644 > --- a/drivers/crypto/virtio/virtio_crypto_algs.c > +++ b/drivers/crypto/virtio/virtio_crypto_algs.c > @@ -49,12 +49,18 @@ struct virtio_crypto_sym_request { > bool encrypt; > }; > > +struct virtio_crypto_algo { > + uint32_t algonum; > + uint32_t service; > + unsigned int active_devs; > + struct crypto_alg algo; > +}; > + > /* > * The algs_lock protects the below global virtio_crypto_active_devs > * and crypto algorithms registion. > */ > static DEFINE_MUTEX(algs_lock); > -static unsigned int virtio_crypto_active_devs; > static void virtio_crypto_ablkcipher_finalize_req( > struct virtio_crypto_sym_request *vc_sym_req, > struct ablkcipher_request *req, > @@ -312,13 +318,19 @@ static int virtio_crypto_ablkcipher_setkey(struct > crypto_ablkcipher *tfm, > unsigned int keylen) > { > struct virtio_crypto_ablkcipher_ctx *ctx = crypto_ablkcipher_ctx(tfm); > + uint32_t alg; > int ret; > > + ret = virtio_crypto_alg_validate_key(keylen, &alg); > + if (ret) > + return ret; > + > if (!ctx->vcrypto) { > /* New key */ > int node = virtio_crypto_get_current_node(); > struct virtio_crypto *vcrypto = > - virtcrypto_get_dev_node(node); > + virtcrypto_get_dev_node(node, > + VIRTIO_CRYPTO_SERVICE_CIPHER, alg); > if (!vcrypto) { > pr_err("virtio_crypto: Could not find a virtio device in the > system\n"); We'd better change the above error message now. What about: " virtio_crypto: Could not find a virtio device in the system or unsupported algo" ? Regards, -Gonglei