qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v1 2/2] crypto/virtio-crypto: Register an algo onl


From: Gonglei (Arei)
Subject: Re: [Qemu-devel] [RFC v1 2/2] crypto/virtio-crypto: Register an algo only if it's supported
Date: Wed, 13 Jun 2018 00:31:10 +0000


> -----Original Message-----
> From: Farhan Ali [mailto:address@hidden
> Sent: Wednesday, June 13, 2018 1:08 AM
> To: Gonglei (Arei) <address@hidden>; address@hidden;
> address@hidden
> Cc: address@hidden; address@hidden; longpeng
> <address@hidden>; address@hidden; address@hidden;
> address@hidden
> Subject: Re: [RFC v1 2/2] crypto/virtio-crypto: Register an algo only if it's
> supported
> 
> 
> 
> On 06/11/2018 04:48 AM, Gonglei (Arei) wrote:
> >
> >
> >> -----Original Message-----
> >> From: Farhan Ali [mailto:address@hidden
> >> Sent: Saturday, June 09, 2018 3:09 AM
> >> To: address@hidden; address@hidden
> >> Cc: address@hidden; address@hidden; Gonglei (Arei)
> >> <address@hidden>; longpeng <address@hidden>;
> >> address@hidden; address@hidden; address@hidden;
> >> address@hidden
> >> Subject: [RFC v1 2/2] crypto/virtio-crypto: Register an algo only if it's
> supported
> >>
> >> From: Farhan Ali <address@hidden>
> >>
> >> 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 <address@hidden>
> >> ---
> >>   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
> 
> 
> Sure, I will update the error message. But other than that does the rest
> of the code looks good to you?
> 
Yes, good work. You can add my ack in v2:

Acked-by: Gonglei <address@hidden>

Regards,
-Gonglei




reply via email to

[Prev in Thread] Current Thread [Next in Thread]