* [v5 1/5] vhost: skip crypto op fetch before vring init [not found] <cover.1740390893.git.gmuthukrishn@marvell.com> @ 2025-02-24 10:35 ` Gowrishankar Muthukrishnan 2025-02-25 16:17 ` Maxime Coquelin 2025-02-24 10:35 ` [v5 3/5] examples/vhost_crypto: fix user callbacks Gowrishankar Muthukrishnan 1 sibling, 1 reply; 3+ messages in thread From: Gowrishankar Muthukrishnan @ 2025-02-24 10:35 UTC (permalink / raw) To: dev, maxime.coquelin, Chenbo Xia, Jay Zhou, Fan Zhang Cc: anoobj, Akhil Goyal, Gowrishankar Muthukrishnan, stable Until virtio avail ring is initialized (by VHOST_USER_SET_VRING_ADDR), worker thread should not try to fetch crypto op, which would lead to memory fault. Fixes: 939066d96563 ("vhost/crypto: add public function implementation") Cc: stable@dpdk.org Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com> Acked-by: Akhil Goyal <gakhil@marvell.com> --- lib/vhost/vhost_crypto.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c index 3dc41a3bd5..55ea24710e 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -1580,6 +1580,16 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, vq = dev->virtqueue[qid]; + if (unlikely(vq == NULL)) { + VC_LOG_ERR("Invalid virtqueue %u", qid); + return 0; + } + + if (unlikely(vq->avail == NULL)) { + VC_LOG_DBG("Virtqueue ring not yet initialized %u", qid); + return 0; + } + avail_idx = *((volatile uint16_t *)&vq->avail->idx); start_idx = vq->last_used_idx; count = avail_idx - start_idx; -- 2.25.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [v5 1/5] vhost: skip crypto op fetch before vring init 2025-02-24 10:35 ` [v5 1/5] vhost: skip crypto op fetch before vring init Gowrishankar Muthukrishnan @ 2025-02-25 16:17 ` Maxime Coquelin 0 siblings, 0 replies; 3+ messages in thread From: Maxime Coquelin @ 2025-02-25 16:17 UTC (permalink / raw) To: Gowrishankar Muthukrishnan, dev, Chenbo Xia, Jay Zhou, Fan Zhang Cc: anoobj, Akhil Goyal, stable On 2/24/25 11:35 AM, Gowrishankar Muthukrishnan wrote: > Until virtio avail ring is initialized (by VHOST_USER_SET_VRING_ADDR), > worker thread should not try to fetch crypto op, which would lead to > memory fault. > > Fixes: 939066d96563 ("vhost/crypto: add public function implementation") > Cc: stable@dpdk.org > > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com> > Acked-by: Akhil Goyal <gakhil@marvell.com> > --- > lib/vhost/vhost_crypto.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c > index 3dc41a3bd5..55ea24710e 100644 > --- a/lib/vhost/vhost_crypto.c > +++ b/lib/vhost/vhost_crypto.c > @@ -1580,6 +1580,16 @@ rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, > > vq = dev->virtqueue[qid]; > > + if (unlikely(vq == NULL)) { > + VC_LOG_ERR("Invalid virtqueue %u", qid); > + return 0; > + } > + > + if (unlikely(vq->avail == NULL)) { > + VC_LOG_DBG("Virtqueue ring not yet initialized %u", qid); > + return 0; > + } > + I think the proper fix to: 1. acquire the access_lock as reader 2. check whether vq is enabled 3. acquire the iotlb lock as a reader 4. check vq's access_ok You can have a look at rte_vhost_dequeue_burst for example. > avail_idx = *((volatile uint16_t *)&vq->avail->idx); > start_idx = vq->last_used_idx; > count = avail_idx - start_idx; ^ permalink raw reply [flat|nested] 3+ messages in thread
* [v5 3/5] examples/vhost_crypto: fix user callbacks [not found] <cover.1740390893.git.gmuthukrishn@marvell.com> 2025-02-24 10:35 ` [v5 1/5] vhost: skip crypto op fetch before vring init Gowrishankar Muthukrishnan @ 2025-02-24 10:35 ` Gowrishankar Muthukrishnan 1 sibling, 0 replies; 3+ messages in thread From: Gowrishankar Muthukrishnan @ 2025-02-24 10:35 UTC (permalink / raw) To: dev, maxime.coquelin, Chenbo Xia, Fan Zhang, Jay Zhou Cc: anoobj, Akhil Goyal, Gowrishankar Muthukrishnan, stable In order to handle new vhost user connection, use new_connection and destroy_connection callbacks. Fixes: f5188211c721 ("examples/vhost_crypto: add sample application") Cc: stable@dpdk.org Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com> Acked-by: Akhil Goyal <gakhil@marvell.com> --- examples/vhost_crypto/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c index 558c09a60f..b1fe4120b9 100644 --- a/examples/vhost_crypto/main.c +++ b/examples/vhost_crypto/main.c @@ -362,8 +362,8 @@ destroy_device(int vid) } static const struct rte_vhost_device_ops virtio_crypto_device_ops = { - .new_device = new_device, - .destroy_device = destroy_device, + .new_connection = new_device, + .destroy_connection = destroy_device, }; static int -- 2.25.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-25 16:18 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <cover.1740390893.git.gmuthukrishn@marvell.com> 2025-02-24 10:35 ` [v5 1/5] vhost: skip crypto op fetch before vring init Gowrishankar Muthukrishnan 2025-02-25 16:17 ` Maxime Coquelin 2025-02-24 10:35 ` [v5 3/5] examples/vhost_crypto: fix user callbacks Gowrishankar Muthukrishnan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).