summaryrefslogtreecommitdiffstats
path: root/include/linux/vringh.h
diff options
context:
space:
mode:
authorStefano Garzarella <sgarzare@redhat.com>2021-03-15 17:34:38 +0100
committerMichael S. Tsirkin <mst@redhat.com>2021-05-03 04:55:52 -0400
commitf53d9910d009bc015b42d88114e2d86a93b0e6b7 (patch)
treef79287a3e556fb2b40c4e0cb1bad5bf93808b669 /include/linux/vringh.h
parent4080fc1067501707b9693b8003feae7d50d14e35 (diff)
downloadlinux-stable-f53d9910d009bc015b42d88114e2d86a93b0e6b7.tar.gz
linux-stable-f53d9910d009bc015b42d88114e2d86a93b0e6b7.tar.bz2
linux-stable-f53d9910d009bc015b42d88114e2d86a93b0e6b7.zip
vringh: add 'iotlb_lock' to synchronize iotlb accesses
Usually iotlb accesses are synchronized with a spinlock. Let's request it as a new parameter in vringh_set_iotlb() and hold it when we navigate the iotlb in iotlb_translate() to avoid race conditions with any new additions/deletions of ranges from the ioltb. Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Link: https://lore.kernel.org/r/20210315163450.254396-3-sgarzare@redhat.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'include/linux/vringh.h')
-rw-r--r--include/linux/vringh.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/vringh.h b/include/linux/vringh.h
index 59bd50f99291..9c077863c8f6 100644
--- a/include/linux/vringh.h
+++ b/include/linux/vringh.h
@@ -46,6 +46,9 @@ struct vringh {
/* IOTLB for this vring */
struct vhost_iotlb *iotlb;
+ /* spinlock to synchronize IOTLB accesses */
+ spinlock_t *iotlb_lock;
+
/* The function to call to notify the guest about added buffers */
void (*notify)(struct vringh *);
};
@@ -258,7 +261,8 @@ static inline __virtio64 cpu_to_vringh64(const struct vringh *vrh, u64 val)
#if IS_REACHABLE(CONFIG_VHOST_IOTLB)
-void vringh_set_iotlb(struct vringh *vrh, struct vhost_iotlb *iotlb);
+void vringh_set_iotlb(struct vringh *vrh, struct vhost_iotlb *iotlb,
+ spinlock_t *iotlb_lock);
int vringh_init_iotlb(struct vringh *vrh, u64 features,
unsigned int num, bool weak_barriers,