[2/2] net/virtio: fix notification area initialization
Checks
Commit Message
Notification area is a Virtio feature that require to be
negotiated because not all devices support it. Currently,
it is tried to be initialized as soon as the backend
implements the callback, so it assumes all Vhost-vDPA
devices support it.
This patch skips calling the notification area map callback
if the device does not advertise its support.
Fixes: 0fd2782660c8 ("net/virtio-user: support notification area mapping")
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/net/virtio/virtio_user/virtio_user_dev.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On Tue, Mar 12, 2024 at 11:48 AM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> Notification area is a Virtio feature that require to be
requires*
> negotiated because not all devices support it. Currently,
> it is tried to be initialized as soon as the backend
> implements the callback, so it assumes all Vhost-vDPA
> devices support it.
>
> This patch skips calling the notification area map callback
> if the device does not advertise its support.
>
> Fixes: 0fd2782660c8 ("net/virtio-user: support notification area mapping")
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
@@ -433,8 +433,9 @@ virtio_user_dev_init_notify(struct virtio_user_dev *dev)
dev->kickfds[i] = kickfd;
}
- if (dev->ops->map_notification_area)
- if (dev->ops->map_notification_area(dev))
+ if (dev->device_features & (1ULL << VIRTIO_F_NOTIFICATION_DATA))
+ if (dev->ops->map_notification_area &&
+ dev->ops->map_notification_area(dev))
goto err;
return 0;