From 03eeb36b74d6da13b3944f9a93a48727bf74296d Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sun, 12 Jan 2025 21:40:49 +0000 Subject: [PATCH] virtio-devices: iommu: Search full range for GVA conversion Remove an erroneous optimisation that used the page size mask to reduce the range to iterate through on the set of mappings. This doesn't work as the virtio-iommu ranges are larger than a single page. This may have worked in the past when the mappings were limited to a single page. Signed-off-by: Rob Bradford --- virtio-devices/src/iommu.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/virtio-devices/src/iommu.rs b/virtio-devices/src/iommu.rs index 8219c3475..03968434c 100644 --- a/virtio-devices/src/iommu.rs +++ b/virtio-devices/src/iommu.rs @@ -4,7 +4,6 @@ use std::collections::BTreeMap; use std::mem::size_of; -use std::ops::Bound::Included; use std::os::unix::io::AsRawFd; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Barrier, Mutex, RwLock}; @@ -811,15 +810,7 @@ impl DmaRemapping for IommuMapping { return Ok(addr); } - let range_start = if VIRTIO_IOMMU_PAGE_SIZE_MASK > addr { - 0 - } else { - addr - VIRTIO_IOMMU_PAGE_SIZE_MASK - }; - for (&key, &value) in domain - .mappings - .range((Included(&range_start), Included(&addr))) - { + for (&key, &value) in domain.mappings.iter() { if addr >= key && addr < key + value.size { let new_addr = addr - key + value.gpa; debug!("Into GPA addr 0x{:x}", new_addr);