[PULL 5/7] vdpa-dev: Fix the issue of device status not updating when configuration interruption is triggered

Michael S. Tsirkin posted 7 patches 1 year, 10 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Manos Pitsidianakis <manos.pitsidianakis@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Raphael Norwitz <raphael@enfabrica.net>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Jason Wang <jasowang@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>
[PULL 5/7] vdpa-dev: Fix the issue of device status not updating when configuration interruption is triggered
Posted by Michael S. Tsirkin 1 year, 10 months ago
From: lyx634449800 <yuxue.liu@jaguarmicro.com>

The set_config callback function vhost_vdpa_device_get_config in
vdpa-dev does not fetch the current device status from the hardware
device, causing the guest os to not receive the latest device status
information.

The hardware updates the config status of the vdpa device and then
notifies the os. The guest os receives an interrupt notification,
triggering a get_config access in the kernel, which then enters qemu
internally. Ultimately, the vhost_vdpa_device_get_config function of
vdpa-dev is called

One scenario encountered is when the device needs to bring down the
vdpa net device. After modifying the status field of virtio_net_config
in the hardware, it sends an interrupt notification. However, the guest
os always receives the STATUS field as VIRTIO_NET_S_LINK_UP.

Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20240408020003.1979-1-yuxue.liu@jaguarmicro.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/vdpa-dev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
index 13e87f06f6..64b96b226c 100644
--- a/hw/virtio/vdpa-dev.c
+++ b/hw/virtio/vdpa-dev.c
@@ -195,7 +195,14 @@ static void
 vhost_vdpa_device_get_config(VirtIODevice *vdev, uint8_t *config)
 {
     VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
+    int ret;
 
+    ret = vhost_dev_get_config(&s->dev, s->config, s->config_size,
+                            NULL);
+    if (ret < 0) {
+        error_report("get device config space failed");
+        return;
+    }
     memcpy(config, s->config, s->config_size);
 }
 
-- 
MST
Re: [PULL 5/7] vdpa-dev: Fix the issue of device status not updating when configuration interruption is triggered
Posted by Michael Tokarev 1 year, 10 months ago
09.04.2024 10:32, Michael S. Tsirkin пишет:
> From: lyx634449800 <yuxue.liu@jaguarmicro.com>
> 
> The set_config callback function vhost_vdpa_device_get_config in
> vdpa-dev does not fetch the current device status from the hardware
> device, causing the guest os to not receive the latest device status
> information.
> 
> The hardware updates the config status of the vdpa device and then
> notifies the os. The guest os receives an interrupt notification,
> triggering a get_config access in the kernel, which then enters qemu
> internally. Ultimately, the vhost_vdpa_device_get_config function of
> vdpa-dev is called
> 
> One scenario encountered is when the device needs to bring down the
> vdpa net device. After modifying the status field of virtio_net_config
> in the hardware, it sends an interrupt notification. However, the guest
> os always receives the STATUS field as VIRTIO_NET_S_LINK_UP.
> 
> Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com>
> Acked-by: Jason Wang <jasowang@redhat.com>
> Message-Id: <20240408020003.1979-1-yuxue.liu@jaguarmicro.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Ditto, is this a -stable material (for 8.2)?

Thanks,

/mjt

> diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
> index 13e87f06f6..64b96b226c 100644
> --- a/hw/virtio/vdpa-dev.c
> +++ b/hw/virtio/vdpa-dev.c
> @@ -195,7 +195,14 @@ static void
>   vhost_vdpa_device_get_config(VirtIODevice *vdev, uint8_t *config)
>   {
>       VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
> +    int ret;
>   
> +    ret = vhost_dev_get_config(&s->dev, s->config, s->config_size,
> +                            NULL);
> +    if (ret < 0) {
> +        error_report("get device config space failed");
> +        return;
> +    }
>       memcpy(config, s->config, s->config_size);
>   }
>   


Re: [PULL 5/7] vdpa-dev: Fix the issue of device status not updating when configuration interruption is triggered
Posted by Michael Tokarev 1 year, 10 months ago
09.04.2024 20:43, Michael Tokarev:
> 09.04.2024 10:32, Michael S. Tsirkin:
>> From: lyx634449800 <yuxue.liu@jaguarmicro.com>
>>
>> The set_config callback function vhost_vdpa_device_get_config in
>> vdpa-dev does not fetch the current device status from the hardware
>> device, causing the guest os to not receive the latest device status
>> information.
>>
>> The hardware updates the config status of the vdpa device and then
>> notifies the os. The guest os receives an interrupt notification,
>> triggering a get_config access in the kernel, which then enters qemu
>> internally. Ultimately, the vhost_vdpa_device_get_config function of
>> vdpa-dev is called
>>
>> One scenario encountered is when the device needs to bring down the
>> vdpa net device. After modifying the status field of virtio_net_config
>> in the hardware, it sends an interrupt notification. However, the guest
>> os always receives the STATUS field as VIRTIO_NET_S_LINK_UP.
>>
>> Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com>
>> Acked-by: Jason Wang <jasowang@redhat.com>
>> Message-Id: <20240408020003.1979-1-yuxue.liu@jaguarmicro.com>
>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> Ditto, is this a -stable material (for 8.2)?

Yes it is, it has already been Cc'ed to qemu-stable. Please excuse me for
the noise.

/mjt