Apply the common device IOTLB teardown when userspace clears
VIRTIO_F_ACCESS_PLATFORM. This drops stale translations and avoids
rebuilding an existing IOTLB during feature updates that keep
ACCESS_PLATFORM enabled.

The transition invalidates cached vring access even with an attached
backend. The backend remains attached, but userspace must configure the
vring addresses for the new address mode after a successful live
transition.

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 | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 38d9c184082d..4d9d7c2216ed 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1696,6 +1696,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) {
-- 
2.34.1


Reply via email to