[1/2] vhost: fix lock on device readiness notification

Message ID 1622189463-392610-2-git-send-email-jiayu.hu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series provide thread unsafe async registration functions |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Hu, Jiayu May 28, 2021, 8:11 a.m. UTC
  The vhost notifies the application of device readiness via
vhost_user_notify_queue_state(), but calling this function
is not protected by the lock. This patch is to make this
function call lock protected.

Fixes: d0fcc38f5fa4 ("vhost: improve device readiness notifications")
Cc: stable@dpdk.org
Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
---
 lib/vhost/vhost_user.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Maxime Coquelin July 2, 2021, 7:36 a.m. UTC | #1
On 5/28/21 10:11 AM, Jiayu Hu wrote:
> The vhost notifies the application of device readiness via
> vhost_user_notify_queue_state(), but calling this function
> is not protected by the lock. This patch is to make this
> function call lock protected.
> 
> Fixes: d0fcc38f5fa4 ("vhost: improve device readiness notifications")
> Cc: stable@dpdk.org
> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> ---
>  lib/vhost/vhost_user.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 8f0eba6..dabce26 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -2915,9 +2915,6 @@ vhost_user_msg_handler(int vid, int fd)
>  		}
>  	}
>  
> -	if (unlock_required)
> -		vhost_user_unlock_all_queue_pairs(dev);
> -
>  	/* If message was not handled at this stage, treat it as an error */
>  	if (!handled) {
>  		VHOST_LOG_CONFIG(ERR,
> @@ -2952,6 +2949,8 @@ vhost_user_msg_handler(int vid, int fd)
>  		}
>  	}
>  
> +	if (unlock_required)
> +		vhost_user_unlock_all_queue_pairs(dev);
>  
>  	if (!virtio_is_ready(dev))
>  		goto out;
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 8f0eba6..dabce26 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -2915,9 +2915,6 @@  vhost_user_msg_handler(int vid, int fd)
 		}
 	}
 
-	if (unlock_required)
-		vhost_user_unlock_all_queue_pairs(dev);
-
 	/* If message was not handled at this stage, treat it as an error */
 	if (!handled) {
 		VHOST_LOG_CONFIG(ERR,
@@ -2952,6 +2949,8 @@  vhost_user_msg_handler(int vid, int fd)
 		}
 	}
 
+	if (unlock_required)
+		vhost_user_unlock_all_queue_pairs(dev);
 
 	if (!virtio_is_ready(dev))
 		goto out;