* [PATCH V3] vdpa/mlx5: preserve CVQ vringh index
@ 2023-11-03 12:26 Steve Sistare
2023-11-03 12:27 ` Steven Sistare
2023-12-04 13:33 ` Steven Sistare
0 siblings, 2 replies; 5+ messages in thread
From: Steve Sistare @ 2023-11-03 12:26 UTC (permalink / raw)
To: virtualization, linux-kernel
Cc: Xuan Zhuo, Michael S. Tsirkin, Eugenio Perez Martin,
Steve Sistare, Eli Cohen
mlx5_vdpa does not preserve userland's view of vring base for the control
queue in the following sequence:
ioctl VHOST_SET_VRING_BASE
ioctl VHOST_VDPA_SET_STATUS VIRTIO_CONFIG_S_DRIVER_OK
mlx5_vdpa_set_status()
setup_cvq_vring()
vringh_init_iotlb()
vringh_init_kern()
vrh->last_avail_idx = 0;
ioctl VHOST_GET_VRING_BASE
To fix, restore the value of cvq->vring.last_avail_idx after calling
vringh_init_iotlb.
Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting")
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index 946488b8989f..ca972af3c89a 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -2795,13 +2795,18 @@ static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
struct mlx5_control_vq *cvq = &mvdev->cvq;
int err = 0;
- if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))
+ if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) {
+ u16 idx = cvq->vring.last_avail_idx;
+
err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
MLX5_CVQ_MAX_ENT, false,
(struct vring_desc *)(uintptr_t)cvq->desc_addr,
(struct vring_avail *)(uintptr_t)cvq->driver_addr,
(struct vring_used *)(uintptr_t)cvq->device_addr);
+ if (!err)
+ cvq->vring.last_avail_idx = cvq->vring.last_used_idx = idx;
+ }
return err;
}
--
2.39.3
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH V3] vdpa/mlx5: preserve CVQ vringh index
2023-11-03 12:26 [PATCH V3] vdpa/mlx5: preserve CVQ vringh index Steve Sistare
@ 2023-11-03 12:27 ` Steven Sistare
2023-12-04 13:33 ` Steven Sistare
1 sibling, 0 replies; 5+ messages in thread
From: Steven Sistare @ 2023-11-03 12:27 UTC (permalink / raw)
To: virtualization, linux-kernel
Cc: Xuan Zhuo, Michael S. Tsirkin, Eugenio Perez Martin, Eli Cohen
In V3 I added the fixes tag and the acks. No other changes.
- Steve
On 11/3/2023 8:26 AM, Steve Sistare wrote:
> mlx5_vdpa does not preserve userland's view of vring base for the control
> queue in the following sequence:
>
> ioctl VHOST_SET_VRING_BASE
> ioctl VHOST_VDPA_SET_STATUS VIRTIO_CONFIG_S_DRIVER_OK
> mlx5_vdpa_set_status()
> setup_cvq_vring()
> vringh_init_iotlb()
> vringh_init_kern()
> vrh->last_avail_idx = 0;
> ioctl VHOST_GET_VRING_BASE
>
> To fix, restore the value of cvq->vring.last_avail_idx after calling
> vringh_init_iotlb.
>
> Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting")
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> Acked-by: Eugenio Pérez <eperezma@redhat.com>
> Acked-by: Jason Wang <jasowang@redhat.com>
> ---
> drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 946488b8989f..ca972af3c89a 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -2795,13 +2795,18 @@ static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
> struct mlx5_control_vq *cvq = &mvdev->cvq;
> int err = 0;
>
> - if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))
> + if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) {
> + u16 idx = cvq->vring.last_avail_idx;
> +
> err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
> MLX5_CVQ_MAX_ENT, false,
> (struct vring_desc *)(uintptr_t)cvq->desc_addr,
> (struct vring_avail *)(uintptr_t)cvq->driver_addr,
> (struct vring_used *)(uintptr_t)cvq->device_addr);
>
> + if (!err)
> + cvq->vring.last_avail_idx = cvq->vring.last_used_idx = idx;
> + }
> return err;
> }
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH V3] vdpa/mlx5: preserve CVQ vringh index
2023-11-03 12:26 [PATCH V3] vdpa/mlx5: preserve CVQ vringh index Steve Sistare
2023-11-03 12:27 ` Steven Sistare
@ 2023-12-04 13:33 ` Steven Sistare
2023-12-04 13:35 ` Michael S. Tsirkin
1 sibling, 1 reply; 5+ messages in thread
From: Steven Sistare @ 2023-12-04 13:33 UTC (permalink / raw)
To: virtualization, linux-kernel
Cc: Michael S. Tsirkin, Jason Wang, Eli Cohen, Si-Wei Liu,
Dragos Tatulea, Xuan Zhuo, Eugenio Perez Martin
What's the decision here, pull it, or do not fix it?
- Steve
On 11/3/2023 8:26 AM, Steve Sistare wrote:
> mlx5_vdpa does not preserve userland's view of vring base for the control
> queue in the following sequence:
>
> ioctl VHOST_SET_VRING_BASE
> ioctl VHOST_VDPA_SET_STATUS VIRTIO_CONFIG_S_DRIVER_OK
> mlx5_vdpa_set_status()
> setup_cvq_vring()
> vringh_init_iotlb()
> vringh_init_kern()
> vrh->last_avail_idx = 0;
> ioctl VHOST_GET_VRING_BASE
>
> To fix, restore the value of cvq->vring.last_avail_idx after calling
> vringh_init_iotlb.
>
> Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting")
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> Acked-by: Eugenio Pérez <eperezma@redhat.com>
> Acked-by: Jason Wang <jasowang@redhat.com>
> ---
> drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index 946488b8989f..ca972af3c89a 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -2795,13 +2795,18 @@ static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
> struct mlx5_control_vq *cvq = &mvdev->cvq;
> int err = 0;
>
> - if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))
> + if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) {
> + u16 idx = cvq->vring.last_avail_idx;
> +
> err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
> MLX5_CVQ_MAX_ENT, false,
> (struct vring_desc *)(uintptr_t)cvq->desc_addr,
> (struct vring_avail *)(uintptr_t)cvq->driver_addr,
> (struct vring_used *)(uintptr_t)cvq->device_addr);
>
> + if (!err)
> + cvq->vring.last_avail_idx = cvq->vring.last_used_idx = idx;
> + }
> return err;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH V3] vdpa/mlx5: preserve CVQ vringh index
2023-12-04 13:33 ` Steven Sistare
@ 2023-12-04 13:35 ` Michael S. Tsirkin
2023-12-04 13:37 ` Steven Sistare
0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2023-12-04 13:35 UTC (permalink / raw)
To: Steven Sistare
Cc: virtualization, linux-kernel, Jason Wang, Eli Cohen, Si-Wei Liu,
Dragos Tatulea, Xuan Zhuo, Eugenio Perez Martin
It's in my tee and I'm sending it to Linus.
On Mon, Dec 04, 2023 at 08:33:22AM -0500, Steven Sistare wrote:
> What's the decision here, pull it, or do not fix it?
>
> - Steve
>
> On 11/3/2023 8:26 AM, Steve Sistare wrote:
> > mlx5_vdpa does not preserve userland's view of vring base for the control
> > queue in the following sequence:
> >
> > ioctl VHOST_SET_VRING_BASE
> > ioctl VHOST_VDPA_SET_STATUS VIRTIO_CONFIG_S_DRIVER_OK
> > mlx5_vdpa_set_status()
> > setup_cvq_vring()
> > vringh_init_iotlb()
> > vringh_init_kern()
> > vrh->last_avail_idx = 0;
> > ioctl VHOST_GET_VRING_BASE
> >
> > To fix, restore the value of cvq->vring.last_avail_idx after calling
> > vringh_init_iotlb.
> >
> > Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting")
> >
> > Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> > Acked-by: Eugenio Pérez <eperezma@redhat.com>
> > Acked-by: Jason Wang <jasowang@redhat.com>
> > ---
> > drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > index 946488b8989f..ca972af3c89a 100644
> > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> > @@ -2795,13 +2795,18 @@ static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
> > struct mlx5_control_vq *cvq = &mvdev->cvq;
> > int err = 0;
> >
> > - if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))
> > + if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) {
> > + u16 idx = cvq->vring.last_avail_idx;
> > +
> > err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
> > MLX5_CVQ_MAX_ENT, false,
> > (struct vring_desc *)(uintptr_t)cvq->desc_addr,
> > (struct vring_avail *)(uintptr_t)cvq->driver_addr,
> > (struct vring_used *)(uintptr_t)cvq->device_addr);
> >
> > + if (!err)
> > + cvq->vring.last_avail_idx = cvq->vring.last_used_idx = idx;
> > + }
> > return err;
> > }
> >
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH V3] vdpa/mlx5: preserve CVQ vringh index
2023-12-04 13:35 ` Michael S. Tsirkin
@ 2023-12-04 13:37 ` Steven Sistare
0 siblings, 0 replies; 5+ messages in thread
From: Steven Sistare @ 2023-12-04 13:37 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: virtualization, linux-kernel, Jason Wang, Eli Cohen, Si-Wei Liu,
Dragos Tatulea, Xuan Zhuo, Eugenio Perez Martin
Glad to hear it, thanks - Steve
On 12/4/2023 8:35 AM, Michael S. Tsirkin wrote:
> It's in my tee and I'm sending it to Linus.
>
> On Mon, Dec 04, 2023 at 08:33:22AM -0500, Steven Sistare wrote:
>> What's the decision here, pull it, or do not fix it?
>>
>> - Steve
>>
>> On 11/3/2023 8:26 AM, Steve Sistare wrote:
>>> mlx5_vdpa does not preserve userland's view of vring base for the control
>>> queue in the following sequence:
>>>
>>> ioctl VHOST_SET_VRING_BASE
>>> ioctl VHOST_VDPA_SET_STATUS VIRTIO_CONFIG_S_DRIVER_OK
>>> mlx5_vdpa_set_status()
>>> setup_cvq_vring()
>>> vringh_init_iotlb()
>>> vringh_init_kern()
>>> vrh->last_avail_idx = 0;
>>> ioctl VHOST_GET_VRING_BASE
>>>
>>> To fix, restore the value of cvq->vring.last_avail_idx after calling
>>> vringh_init_iotlb.
>>>
>>> Fixes: 5262912ef3cf ("vdpa/mlx5: Add support for control VQ and MAC setting")
>>>
>>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>>> Acked-by: Eugenio Pérez <eperezma@redhat.com>
>>> Acked-by: Jason Wang <jasowang@redhat.com>
>>> ---
>>> drivers/vdpa/mlx5/net/mlx5_vnet.c | 7 ++++++-
>>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
>>> index 946488b8989f..ca972af3c89a 100644
>>> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
>>> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
>>> @@ -2795,13 +2795,18 @@ static int setup_cvq_vring(struct mlx5_vdpa_dev *mvdev)
>>> struct mlx5_control_vq *cvq = &mvdev->cvq;
>>> int err = 0;
>>>
>>> - if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ))
>>> + if (mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)) {
>>> + u16 idx = cvq->vring.last_avail_idx;
>>> +
>>> err = vringh_init_iotlb(&cvq->vring, mvdev->actual_features,
>>> MLX5_CVQ_MAX_ENT, false,
>>> (struct vring_desc *)(uintptr_t)cvq->desc_addr,
>>> (struct vring_avail *)(uintptr_t)cvq->driver_addr,
>>> (struct vring_used *)(uintptr_t)cvq->device_addr);
>>>
>>> + if (!err)
>>> + cvq->vring.last_avail_idx = cvq->vring.last_used_idx = idx;
>>> + }
>>> return err;
>>> }
>>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-04 13:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-03 12:26 [PATCH V3] vdpa/mlx5: preserve CVQ vringh index Steve Sistare
2023-11-03 12:27 ` Steven Sistare
2023-12-04 13:33 ` Steven Sistare
2023-12-04 13:35 ` Michael S. Tsirkin
2023-12-04 13:37 ` Steven Sistare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox