Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: virtio - Add spinlock protection with virtqueue notification

When VM boots with one virtio-crypto PCI device and builtin backend,
run openssl benchmark command with multiple processes, such as
openssl speed -evp aes-128-cbc -engine afalg -seconds 10 -multi 32

openssl processes will hangup and there is error reported like this:
virtio_crypto virtio0: dataq.0:id 3 is not a head!

It seems that the data virtqueue need protection when it is handled
for virtio done notification. If the spinlock protection is added
in virtcrypto_done_task(), openssl benchmark with multiple processes
works well.

Fixes: fed93fb62e05 ("crypto: virtio - Handle dataq logic with tasklet")
Cc: stable@vger.kernel.org
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Bibo Mao and committed by
Herbert Xu
b505047f 0ceeadc7

+5
+5
drivers/crypto/virtio/virtio_crypto_core.c
··· 75 75 struct data_queue *data_vq = (struct data_queue *)data; 76 76 struct virtqueue *vq = data_vq->vq; 77 77 struct virtio_crypto_request *vc_req; 78 + unsigned long flags; 78 79 unsigned int len; 79 80 81 + spin_lock_irqsave(&data_vq->lock, flags); 80 82 do { 81 83 virtqueue_disable_cb(vq); 82 84 while ((vc_req = virtqueue_get_buf(vq, &len)) != NULL) { 85 + spin_unlock_irqrestore(&data_vq->lock, flags); 83 86 if (vc_req->alg_cb) 84 87 vc_req->alg_cb(vc_req, len); 88 + spin_lock_irqsave(&data_vq->lock, flags); 85 89 } 86 90 } while (!virtqueue_enable_cb(vq)); 91 + spin_unlock_irqrestore(&data_vq->lock, flags); 87 92 } 88 93 89 94 static void virtcrypto_dataq_callback(struct virtqueue *vq)