From fbdc5d4487346791e44773df9b5e8461f1725bb4 Mon Sep 17 00:00:00 2001 From: Andrew Carp Date: Thu, 21 Mar 2024 12:21:34 -0700 Subject: [PATCH] virtio-devices: Removing all mappings found in an unmap request According to the virtio iommu spec (section 5.13.6.6), all mappings within the entire range from virt_start to virt_end in an unmap request must be removed. This change adds this functionality, iterating through all mappings that fall within an unmap request for that domain and removing them. Signed-off-by: Andrew Carp --- virtio-devices/src/iommu.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtio-devices/src/iommu.rs b/virtio-devices/src/iommu.rs index 206e4564b..e3db1662a 100644 --- a/virtio-devices/src/iommu.rs +++ b/virtio-devices/src/iommu.rs @@ -563,7 +563,7 @@ impl Request { } } - // Remove mapping associated with the domain + // Remove all mappings associated with the domain within the requested range mapping .domains .write() @@ -571,7 +571,7 @@ impl Request { .get_mut(&domain_id) .unwrap() .mappings - .remove(&virt_start); + .retain(|&x, _| (x < req.virt_start || x > req.virt_end)); } VIRTIO_IOMMU_T_PROBE => { if desc_size_left != size_of::() {