OSDN Git Service

vhost-user: fix VirtQ notifier cleanup
authorXueming Li <xuemingl@nvidia.com>
Mon, 7 Feb 2022 07:19:29 +0000 (15:19 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 4 Mar 2022 13:30:52 +0000 (08:30 -0500)
commit0b0af4d62f7002b31cd7b2762b26d2fcb76bb2ba
tree7447197ae56a8a4a7504637571776958dd6d66dc
parente867144b73b3c5009266b6df07d5ff44acfb82c3
vhost-user: fix VirtQ notifier cleanup

When vhost-user device cleanup, remove notifier MR and munmaps notifier
address in the event-handling thread, VM CPU thread writing the notifier
in concurrent fails with an error of accessing invalid address. It
happens because MR is still being referenced and accessed in another
thread while the underlying notifier mmap address is being freed and
becomes invalid.

This patch calls RCU and munmap notifiers in the callback after the
memory flatview update finish.

Fixes: 44866521bd6e ("vhost-user: support registering external host notifiers")
Cc: qemu-stable@nongnu.org
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Message-Id: <20220207071929.527149-3-xuemingl@nvidia.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/vhost-user.c
include/hw/virtio/vhost-user.h