|
| From: | Cédric Le Goater |
| Subject: | Re: [PATCH v6 01/21] backends/iommufd: Introduce the iommufd object |
| Date: | Fri, 17 Nov 2023 12:09:50 +0100 |
| User-agent: | Mozilla Thunderbird |
Hello,
+int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
+ ram_addr_t size, void *vaddr, bool readonly)
+{
+ int ret, fd = be->fd;
+ struct iommu_ioas_map map = {
+ .size = sizeof(map),
+ .flags = IOMMU_IOAS_MAP_READABLE |
+ IOMMU_IOAS_MAP_FIXED_IOVA,
+ .ioas_id = ioas_id,
+ .__reserved = 0,
+ .user_va = (uintptr_t)vaddr,
+ .iova = iova,
+ .length = size,
+ };
+
+ if (!readonly) {
+ map.flags |= IOMMU_IOAS_MAP_WRITEABLE;
+ }
+
+ ret = ioctl(fd, IOMMU_IOAS_MAP, &map);
+ trace_iommufd_backend_map_dma(fd, ioas_id, iova, size,
+ vaddr, readonly, ret);
+ if (ret) {
+ ret = -errno;
+ error_report("IOMMU_IOAS_MAP failed: %m");
+ }
+ return ret;
+}
When using a UEFI guest, QEMU reports errors when mapping regions in the top PCI space : iommufd_backend_map_dma iommufd=10 ioas=2 iova=0x380000001000 size=0x3000 addr=0x7fce2c28b000 readonly=0 (-1) qemu-system-x86_64: IOMMU_IOAS_MAP failed: Invalid argument qemu-system-x86_64: vfio_container_dma_map(0x55a21b03a150, 0x380000001000, 0x3000, 0x7fce2c28b000) = -22 (Invalid argument) iommufd_backend_map_dma iommufd=10 ioas=2 iova=0x380000004000 size=0x4000 addr=0x7fce2c980000 readonly=0 (-1) qemu-system-x86_64: IOMMU_IOAS_MAP failed: Invalid argument qemu-system-x86_64: vfio_container_dma_map(0x55a21b03a150, 0x380000004000, 0x4000, 0x7fce2c980000) = -22 (Invalid argument) This is because IOMMUFD reserved IOVAs areas are : [ fee00000 - feefffff ] [ 8000000000 - ffffffffffffffff ] (39 bits address space) which were allocated when the device was initially attached. The topology is basic. Something is wrong. Thanks, C.
| [Prev in Thread] | Current Thread | [Next in Thread] |