[PATCH v6 0/3] vhost: fix device IOTLB feature lifecycle
From: Jia Jia <hidden>
Date: 2026-08-18 04:26:30
Also in:
kvm, lkml, virtualization
Both vhost-vsock and vhost-net can leave the device IOTLB attached when userspace clears VIRTIO_F_ACCESS_PLATFORM. They can also replace an existing IOTLB with a new empty table when a later feature update keeps ACCESS_PLATFORM enabled, for example when updating logging. When the IOTLB mode changes, the vring addresses previously supplied by userspace no longer have the same address-space meaning. Leaving those addresses installed would allow an old IOVA to be used as a direct userspace address after the IOTLB is detached. This series invalidates the vring access state during IOTLB transitions, makes IOTLB initialization idempotent, and uses a common teardown helper for vhost-vsock and vhost-net. IOTLB mode changes are applied even while a virtqueue backend is attached. The device-wide IOTLB is dropped first, each virtqueue then clears its IOTLB pointer and cached ring access under its own mutex, and the old table is freed only after every virtqueue has completed the handoff. A successful live mode change leaves the backend attached but invalidates the cached vring addresses. Userspace must configure the vring addresses for the new address mode before data processing can resume. When ACCESS_PLATFORM is enabled, the usual IOTLB miss/update protocol repopulates the new table. Changes since v5: - invalidate desc, avail, used, logging state, and metadata on IOTLB transitions; - apply IOTLB mode changes while a backend is attached, following the per-virtqueue handoff suggested in review; - apply the IOTLB teardown to vhost-net as well as vhost-vsock. Jia Jia (3): vhost: invalidate vring access on IOTLB transitions vhost/vsock: discard IOTLB when ACCESS_PLATFORM is cleared vhost/net: discard IOTLB when ACCESS_PLATFORM is cleared drivers/vhost/net.c | 8 ++++++-- drivers/vhost/vhost.c | 53 ++++++++++++++++++++++++++++++++++++++++- drivers/vhost/vhost.h | 1 + drivers/vhost/vsock.c | 10 ++++++--- 4 files changed, 66 insertions(+), 6 deletions(-)