vhost_vsock_set_features() currently leaves the device IOTLB
attached when userspace clears VIRTIO_F_ACCESS_PLATFORM. Descriptor
translation can therefore continue to use mappings installed before the
feature change, including HVAs made stale by a later memory table update.
Use the common vhost helper when ACCESS_PLATFORM is absent. The helper
handles the no-IOTLB case internally, while the common initializer keeps
an existing IOTLB when ACCESS_PLATFORM remains enabled across a feature
update.
Fixes: e13a6915a03f ("vhost/vsock: add IOTLB API support")
Suggested-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Jia Jia <[email protected]>
---
drivers/vhost/vsock.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index 1d8ec6bed53e..1a61d7db7605 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -849,10 +849,11 @@ static int vhost_vsock_set_features(struct vhost_vsock
*vsock, u64 features)
goto err;
}
- if ((features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) {
+ if (features & (1ULL << VIRTIO_F_ACCESS_PLATFORM)) {
if (vhost_init_device_iotlb(&vsock->dev))
goto err;
- }
+ } else
+ vhost_clear_device_iotlb(&vsock->dev);
vsock->seqpacket_allow = features & (1ULL << VIRTIO_VSOCK_F_SEQPACKET);