[PATCH for 11.2 v2] vhost: only use config notifier when exists/initialized

Eric Farman posted 1 patch 2 weeks, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261103172732.837511-1-farman@linux.ibm.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>
hw/virtio/vhost.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH for 11.2 v2] vhost: only use config notifier when exists/initialized
Posted by Eric Farman 2 weeks, 5 days ago
Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an
assert for an uninitialized file descriptor in event_notifier_get_fd(),
but it presumes that such a thing always exists.

On s390x, where a config notifier does not exist, this is a breaking
change for any vhost-backed device such as virtio-net. To remedy this,
move the acquisition of the file descriptor within the guard against
vhost_set_config_call and expand the guard to ensure the notifier is
initialized before being used.

Fixes: e3b12d0c55e4 ("util/event_notifier: more strict API")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 hw/virtio/vhost.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index b25919c5c7d..189ac541178 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -2119,8 +2119,9 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
         virtio_config_get_guest_notifier(dev->vdev);
 
     assert(dev->vhost_ops);
-    int fd = event_notifier_get_fd(config_notifier);
-    if (dev->vhost_ops->vhost_set_config_call) {
+    if (dev->vhost_ops->vhost_set_config_call &&
+        event_notifier_initialized(config_notifier)) {
+        int fd = event_notifier_get_fd(config_notifier);
         r = dev->vhost_ops->vhost_set_config_call(dev, fd);
         if (!r) {
             event_notifier_set(config_notifier);
-- 
2.53.0
Re: [PATCH v2] vhost: only use config notifier when exists/initialized
Posted by Konstantin Shkolnyy 1 week, 6 days ago
On 261103 11:27, Eric Farman wrote:
> Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an
> assert for an uninitialized file descriptor in event_notifier_get_fd(),
> but it presumes that such a thing always exists.
> 
> On s390x, where a config notifier does not exist, this is a breaking
> change for any vhost-backed device such as virtio-net. To remedy this,
> move the acquisition of the file descriptor within the guard against
> vhost_set_config_call and expand the guard to ensure the notifier is
> initialized before being used.
> 
> Fixes: e3b12d0c55e4 ("util/event_notifier: more strict API")
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>   hw/virtio/vhost.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index b25919c5c7d..189ac541178 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -2119,8 +2119,9 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
>           virtio_config_get_guest_notifier(dev->vdev);
>   
>       assert(dev->vhost_ops);
> -    int fd = event_notifier_get_fd(config_notifier);
> -    if (dev->vhost_ops->vhost_set_config_call) {
> +    if (dev->vhost_ops->vhost_set_config_call &&
> +        event_notifier_initialized(config_notifier)) {
> +        int fd = event_notifier_get_fd(config_notifier);
>           r = dev->vhost_ops->vhost_set_config_call(dev, fd);
>           if (!r) {
>               event_notifier_set(config_notifier);
> 

On s390x:

For VDPA-based virtio-net devices using the CCW transport this patch 
fixes the "Assertion `e->initialized' failed" in 
event_notifier_get_fd(). In this setup all fields in config_notifier are 0.

With the same setup using the PCI transport, the config_notifier 
assertion never happesn, because config_notifier is initialized.

Tested-by: Konstantin Shkolnyy <kshk@linux.ibm.com>
Re: [PATCH for 11.2 v2] vhost: only use config notifier when exists/initialized
Posted by Vladimir Sementsov-Ogievskiy 2 weeks, 4 days ago
On 03.11.26 20:27, Eric Farman wrote:
> Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an
> assert for an uninitialized file descriptor in event_notifier_get_fd(),
> but it presumes that such a thing always exists.
> 
> On s390x, where a config notifier does not exist, this is a breaking
> change for any vhost-backed device such as virtio-net. To remedy this,
> move the acquisition of the file descriptor within the guard against
> vhost_set_config_call and expand the guard to ensure the notifier is
> initialized before being used.
> 
> Fixes: e3b12d0c55e4 ("util/event_notifier: more strict API")
> Signed-off-by: Eric Farman <farman@linux.ibm.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>


> ---
>   hw/virtio/vhost.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index b25919c5c7d..189ac541178 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -2119,8 +2119,9 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
>           virtio_config_get_guest_notifier(dev->vdev);
>   
>       assert(dev->vhost_ops);
> -    int fd = event_notifier_get_fd(config_notifier);
> -    if (dev->vhost_ops->vhost_set_config_call) {
> +    if (dev->vhost_ops->vhost_set_config_call &&
> +        event_notifier_initialized(config_notifier)) {
> +        int fd = event_notifier_get_fd(config_notifier);
>           r = dev->vhost_ops->vhost_set_config_call(dev, fd);
>           if (!r) {
>               event_notifier_set(config_notifier);


-- 
Best regards,
Vladimir