[PATCH v5 3/3] vhost/net: discard IOTLB when ACCESS_PLATFORM is cleared
Jia Jia <[email protected]>
| Newsgroups | org.kernel.vger.kvm,dev.linux.lists.virtualization,org.kernel.vger.linux-kernel,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
vhost_net_set_features() leaves the device IOTLB attached when
userspace clears VIRTIO_F_ACCESS_PLATFORM. Later descriptor translation
can therefore continue to use translations from the old IOTLB after the
userspace memory table has changed.
Use the common vhost helper when ACCESS_PLATFORM is absent. The helper
handles the no-IOTLB case internally, while the common initializer also
keeps an existing IOTLB when a feature update retains ACCESS_PLATFORM, so
logging updates do not discard valid translations.
Fixes: 6b1e6cc7855b ("vhost: new device IOTLB API")
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Jia Jia <[email protected]>
---
drivers/vhost/net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index c6536cad9c4f..8d6f530f49b3 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1687,7 +1687,8 @@ static int vhost_net_set_features(struct vhost_net *n, const u64 *features)
if (virtio_features_test_bit(features, VIRTIO_F_ACCESS_PLATFORM)) {
if (vhost_init_device_iotlb(&n->dev))
goto out_unlock;
- }
+ } else
+ vhost_clear_device_iotlb(&n->dev);
for (i = 0; i < VHOST_NET_VQ_MAX; ++i) {
mutex_lock(&n->vqs[i].vq.mutex);